diff --git a/harbour/ChangeLog b/harbour/ChangeLog index adad37e211..6220778518 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,18 @@ +19991119-10:02 GMT+1 Victor Szel + * source/common/hbfsapi.c + ! Fixes (tracing mainly), cleanups. + * source/rtl/gt/gtstd.c + * Minor change. (0/1 -> FALSE/TRUE) + * source/pp/hbpp.c + ! Fixed GPF when an #include file was not found. + + Added support for #include `hello.ch' (new filename delimiters) + * source/compiler/harbour.c + source/compiler/harbour.y + * Include() return type changed from int to BOOL. + * Some cleanups in Include() + * source/compiler/gen*.c + * Minor formatting. + 19991118-19:30 EDT David G. Holm - tests/strings3.prg diff --git a/harbour/source/common/hbfsapi.c b/harbour/source/common/hbfsapi.c index b4afef3ef4..eeb8ff96af 100644 --- a/harbour/source/common/hbfsapi.c +++ b/harbour/source/common/hbfsapi.c @@ -45,22 +45,19 @@ PHB_FNAME hb_fsFNameSplit( char * pszFileName ) HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameSplit(%s)", pszFileName)); + HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: Filename: |%s|\n", pszFileName)); + /* Grab memory, set defaults */ pFileName = ( PHB_FNAME ) hb_xgrab( sizeof( HB_FNAME ) ); - pFileName->szPath = - pFileName->szName = - pFileName->szExtension = - pFileName->szDrive = NULL; - pszPos = pFileName->szBuffer; /* Find the end of the path part, and find out where the name+ext starts */ pszAt = NULL; - if( pszFileName[ 0 ] ) + if( pszFileName[ 0 ] != '\0' ) { int iPos = strlen( pszFileName ); @@ -82,6 +79,8 @@ PHB_FNAME hb_fsFNameSplit( char * pszFileName ) *pszPos++ = '\0'; pszFileName = pszAt + 1; } + else + pFileName->szPath = NULL; /* From this point pszFileName will point to the name+ext part of the path */ @@ -97,32 +96,36 @@ PHB_FNAME hb_fsFNameSplit( char * pszFileName ) pFileName->szExtension = pszPos; strcpy( pszPos, pszAt ); - pszPos += strlen( pszPos) + 1; + pszPos += strlen( pszAt ) + 1; } else { - pFileName->szName = pszPos; - strcpy( pszPos, pszFileName ); - pszPos += strlen( pszPos) + 1; + if( pszFileName[ 0 ] != '\0' ) + { + pFileName->szName = pszPos; + strcpy( pszPos, pszFileName ); + pszPos += strlen( pszFileName ) + 1; + } + else + pFileName->szName = NULL; + + pFileName->szExtension = NULL; } /* Duplicate the drive letter from the path for easy access on platforms where applicable. Note that the drive info is always present also in the path itself. */ - if( pFileName->szPath ) + if( pFileName->szPath && ( pszAt = strchr( pFileName->szPath, ':' ) ) ) { - pszAt = strchr( pFileName->szPath, ':' ); - if( pszAt ) - { - pFileName->szDrive = pszPos; - strncpy( pszPos, pFileName->szPath, pszAt - pFileName->szPath + 1 ); - pszPos += pszAt - pFileName->szPath + 1; - *pszPos = '\0'; - } + pFileName->szDrive = pszPos; + strncpy( pszPos, pFileName->szPath, pszAt - pFileName->szPath + 1 ); + pszPos += pszAt - pFileName->szPath + 1; + *pszPos = '\0'; } + else + pFileName->szDrive = NULL; - HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: Filename: |%s|\n", szFileName)); HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: szPath: |%s|\n", pFileName->szPath)); HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: szName: |%s|\n", pFileName->szName)); HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: szExt: |%s|\n", pFileName->szExtension)); @@ -138,23 +141,23 @@ char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ) { char * pszName; - HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameMerge(%s, %p)", pszFileName, pFileName)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameMerge(%p, %p)", pszFileName, pFileName)); /* Set the result to an empty string */ pszFileName[ 0 ] = '\0'; /* Strip preceding path separators from the filename */ pszName = pFileName->szName; - if( pszName && pszName[ 0 ] && strchr( OS_PATH_DELIMITER_LIST, pszName[ 0 ] ) ) + if( pszName && pszName[ 0 ] != '\0' && strchr( OS_PATH_DELIMITER_LIST, pszName[ 0 ] ) ) pszName++; /* Add path if specified */ if( pFileName->szPath ) strcat( pszFileName, pFileName->szPath ); - /* If we have a filename, append a path separator to the path if there + /* If we have a path, append a path separator to the path if there was none. */ - if( pszFileName[ 0 ] && ( pszName || pFileName->szExtension ) ) + if( pszFileName[ 0 ] != '\0' && ( pszName || pFileName->szExtension ) ) { int iLen = strlen( pszFileName ) - 1; @@ -177,7 +180,8 @@ char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ) if( pFileName->szExtension ) { /* Add a dot if the extension doesn't have it */ - if( pFileName->szExtension[ 0 ] && pFileName->szExtension[ 0 ] != '.' ) + if( pFileName->szExtension[ 0 ] != '\0' && + pFileName->szExtension[ 0 ] != '.' ) strcat( pszFileName, "." ); strcat( pszFileName, pFileName->szExtension ); @@ -187,7 +191,7 @@ char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ) HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: szName: |%s|\n", pFileName->szName)); HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: szExt: |%s|\n", pFileName->szExtension)); HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: szDrive: |%s|\n", pFileName->szDrive)); - HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: Filename: |%s|\n", szFileName)); + HB_TRACE(HB_TR_INFO, ("hb_fsFNameMerge: Filename: |%s|\n", pszFileName)); return pszFileName; } diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 51212f3058..ef1e753ada 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -49,7 +49,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */ FILE * yyc; /* file handle for C output */ if( ! pFileName->szExtension ) - pFileName->szExtension =".c"; + pFileName->szExtension = ".c"; hb_fsFNameMerge( szFileName, pFileName ); yyc = fopen( szFileName, "wb" ); diff --git a/harbour/source/compiler/genhrb.c b/harbour/source/compiler/genhrb.c index a3d957e8b9..9925fdc3f1 100644 --- a/harbour/source/compiler/genhrb.c +++ b/harbour/source/compiler/genhrb.c @@ -53,7 +53,7 @@ void GenPortObj( PHB_FNAME pFileName ) FILE * yyc; /* file handle for C output */ if( ! pFileName->szExtension ) - pFileName->szExtension =".hrb"; + pFileName->szExtension = ".hrb"; hb_fsFNameMerge( szFileName, pFileName ); yyc = fopen( szFileName, "wb" ); diff --git a/harbour/source/compiler/genjava.c b/harbour/source/compiler/genjava.c index d11a4c5d36..2667a9a882 100644 --- a/harbour/source/compiler/genjava.c +++ b/harbour/source/compiler/genjava.c @@ -63,7 +63,7 @@ void GenJava( PHB_FNAME pFileName ) FILE * yyc; /* file handle for C output */ if( ! pFileName->szExtension ) - pFileName->szExtension =".java"; + pFileName->szExtension = ".java"; hb_fsFNameMerge( szFileName, pFileName ); yyc = fopen( szFileName, "wb" ); diff --git a/harbour/source/compiler/genobj32.c b/harbour/source/compiler/genobj32.c index e7b5c68abd..92f31bf548 100644 --- a/harbour/source/compiler/genobj32.c +++ b/harbour/source/compiler/genobj32.c @@ -77,7 +77,7 @@ void GenObj32( PHB_FNAME pFileName ) FILE * hObjFile; /* file handle for OBJ output */ if( ! pFileName->szExtension ) - pFileName->szExtension =".obj"; + pFileName->szExtension = ".obj"; hb_fsFNameMerge( szFileName, pFileName ); if( ! ( hObjFile = fopen( szFileName, "wb" ) ) ) diff --git a/harbour/source/compiler/genpas.c b/harbour/source/compiler/genpas.c index 806384c04c..a8ccc17525 100644 --- a/harbour/source/compiler/genpas.c +++ b/harbour/source/compiler/genpas.c @@ -43,7 +43,7 @@ void GenPascal( PHB_FNAME pFileName ) char szFileName[ _POSIX_PATH_MAX ]; if( ! pFileName->szExtension ) - pFileName->szExtension =".pas"; + pFileName->szExtension = ".pas"; hb_fsFNameMerge( szFileName, pFileName ); printf( "\nGenerating Pascal source output to \'%s\'... ", szFileName ); diff --git a/harbour/source/compiler/genrc.c b/harbour/source/compiler/genrc.c index 9bd3e7fede..b6e50ab9c4 100644 --- a/harbour/source/compiler/genrc.c +++ b/harbour/source/compiler/genrc.c @@ -43,7 +43,7 @@ void GenRC( PHB_FNAME pFileName ) char szFileName[ _POSIX_PATH_MAX ]; if( ! pFileName->szExtension ) - pFileName->szExtension =".rc"; + pFileName->szExtension = ".rc"; hb_fsFNameMerge( szFileName, pFileName ); printf( "\nGenerating Windows resource output to \'%s\'... ", szFileName ); diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 166901e9b8..a7c610207f 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -58,7 +58,7 @@ typedef enum extern int harbour_main( char *szName ); -extern int Include( char * szFileName, PATHNAMES * pSearchPath ); /* end #include support */ +extern BOOL Include( char * szFileName, PATHNAMES * pSearchPath ); /* end #include support */ /* Following line added for preprocessor */ extern void Hbpp_init ( void ); @@ -667,11 +667,12 @@ int main( int argc, char * argv[] ) hb_comp_pFileName->szPath = NULL; hb_comp_pFileName->szExtension = NULL; - /* we create a the output file */ + /* we create a the output file name */ if( s_pOutPath ) { if( s_pOutPath->szPath ) hb_comp_pFileName->szPath = s_pOutPath->szPath; + if( s_pOutPath->szName ) { hb_comp_pFileName->szName = s_pOutPath->szName; diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 5c0efe8c61..a592a6452d 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -1189,8 +1189,7 @@ void yyerror( char * s ) hb_compGenError( hb_comp_szCErrors, 'E', ERR_YACC, s, yytext ); } - -int Include( char * szFileName, PATHNAMES * pSearch ) +BOOL Include( char * szFileName, PATHNAMES * pSearch ) { PFILE pFile; @@ -1200,12 +1199,11 @@ int Include( char * szFileName, PATHNAMES * pSearch ) if( pSearch ) { PHB_FNAME pFileName = hb_fsFNameSplit( szFileName ); - char szFName[ _POSIX_PATH_MAX ]; /* filename to parse */ - pFileName->szName = szFileName; - pFileName->szExtension = NULL; while( pSearch && !yyin ) { + char szFName[ _POSIX_PATH_MAX ]; /* filename to parse */ + pFileName->szPath = pSearch->szPath; hb_fsFNameMerge( szFName, pFileName ); yyin = fopen( szFName, "r" ); @@ -1213,13 +1211,14 @@ int Include( char * szFileName, PATHNAMES * pSearch ) { pSearch = pSearch->pNext; if( ! pSearch ) - return 0; + return FALSE; } } + hb_xfree( ( void * ) pFileName ); } else - return 0; + return FALSE; } if( ! hb_comp_bQuiet ) @@ -1245,7 +1244,8 @@ int Include( char * szFileName, PATHNAMES * pSearch ) yy_switch_to_buffer( pFile->pBuffer = yy_create_buffer( yyin, 8192 * 2 ) ); #endif hb_comp_files.iFiles++; - return 1; + + return TRUE; } int yywrap( void ) /* handles the EOF of the currently processed file */ diff --git a/harbour/source/pp/hbpp.c b/harbour/source/pp/hbpp.c index 7c1b7ae588..7a9302d117 100644 --- a/harbour/source/pp/hbpp.c +++ b/harbour/source/pp/hbpp.c @@ -208,12 +208,14 @@ int ParseDirective( char* sLine ) { /* --- #include --- */ char cDelimChar; - if ( *sLine != '\"' && *sLine != '\'' && *sLine != '<' ) + if ( *sLine != '\"' && *sLine != '\'' && *sLine != '<' && *sLine != '`' ) hb_compGenError( _szPErrors, 'P', ERR_WRONG_NAME, NULL, NULL ); cDelimChar = *sLine; - if (cDelimChar == '<') + if( cDelimChar == '<' ) cDelimChar = '>'; + else if( cDelimChar == '`' ) + cDelimChar = '\''; sLine++; i = 0; while ( *(sLine+i) != '\0' && *(sLine+i) != cDelimChar ) i++; @@ -222,12 +224,15 @@ int ParseDirective( char* sLine ) *(sLine+i) = '\0'; /* if ((handl_i = fopen(sLine, "r")) == NULL) */ - if ( !OpenInclude( sLine, hb_comp_pIncludePath, &handl_i, (cDelimChar == '>'), szInclude ) ) + if( OpenInclude( sLine, hb_comp_pIncludePath, &handl_i, ( cDelimChar == '>' ), szInclude ) ) + { + lInclude++; + Hp_Parse(handl_i, 0, szInclude ); + lInclude--; + fclose(handl_i); + } + else hb_compGenError( _szPErrors, 'P', ERR_CANNOT_OPEN, sLine, NULL ); - lInclude++; - Hp_Parse(handl_i, 0, szInclude ); - lInclude--; - fclose(handl_i); } else if ( i == 6 && memcmp ( sDirective, "DEFINE", 6 ) == 0 ) diff --git a/harbour/source/rtl/gt/gtstd.c b/harbour/source/rtl/gt/gtstd.c index f515be49ff..52f5c59e6a 100644 --- a/harbour/source/rtl/gt/gtstd.c +++ b/harbour/source/rtl/gt/gtstd.c @@ -208,7 +208,7 @@ BOOL hb_gt_SetMode( USHORT uiMaxRow, USHORT uiMaxCol ) s_uiMaxRow = uiMaxRow; s_uiMaxCol = uiMaxCol; - return 0; + return FALSE; } void hb_gt_Replicate( BYTE byChar, ULONG ulLen )