diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8f017db4ed..5aa3f2312c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +19990915-23:20 GMT+3 Alexander Kresin + * source/hbpp/hbpp.c + * source/hbpp/table.c + * fixed some bugs, reported by Victor and Matteo + 19990915-15:50 GMT+1 Victor Szel * doc/hdr_tpl.txt * Some small changes. @@ -35,7 +40,7 @@ * Slight change in the format of the copyright header, the text itself has not changed. * source/rtl/filesys.c - + hb_fnFNameMerge() - TOFIX: added again about the lack of buffer overlow + + hb_fnFNameMerge() - TOFIX: added again about the lack of buffer overlow handling. * .cvsignore ! DOS/LINUX/OS2 GNU Make systems working directories added. @@ -80,7 +85,7 @@ with. * tests/working/dirtest.prg + added 3rd parameter to indicate 'want 8.3 filenames' - + 19990915-03:20 GMT+1 Victor Szel * source/rtl/do.c - Previous fix undone, since it was causing other problems. @@ -123,11 +128,11 @@ * config/rules.cf * Harbour flag /q changed to /q0 to omit the compiler header. * source/rtl/do.c - ! DO() fixed to use hb_dynsymFind() instead of hb_dynsymGet(), + ! DO() fixed to use hb_dynsymFind() instead of hb_dynsymGet(), now it properly displays when the passed string is not a symbol, rather then throwing an internal error. * source/compiler/harbour.y - + /CREDITS command line switch to display the development team. Like in + + /CREDITS command line switch to display the development team. Like in Clipper. 19990914-13:15 GMT+1 Victor Szel @@ -137,7 +142,7 @@ + /f switch changed to /gf, and the whole object generation build in to the source in a more standard way. It works now. + /q0 switch added to the help screen. - + All filename composing stuff related to specific output types moved to + + All filename composing stuff related to specific output types moved to the appropriate gen*.c file. This way the code is more modular. ! One variable made static in genobj32.c @@ -146,7 +151,7 @@ include/external.ch * Regenerated. * source/runner/runlib.c - ! Made some steps to release memory blocks when an undeclared symbol error + ! Made some steps to release memory blocks when an undeclared symbol error occurs, seemingly with few success. This needs some more work. + TODO added about a possible direction for further development. The idea would be to replicate the Blinker DLL functionality. @@ -155,9 +160,9 @@ source/compiler/gen*.c * Only every 100th line number is shown on the counter while parsing, this way it's more Clipper like. In theory it should also be faster, - but due to the stdout buffering, it's approx. the same speed. Though it + but due to the stdout buffering, it's approx. the same speed. Though it could be faster in some platform/compiler/screen output combinations. - + The "syntax ok" message is now replaced with the total number of + + The "syntax ok" message is now replaced with the total number of functions and the total number of lines. Similar to Clipper, but not so specific to the generated output. + /q0 switch no suppresses the "Harbour Compiler" header. @@ -179,7 +184,7 @@ hb_itemPutNLen(). * source/rtl/itemapi.c include/itemapi.h - + hb_itemPutNLen() generic function added to assign a number to an item, + + hb_itemPutNLen() generic function added to assign a number to an item, the low-level type of the number is automatically selected, based on the magnitude and presence of decimal places. Similar to hb_vmPushNumber(). + hb_itemPutN?Len() functions will now accept any negative width/dec @@ -197,7 +202,7 @@ + hb_stackDispLocal() - More values are printed, the format changed. * tests/working/rtl_test.prg tests/working/overload.prg - ! The tests fixed again, "+="/"-=" operators removed from the class + ! The tests fixed again, "+="/"-=" operators removed from the class declaration. * "+"/"-" implementation changed to not modify the original value, since the expression "oString + 'A'" in itself in one line is not valid anyway. @@ -209,7 +214,7 @@ * source/vm/hvm.c + hb_vmInString() - Added support for overloading the "$" operator. ! hb_vmPlus() - Fixed the operator overloading feature. - + hb_vmNotEqual() - Added support for alternate notequal operators: + + hb_vmNotEqual() - Added support for alternate notequal operators: "<>" and "#". * tests/working/rtl_test.prg tests/working/overload.prg diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index 9336f7aa0e..39ad297d1f 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -65,7 +65,7 @@ int WorkDefine ( char**, char*, DEFINES * ); /* Replace fragment of code with int WorkPseudoF ( char**, char*, DEFINES*); /* Replace pseudofunction with a #defined result text */ int WorkCommand ( char*, char*, COMMANDS* ); int WorkTranslate ( char*, char*, COMMANDS*, int* ); -int CommandStuff ( char *, char *, char *, int*, int ); +int CommandStuff ( char *, char *, char *, int*, int, int ); int RemoveSlash( char * ); int WorkMarkers( char**, char**, char*, int* ); int getExpReal ( char *, char **, int, int ); @@ -87,7 +87,7 @@ void pp_Stuff (char*, char*, int, int, int); int strocpy (char*, char* ); int stroncpy (char*, char*, int); int strincpy (char*, char*); -int strincmp (char*, char**); +int strincmp (char*, char**, int); int strolen ( char* ); void stroupper ( char* ); int strotrim ( char* ); @@ -122,7 +122,7 @@ int ParseState = 0; int lInclude = 0; int *aCondCompile, nCondCompile = 0, maxCondCompile = 5; int nline=0; -int Repeate; +int aIsRepeate[5],Repeate; int numBrackets; char groupchar; @@ -707,7 +707,7 @@ int WorkDefine ( char** ptri, char* ptro, DEFINES *stdef ) int WorkPseudoF ( char** ptri, char* ptro, DEFINES *stdef ) { - char parfict[MAX_NAME], parreal[MAX_NAME]; + char parfict[MAX_NAME], *ptrreal; char *ptrb; int ipos, ifou, ibeg; int lenfict, lenreal, lenres; @@ -727,7 +727,9 @@ int WorkPseudoF ( char** ptri, char* ptro, DEFINES *stdef ) if ( **ptri != ')' ) { (*ptri)++; /* Get next real parameter */ - lenreal = NextParm( ptri, parreal ); + SKIPTABSPACES( *ptri ); + ptrreal = *ptri; + lenreal = NextParm( ptri, NULL); ptrb = ptro; while ( (ifou = pp_strAt( parfict, lenfict, ptrb, lenres-(ptrb-ptro) )) > 0 ) @@ -735,7 +737,7 @@ int WorkPseudoF ( char** ptri, char* ptro, DEFINES *stdef ) ptrb = ptrb+ifou-1; if ( !ISNAME(*(ptrb-1)) && !ISNAME(*(ptrb+lenfict)) ) { - pp_Stuff ( parreal, ptrb, lenreal, lenfict, lenres ); + pp_Stuff ( ptrreal, ptrb, lenreal, lenfict, lenres ); lenres += lenreal - lenfict; ptrb += lenreal; } @@ -768,7 +770,7 @@ int WorkCommand ( char* ptri, char* ptro, COMMANDS *stcmd ) ptrmp = stcmd->mpatt; /* Pointer to a match pattern */ Repeate = 0; groupchar = '@'; - rez = CommandStuff ( ptrmp, ptri, ptro, &lenres, TRUE ); + rez = CommandStuff ( ptrmp, ptri, ptro, &lenres, TRUE, stcmd->com_or_xcom ); stcmd = stcmd->last; if ( rez < 0 && stcmd != NULL ) stcmd = ComSearch(sToken, stcmd); @@ -793,7 +795,7 @@ int WorkTranslate ( char* ptri, char* ptro, COMMANDS *sttra, int *lens ) ptrmp = sttra->mpatt; Repeate = 0; groupchar = '@'; - rez = CommandStuff ( ptrmp, ptri, ptro, &lenres, FALSE ); + rez = CommandStuff ( ptrmp, ptri, ptro, &lenres, FALSE, sttra->com_or_xcom ); sttra = sttra->last; if ( rez < 0 && sttra != NULL ) sttra = TraSearch(sToken, sttra); @@ -809,7 +811,7 @@ int WorkTranslate ( char* ptri, char* ptro, COMMANDS *sttra, int *lens ) return -1; } -int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int com_or_tra ) +int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int com_or_tra, int com_or_xcom ) { int endTranslation = FALSE; char *lastopti[2]; @@ -822,16 +824,21 @@ int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int c while ( *ptri != '\0' && !endTranslation ) { SKIPTABSPACES( ptrmp ); - SKIPTABSPACES( ptri ); switch ( *ptrmp ) { case '[': numBrackets++; + aIsRepeate[ Repeate ] = 0; lastopti[Repeate++] = ptrmp; ptrmp++; break; case ']': if ( Repeate ) - { Repeate--; ptrmp = lastopti[Repeate]; numBrackets--; } + { + Repeate--; + if( aIsRepeate[ Repeate ] ) ptrmp = lastopti[Repeate]; + else ptrmp++; + numBrackets--; + } else { numBrackets--; ptrmp++; } break; case ',': @@ -862,7 +869,7 @@ int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int c break; default: /* Key word */ ptr = ptrmp; - if ( *ptri == ',' || strincmp(ptri, &ptrmp ) ) + if ( *ptri == ',' || strincmp(ptri, &ptrmp, !com_or_xcom ) ) { if ( numBrackets ) { @@ -872,6 +879,7 @@ int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int c } else if ( *ptri != ',' ) ptri += (ptrmp - ptr); } + SKIPTABSPACES( ptri ); }; if ( *ptrmp != '\0' ) @@ -1055,7 +1063,7 @@ int WorkMarkers( char **ptrmp, char **ptri, char *ptro, int *lenres ) SKIPTABSPACES( ptr ); /* Comparing real parameter and restriction value */ ptrtemp = ptr; - if ( !strincmp ( *ptri, &ptr ) ) + if ( !strincmp ( *ptri, &ptr, FALSE ) ) { lenreal = stroncpy( expreal, *ptri, (ptr-ptrtemp) ); *ptri += lenreal; @@ -1097,7 +1105,7 @@ int WorkMarkers( char **ptrmp, char **ptri, char *ptro, int *lenres ) int getExpReal ( char *expreal, char **ptri, int prlist, int maxrez ) { int lens = 0; - char *sZnaki = "+-=><*/$.&:#%!"; + char *sZnaki = "+-=><*/$.&:#%!^"; int State; int StBr1 = 0, StBr2 = 0, StBr3 = 0; int rez = 0; @@ -1253,6 +1261,7 @@ void SearnRep( char *exppatt,char *expreal,int lenreal,char *ptro, int *lenres) } if ( *ptr == '[' ) { + if( Repeate ) aIsRepeate[ Repeate - 1 ]++; ptr2 = ptrOut + ifou + 3; while ( *ptr2 != ']' && *(ptr-1) != '\\' ) { @@ -1392,7 +1401,8 @@ int ReplacePattern ( char patttype, char *expreal, int lenreal, char *ptro, int if( *expreal != '\0' ) { if ( !lenitem || *expreal == '(' || *expreal == '&' || - *expreal == '\"' || *expreal == '\'' ) + (*expreal=='\"' && *(expreal+lenitem-1)=='\"') || + (*expreal == '\'' && *(expreal+lenitem-1)=='\'') ) { if( ifou ) lenitem++; pp_Stuff ( (*expreal=='&')? expreal+1:expreal, ptro, @@ -1416,7 +1426,8 @@ int ReplacePattern ( char patttype, char *expreal, int lenreal, char *ptro, int while ( ifou > 0 ); } else if ( !lenreal || *expreal == '(' || *expreal == '&' || - *expreal == '\"' || *expreal == '\'' ) + (*expreal=='\"' && *(expreal+lenreal-1)=='\"') || + (*expreal == '\'' && *(expreal+lenreal-1)=='\'') ) pp_Stuff ( (*expreal=='&')? expreal+1:expreal, ptro, (*expreal=='&')? lenreal-1:lenreal, 4, lenres ); else @@ -1720,17 +1731,26 @@ int stroncpy (char* ptro, char* ptri, int lens ) return i; } -int strincmp (char* ptro, char** ptri ) +int strincmp (char* ptro, char** ptri, int lTrunc ) { - for ( ; **ptri != ' ' && **ptri != '\t' && **ptri != ',' && **ptri != '[' && **ptri != ']' && - **ptri != '\1' && **ptri != '\0' && toupper(**ptri)==toupper(*ptro); - ptro++, (*ptri)++ ); - if ( ( **ptri == ' ' || **ptri == ',' || **ptri == '[' || - **ptri == ']' || **ptri == '\1' || **ptri == '\0' ) && - ( ( !ISNAME(*ptro) && ISNAME(*(ptro-1)) ) || - ( !ISNAME(*(ptro-1)) ) ) ) - return 0; - return 1; + char *ptrb = ptro, co, ci; + + for ( ; **ptri != ' ' && **ptri != '\t' && **ptri != ',' && **ptri != '[' && **ptri != ']' && + **ptri != '\1' && **ptri != '\0' && toupper(**ptri)==toupper(*ptro); + ptro++, (*ptri)++ ); + co = *(ptro-1); + ci = **ptri; + if ( ( ( ci == ' ' || ci == ',' || ci == '[' || + ci == ']' || ci == '\1' || ci == '\0' ) && + ( ( !ISNAME(*ptro) && ISNAME(co) ) || + ( !ISNAME(co) ) ) ) ) + return 0; + else if ( lTrunc && ptro-ptrb >= 4 && ISNAME(ci) && !ISNAME(*ptro) && ISNAME(co) ) + { + while( ISNAME(**ptri) ) (*ptri)++; + return 0; + } + return 1; } int strincpy (char* ptro, char* ptri ) @@ -1771,25 +1791,23 @@ void stroupper ( char *stroka ) int strotrim ( char *stroka ) { - char *ptr = stroka, lastc = '0'; + char *ptr = stroka, lastc = '0', curc; int lens = 0, State = STATE_NORMAL; - while ( *stroka != '\0' ) + while ( ( curc = *stroka ) != '\0' ) { - if ( State == STATE_QUOTE1 ) { if (*stroka == '\'') State = STATE_NORMAL; } - else if ( State == STATE_QUOTE2 ) { if (*stroka=='\"') State = STATE_NORMAL; } + if ( State == STATE_QUOTE1 ) { if (curc == '\'') State = STATE_NORMAL; } + else if ( State == STATE_QUOTE2 ) { if (curc=='\"') State = STATE_NORMAL; } else { - if ( *stroka == '\'' ) State = STATE_QUOTE1; - else if ( *stroka == '\"' ) State = STATE_QUOTE2; + if ( curc == '\'' ) State = STATE_QUOTE1; + else if ( curc == '\"' ) State = STATE_QUOTE2; + else if ( curc == '\t' ) curc = ' '; } -/* if ( State != STATE_NORMAL || (*stroka != ' ' && *stroka != '\t') || - ( (ISNAME(lastc) || lastc=='>') && (ISNAME(*(stroka+1)) || *(stroka+1)=='<') ) ) -*/ - if ( State != STATE_NORMAL || (*stroka != ' ' && *stroka != '\t') || - ( *stroka==' ' && lastc != ' ' && lastc != ',' && lastc != '(' && *(stroka+1)!=',') ) + if ( State != STATE_NORMAL || curc != ' ' || + ( curc==' ' && lastc != ' ' && lastc != ',' && lastc != '(' && *(stroka+1)!=',') ) { - *ptr++ = *stroka; - lastc = *stroka; + *ptr++ = curc; + lastc = curc; lens++; } stroka++; diff --git a/harbour/source/hbpp/table.c b/harbour/source/hbpp/table.c index 7ad854e11d..7692dfe128 100644 --- a/harbour/source/hbpp/table.c +++ b/harbour/source/hbpp/table.c @@ -227,7 +227,7 @@ static COMMANDS sC___127 = {0,"SET","KEY \1A00 [TO]","SetKey( \1A00, NIL )",&sC___126 }; static COMMANDS sC___128 = {0,"SET","FUNCTION \1A00 [TO] [\1B00]","__SetFunction( \1A00, \1B00 )",&sC___127 }; static COMMANDS sC___129 = {0,"CLEAR","MEMORY","__MVClear()",&sC___128 }; - static COMMANDS sC___130 = {0,"RELEASE"," \1A00","__MVXRelease( \1A30 )",&sC___129 }; + static COMMANDS sC___130 = {0,"RELEASE"," \1A10","__MVXRelease( \1A30 )",&sC___129 }; static COMMANDS sC___131 = {0,"RELEASE","ALL","__MVRelease('*', .t.)",&sC___130 }; static COMMANDS sC___132 = {0,"RELEASE","ALL LIKE \1A00","__MVRelease( \1A10, .t. )",&sC___131 }; static COMMANDS sC___133 = {0,"RELEASE","ALL EXCEPT \1A00","__MVRelease( \1A10, .f. )",&sC___132 };