diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8882904341..351496afb9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +20000220-19:55 GMT+3 Alexander Kresin + * source/pp/stdalone/hbpp.c + * source/pp/hbppint.c + * source/pp/hbpp.c + * corrected .ppo output - removed empty lines in #include files, as + CA-Clipper does it + 20000220-14:30 GMT+1 Victor Szakats * ../FT_HELPC.PRG ../HA.LNK @@ -5,7 +12,7 @@ ! Trying to remove trash from the root of the repository. * source/rtl/objfunc.prg - Removed the runtime errors if the method/data to be deleted doesn't - exist, or the method/data to be added already exist. Reasons: These + exist, or the method/data to be added already exist. Reasons: These error cases are better handled manually by the developer if needed. ! PLEASE UPDATE THE DOCS ! * makefile.bc diff --git a/harbour/source/pp/hbpp.c b/harbour/source/pp/hbpp.c index 5e3b7ac74c..75b70023ba 100644 --- a/harbour/source/pp/hbpp.c +++ b/harbour/source/pp/hbpp.c @@ -170,10 +170,6 @@ char * hb_pp_szErrors[] = /* NOTE: The first character stores the warning's level that triggers this * warning. The warning's level is set by -w command line option. */ -char * hb_pp_szWarnings[] = -{ - "3Non directive in include file %s(%s)" -}; int hb_pp_ParseDirective( char * sLine ) { diff --git a/harbour/source/pp/hbppint.c b/harbour/source/pp/hbppint.c index 23fe6473fd..a1cac3f4e0 100644 --- a/harbour/source/pp/hbppint.c +++ b/harbour/source/pp/hbppint.c @@ -64,17 +64,22 @@ void hb_pp_Init( void ) int hb_pp_Internal( FILE * handl_o, char * sOut ) { - char *sBuffer = (char*) hb_comp_files.pLast->pBuffer; /* File read buffer */ - char * ptr, * ptrOut = sOut; - int lContinue = 0; - int lens = 0, rdlen; - FILE * handl_i = hb_comp_files.pLast->handle; + PFILE pFile; + char *ptr, *ptrOut; + int lContinue; + int lens, rdlen; + int nEmptyStrings = 0, lLine = 0, i; HB_TRACE(HB_TR_DEBUG, ("PreProcess(%p, %p, %s)", handl_o, sOut)); - while( ( rdlen = hb_pp_RdStr( handl_i, s_szLine + lens, HB_PP_STR_SIZE - - lens, lContinue, sBuffer, &(hb_comp_files.pLast->lenBuffer), - &(hb_comp_files.pLast->iBuffer) ) ) >= 0 ) + while( 1 ) + { + pFile = hb_comp_files.pLast; + lens = lContinue = 0; + ptrOut = sOut; + while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - + lens, lContinue, pFile->pBuffer, &(pFile->lenBuffer), + &(pFile->iBuffer) ) ) >= 0 ) { lens += rdlen; @@ -87,7 +92,7 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) s_szLine[ ++lens ] = ' '; s_szLine[ ++lens ] = '\0'; - *ptrOut++ = '\n'; + nEmptyStrings++; } else { @@ -104,20 +109,41 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) if( *ptr == '#' ) { hb_pp_ParseDirective( ptr + 1 ); - if( sBuffer != hb_comp_files.pLast->pBuffer ) - sprintf( s_szLine, "#line 1 \"%s\"", + if( pFile != hb_comp_files.pLast ) + { + pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; + if( lLine ) + sprintf( s_szLine, "#line %d \"%s\"\n", + pFile->iLine+nEmptyStrings, pFile->szFileName ); + else + *s_szLine = '\0'; + lLine = 0; + pFile->iLine += 1+nEmptyStrings; + sprintf( s_szLine+strlen(s_szLine), "#line 1 \"%s\"", hb_comp_files.pLast->szFileName ); + nEmptyStrings = 0; + } else + { *s_szLine = '\0'; + nEmptyStrings++; + } } else { if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) + { hb_pp_ParseExpression( ptr, s_szOutLine ); + } else + { *s_szLine = '\0'; + nEmptyStrings++; + } } } + else + nEmptyStrings++; break; } } @@ -127,7 +153,6 @@ 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 */ - PFILE pFile; fclose( hb_comp_files.pLast->handle ); hb_xfree( hb_comp_files.pLast->pBuffer ); hb_xfree( hb_comp_files.pLast->szFileName ); @@ -136,10 +161,23 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) hb_comp_files.pLast = pFile; hb_comp_iLine = hb_comp_files.pLast->iLine; hb_comp_files.iFiles--; - sprintf( s_szLine, "#line %d \"%s\"",hb_comp_iLine+2,hb_comp_files.pLast->szFileName ); + lLine = 1; + nEmptyStrings = 0; } } - + if( *s_szLine ) break; + } + if( lLine ) + { + sprintf( ptrOut, "#line %d \"%s\"\n",hb_comp_iLine+nEmptyStrings,hb_comp_files.pLast->szFileName ); + while( *ptrOut ) ptrOut++; + } + else + { + if( nEmptyStrings ) + for( i=0;i 0 ); fclose( hb_comp_files.pLast->handle ); hb_xfree( hb_comp_files.pLast->pBuffer ); hb_xfree( hb_comp_files.pLast ); @@ -230,81 +230,123 @@ int main( int argc, char * argv[] ) int hb_pp_Parse( FILE * handl_o ) { - char *sBuffer = (char*) hb_comp_files.pLast->pBuffer; /* File read buffer */ - FILE * handl_i = hb_comp_files.pLast->handle; - char * ptr; - int lContinue = 0; - int iBuffer = 10, lenBuffer = 10; - int lens = 0, rdlen; + PFILE pFile; + char *ptr; + int lContinue; + int lens, rdlen; + int nEmptyStrings = 0, lLine = 0, i; - HB_TRACE(HB_TR_DEBUG, ("hb_pp_Parse(%p, %p, %s)", handl_o )); + HB_TRACE(HB_TR_DEBUG, ("PreProcess(%p, %p, %s)", handl_o, sOut)); - while( ( rdlen = hb_pp_RdStr( handl_i, s_szLine + lens, HB_PP_STR_SIZE - lens, lContinue, - sBuffer, &lenBuffer, &iBuffer ) ) >= 0 ) - { - lens += rdlen; + while( 1 ) + { + pFile = hb_comp_files.pLast; + lens = lContinue = 0; + while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - + lens, lContinue, pFile->pBuffer, &(pFile->lenBuffer), + &(pFile->iBuffer) ) ) >= 0 ) + { + lens += rdlen; - 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; - } + 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 != '\0' && !lContinue ) - { - printf( "\r line %i", hb_comp_iLine ); - ptr = s_szLine; - HB_SKIPTABSPACES( ptr ); - if( *ptr == '#' ) - { - hb_pp_ParseDirective( ptr + 1 ); - if( sBuffer != hb_comp_files.pLast->pBuffer ) - { - PFILE pFile; - sprintf( s_szLine, "#line 1 \"%s\"", - hb_comp_files.pLast->szFileName ); - hb_pp_WrStr( handl_o, s_szLine ); - hb_pp_Parse( handl_o ); - 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--; - sprintf( s_szLine, "#line %d \"%s\"",hb_comp_iLine+1,hb_comp_files.pLast->szFileName ); - } - else - *s_szLine = '\0'; - } - else - { - if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) - hb_pp_ParseExpression( ptr, s_szOutLine ); - else - *s_szLine = '\0'; - } - } + nEmptyStrings++; + } + else + { + lContinue = 0; + lens = 0; + } -// if( hb_comp_files.iFiles == 1 ) -// { - if( lContinue ) hb_pp_WrStr( handl_o, "\n" ); - else hb_pp_WrStr( handl_o, s_szLine ); -// } - hb_comp_iLine++; - } + if( !lContinue ) + { + if( *s_szLine != '\0' ) + { + printf( "\r line %i", hb_comp_iLine ); + 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 ) + sprintf( s_szLine, "#line %d \"%s\"\n", + pFile->iLine+nEmptyStrings, pFile->szFileName ); + else + *s_szLine = '\0'; + lLine = 0; + pFile->iLine += 1+nEmptyStrings; + sprintf( s_szLine+strlen(s_szLine), "#line 1 \"%s\"", + hb_comp_files.pLast->szFileName ); + nEmptyStrings = 0; + hb_comp_iLine = 0; + } + else + { + *s_szLine = '\0'; + nEmptyStrings++; + } + } + else + { + if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) + { + hb_pp_ParseExpression( ptr, s_szOutLine ); + } + else + { + *s_szLine = '\0'; + nEmptyStrings++; + } + } + } + else + nEmptyStrings++; + 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--; + lLine = 1; + nEmptyStrings = 0; + } + } + if( *s_szLine ) break; + } + if( lLine ) + fprintf( handl_o, "#line %d \"%s\"\n",hb_comp_iLine+nEmptyStrings,hb_comp_files.pLast->szFileName ); + else + { + if( nEmptyStrings ) + for( i=0;i