diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e26aa514e9..115b627cfd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ * fixed <-x-> match marker +2006-02-11 12:40 UTC+0100 Ryszard Glab + * source/compiler/harbour.c + * source/compiler/harbour.y + * source/pp/ppcore.c + * added tracing code + * fixed one more memory leak + 2006-02-09 15:25 UTC+0100 Ryszard Glab * source/compiler/harbour.c * fixed to release memory allocated with the proeprocessor diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 5d8b5cde56..4303c83a9b 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -50,6 +50,15 @@ #include */ +/* + * Avoid tracing in preprocessor/compiler. + */ +#if ! defined(HB_TRACE_UTILS) + #if defined(HB_TRACE_LEVEL) + #undef HB_TRACE_LEVEL + #endif +#endif + #include "hbcomp.h" #include "hbhash.h" @@ -190,6 +199,8 @@ int main( int argc, char * argv[] ) int i; BOOL bAnyFiles; + HB_TRACE(HB_TR_DEBUG, ("main()")); + hb_comp_pOutPath = NULL; #if defined( HOST_OS_UNIX_COMPATIBLE ) @@ -246,13 +257,22 @@ int main( int argc, char * argv[] ) for( i = 1; i < argc; i++ ) { + HB_TRACE(HB_TR_DEBUG, ("main LOOP(%i,%s)", i, argv[i])); if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) ) { if( ! bAnyFiles ) + { bAnyFiles = TRUE; - - if( i > 1 ) + /* do not call hb_pp_Init() because it was already called + * in hb_pp_SetRules + */ + } + else + { + /* Clear and reinitialize preprocessor state + */ hb_pp_Init(); + } iStatus = hb_compCompile( argv[ i ], argc, argv ); @@ -4322,6 +4342,7 @@ static void hb_compInitVars( void ) static void hb_compGenOutput( int iLanguage ) { + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compGenOutput()")); switch( iLanguage ) { @@ -4353,6 +4374,8 @@ static void hb_compGenOutput( int iLanguage ) static void hb_compPpoFile( void ) { + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compPpoFile()")); + hb_comp_pFilePpo->szPath = NULL; hb_comp_pFilePpo->szExtension = NULL; @@ -4377,6 +4400,8 @@ static void hb_compPpoFile( void ) static void hb_compOutputFile( void ) { + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compOutputFile()")); + hb_comp_pFileName->szPath = NULL; hb_comp_pFileName->szExtension = NULL; @@ -4400,6 +4425,8 @@ int hb_compCompile( char * szPrg, int argc, char * argv[] ) int iStatus = EXIT_SUCCESS; PHB_FNAME pFileName; + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compCompile(%s,%i)", szPrg, argc)); + hb_comp_pFileName = hb_fsFNameSplit( szPrg ); if( hb_comp_pFileName->szName ) @@ -4630,6 +4657,8 @@ int hb_compCompile( char * szPrg, int argc, char * argv[] ) void hb_compAutoOpenAdd( char * szName ) { + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compAutoOpenAdd(%s)", szName)); + if( hb_comp_bAutoOpen && ! hb_compAutoOpenFind( szName ) ) { PAUTOOPEN pAutoOpen = ( PAUTOOPEN ) hb_xgrab( sizeof( AUTOOPEN ) ), pLast; @@ -4654,6 +4683,8 @@ BOOL hb_compAutoOpenFind( char * szName ) { PAUTOOPEN pLast = hb_comp_pAutoOpen; + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compAutoOpenFind(%s)", szName)); + if( pLast == NULL ) return FALSE; diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 1b70b37671..88ff4f4d1f 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -1936,6 +1936,15 @@ int hb_compYACCMain( char * szName ) /* ------------------------------------------------------------------------ */ +/* + * Avoid tracing in preprocessor/compiler. + */ +#if ! defined(HB_TRACE_UTILS) + #if defined(HB_TRACE_LEVEL) + #undef HB_TRACE_LEVEL + #endif +#endif + void yyerror( char * s ) { if( yytext[ 0 ] == '\n' ) @@ -1949,6 +1958,8 @@ BOOL hb_compInclude( char * szFileName, HB_PATHNAMES * pSearch ) { PFILE pFile; + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compInclude(%s,%p)", szFileName, pSearch)); + yyin = fopen( szFileName, "r" ); if( ! yyin ) { @@ -1999,6 +2010,8 @@ BOOL hb_compInclude( char * szFileName, HB_PATHNAMES * pSearch ) int yywrap( void ) /* handles the EOF of the currently processed file */ { + HB_TRACE(HB_TR_DEBUG, ("yywrap()")); + if( hb_comp_files.iFiles == 1 ) { hb_xfree( hb_comp_files.pLast->pBuffer ); diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index cc6436b5dc..13b7777597 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -376,6 +376,12 @@ void hb_pp_Free( void ) hb_xfree( stcmd ); s_kolAddTras--; } + if( hb_pp_aCondCompile ) + { + hb_xfree( (void *)hb_pp_aCondCompile ); + hb_pp_aCondCompile = NULL; + } + } void hb_pp_Init( void )