From 4aad1f1710aa5ee16b2cc6efd59bce21bc5c32d1 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Fri, 17 Mar 2000 07:02:11 +0000 Subject: [PATCH] Updating preprocessor files --- harbour/ChangeLog | 12 +++++++ harbour/contrib/rdd_ads/adsfunc.c | 2 +- harbour/source/compiler/hbgenerr.c | 6 ++-- harbour/source/pp/ppcomp.c | 6 ++-- harbour/source/pp/ppcore.c | 51 +++++++++++++++++++++++++----- harbour/source/pp/pplib.c | 1 + harbour/source/pp/stdalone/hbpp.c | 4 ++- 7 files changed, 67 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3b4520a9a4..cdccd9079f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +20000317-09:56 GMT+3 Alexander Kresin + * source/pp/stdalone/hbpp.c + * source/pp/ppcomp.c + * source/pp/ppcore.c + * source/pp/pplib.c + * source/compiler/hbgenerr.c + * fixed line number output for errors and warnings + * hb_pp_init() changed for supporting multiply files compiling + * warning in addDefine about duplicate define uncommented + * contrib/rdd_ads/adsfunc.c + * typo fixed ( HB_ADCUSTOMIZEAOF -> HB_ADSCUSTOMIZEAOF ) + 20000317-01:09 GMT+1 Victor Szakats * source/rtl/console.c - Removed the non-GT branch from __ACCEPT(). diff --git a/harbour/contrib/rdd_ads/adsfunc.c b/harbour/contrib/rdd_ads/adsfunc.c index fb66b2f55e..4f380c9e4e 100644 --- a/harbour/contrib/rdd_ads/adsfunc.c +++ b/harbour/contrib/rdd_ads/adsfunc.c @@ -258,7 +258,7 @@ HARBOUR HB_ADSCLEARAOF( void ) hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCLEARAOF" ); } -HARBOUR HB_ADCUSTOMIZEAOF( void ) +HARBOUR HB_ADSCUSTOMIZEAOF( void ) { ADSAREAP pArea; UNSIGNED32 pulRecords[1]; diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 3db7e9295a..c7f8718773 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -35,6 +35,8 @@ #include "hbcomp.h" +extern int nEmptyStrings; + /* Table with parse errors */ char * hb_comp_szErrors[] = { @@ -113,7 +115,7 @@ char * hb_comp_szWarnings[] = void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) { if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine + nEmptyStrings ); printf( "Error %c%04i ", cPrefix, iError ); printf( szErrors[ iError - 1 ], szError1, szError2 ); @@ -133,7 +135,7 @@ void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * if( ( szText[ 0 ] - '0' ) <= hb_comp_iWarnings ) { if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine + nEmptyStrings ); printf( "Warning %c%04i ", cPrefix, iWarning ); printf( szText + 1, szWarning1, szWarning2 ); printf( "\n" ); diff --git a/harbour/source/pp/ppcomp.c b/harbour/source/pp/ppcomp.c index fe3b83d167..085da6352c 100644 --- a/harbour/source/pp/ppcomp.c +++ b/harbour/source/pp/ppcomp.c @@ -49,8 +49,7 @@ #include "hbpp.h" #include "hbcomp.h" -extern FILES hb_comp_files; -extern int hb_comp_iLine; /* currently parsed file line number */ +extern int nEmptyStrings; static char s_szLine[ HB_PP_STR_SIZE ]; static char s_szOutLine[ HB_PP_STR_SIZE ]; @@ -61,10 +60,11 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) char * ptr, * ptrOut; int lContinue; int lens, rdlen; - int nEmptyStrings = 0, lLine = 0, i; + int lLine = 0, i; HB_TRACE(HB_TR_DEBUG, ("PreProcess(%p, %p, %s)", handl_o, sOut)); + nEmptyStrings = 0; while( TRUE ) { pFile = hb_comp_files.pLast; diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 8a0cdb7d29..013b5f6d2f 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -143,7 +143,9 @@ static BOOL s_bTracePragma = FALSE; #define IT_COMMA 3 #define IT_ID_OR_EXPR 4 -static int s_kolAddDefs; +static int s_kolAddDefs = 0; +static int s_kolAddComs = 0; +static int s_kolAddTras = 0; static int s_ParseState; static int s_maxCondCompile; static int s_aIsRepeate[ 5 ]; @@ -153,8 +155,8 @@ static int s_numBrackets; static char s_groupchar; static char s_prevchar; -extern int hb_comp_iLine; /* currently parsed file line number */ -int * hb_pp_aCondCompile; +int nEmptyStrings; +int * hb_pp_aCondCompile = NULL; int hb_pp_nCondCompile = 0; /* Table with parse errors */ @@ -184,17 +186,50 @@ char * hb_pp_szWarnings[] = void hb_pp_Init( void ) { + DEFINES * stdef; + COMMANDS * stcmd; + HB_TRACE(HB_TR_DEBUG, ("hb_pp_Init()")); - /* TOFIX: The tables in PPTABLE.C should also be reinitialized */ + while( s_kolAddDefs ) + { + stdef = hb_pp_topDefine; + if( stdef->pars ) hb_xfree( stdef->pars ); + if( stdef->value ) hb_xfree( stdef->value ); + hb_xfree( stdef->name ); + hb_pp_topDefine = stdef->last; + hb_xfree( stdef ); + s_kolAddDefs--; + } + while( s_kolAddComs ) + { + stcmd = hb_pp_topCommand; + if( stcmd->mpatt ) hb_xfree( stcmd->mpatt ); + if( stcmd->value ) hb_xfree( stcmd->value ); + hb_xfree( stcmd->name ); + hb_pp_topCommand = stcmd->last; + hb_xfree( stcmd ); + s_kolAddComs--; + } + while( s_kolAddTras ) + { + stcmd = hb_pp_topTranslate; + if( stcmd->mpatt ) hb_xfree( stcmd->mpatt ); + if( stcmd->value ) hb_xfree( stcmd->value ); + hb_xfree( stcmd->name ); + hb_pp_topTranslate = stcmd->last; + hb_xfree( stcmd ); + s_kolAddTras--; + } - s_kolAddDefs = 0; s_ParseState = 0; s_maxCondCompile = 5; s_bReplacePat = TRUE; s_prevchar = 'A'; - hb_pp_aCondCompile = ( int * ) hb_xgrab( sizeof( int ) * 5 ); + if( !hb_pp_aCondCompile ) + hb_pp_aCondCompile = ( int * ) hb_xgrab( sizeof( int ) * 5 ); + hb_pp_nCondCompile = 0; { @@ -378,9 +413,7 @@ DEFINES * hb_pp_AddDefine( char * defname, char * value ) if( stdef != NULL ) { -/* hb_compGenWarning( hb_pp_szWarnings, 'I', HB_PP_WARN_DEFINE_REDEF, defname, NULL ); -*/ if( isNew ) { @@ -400,6 +433,7 @@ DEFINES * hb_pp_AddDefine( char * defname, char * value ) } stdef->value = ( value == NULL ) ? NULL : hb_strdup( value ); + stdef->pars = NULL; return stdef; } @@ -683,6 +717,7 @@ static COMMANDS * AddCommand( char * cmdname ) stcmd->last = hb_pp_topCommand; hb_pp_topCommand = stcmd; stcmd->name = hb_strdup( cmdname ); + s_kolAddComs++; return stcmd; } diff --git a/harbour/source/pp/pplib.c b/harbour/source/pp/pplib.c index 3662347504..5b04653b6a 100644 --- a/harbour/source/pp/pplib.c +++ b/harbour/source/pp/pplib.c @@ -54,6 +54,7 @@ PATHNAMES * hb_comp_pIncludePath = NULL; PHB_FNAME hb_comp_pFileName = NULL; FILES hb_comp_files; int hb_comp_iLine; /* currently parsed file line number */ +extern int nEmptyStrings; /* These are need for the PP #pragma support */ BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */ diff --git a/harbour/source/pp/stdalone/hbpp.c b/harbour/source/pp/stdalone/hbpp.c index a1017a05fd..ea79f730be 100644 --- a/harbour/source/pp/stdalone/hbpp.c +++ b/harbour/source/pp/stdalone/hbpp.c @@ -64,6 +64,7 @@ PATHNAMES * hb_comp_pIncludePath = NULL; PHB_FNAME hb_comp_pFileName = NULL; FILES hb_comp_files; int hb_comp_iLine = 1; /* currently parsed file line number */ +extern int nEmptyStrings; /* These are need for the PP #pragma support */ BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */ @@ -234,10 +235,11 @@ int hb_pp_Parse( FILE * handl_o ) char * ptr; int lContinue; int lens, rdlen; - int nEmptyStrings = 0, lLine = 0, i; + int lLine = 0, i; HB_TRACE(HB_TR_DEBUG, ("PreProcess(%p, %p, %s)", handl_o, sOut)); + nEmptyStrings = 0; while( TRUE ) { pFile = hb_comp_files.pLast;