diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c44cff3f10..f238c7db8b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +19990620-22:29 Alexander Kresin + updated: + * source\hbpp\hbppmain.c + * source\hbpp\hbpp.c + * source\hbpp\harb.h + Fixed some problems with preprocessor + 19990620-15:50 CET Victor Szel * hb_gtBox() rewritten. It's now 100% Clipper compatible, fill character @@ -23,7 +30,7 @@ * added support for other compilers not compatible with gcc (there were gcc switches hardcoded into common rules) New compiler: Watcom C/C++ 10.0 - * changed rules for DJGPP - the Makefile can be used now to + * changed rules for DJGPP - the Makefile can be used now to create harbour with DJGPP. The makedos.env and makefile.dos are obsolete now. * cleared the use of '\' and '/' in make rules for DOS environment @@ -32,25 +39,25 @@ * changed the rule for creating DJGPP library (archive) to use script file instead of command line - there is a limit of 128 characters that can be placed into command line in DOS - + + include/hbpp.h + new file with definition shared by the preprocessor and harbour.y (needed to match the declaration of AddDefine function) - + * source/hbpp/harb.h * changed to include the new hbpp.h file - + * source/compiler/harbour.y * changed the declaration of yy_create_buffer to make it compatible with C++ compilers - * added inclusion of hbpp.h (to keep C++ compilers happy with + * added inclusion of hbpp.h (to keep C++ compilers happy with AaddDefine function) - + * source/compiler/harbour.l + added #pragma to suppress warnings of unreachable code when compiled with Watcom C++ compiler - - + + 19990619-14:35 CET Matteo Baccan * makefile.vc, source/hbpp/hbpp.c, source/hbpp/hbppint.c, source/rtl/environ.c, source/rtl/files.c, source/rtl/gt/gtwin.c, @@ -62,44 +69,44 @@ * tests/working/testcgi.prg * tests/working/testinc.prg * changed the names of included files into lowercase - + * include/extend.h + added include - + * source/rtl/set.c - + files created by SET PRINTER TO or SET ALTERNATE TO have now + + files created by SET PRINTER TO or SET ALTERNATE TO have now changed permissions to write/read by user on UNIX like OS - + 19990619-12:22 Ryszard Glab * include/hbsetup.h + added automatic definition of settings that can be used for OS specific code OS_UNIX_COMPATIBLE -for UNIX like systems OS_DOS_COMPATIBLE -for DOS like systems - + * source/rtl/console.c - + added calls for fgets instead of gets for GCC on UNIX-es + + added calls for fgets instead of gets for GCC on UNIX-es TODO: check if this change can be applied on DOS also * changed CR/LF use to LF for GCC on UNIX-es - + * source/rtl/dir.c * changed to use OS_UNIX_COMPATIBLE/OS_DOS_COMPATIBLE settings - + 19990619-10:42 Ryszard Glab * tests/working/Makefile * moved some files into BAD_PRG_SOURCES - + * tests/working/testid.prg + added TODO comment because it core dumps if /dTEST is not passed - + 19990619-09:49 CET Patrick Mast * Updated build numbers 19990619-09:40 CET Patrick Mast * tests\working\hscript\hscript.prg removed line 150 - + 19990618-21:50 EDT David G. Holm * makefile.icc - genobj.c was moved to source/contrib @@ -118,18 +125,18 @@ * config/linux/gcc.cf * added default gcc library libm * added location of libm library (I have assumed /usr/lib) - + * source/include/hbsetup.h - + the order of static variables initialisation is not determined in + + the order of static variables initialisation is not determined in gcc on Linux. This requires the definition of HARBOUR_START_PROCEDURE The dafault is 'MAIN' -- tests/working/next.prg +- tests/working/next.prg - removed because it is contained in keywords.prg - + * tests/working/Makefile -removed reference to next.prg - + 19990618-23:17 CET Patrick Mast * Release of Build #27 @@ -268,77 +275,77 @@ Thu Jun 17 11:34:35 1999 Gonzalo A. Diethelm - * source/Makefile: - * source/compiler/Makefile: - * source/hbpp/Makefile: - Now the hbpp preprocessor is compiled before the compiler, and it - generates a library. No stand-alone preprocessor is generated. The - compiler links against the new preprocessor library. + * source/Makefile: + * source/compiler/Makefile: + * source/hbpp/Makefile: + Now the hbpp preprocessor is compiled before the compiler, and it + generates a library. No stand-alone preprocessor is generated. The + compiler links against the new preprocessor library. - * include/Makefile: - * tests/working/Makefile: - Updated the list of files. + * include/Makefile: + * tests/working/Makefile: + Updated the list of files. - * include/compiler.h: - * include/ctoharb.h: - * include/dates.h: - * include/error.api: - * include/errorapi.h: - * include/extend.h: - * include/filesys.h: - * include/gtapi.h: - * include/hberrors.h: - * include/hbsetup.h: - * include/init.h: - * include/itemapi.h: - * include/pcode.h: - * include/set.h: - * include/types.h: - * include/version.h: - * source/compiler/fixflex.c: - * source/compiler/genobj32.c: - * source/compiler/harbour.l: - * source/compiler/harbour.y: - * source/hbpp/harb.h: - * source/hbpp/hbpp.c: - * source/rtl/asort.prg: - * source/rtl/descend.c: - * source/rtl/error.prg: - * source/rtl/errorsys.prg: - * source/rtl/hardcr.c: - * source/rtl/itemapi.c: - * source/rtl/mtran.c: - * source/rtl/objfunc.prg: - * source/rtl/tclass.prg: - * source/tools/asciisum.c: - * source/tools/ascpos.c: - * source/tools/atdiff.c: - * source/tools/chareven.c: - * source/tools/charmix.c: - * source/tools/charodd.c: - * source/tools/chrcount.c: - * source/tools/chrfirst.c: - * source/tools/chrtotal.c: - * source/tools/debug.c: - * source/tools/hb_f.c: - * source/tools/strasint.c: - * source/tools/strcount.c: - * source/tools/strcspn.c: - * source/tools/strdiff.c: - * source/tools/strexpan.c: - * source/tools/stringp.prg: - * source/tools/strleft.c: - * source/tools/strpbrk.c: - * source/tools/strright.c: - * source/vm/hvm.c: - * source/vm/initsymb.c: - Made sure all *.{h,c,ch,api,prg,l,y} files under include/ and - source/ have an RCS Id keyword. - Got rid of the RCS Log keyword on several files; this keyword - should never be placed in a source file. - Made sure all *.h files have a proper include guard. If the file - name is foo.h, the include guard is called FOO_H_, without a - leading underscore, to comply with ANSI rules. + * include/compiler.h: + * include/ctoharb.h: + * include/dates.h: + * include/error.api: + * include/errorapi.h: + * include/extend.h: + * include/filesys.h: + * include/gtapi.h: + * include/hberrors.h: + * include/hbsetup.h: + * include/init.h: + * include/itemapi.h: + * include/pcode.h: + * include/set.h: + * include/types.h: + * include/version.h: + * source/compiler/fixflex.c: + * source/compiler/genobj32.c: + * source/compiler/harbour.l: + * source/compiler/harbour.y: + * source/hbpp/harb.h: + * source/hbpp/hbpp.c: + * source/rtl/asort.prg: + * source/rtl/descend.c: + * source/rtl/error.prg: + * source/rtl/errorsys.prg: + * source/rtl/hardcr.c: + * source/rtl/itemapi.c: + * source/rtl/mtran.c: + * source/rtl/objfunc.prg: + * source/rtl/tclass.prg: + * source/tools/asciisum.c: + * source/tools/ascpos.c: + * source/tools/atdiff.c: + * source/tools/chareven.c: + * source/tools/charmix.c: + * source/tools/charodd.c: + * source/tools/chrcount.c: + * source/tools/chrfirst.c: + * source/tools/chrtotal.c: + * source/tools/debug.c: + * source/tools/hb_f.c: + * source/tools/strasint.c: + * source/tools/strcount.c: + * source/tools/strcspn.c: + * source/tools/strdiff.c: + * source/tools/strexpan.c: + * source/tools/stringp.prg: + * source/tools/strleft.c: + * source/tools/strpbrk.c: + * source/tools/strright.c: + * source/vm/hvm.c: + * source/vm/initsymb.c: + Made sure all *.{h,c,ch,api,prg,l,y} files under include/ and + source/ have an RCS Id keyword. + Got rid of the RCS Log keyword on several files; this keyword + should never be placed in a source file. + Made sure all *.h files have a proper include guard. If the file + name is foo.h, the include guard is called FOO_H_, without a + leading underscore, to comply with ANSI rules. 19990617-12:40 CET Eddie Runia * source/rtl/dir.c diff --git a/harbour/source/hbpp/harb.h b/harbour/source/hbpp/harb.h index d15465f23c..c5b36bf53b 100644 --- a/harbour/source/hbpp/harb.h +++ b/harbour/source/hbpp/harb.h @@ -21,6 +21,21 @@ typedef unsigned long ULONG; #define IS_PATH_SEP( c ) (strchr(PATH_DELIMITER, (c))!=NULL) #define OPT_DELIMITER "/-" #define IS_OPT_SEP( c ) (strchr(OPT_DELIMITER, (c))!=NULL) +#ifdef __GNUC__ + /* The GNU C compiler is used */ + #ifdef __DJGPP__ + /* The DJGPP port of GNU C is used - for DOS platform */ + #define OS_PATH_LIST_SEPARATOR ';' + #define OS_PATH_DELIMITER '\\' + #else + #define OS_PATH_LIST_SEPARATOR ':' + #define OS_PATH_DELIMITER '/' + #endif +#else + /* we are assuming here the DOS compatible OS */ + #define OS_PATH_LIST_SEPARATOR ';' + #define OS_PATH_DELIMITER '\\' +#endif typedef struct _PATHNAMES { /* the list of pathnames to search with #include */ char *szPath; struct _PATHNAMES *pNext; @@ -43,6 +58,7 @@ void * _xgrab( ULONG ); /* allocates fixed memory */ void * _xrealloc( void *, ULONG ); /* reallocates memory */ void _xfree( void * ); /* frees fixed memory */ +/* ------------------------------------------ */ /* includes common definitions shared by preprocessor and harbour.y */ #include "hbpp.h" diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index 0ac955027f..84da5fbe05 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -526,7 +526,9 @@ int ParseExpression( char* sLine, char* sOutLine ) lenToken = NextName( &ptri, sToken, NULL); else { *sToken = *ptri++; *(sToken+1) = '\0'; lenToken = 1; } - if ( (ndef=ComSearch(sToken,0)) >= 0 ) + SKIPTABSPACES( ptri ); + + if ( *ptri != ':' && *ptri != '=' && (ndef=ComSearch(sToken,0)) >= 0 ) { ptro = sOutLine; i = WorkCommand( sToken, ptri, ptro, ndef ); @@ -711,7 +713,9 @@ int CommandStuff ( char *ptrmp, char *inputLine, char * ptro, int *lenres, int c SKIPTABSPACES( ptri ); switch ( *ptrmp ) { case '[': - nbr++; ptrmp++; lastopti[Repeate] = ptrmp; + nbr++; + ptrmp++; + lastopti[Repeate] = ptrmp; break; case ']': if ( Repeate ) { Repeate--; ptrmp = lastopti[Repeate]; } @@ -1252,6 +1256,10 @@ int md_strAt(char *szSub, int lSubLen, char *szText) { lSubPos++; lPos++; + if ( lSubPos >= lSubLen && + ( ( isname(*szSub) && lPos>lSubPos && isname(*(szText+lPos-lSubPos-1)) ) || + ( isname(*(szSub+lSubLen-1)) && isname(*(szText+lPos)) ) ) ) + lSubPos = 0; } else if( lSubPos ) lSubPos = 0; else lPos++; @@ -1392,17 +1400,28 @@ int NextWord ( char** sSource, char* sDest, int lLower ) int NextName ( char** sSource, char* sDest, char **sOut ) { - int i = 0; - while ( **sSource != '\0' && !isname(**sSource) ) - { if ( sOut !=NULL ) *(*sOut)++ = **sSource; (*sSource)++; } + int lenName = 0, State = STATE_NORMAL; + while ( **sSource != '\0' && ( !isname(**sSource) || State != STATE_NORMAL ) ) + { + if ( State == STATE_QUOTE1 ) + { if ( **sSource == '\'' ) State = STATE_NORMAL; } + else if ( State == STATE_QUOTE2 ) + { if ( **sSource == '\"' ) State = STATE_NORMAL; } + else if ( **sSource == '\"' ) State = STATE_QUOTE2; + else if ( **sSource == '\'' ) State = STATE_QUOTE1; + + if ( sOut !=NULL ) *(*sOut)++ = **sSource; + (*sSource)++; + } while ( **sSource != '\0' && isname(**sSource) ) { if ( sOut !=NULL ) *(*sOut)++ = **sSource; - *sDest++ = *(*sSource)++; i++; + *sDest++ = *(*sSource)++; + lenName++; } *sDest = '\0'; - return i; + return lenName; } int OpenInclude( char * szFileName, PATHNAMES *pSearch, FILE** fptr ) diff --git a/harbour/source/hbpp/hbppmain.c b/harbour/source/hbpp/hbppmain.c index 9fbf35cf76..4c0c47fb48 100644 --- a/harbour/source/hbpp/hbppmain.c +++ b/harbour/source/hbpp/hbppmain.c @@ -4,12 +4,12 @@ #if defined(__DJGPP__) || defined(__GNUC__) #include - #include #else #include #include #endif #include +#include #include #include "harb.h" @@ -18,6 +18,7 @@ extern int ParseDirective( char* ); extern int ParseExpression( char*, char* ); extern int RdStr(FILE*,char *,int,int,char*,int*,int*); extern int WrStr(FILE*,char *); +extern char* strodup ( char * ); #define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++ @@ -40,8 +41,11 @@ int main (int argc,char* argv[]) { FILE *handl_i,*handl_o; char szFileName[ _POSIX_PATH_MAX ]; +char * szDefText; FILENAME *pFileName =NULL; -int iArg = 1; +int iArg = 1, i; + + aDefnew = ( DEFINES * ) _xgrab( sizeof(DEFINES) * 50 ); while( iArg < argc ) { @@ -52,12 +56,12 @@ int iArg = 1; case 'd': case 'D': /* defines a Lex #define from the command line */ { - unsigned int i = 0; - char * szDefText = strdup( argv[ iArg ] + 2 ); + i = 0; + szDefText = strodup( argv[ iArg ] + 2 ); while( i < strolen( szDefText ) && szDefText[ i ] != '=' ) - i++; + i++; if( szDefText[ i ] != '=' ) - AddDefine( szDefText, 0 ); + AddDefine( szDefText, 0 ); else { szDefText[ i ] = 0; @@ -94,8 +98,26 @@ int iArg = 1; if ((handl_o = fopen(szFileName, "wt" )) == NULL) { printf("\nCan't open %s\n",szFileName); return 1; } + { + char * szInclude = getenv( "INCLUDE" ); + + if( szInclude ) + { + char * pPath; + char * pDelim; + + pPath = szInclude = strodup( szInclude ); + while( (pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR )) != NULL ) + { + *pDelim = '\0'; + AddSearchPath( pPath, &_pIncludePath ); + pPath = pDelim + 1; + } + AddSearchPath( pPath, &_pIncludePath ); + } + } + aCondCompile = (int*) _xgrab( sizeof(int) * 5 ); - aDefnew = ( DEFINES * ) _xgrab( sizeof(DEFINES) * 50 ); aCommnew = ( COMMANDS * ) _xgrab( sizeof(COMMANDS) * INITIAL_ACOM_SIZE ); aTranslates = ( TRANSLATES * ) _xgrab( sizeof(TRANSLATES) * 50 );