diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f47dfd77dd..2d9b842f7a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,6 +1,49 @@ +20000415-12:38 GMT+1 Victor Szakats + + * source/rtl/net.c + ! Experimental NETNAME() support for DOS. I currently GPFs with DJGPP. + + * include/hbdefs.h + - Removed #include for __WATCOMC__, since it seems that dos.h + is including it automatically. + + Added HB_DOS_INT86X() macro. + + * include/hbapilng.h + * source/rtl/langapi.c + * HB_LANG_REQUEST() moved to the header. + + * include/hbextern.ch + + HB_LANGNAME() added. + + * source/vm/itemapi.c + ! hb_itemDo() fixed rare bug. + + * source/rtl/errorapi.c + * source/vm/hvm.c + * source/pp/pplib.c + * source/pp/stdalone/hbpp.c + * source/rtl/set.c + * source/rtl/transfrm.c + * source/compiler/genc.c + ! Fixed GCC -O2 warnings + * One TODO changed to TOFIX in __PREPROCESS() + + * source/rtl/gtapi.c + * source/vm/extend.c + ! Small modifications. + + * source/rtl/langapi.c + ! Typo + + * source/vm/classes.c + ! __CLSINSTSUPER() fix for error recovery code path. + ! The return value of some Harbour functions made consistent on error + cases (return 0 instead of NIL). + 20000415-05:12 GMT+1 Victor Szakats * include/error.ch + * include/hbapilng.h * source/rdd/dbcmd.c * source/rtl/errorapi.c * source/vm/classes.c diff --git a/harbour/bin/bld.bat b/harbour/bin/bld.bat index 742d6dbd61..50a9edd797 100644 --- a/harbour/bin/bld.bat +++ b/harbour/bin/bld.bat @@ -108,7 +108,30 @@ rem if "%HB_GT_LIB%" == "" set HB_GT_LIB= if "%HB_GT_LIB%" == "" set HB_GT_LIB=gtdos if "%HB_COMPILER%" == "bcc16" bcc -O2 -mh -I..\include -L..\lib %1.c tools.lib debug.lib vm.lib rtl.lib %HB_GT_LIB%.lib lang.lib rdd.lib macro.lib pp.lib dbfntx.lib dbfcdx.lib common.lib - if "%HB_COMPILER%" == "djgpp" gcc %1.c -o%1.exe -I..\include -L..\lib -ltools -ldebug -lvm -lrtl -l%HB_GT_LIB% -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfnt -ldbfcd -lcommo + + if not "%HB_COMPILER%" == "djgpp" goto A_DOS_NOTDJGPP + + echo %1.c -o%1.exe -I..\include -L..\lib > build.tmp + echo -ltools >> build.tmp + echo -ldebug >> build.tmp + echo -lvm >> build.tmp + echo -lrtl >> build.tmp + echo -l%HB_GT_LIB% >> build.tmp + echo -llang >> build.tmp + echo -lrdd >> build.tmp + echo -lrtl >> build.tmp + echo -lvm >> build.tmp + echo -lmacro >> build.tmp + echo -lpp >> build.tmp + echo -ldbfnt >> build.tmp + echo -ldbfcd >> build.tmp + echo -lcommo >> build.tmp + gcc @build.tmp + del build.tmp + goto END + +:A_DOS_NOTDJGPP + if "%HB_COMPILER%" == "rsx32" gcc %1.c -Zrsx32 -I..\include -L..\lib -ltools -ldebug -lvm -lrtl -l%HB_GT_LIB% -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon goto END diff --git a/harbour/include/hbapilng.h b/harbour/include/hbapilng.h index ec91d6e3c0..e662c6148c 100644 --- a/harbour/include/hbapilng.h +++ b/harbour/include/hbapilng.h @@ -44,9 +44,6 @@ extern "C" { #endif -/* Macro to publish a specific language module, for both C and Harbour level */ -#define HB_LANG_ANNOUNCE( id ) HB_FUNC( HB_LANG_##id ) {} - /* Base values for the unified language item table */ #define HB_LANG_ITEM_BASE_ID 0 #define HB_LANG_ITEM_BASE_MONTH 6 @@ -57,6 +54,17 @@ extern "C" { #define HB_LANG_ITEM_BASE_TEXT 111 #define HB_LANG_ITEM_MAX_ 114 +/* This hack is needed to force preprocessing if id is also a macro */ +#define HB_LANG_REQUEST( id ) HB_LANG_REQUEST_( id ) +#define HB_LANG_REQUEST_( id ) extern HB_FUNC( HB_LANG_##id ); \ + void hb_lang_ForceLink( void ) \ + { \ + HB_FUNCNAME( HB_LANG_##id )(); \ + } + +/* Macro to publish a specific language module, for both C and Harbour level */ +#define HB_LANG_ANNOUNCE( id ) HB_FUNC( HB_LANG_##id ) {} + typedef struct _HB_LANG { void * pItemList[ HB_LANG_ITEM_MAX_ ]; diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 804fc59e47..defe38b240 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -81,16 +81,16 @@ #elif defined(HB_OS_DOS) #include - #if defined(__WATCOMC__) - #include - #endif #if defined(__WATCOMC__) && defined(__386__) && !defined(__WINDOWS_386__) #define HB_DOS_INT86 int386 + #define HB_DOS_INT86X int386x #elif defined(__RSX32__) #define HB_DOS_INT86 _int86 + #define HB_DOS_INT86X _int86x #else #define HB_DOS_INT86 int86 + #define HB_DOS_INT86X int86x #endif #endif diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 3bb0e88dcb..a7d57c0f49 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -893,5 +893,6 @@ EXTERNAL HB_FTEMPCREATE EXTERNAL __HRBRUN EXTERNAL HB_LANGSELECT +EXTERNAL HB_LANGNAME #endif /* HB_EXTERN_CH_ */ diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 9e930ffcde..52e63f42d5 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -358,12 +358,11 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou case HB_P_JUMP: /* if( 1 ) ( lPCodePos + 3 ) < pFunc->lPCodePos ) */ { - SHORT sPos; - sPos = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; fprintf( yyc, "\tHB_P_JUMP, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] ); - if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %li (abs: %05li) */", sPos, lPCodePos + ( sPos ? sPos : 3 ) ); + if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) ); fprintf( yyc, "\n" ); } lPCodePos += 3; @@ -374,7 +373,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou fprintf( yyc, "\tHB_P_JUMPFALSE, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] ); - if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %li (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) ); + if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) ); fprintf( yyc, "\n" ); lPCodePos += 3; break; @@ -384,7 +383,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou fprintf( yyc, "\tHB_P_JUMPTRUE, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] ); - if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %li (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) ); + if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) ); fprintf( yyc, "\n" ); lPCodePos += 3; break; diff --git a/harbour/source/pp/pplib.c b/harbour/source/pp/pplib.c index 79854702ee..f19ce68989 100644 --- a/harbour/source/pp/pplib.c +++ b/harbour/source/pp/pplib.c @@ -84,27 +84,23 @@ HB_FUNC( __PREPROCESS ) { char * pText = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); char * pOut = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); - char * ptr = pText; - - int slen; - - /* hb_pp_Init(); */ - - slen = HB_MIN( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 ); - memcpy( pText, hb_parc( 1 ), slen ); - pText[ slen ] = 0; /* Preprocessor expects null-terminated string */ - memset( pOut, 0, HB_PP_STR_SIZE ); - - HB_SKIPTABSPACES( ptr ); if( setjmp( s_env ) == 0 ) { - int resParse; + char * ptr = pText; + int slen; + + /* hb_pp_Init(); */ + + slen = HB_MIN( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 ); + memcpy( pText, hb_parc( 1 ), slen ); + pText[ slen ] = 0; /* Preprocessor expects null-terminated string */ + memset( pOut, 0, HB_PP_STR_SIZE ); + + HB_SKIPTABSPACES( ptr ); - if( ( resParse = hb_pp_ParseExpression( ptr, pOut ) ) > 0 ) + if( hb_pp_ParseExpression( ptr, pOut ) > 0 ) { - HB_SYMBOL_UNUSED( resParse ); - /* Some error here? */ } @@ -134,16 +130,15 @@ void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szErro HB_TRACE(HB_TR_DEBUG, ("GenError(%p, %c, %d, %s, %s)", szErrors, cPrefix, iError, szError1, szError2)); - /* TODO: The internal buffers allocated by the preprocessor should be - * deallocated here - */ + /* TOFIX: The internal buffers allocated by the preprocessor should be + deallocated here */ sprintf( buffer, szErrors[ iError - 1 ], szError1, szError2 ); pError = hb_errRT_New( ES_ERROR, "PP", 9999, ( ULONG ) iError, buffer, NULL, 0, EF_NONE | EF_CANDEFAULT ); hb_errLaunch( pError ); hb_errRelease( pError ); - longjmp( s_env, iError ); + longjmp( s_env, iError == 0 ? -1 : iError ); } void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2 ) diff --git a/harbour/source/pp/stdalone/hbpp.c b/harbour/source/pp/stdalone/hbpp.c index 74b9fb39a1..e9538204f8 100644 --- a/harbour/source/pp/stdalone/hbpp.c +++ b/harbour/source/pp/stdalone/hbpp.c @@ -353,7 +353,7 @@ int hb_pp_Parse( FILE * handl_o ) static void OutTable( DEFINES * endDefine, COMMANDS * endCommand ) { FILE *handl_o; - int ipos, len_mpatt, len_value; + int ipos, len_mpatt = 0, len_value; int num; DEFINES * stdef1 = hb_pp_topDefine, * stdef2 = NULL, * stdef3; COMMANDS * stcmd1 = hb_pp_topCommand, * stcmd2 = NULL, * stcmd3; diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index e3ad1a894f..cab6af9770 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -165,7 +165,7 @@ PHB_ITEM hb_errNew( void ) USHORT hb_errLaunch( PHB_ITEM pError ) { - USHORT uiAction; + USHORT uiAction = E_DEFAULT; /* Needed to avoid GCC -O2 warning */ USHORT usRequest; HB_TRACE(HB_TR_DEBUG, ("hb_errLaunch(%p)", pError)); diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index b95b423836..75d0545bb3 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -175,30 +175,36 @@ USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, B USHORT uiRow; USHORT uiCol; - USHORT height, width, tmp; + USHORT uiHeight; + USHORT uiWidth; USHORT uiTopBak = uiTop; USHORT uiLeftBak = uiLeft; - /* For full compatibility, pad box string with last char if too short */ + /* NOTE: For full compatibility, pad box string with last char if too + short [vszakats] */ - cPadChar = ' '; - for( tmp = 0; *pbyFrame && tmp < 9; tmp++ ) - cPadChar = szBox[ tmp ] = *pbyFrame++; - while( tmp < 8 ) - szBox[ tmp++ ] = cPadChar; - szBox[ tmp ] = '\0'; + { + USHORT tmp; + + cPadChar = ' '; + for( tmp = 0; *pbyFrame && tmp < 9; tmp++ ) + cPadChar = szBox[ tmp ] = *pbyFrame++; + while( tmp < 8 ) + szBox[ tmp++ ] = cPadChar; + szBox[ tmp ] = '\0'; + } /* Ensure that box is drawn from top left to bottom right. */ if( uiTop > uiBottom ) { - tmp = uiTop; + USHORT tmp = uiTop; uiTop = uiBottom; uiBottom = tmp; } if( uiLeft > uiRight ) { - tmp = uiLeft; + USHORT tmp = uiLeft; uiLeft = uiRight; uiRight = tmp; } @@ -207,23 +213,23 @@ USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, B uiCol = uiLeft; /* Draw the box or line as specified */ - height = uiBottom - uiTop + 1; - width = uiRight - uiLeft + 1; + uiHeight = uiBottom - uiTop + 1; + uiWidth = uiRight - uiLeft + 1; hb_gtDispBegin(); - if( height > 1 && width > 1 ) + if( uiHeight > 1 && uiWidth > 1 ) hb_gtWriteAt( uiRow, uiCol, szBox + 0, sizeof( BYTE ) ); /* Upper left corner */ - uiCol = ( height > 1 ? uiLeft + 1 : uiLeft ); + uiCol = ( uiHeight > 1 ? uiLeft + 1 : uiLeft ); if( uiCol <= uiRight ) - hb_gtRepChar( uiRow, uiCol, szBox[ 1 ], uiRight - uiLeft + ( height > 1 ? -1 : 1 ) ); /* Top line */ + hb_gtRepChar( uiRow, uiCol, szBox[ 1 ], uiRight - uiLeft + ( uiHeight > 1 ? -1 : 1 ) ); /* Top line */ - if( height > 1 && width > 1 ) + if( uiHeight > 1 && uiWidth > 1 ) hb_gtWriteAt( uiRow, uiRight, szBox + 2, sizeof( BYTE ) ); /* Upper right corner */ - if( szBox[ 8 ] && height > 2 && width > 2 ) + if( szBox[ 8 ] && uiHeight > 2 && uiWidth > 2 ) { for( uiRow = uiTop + 1; uiRow < uiBottom; uiRow++ ) { @@ -235,22 +241,22 @@ USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, B } else { - for( uiRow = ( width > 1 ? uiTop + 1 : uiTop ); uiRow < ( width > 1 ? uiBottom : uiBottom + 1 ); uiRow++ ) + for( uiRow = ( uiWidth > 1 ? uiTop + 1 : uiTop ); uiRow < ( uiWidth > 1 ? uiBottom : uiBottom + 1 ); uiRow++ ) { hb_gtWriteAt( uiRow, uiLeft, szBox + 7, sizeof( BYTE ) ); /* Left side */ - if( width > 1 ) + if( uiWidth > 1 ) hb_gtWriteAt( uiRow, uiRight, szBox + 3, sizeof( BYTE ) ); /* Right side */ } } - if( height > 1 && width > 1 ) + if( uiHeight > 1 && uiWidth > 1 ) { hb_gtWriteAt( uiBottom, uiLeft, szBox + 6, sizeof( BYTE ) ); /* Bottom left corner */ - uiCol = ( height > 1 ? uiLeft + 1 : uiLeft ); + uiCol = ( uiHeight > 1 ? uiLeft + 1 : uiLeft ); - if( uiCol <= uiRight && height > 1 ) - hb_gtRepChar( uiBottom, uiCol, szBox[ 5 ], uiRight - uiLeft + ( height > 1 ? -1 : 1 ) ); /* Bottom line */ + if( uiCol <= uiRight && uiHeight > 1 ) + hb_gtRepChar( uiBottom, uiCol, szBox[ 5 ], uiRight - uiLeft + ( uiHeight > 1 ? -1 : 1 ) ); /* Bottom line */ hb_gtWriteAt( uiBottom, uiRight, szBox + 4, sizeof( BYTE ) ); /* Bottom right corner */ } @@ -363,7 +369,7 @@ USHORT hb_gtPostExt( void ) return 0; } -/* NOTE: szColorString must be an at least CLR_STRLEN wide by the NG. It seems +/* NOTE: szColorString must be at least CLR_STRLEN wide by the NG. It seems that CA-Cl*pper SETCOLOR() will return string lengths up to 131+EOF. That seems like a 127+1 buffer size, plus lazy overflow checking. [vszakats] */ @@ -731,7 +737,6 @@ USHORT hb_gtRepChar( USHORT uiRow, USHORT uiCol, BYTE byChar, USHORT uiCount ) BYTE buffer[ REPCHAR_BUFFER_SIZE ]; memset( buffer, byChar, uiCount ); - hb_gtWriteAt( uiRow, uiCol, buffer, uiCount ); } else @@ -739,7 +744,6 @@ USHORT hb_gtRepChar( USHORT uiRow, USHORT uiCol, BYTE byChar, USHORT uiCount ) BYTE * buffer = ( BYTE * ) hb_xgrab( uiCount ); memset( buffer, byChar, uiCount ); - hb_gtWriteAt( uiRow, uiCol, buffer, uiCount ); hb_xfree( buffer ); diff --git a/harbour/source/rtl/langapi.c b/harbour/source/rtl/langapi.c index 81dbbd886f..14c4d67837 100644 --- a/harbour/source/rtl/langapi.c +++ b/harbour/source/rtl/langapi.c @@ -37,15 +37,6 @@ #include "hbapilng.h" /* Always link in the default language */ - -/* This hack is needed to force preprocessing if id is also a macro */ -#define HB_LANG_REQUEST( id ) HB_LANG_REQUEST_( id ) -#define HB_LANG_REQUEST_( id ) extern HB_FUNC( HB_LANG_##id ); \ - void hb_lang_ForceLink( void ) \ - { \ - HB_FUNCNAME( HB_LANG_##id )(); \ - } - HB_LANG_REQUEST( HB_LANG_DEFAULT ); /* NOTE: This is the maximum number of registered languages, later this can be @@ -178,7 +169,7 @@ char * hb_langName( void ) ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ), ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) ); else - strcpy( pszName, "Harbour Language: (not installled)" ); + strcpy( pszName, "Harbour Language: (not installed)" ); return pszName; } diff --git a/harbour/source/rtl/net.c b/harbour/source/rtl/net.c index 18a85bceea..d994f08cca 100644 --- a/harbour/source/rtl/net.c +++ b/harbour/source/rtl/net.c @@ -41,23 +41,27 @@ /* NOTE: Clipper will only return a maximum of 15 bytes from this function. [vszakats] */ -/* NOTE: DOS instructions: - - On entry: AH 5Eh - AL 00h - DS:DX Pointer to a memory buffer (16 bytes) where - computer name will be returned - - Returns: CH 0 name not defined - not 0 name is defined - CL NETBIOS name number (if CH not 0) - DS:DX Pointer to computer name (ASCIIZ string) - AX Error code, if CF is set -*/ - HB_FUNC( NETNAME ) { -#if defined(HB_OS_WIN_32) +#if defined(HB_OS_DOS) + + #define LP_SEG( lp ) ( ( unsigned )( ( unsigned )( lp ) >> 16 ) ) + #define LP_OFF( lp ) ( ( unsigned )( lp ) ) + + { + char szValue[ 16 ]; + union REGS regs; + struct SREGS sregs; + + regs.x.ax = 0x5E00; + regs.x.dx = LP_OFF( szValue ); + sregs.ds = LP_SEG( szValue ); + + HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); + + hb_retc( regs.h.ch == 0 ? "" : szValue ); + } +#elif defined(HB_OS_WIN_32) { DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1; char * pszValue = ( char * ) hb_xgrab( ulLen ); diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index bc3a67963d..bb32f48a94 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -321,13 +321,10 @@ HB_FUNC( SET ) { BOOL bFlag; int args = hb_pcount(); - PHB_ITEM pArg2, pArg3; - HB_set_enum set_specifier; - if( args > 0 ) set_specifier = ( HB_set_enum ) hb_parni( 1 ); - else set_specifier = HB_SET_INVALID_; - if( args > 1 ) pArg2 = hb_param( 2, HB_IT_ANY ); - if( args > 2 ) pArg3 = hb_param( 3, HB_IT_ANY ); + HB_set_enum set_specifier = ( args > 0 ) ? ( HB_set_enum ) hb_parni( 1 ) : HB_SET_INVALID_; + PHB_ITEM pArg2 = ( args > 1 ) ? hb_param( 2, HB_IT_ANY ) : NULL; + PHB_ITEM pArg3 = ( args > 2 ) ? hb_param( 3, HB_IT_ANY ) : NULL; switch ( set_specifier ) { diff --git a/harbour/source/rtl/transfrm.c b/harbour/source/rtl/transfrm.c index c439aaa62c..93b4cbe4e6 100644 --- a/harbour/source/rtl/transfrm.c +++ b/harbour/source/rtl/transfrm.c @@ -533,7 +533,10 @@ HB_FUNC( TRANSFORM ) } } else + { + szResult = NULL; /* To avoid GCC -O2 warning */ bError = TRUE; + } if( ! bError ) { diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 432730d823..ef57711b31 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -624,11 +624,9 @@ HB_FUNC( __CLSDELMSG ) PHB_FUNC pFunc = pClass->pMethods[ uiAt ].pFunction; if( pFunc == hb___msgEvalInline ) /* INLINE method deleted */ - { - hb_arrayDel( pClass->pInlines, pClass->pMethods[ uiAt ].uiData ); - /* Delete INLINE block */ - } - /* Move messages */ + hb_arrayDel( pClass->pInlines, pClass->pMethods[ uiAt ].uiData ); /* Delete INLINE block */ + + /* Move messages */ while( pClass->pMethods[ uiAt ].pMessage && uiAt != uiLimit ) { memcpy( pClass->pMethods + uiAt, @@ -745,9 +743,7 @@ HB_FUNC( __CLSMODMSG ) hb_arraySet( pClass->pInlines, pClass->pMethods[ uiAt ].uiData, pBlock ); } else if( ( pFunc == hb___msgSetData ) || ( pFunc == hb___msgGetData ) ) - { /* Not allowed for DATA */ - hb_errRT_BASE( EG_ARG, 3004, "Cannot modify a DATA item", "__CLSMODMSG" ); - } + hb_errRT_BASE( EG_ARG, 3004, "Cannot modify a DATA item", "__CLSMODMSG" ); /* Not allowed for DATA */ else /* Modify METHOD */ pClass->pMethods[ uiAt ].pFunction = ( PHB_FUNC ) hb_parnl( 3 ); } @@ -875,24 +871,25 @@ HB_FUNC( __CLSINSTSUPER ) hb_vmPushNil(); hb_vmFunction( 0 ); /* Execute super class */ - if( !HB_IS_OBJECT( &hb_stack.Return ) ) + if( HB_IS_OBJECT( &hb_stack.Return ) ) { - hb_errRT_BASE( EG_ARG, 3002, "Super class does not return an object", "__CLSINSTSUPER" ); - } - - for( uiClass = 0; ! bFound && uiClass < s_uiClasses; uiClass++ ) - { /* Locate the entry */ - if( hb_stricmp( pString->item.asString.value, s_pClasses[ uiClass ].szName ) == 0 ) - { - hb_retni( uiClass + 1 ); /* Entry + 1 = hb___msgClsH */ - bFound = TRUE; + for( uiClass = 0; ! bFound && uiClass < s_uiClasses; uiClass++ ) + { /* Locate the entry */ + if( hb_stricmp( pString->item.asString.value, s_pClasses[ uiClass ].szName ) == 0 ) + { + hb_retni( uiClass + 1 ); /* Entry + 1 = hb___msgClsH */ + bFound = TRUE; + } } } + else + hb_errRT_BASE( EG_ARG, 3002, "Super class does not return an object", "__CLSINSTSUPER" ); } else hb_errRT_BASE( EG_ARG, 3003, "Cannot find super class", "__CLSINSTSUPER" ); } - if( !bFound ) + + if( ! bFound ) hb_retni( 0 ); } @@ -911,6 +908,8 @@ HB_FUNC( __CLS_CNTCLSDATA ) PCLASS pClass = &s_pClasses[ uiClass - 1 ]; hb_retni( hb_arrayLen( pClass->pClassDatas ) ); } + else + hb_retni( 0 ); } @@ -923,8 +922,7 @@ HB_FUNC( __CLS_CNTDATA ) { USHORT uiClass = hb_parni( 1 ); - if( uiClass ) - hb_retni( s_pClasses[ uiClass - 1 ].uiDatas ); + hb_retni( uiClass != 0 ? s_pClasses[ uiClass - 1 ].uiDatas : 0 ); } @@ -937,8 +935,7 @@ HB_FUNC( __CLS_DECDATA ) { USHORT uiClass = hb_parni( 1 ); - if( uiClass ) - hb_retni( s_pClasses[ uiClass - 1 ].uiDatas-- ); + hb_retni( uiClass != 0 ? s_pClasses[ uiClass - 1 ].uiDatas-- : 0 ); } @@ -951,8 +948,7 @@ HB_FUNC( __CLS_INCDATA ) { USHORT uiClass = hb_parni( 1 ); - if( uiClass ) - hb_retni( ++s_pClasses[ uiClass - 1 ].uiDatas ); + hb_retni( uiClass != 0 ? ++s_pClasses[ uiClass - 1 ].uiDatas : 0 ); } /* NOTE: Undocumented Clipper function */ diff --git a/harbour/source/vm/extend.c b/harbour/source/vm/extend.c index 93e9cf5ce7..7c15f660c0 100644 --- a/harbour/source/vm/extend.c +++ b/harbour/source/vm/extend.c @@ -410,12 +410,7 @@ int hb_parinfo( int iParam ) if( uiType & HB_IT_BYREF ) { - PHB_ITEM pItem; - - if( iParam == -1 ) - pItem = hb_itemUnRef( &hb_stack.Return ); - else - pItem = hb_itemUnRef( hb_stack.pBase + 1 + iParam ); + PHB_ITEM pItem = hb_itemUnRef( ( iParam == -1 ) ? &hb_stack.Return : ( hb_stack.pBase + 1 + iParam ) ); if( pItem ) uiType |= pItem->type; @@ -465,7 +460,7 @@ void hb_retclen( char * szText, ULONG ulLen ) hb_itemPutCL( &hb_stack.Return, szText, ulLen ); } -/* szDate must have yyyymmdd format */ +/* szDate must have YYYYMMDD format */ void hb_retds( char * szDate ) { @@ -583,7 +578,7 @@ void hb_storclen( char * szText, ULONG ulLen, int iParam, ... ) } } -/* szDate should have yyyymmdd format */ +/* szDate must have YYYYMMDD format */ void hb_stords( char * szDate, int iParam, ... ) { diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index a4bc0aa2af..08d81b9ab9 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -367,8 +367,8 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols ) * macro evaluation belong to a function/procedure where macro * compiler was called. */ - if( pSymbols ) - ulPrivateBase = hb_memvarGetPrivatesBase(); + /* NOTE: Initialization with 0 is needed to avoid GCC -O2 warning */ + ulPrivateBase = pSymbols ? hb_memvarGetPrivatesBase() : 0; while( ( bCode = pCode[ w ] ) != HB_P_ENDPROC ) { @@ -1190,16 +1190,17 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols ) break; else if( s_uiActionRequest & HB_ENDPROC_REQUESTED ) { - /* request to stop current procedure was issued - * (from macro evaluation) - */ - s_uiActionRequest = 0; - break; + /* request to stop current procedure was issued + * (from macro evaluation) + */ + s_uiActionRequest = 0; + break; } } } + if( pSymbols ) - hb_memvarSetPrivatesBase( ulPrivateBase ); + hb_memvarSetPrivatesBase( ulPrivateBase ); } /* ------------------------------- */ @@ -3283,6 +3284,7 @@ static double hb_vmPopNumber( void ) break; default: + dNumber = 0; /* To avoid GCC -O2 warning */ hb_errInternal( IE_VMPOPINVITEM, NULL, "hb_vmPopNumber()", NULL ); break; } @@ -3322,6 +3324,7 @@ static double hb_vmPopDouble( int * piDec ) break; default: + dNumber = 0; /* To avoid GCC -O2 warning */ hb_errInternal( IE_VMPOPINVITEM, NULL, "hb_vmPopDouble()", NULL ); break; } diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index ac4a54f2d9..c163712bd6 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -215,6 +215,8 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) pResult = hb_itemNew( NULL ); hb_itemCopy( pResult, &hb_stack.Return ); } + else + pResult = NULL; } else if( HB_IS_BLOCK( pItem ) ) {