From 2e6b5eee7d935131ef710663e9931f4a678a8f3e Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 24 Nov 2008 11:33:13 +0000 Subject: [PATCH] 2008-11-24 12:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hberrors.h * harbour/source/compiler/hbgenerr.c + added new compile time error (file write error) * harbour/source/pp/ppcore.c * harbour/source/rtl/errorint.c * harbour/source/compiler/genhrb.c * harbour/source/compiler/genc.c * harbour/source/rtl/run.c * harbour/source/vm/estack.c * pacified warnings - Lorenzo please verify it compiling with C header files from Ubuntu. * harbour/contrib/xhb/filestat.c ! fixed UNICODE compilation * harbour/contrib/gtwvg/wvgsink.c ! added #define NONAMELESSUNION to fix MinGW compilation --- harbour/ChangeLog | 20 ++++++++++++++++++++ harbour/contrib/gtwvg/wvgsink.c | 2 ++ harbour/contrib/xhb/filestat.c | 22 +++++++++++----------- harbour/include/hberrors.h | 9 +++++---- harbour/source/compiler/genc.c | 14 +++++--------- harbour/source/compiler/genhrb.c | 5 ++++- harbour/source/compiler/hbgenerr.c | 1 + harbour/source/pp/ppcore.c | 14 +++++++------- harbour/source/rtl/errorint.c | 4 ++-- harbour/source/rtl/run.c | 2 +- harbour/source/vm/estack.c | 6 +++--- 11 files changed, 61 insertions(+), 38 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5e93351629..4a3da43670 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,26 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-24 12:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hberrors.h + * harbour/source/compiler/hbgenerr.c + + added new compile time error (file write error) + + * harbour/source/pp/ppcore.c + * harbour/source/rtl/errorint.c + * harbour/source/compiler/genhrb.c + * harbour/source/compiler/genc.c + * harbour/source/rtl/run.c + * harbour/source/vm/estack.c + * pacified warnings - Lorenzo please verify it compiling with C header + files from Ubuntu. + + * harbour/contrib/xhb/filestat.c + ! fixed UNICODE compilation + + * harbour/contrib/gtwvg/wvgsink.c + ! added #define NONAMELESSUNION to fix MinGW compilation + 2008-11-23 17:28 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/Makefile * harbour/contrib/gtwvg/common.mak diff --git a/harbour/contrib/gtwvg/wvgsink.c b/harbour/contrib/gtwvg/wvgsink.c index f7a60b6252..9221f99cc5 100644 --- a/harbour/contrib/gtwvg/wvgsink.c +++ b/harbour/contrib/gtwvg/wvgsink.c @@ -80,6 +80,8 @@ */ //----------------------------------------------------------------------// +#define NONAMELESSUNION + #ifdef __XHARBOUR__ #include "hbvmopt.h" #else diff --git a/harbour/contrib/xhb/filestat.c b/harbour/contrib/xhb/filestat.c index d359b94423..45fa7a36c6 100644 --- a/harbour/contrib/xhb/filestat.c +++ b/harbour/contrib/xhb/filestat.c @@ -186,26 +186,26 @@ static BOOL hb_fsFileStats( HANDLE hFind; FILETIME filetime; SYSTEMTIME time; - + /* Get attributes... */ - dwAttribs = GetFileAttributes( (char*) pszFileName ); + dwAttribs = GetFileAttributesA( ( char * ) pszFileName ); if ( dwAttribs == INVALID_FILE_ATTRIBUTES ) { /* return */ return FALSE; } - - hb_fsAttrDecode( hb_fsAttrFromRaw( dwAttribs ), (char*) pszAttr ); - + + hb_fsAttrDecode( hb_fsAttrFromRaw( dwAttribs ), ( char * ) pszAttr ); + /* If file existed, do a findfirst */ - hFind = FindFirstFile( (char*) pszFileName, &ffind ); + hFind = FindFirstFileA( ( char * ) pszFileName, &ffind ); if ( hFind != INVALID_HANDLE_VALUE ) { CloseHandle( hFind ); - + /* get file times and work them out */ *llSize = ( HB_FOFFSET ) ffind.nFileSizeLow + ( ( HB_FOFFSET ) ffind.nFileSizeHigh << 32 ); - + if ( FileTimeToLocalFileTime( &ffind.ftCreationTime, &filetime ) && FileTimeToSystemTime( &filetime, &time ) ) { @@ -217,7 +217,7 @@ static BOOL hb_fsFileStats( *lcDate = hb_dateEncode( 0, 0, 0 ); *lcTime = 0; } - + if ( FileTimeToLocalFileTime( &ffind.ftLastAccessTime, &filetime ) && FileTimeToSystemTime( &filetime, &time ) ) { @@ -237,11 +237,11 @@ static BOOL hb_fsFileStats( /* Generic algorithm based on findfirst */ { - PHB_FFIND findinfo = hb_fsFindFirst( (char*) pszFileName, HB_FA_ALL ); + PHB_FFIND findinfo = hb_fsFindFirst( ( char * ) pszFileName, HB_FA_ALL ); if( findinfo ) { - hb_fsAttrDecode( findinfo->attr, (char*) pszAttr ); + hb_fsAttrDecode( findinfo->attr, ( char * ) pszAttr ); *llSize = ( HB_FOFFSET ) findinfo->size; *lcDate = findinfo->lDate; *lcTime = (findinfo->szTime[0] - '0') * 36000 + diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 69f27b17b8..e3b8923219 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -127,10 +127,11 @@ HB_EXTERN_BEGIN #define HB_COMP_ERR_NOT_VPARAMS 65 #define HB_COMP_ERR_OPEN_CFG 66 #define HB_COMP_ERR_ALWAYS_AFTER_EXIT 67 -#define HB_COMP_ERR_HISTORICAL_1 68 -#define HB_COMP_ERR_HISTORICAL_2 69 -#define HB_COMP_ERR_HISTORICAL_3 70 -#define HB_COMP_ERR_HISTORICAL_4 71 +#define HB_COMP_ERR_FILE_WRITE 68 +#define HB_COMP_ERR_HISTORICAL_1 69 +#define HB_COMP_ERR_HISTORICAL_2 70 +#define HB_COMP_ERR_HISTORICAL_3 71 +#define HB_COMP_ERR_HISTORICAL_4 72 #define HB_COMP_WARN_AMBIGUOUS_VAR 1 #define HB_COMP_WARN_MEMVAR_ASSUMED 2 diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 6cfa128eec..115d683505 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -410,16 +410,16 @@ static void hb_compGenCFunc( FILE * yyc, const char *cDecor, const char *szName, if( cDecor[i] == '%' && cDecor[i+1] == 's' ) { int j=0; - while( szName[j+iStrip] ) + while( szName[ j + iStrip ] ) { - fwrite( (void*)(szName+j), 1, 1, yyc ); + fputc( ( UCHAR ) szName[ j ], yyc ); j++; } i +=2; } else { - fwrite( (void*)(cDecor+i), 1, 1, yyc ); + fputc( ( UCHAR ) cDecor[ i ], yyc ); i++; } } @@ -437,12 +437,8 @@ static void hb_compGenCByteStr( FILE * yyc, BYTE * pText, ULONG ulLen ) * * TODO: add switch to use hexadecimal format "%#04x" */ - if( ( uchr < ( BYTE ) ' ' ) || ( uchr >= 127 ) ) - fprintf( yyc, "%i, ", uchr ); - else if( strchr( "\'\\\"", uchr ) ) - fprintf( yyc, "%i, ", uchr ); - else - fprintf( yyc, "\'%c\', ", uchr ); + fprintf( yyc, ( uchr < ( BYTE ) ' ' || uchr >= 127 || uchr == '\\' || + uchr == '\'' ) ? "%i, " : "\'%c\', ", uchr ); } } diff --git a/harbour/source/compiler/genhrb.c b/harbour/source/compiler/genhrb.c index 93761c8892..5fa42190d8 100644 --- a/harbour/source/compiler/genhrb.c +++ b/harbour/source/compiler/genhrb.c @@ -167,7 +167,10 @@ void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME pFileName ) } hb_compGenBufPortObj( HB_COMP_PARAM, &pHrbBody, &ulSize ); - fwrite( pHrbBody, ulSize, 1, yyc ); + + if( fwrite( pHrbBody, ulSize, 1, yyc ) != 1 ) + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FILE_WRITE, szFileName, NULL ); + hb_xfree( pHrbBody ); fclose( yyc ); diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index abe3ca10d6..de39dae422 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -98,6 +98,7 @@ const char * hb_comp_szErrors[] = "%s not declared with variable number of parameters", "Can't find %s file", "Invalid ALWAYS after %s in RECOVER code", + "File write error", /* Some historical, funny sounding error messages from original CA-Cl*pper. They serve no purpose whatsoever. [vszakats] */ "END wreaks terrible vengeance on control stack", diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 9602053e8f..820f152aed 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -837,7 +837,7 @@ static void hb_pp_dumpEnd( PHB_PP_STATE pState ) pBuffer = hb_membufPtr( pState->pDumpBuffer ); ulLen = hb_membufLen( pState->pDumpBuffer ); fputs( "#pragma BEGINDUMP\n", pState->file_out ); - fwrite( pBuffer, sizeof( char ), ulLen, pState->file_out ); + ( void ) fwrite( pBuffer, sizeof( char ), ulLen, pState->file_out ); fputs( "#pragma ENDDUMP\n", pState->file_out ); while( ulLen-- ) @@ -2516,8 +2516,8 @@ static void hb_pp_pragmaNew( PHB_PP_STATE pState, PHB_PP_TOKEN pToken ) hb_membufAddCh( pState->pBuffer, '\n' ); if( pState->fWriteTrace ) { - fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), - hb_membufLen( pState->pBuffer ), pState->file_trace ); + ( void ) fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), + hb_membufLen( pState->pBuffer ), pState->file_trace ); } if( pState->fTracePragmas ) { @@ -5124,8 +5124,8 @@ PHB_PP_TOKEN hb_pp_tokenGet( PHB_PP_STATE pState ) pState->usLastType ); #endif pState->usLastType = HB_PP_TOKEN_TYPE( pState->pTokenOut->type ); - fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), - hb_membufLen( pState->pBuffer ), pState->file_out ); + ( void ) fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), + hb_membufLen( pState->pBuffer ), pState->file_out ); } return pState->pTokenOut; @@ -5873,8 +5873,8 @@ void hb_pp_tokenToString( PHB_PP_STATE pState, PHB_PP_TOKEN pToken ) { if( !fError ) hb_membufAddCh( pState->pBuffer, ']' ); - fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), - hb_membufLen( pState->pBuffer ), pState->file_out ); + ( void ) fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ), + hb_membufLen( pState->pBuffer ), pState->file_out ); } } diff --git a/harbour/source/rtl/errorint.c b/harbour/source/rtl/errorint.c index ed963d1dcf..d2b48b0021 100644 --- a/harbour/source/rtl/errorint.c +++ b/harbour/source/rtl/errorint.c @@ -107,7 +107,7 @@ void hb_errInternalRaw( ULONG ulIntCode, const char * szText, const char * szPar hb_conOutErr( buffer, 0 ); if( hLog ) - fwrite( buffer, sizeof( buffer[ 0 ] ), strlen( buffer ), hLog ); + ( void ) fwrite( buffer, sizeof( buffer[ 0 ] ), strlen( buffer ), hLog ); if( szText ) hb_snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); @@ -130,7 +130,7 @@ void hb_errInternalRaw( ULONG ulIntCode, const char * szText, const char * szPar hb_conOutErr( msg, 0 ); if( hLog ) - fwrite( msg, sizeof( msg[ 0 ] ), strlen( msg ), hLog ); + ( void ) fwrite( msg, sizeof( msg[ 0 ] ), strlen( msg ), hLog ); } if( hLog ) diff --git a/harbour/source/rtl/run.c b/harbour/source/rtl/run.c index 95f0547535..703d6b80ae 100644 --- a/harbour/source/rtl/run.c +++ b/harbour/source/rtl/run.c @@ -61,7 +61,7 @@ HB_FUNC( __RUN ) { if( ISCHAR( 1 ) && hb_gtSuspend() == 0 ) { - system( hb_parc( 1 ) ); + ( void ) system( hb_parc( 1 ) ); if( hb_gtResume() != 0 ) { diff --git a/harbour/source/vm/estack.c b/harbour/source/vm/estack.c index fa7ee60904..20319fe36c 100644 --- a/harbour/source/vm/estack.c +++ b/harbour/source/vm/estack.c @@ -1037,16 +1037,16 @@ void hb_stackDispLocal( void ) HB_TRACE(HB_TR_DEBUG, ("hb_stackDispLocal()")); - printf( hb_conNewLine() ); + printf( "%s", hb_conNewLine() ); printf( HB_I_("Virtual Machine Stack Dump at %s(%i):"), ( *hb_stack.pBase )->item.asSymbol.value->szName, ( *hb_stack.pBase )->item.asSymbol.stackstate->uiLineNo ); - printf( hb_conNewLine() ); + printf( "%s", hb_conNewLine() ); printf( "--------------------------" ); for( pBase = hb_stack.pBase; pBase <= hb_stack.pPos; pBase++ ) { - printf( hb_conNewLine() ); + printf( "%s", hb_conNewLine() ); switch( hb_itemType( *pBase ) ) {