From 90dd4a548c84e7298a0be13bfce9997dc3d42010 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Mon, 2 Oct 2000 20:02:42 +0000 Subject: [PATCH] 2000-10-02 13:00 UTC+0800 Ron Pinkas * source/compiler/hbpcode.c * Corrected 1 compiler warning. * source/pp/ppcomp.c * Cleaned-up and corrected bug when rules files had an #include directive. + Added CloseInclude() and moved relevant logic into it. * source/pp/ppcore.c - Removed unused s_iIncludes, and hb_pp_nEmptyStrings * utils/hbpp/hbpp.c + Added local hb_pp_nEmptyStrings to hb_pp_Parse() --- harbour/ChangeLog | 14 ++++ harbour/source/compiler/hbpcode.c | 6 +- harbour/source/pp/ppcomp.c | 129 ++++++++++++------------------ harbour/source/pp/ppcore.c | 18 ++++- harbour/utils/hbpp/hbpp.c | 3 +- 5 files changed, 86 insertions(+), 84 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6d97d19ecf..af53a720b4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,17 @@ +2000-10-02 13:00 UTC+0800 Ron Pinkas + * source/compiler/hbpcode.c + * Corrected 1 compiler warning. + + * source/pp/ppcomp.c + * Cleaned-up and corrected bug when rules files had an #include directive. + + Added CloseInclude() and moved relevant logic into it. + + * source/pp/ppcore.c + - Removed unused s_iIncludes, and hb_pp_nEmptyStrings + + * utils/hbpp/hbpp.c + + Added local hb_pp_nEmptyStrings to hb_pp_Parse() + 2000-10-02 12:45 UTC-0400 David G. Holm * source/pp/ppcore.c ! The include file limit check now uses hb_comp_files.iFiles diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 76aa1509ab..f0b8189ca0 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -233,7 +233,7 @@ void hb_compStrongType( int iSize ) PCOMDECLARED pDeclared; ULONG ulPos = pFunc->lPCodePos - iSize; SHORT wVar = 0; - BYTE szType1[64], szType2[64], cType = 0, cSubType1 = 0, cSubType2 = 0; + BYTE szType1[64], szType2[64], cType, cSubType1 = 0, cSubType2 = 0; BYTE bLast1, bLast2; /* Make sure we have enough stack space. */ @@ -1459,7 +1459,7 @@ void hb_compStrongType( int iSize ) if( pVar ) { - BYTE cType = pVar->cType; + cType = pVar->cType; /*printf( "\nPushed: %s Type: %c SubType: %c\n", pVar->szName, pVar->cType, pVar->cType - 100 );*/ @@ -1485,7 +1485,7 @@ void hb_compStrongType( int iSize ) } else { - BYTE cType = pSym->cType; + cType = pSym->cType; /*printf( "\nPushed Symbol: %s Type: %c SubType: %c\n", pSym->szName, pSym->cType, pSym->cType - 100 );*/ diff --git a/harbour/source/pp/ppcomp.c b/harbour/source/pp/ppcomp.c index 5ac5aeefb5..5e250a2f29 100644 --- a/harbour/source/pp/ppcomp.c +++ b/harbour/source/pp/ppcomp.c @@ -57,6 +57,8 @@ static int hb_pp_LastOutLine = 1; BOOL bDebug = FALSE; */ +extern void CloseInclude( void ); + int hb_pp_Internal( FILE * handl_o, char * sOut ) { PFILE pFile; @@ -67,8 +69,6 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) HB_TRACE(HB_TR_DEBUG, ("hb_pp_Internal(%p, %s)", handl_o, sOut)); - hb_pp_nEmptyStrings = 0; - while( TRUE ) { pFile = hb_comp_files.pLast; @@ -157,16 +157,7 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) return 0; /* we have reached the main EOF */ else { - /* we close the currently include file and continue */ - fclose( hb_comp_files.pLast->handle ); - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_xfree( hb_comp_files.pLast->szFileName ); - pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; - hb_xfree( hb_comp_files.pLast ); - hb_comp_files.pLast = pFile; - - hb_comp_iLine = hb_comp_files.pLast->iLine; - hb_comp_files.iFiles--; + CloseInclude(); lLine = 1; } @@ -183,7 +174,9 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) { if( hb_comp_files.iFiles == 1 ) hb_pp_LastOutLine = hb_comp_iLine; + sprintf( ptrOut, "#line %d \"%s\"", ( hb_comp_files.pLast->iLine ) , hb_comp_files.pLast->szFileName ); + while( *ptrOut ) ptrOut++; /* Ron Pinkas added 2000-06-14 */ @@ -230,7 +223,6 @@ int hb_pp_ReadRules( void ) HB_TRACE(HB_TR_DEBUG, ("hb_pp_ReadRules()")); - hb_pp_nEmptyStrings = 0; while( TRUE ) { pFile = hb_comp_files.pLast; @@ -238,81 +230,64 @@ int hb_pp_ReadRules( void ) while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - lens, lContinue, ( char * ) pFile->pBuffer, &( pFile->lenBuffer ), &( pFile->iBuffer ) ) ) >= 0 ) - { - lens += rdlen; + { + lens += rdlen; + hb_comp_iLine++; - if( s_szLine[ lens - 1 ] == ';' ) - { - lContinue = 1; - lens--; - lens--; - while( s_szLine[ lens ] == ' ' || s_szLine[ lens ] == '\t' ) lens--; - s_szLine[ ++lens ] = ' '; - s_szLine[ ++lens ] = '\0'; + if( s_szLine[ lens - 1 ] == ';' ) + { + lContinue = 1; + lens--; + lens--; + while( s_szLine[ lens ] == ' ' || s_szLine[ lens ] == '\t' ) lens--; + s_szLine[ ++lens ] = ' '; + s_szLine[ ++lens ] = '\0'; + } + else + { + lContinue = 0; + lens = 0; + } - hb_pp_nEmptyStrings++; - } - else + if( ! lContinue ) + { + if( *s_szLine != '\0' ) { - lContinue = 0; - lens = 0; + ptr = s_szLine; + HB_SKIPTABSPACES( ptr ); + + if( *ptr == '#' ) + { + hb_pp_ParseDirective( ptr + 1 ); + } + + *s_szLine = '\0'; } - if( !lContinue ) - { - if( *s_szLine != '\0' ) - { - ptr = s_szLine; - HB_SKIPTABSPACES( ptr ); - if( *ptr == '#' ) - { - hb_pp_ParseDirective( ptr + 1 ); - if( pFile != hb_comp_files.pLast ) - { - pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; - if( lLine == 0) - *s_szLine = '\0'; - lLine = 0; - pFile->iLine += ( 1 + hb_pp_nEmptyStrings ); - hb_pp_nEmptyStrings = 0; - } - else - { - *s_szLine = '\0'; - hb_pp_nEmptyStrings++; - } - } - else - { - *s_szLine = '\0'; - hb_pp_nEmptyStrings++; - } - } - else - hb_pp_nEmptyStrings++; - break; - } - } + break; + } + } + if( rdlen < 0 ) - { + { if( hb_comp_files.iFiles == 1 ) return 0; /* we have reached the main EOF */ else - { /* we close the currently include file and continue */ - fclose( hb_comp_files.pLast->handle ); - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_xfree( hb_comp_files.pLast->szFileName ); - pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; - hb_xfree( hb_comp_files.pLast ); - hb_comp_files.pLast = pFile; - hb_comp_iLine = hb_comp_files.pLast->iLine; - hb_comp_files.iFiles--; + { + CloseInclude(); lLine = 1; - hb_pp_nEmptyStrings = 0; - } - } - if( *s_szLine ) break; + } + + *s_szLine = '\0'; + } + } + + if( lLine ) + { + if( hb_comp_files.iFiles == 1 ) + hb_pp_LastOutLine = hb_comp_iLine; } return lens; } + diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 9f648bb4e8..5566f47e79 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -112,6 +112,7 @@ static int NextWord( char **, char *, BOOL ); static int NextName( char **, char * ); static int NextParm( char **, char * ); static BOOL OpenInclude( char *, PATHNAMES *, PHB_FNAME, BOOL bStandardOnly, char * ); +void CloseInclude( void ); #define ISNAME( c ) ( isalnum( ( int ) c ) || ( c ) == '_' || ( c ) > 0x7E ) #define MAX_NAME 255 @@ -149,7 +150,6 @@ static int s_numBrackets; static char s_groupchar; static char s_prevchar; -int hb_pp_nEmptyStrings; int * hb_pp_aCondCompile = NULL; int hb_pp_nCondCompile = 0; @@ -2938,7 +2938,7 @@ static BOOL OpenInclude( char * szFileName, PATHNAMES * pSearch, PHB_FNAME pMain HB_TRACE(HB_TR_DEBUG, ("OpenInclude(%s, %p, %p, %p, %d)", szFileName, pSearch, pMainFileName, fptr, (int) bStandardOnly)); - if( hb_comp_files.iFiles >= HB_PP_MAX_INCLUDES ) + if( hb_comp_files.iFiles > HB_PP_MAX_INCLUDES ) hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_TOO_MANY_INCLUDES, szFileName, NULL ); if( bStandardOnly ) @@ -2996,3 +2996,17 @@ static BOOL OpenInclude( char * szFileName, PATHNAMES * pSearch, PHB_FNAME pMain return FALSE; } +void CloseInclude( void ) +{ + PFILE pFile; + + /* we close the currently include file and continue */ + fclose( hb_comp_files.pLast->handle ); + hb_xfree( hb_comp_files.pLast->pBuffer ); + hb_xfree( hb_comp_files.pLast->szFileName ); + pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; + hb_xfree( hb_comp_files.pLast ); + hb_comp_files.pLast = pFile; + hb_comp_iLine = hb_comp_files.pLast->iLine; + hb_comp_files.iFiles--; +} diff --git a/harbour/utils/hbpp/hbpp.c b/harbour/utils/hbpp/hbpp.c index e9538204f8..9dab173395 100644 --- a/harbour/utils/hbpp/hbpp.c +++ b/harbour/utils/hbpp/hbpp.c @@ -234,11 +234,10 @@ int hb_pp_Parse( FILE * handl_o ) char * ptr; int lContinue; int lens, rdlen; - int lLine = 0, i; + int lLine = 0, i, hb_pp_nEmptyStrings = 0;; HB_TRACE(HB_TR_DEBUG, ("hb_pp_Parse(%p)", handl_o)); - hb_pp_nEmptyStrings = 0; while( TRUE ) { pFile = hb_comp_files.pLast;