From bd80e8d997a01f1944cd8317595b9f1d5d7cefd7 Mon Sep 17 00:00:00 2001 From: Maurilio Longo Date: Wed, 18 Jul 2001 07:21:03 +0000 Subject: [PATCH] 2001-07-18 09:06 GMT+2 Maurilio Longo * source/rtl/tbrowse.prg + activated scoping * include/hbapierr.h include/hbapiitm.h include/hbvm.h source/rtl/errorapi.c source/vm/hvm.c source/vm/itemapi.c ! fixed va_start() use or, better, changed it to be compatible with OS/2 EMX GCC compiler which REQUIRES that va_start() calls use a type which cannot be promoted to something bigger. That is, this call is correct: va_start(valist, ulUnsignedLongType) while this one is not: va_start(valist, usUnsignedShortType) Using a type which can be promoted to a bigger one leads to memory corruption. I think this requirement could exist even on other ANSI C compilers. ! Removed workaround inside hb_itemDo() and hb_itemDoC() to prevent this corruption. --- harbour/ChangeLog | 20 +++++++++++ harbour/include/hbapierr.h | 10 +++--- harbour/include/hbapiitm.h | 4 +-- harbour/include/hbvm.h | 2 +- harbour/source/rtl/errorapi.c | 66 +++++++++++++++++----------------- harbour/source/rtl/tbrowse.prg | 6 ++-- harbour/source/vm/hvm.c | 14 ++++---- harbour/source/vm/itemapi.c | 50 ++++++++++++-------------- 8 files changed, 93 insertions(+), 79 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fa6820b250..e361a6e7ae 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,23 @@ +2001-07-18 09:06 GMT+2 Maurilio Longo + + * source/rtl/tbrowse.prg + + activated scoping + * include/hbapierr.h + include/hbapiitm.h + include/hbvm.h + source/rtl/errorapi.c + source/vm/hvm.c + source/vm/itemapi.c + ! fixed va_start() use or, better, changed it to be compatible with OS/2 EMX GCC + compiler which REQUIRES that va_start() calls use a type which cannot be promoted + to something bigger. That is, this call is correct: + va_start(valist, ulUnsignedLongType) + while this one is not: + va_start(valist, usUnsignedShortType) + Using a type which can be promoted to a bigger one leads to memory corruption. + I think this requirement could exist even on other ANSI C compilers. + ! Removed workaround inside hb_itemDo() and hb_itemDoC() to prevent this corruption. + 2001-07-17 18:25 UTC-0800 Ron Pinkas * utils/hbpp/hbpp.c * Commented an exit() call in hb_compGenError() to continue processing after an error just like Harbour does. diff --git a/harbour/include/hbapierr.h b/harbour/include/hbapierr.h index 94aa9cb42e..edac6280fd 100644 --- a/harbour/include/hbapierr.h +++ b/harbour/include/hbapierr.h @@ -109,7 +109,7 @@ extern char * hb_errGetSubSystem ( PHB_ITEM pError ); extern USHORT hb_errGetTries ( PHB_ITEM pError ); extern USHORT hb_errLaunch ( PHB_ITEM pError ); extern PHB_ITEM hb_errNew ( void ); -extern PHB_ITEM hb_errPutArgs ( PHB_ITEM pError, USHORT uiArgCount, ... ); +extern PHB_ITEM hb_errPutArgs ( PHB_ITEM pError, ULONG ulArgCount, ... ); extern PHB_ITEM hb_errPutDescription ( PHB_ITEM pError, char * szDescription ); extern PHB_ITEM hb_errPutFileName ( PHB_ITEM pError, char * szFileName ); extern PHB_ITEM hb_errPutFlags ( PHB_ITEM pError, USHORT uiFlags ); @@ -145,10 +145,10 @@ extern PHB_ITEM hb_errRT_New_Subst( USHORT uiSeverity, char * szSubSystem, USHORT uiOsCode, USHORT uiFlags ); -extern USHORT hb_errRT_BASE ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ); -extern USHORT hb_errRT_BASE_Ext1 ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags, USHORT uiArgCount, ... ); -extern PHB_ITEM hb_errRT_BASE_Subst ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ); -extern void hb_errRT_BASE_SubstR ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ); +extern USHORT hb_errRT_BASE ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ); +extern USHORT hb_errRT_BASE_Ext1 ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... ); +extern PHB_ITEM hb_errRT_BASE_Subst ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ); +extern void hb_errRT_BASE_SubstR ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ); extern USHORT hb_errRT_TERM ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOSCode, USHORT uiFlags ); extern USHORT hb_errRT_DBCMD ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); extern USHORT hb_errRT_TOOLS ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index 547659ea26..45878b86d8 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -72,8 +72,8 @@ extern BOOL hb_evalNew ( PEVALINFO pEvalInfo, PHB_ITEM pItem ); extern BOOL hb_evalPutParam ( PEVALINFO pEvalInfo, PHB_ITEM pItem ); extern BOOL hb_evalRelease ( PEVALINFO pEvalInfo ); -extern PHB_ITEM hb_itemDo ( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ); -extern PHB_ITEM hb_itemDoC ( char * szFunc, USHORT uiPCount, PHB_ITEM pItemArg1, ... ); +extern PHB_ITEM hb_itemDo ( PHB_ITEM pItem, ULONG ulPCount, ... ); +extern PHB_ITEM hb_itemDoC ( char * szFunc, ULONG ulPCount, ... ); extern PHB_ITEM hb_itemArrayGet ( PHB_ITEM pArray, ULONG ulIndex ); extern PHB_ITEM hb_itemArrayNew ( ULONG ulLen ); diff --git a/harbour/include/hbvm.h b/harbour/include/hbvm.h index 38706f4ea6..ffabd5468e 100644 --- a/harbour/include/hbvm.h +++ b/harbour/include/hbvm.h @@ -92,7 +92,7 @@ extern void hb_vmFunction( USHORT uiParams ); /* executes a function saving i extern void hb_vmSend( USHORT uiParams ); /* sends a message to an object */ extern PHB_ITEM hb_vmEvalBlock( PHB_ITEM pBlockItem ); /* executes passed codeblock with no arguments */ /* executes passed codeblock with variable number of arguments */ -extern PHB_ITEM hb_vmEvalBlockV( PHB_ITEM pBlockItem, USHORT uiArgCount, ... ); +extern PHB_ITEM hb_vmEvalBlockV( PHB_ITEM pBlockItem, ULONG ulArgCount, ... ); /* Push */ extern void hb_vmPush( PHB_ITEM pItem ); /* pushes a generic item onto the stack */ diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index fd73db0951..1db7247584 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -647,21 +647,21 @@ PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags ) return pError; } -PHB_ITEM hb_errPutArgs( PHB_ITEM pError, USHORT uiArgCount, ... ) +PHB_ITEM hb_errPutArgs( PHB_ITEM pError, ULONG ulArgCount, ... ) { PHB_ITEM pArray; - USHORT uiArgPos; + ULONG ulArgPos; va_list va; - HB_TRACE(HB_TR_DEBUG, ("hb_errPutArgs(%p, %hu, ...)", pError, uiArgCount)); + HB_TRACE(HB_TR_DEBUG, ("hb_errPutArgs(%p, %hu, ...)", pError, ulArgCount)); - pArray = hb_itemArrayNew( uiArgCount ); + pArray = hb_itemArrayNew( ulArgCount ); /* Build the array from the passed arguments. */ - va_start( va, uiArgCount ); - for( uiArgPos = 1; uiArgPos <= uiArgCount; uiArgPos++ ) - hb_itemArrayPut( pArray, uiArgPos, va_arg( va, PHB_ITEM ) ); + va_start( va, ulArgCount ); + for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) + hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); va_end( va ); /* Assign the new array to the object data item. */ @@ -746,19 +746,19 @@ HB_FUNC( __ERRRT_SBASE ) hb_param( 6, HB_IT_ANY ) ); } -USHORT hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ) +USHORT hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ) { USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray, pArg; va_list va; - USHORT uiArgPos; + ULONG ulArgPos; BOOL bRelease = TRUE; /* Build the array from the passed arguments. */ - va_start( va, uiArgCount ); - if( ( ulSubCode == 1001 || ulSubCode == 1004 || ulSubCode == 1005 ) && uiArgCount == 1 ) + va_start( va, ulArgCount ); + if( ( ulSubCode == 1001 || ulSubCode == 1004 || ulSubCode == 1005 ) && ulArgCount == 1 ) { pArray = va_arg( va, PHB_ITEM ); @@ -775,11 +775,11 @@ USHORT hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, ch } else { - pArray = hb_itemArrayNew( uiArgCount ); + pArray = hb_itemArrayNew( ulArgCount ); - for( uiArgPos = 1; uiArgPos <= uiArgCount; uiArgPos++ ) + for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { - hb_itemArrayPut( pArray, uiArgPos, va_arg( va, PHB_ITEM ) ); + hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); } } va_end( va ); @@ -807,21 +807,21 @@ USHORT hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, ch return uiAction; } -USHORT hb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags, USHORT uiArgCount, ... ) +USHORT hb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... ) { USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray; va_list va; - USHORT uiArgPos; + ULONG ulArgPos; - pArray = hb_itemArrayNew( uiArgCount ); + pArray = hb_itemArrayNew( ulArgCount ); /* Build the array from the passed arguments. */ - va_start( va, uiArgCount ); - for( uiArgPos = 1; uiArgPos <= uiArgCount; uiArgPos++ ) - hb_itemArrayPut( pArray, uiArgPos, va_arg( va, PHB_ITEM ) ); + va_start( va, ulArgCount ); + for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) + hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); va_end( va ); pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags ); @@ -843,21 +843,21 @@ USHORT hb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, char * szDescriptio return uiAction; } -PHB_ITEM hb_errRT_BASE_Subst( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ) +PHB_ITEM hb_errRT_BASE_Subst( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ) { PHB_ITEM pRetVal; PHB_ITEM pError; PHB_ITEM pArray; va_list va; - USHORT uiArgPos; + ULONG ulArgPos; - pArray = hb_itemArrayNew( uiArgCount ); + pArray = hb_itemArrayNew( ulArgCount ); /* Build the array from the passed arguments. */ - va_start( va, uiArgCount ); - for( uiArgPos = 1; uiArgPos <= uiArgCount; uiArgPos++ ) - hb_itemArrayPut( pArray, uiArgPos, va_arg( va, PHB_ITEM ) ); + va_start( va, ulArgCount ); + for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) + hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); va_end( va ); pError = hb_errRT_New_Subst( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); @@ -879,18 +879,18 @@ PHB_ITEM hb_errRT_BASE_Subst( ULONG ulGenCode, ULONG ulSubCode, char * szDescrip return pRetVal; } -void hb_errRT_BASE_SubstR( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiArgCount, ... ) +void hb_errRT_BASE_SubstR( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, ULONG ulArgCount, ... ) { PHB_ITEM pError; PHB_ITEM pArray, pArg; va_list va; - USHORT uiArgPos; + ULONG ulArgPos; BOOL bRelease = TRUE; /* Build the array from the passed arguments. */ - va_start( va, uiArgCount ); - if( ( ulSubCode == 1001 || ulSubCode == 1004 || ulSubCode == 1005 ) && uiArgCount == 1 ) + va_start( va, ulArgCount ); + if( ( ulSubCode == 1001 || ulSubCode == 1004 || ulSubCode == 1005 ) && ulArgCount == 1 ) { pArray = va_arg( va, PHB_ITEM ); @@ -907,11 +907,11 @@ void hb_errRT_BASE_SubstR( ULONG ulGenCode, ULONG ulSubCode, char * szDescriptio } else { - pArray = hb_itemArrayNew( uiArgCount ); + pArray = hb_itemArrayNew( ulArgCount ); - for( uiArgPos = 1; uiArgPos <= uiArgCount; uiArgPos++ ) + for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { - hb_itemArrayPut( pArray, uiArgPos, va_arg( va, PHB_ITEM ) ); + hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); } } va_end( va ); diff --git a/harbour/source/rtl/tbrowse.prg b/harbour/source/rtl/tbrowse.prg index 60937e87da..b134ae8e8f 100644 --- a/harbour/source/rtl/tbrowse.prg +++ b/harbour/source/rtl/tbrowse.prg @@ -168,12 +168,12 @@ CLASS TBrowse METHOD TApplyKey(nKey, o) #endif - /* PROTECTED: /* P R O T E C T E D */ + PROTECTED: /* P R O T E C T E D */ + METHOD MGotoYX(nRow, nCol) // Given screen coordinates nRow, nCol sets TBrowse cursor on underlaying cell // _M_GotoXY because this method will mostly be called to handle mouse requests - - /*HIDDEN: /* H I D D E N */ + HIDDEN: /* H I D D E N */ METHOD LeftDetermine() // Determine leftmost unfrozen column in display METHOD DispCell(nColumn, nColor) // Displays a single cell diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 76ee84b02c..6f7003849b 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -3277,28 +3277,28 @@ HB_ITEM_PTR hb_vmEvalBlock( HB_ITEM_PTR pBlock ) /* Evaluates a codeblock item using passed additional arguments * pBlock = an item of codeblock type to evaluate - * uiArgCount = number of arguments passed to a codeblock + * ulArgCount = number of arguments passed to a codeblock * ... = the list of arguments of type PHB_ITEM * *for example: * retVal = hb_vmEvalBlockV( pBlock, 2, pParam1, pParam2 ); */ -HB_ITEM_PTR hb_vmEvalBlockV( HB_ITEM_PTR pBlock, USHORT uiArgCount, ... ) +HB_ITEM_PTR hb_vmEvalBlockV( HB_ITEM_PTR pBlock, ULONG ulArgCount, ... ) { va_list va; - USHORT i; + ULONG i; - HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlockV(%p, %hu, ...)", pBlock, uiArgCount)); + HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlockV(%p, %hu, ...)", pBlock, ulArgCount)); hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pBlock ); - va_start( va, uiArgCount ); - for( i = 1; i <= uiArgCount; i++ ) + va_start( va, ulArgCount ); + for( i = 1; i <= ulArgCount; i++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); - hb_vmDo( uiArgCount ); + hb_vmDo( ulArgCount ); return &hb_stack.Return; } diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 765db9aff0..3bc8a8e083 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -215,14 +215,13 @@ BOOL hb_evalRelease( PEVALINFO pEvalInfo ) NOTE: When calling hb_itemDo() with no arguments for the Harbour item being evaluated, you must use '(PHB_ITEM *) 0' as the third parameter. +*/ - NOTE: pItemArg1 is needed to workaround a bug in OS2/GCC. */ - -PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) +PHB_ITEM hb_itemDo( PHB_ITEM pItem, ULONG ulPCount, ... ) { PHB_ITEM pResult; - HB_TRACE(HB_TR_DEBUG, ("hb_itemDo(%p, %hu, %p, ...)", pItem, uiPCount, pItemArg1)); + HB_TRACE(HB_TR_DEBUG, ("hb_itemDo(%p, %hu, ...)", pItem, ulPCount)); if( pItem ) { @@ -232,16 +231,15 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) if( pDynSym ) { - USHORT uiParam; + ULONG ulParam; va_list va; - va_start( va, pItemArg1 ); + va_start( va, ulPCount ); hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); - if( uiPCount >= 1 ) hb_vmPush( pItemArg1 ); - for( uiParam = 2; uiParam <= uiPCount; uiParam++ ) + for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); - hb_vmDo( uiPCount ); + hb_vmDo( ulPCount ); va_end( va ); pResult = hb_itemNew( NULL ); @@ -252,16 +250,15 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) } else if( HB_IS_BLOCK( pItem ) ) { - USHORT uiParam; + ULONG ulParam; va_list va; - va_start( va, pItemArg1 ); + va_start( va, ulPCount ); hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pItem ); - if( uiPCount >= 1 ) hb_vmPush( pItemArg1 ); - for( uiParam = 2; uiParam <= uiPCount; uiParam++ ) + for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); - hb_vmDo( uiPCount ); + hb_vmDo( ulPCount ); va_end( va ); pResult = hb_itemNew( NULL ); @@ -269,16 +266,15 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) } else if( HB_IS_SYMBOL( pItem ) ) { - USHORT uiParam; + ULONG ulParam; va_list va; - va_start( va, pItemArg1 ); + va_start( va, ulPCount ); hb_vmPushSymbol( pItem->item.asSymbol.value ); hb_vmPushNil(); - if( uiPCount >= 1 ) hb_vmPush( pItemArg1 ); - for( uiParam = 2; uiParam <= uiPCount; uiParam++ ) + for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); - hb_vmDo( uiPCount ); + hb_vmDo( ulPCount ); va_end( va ); pResult = hb_itemNew( NULL ); @@ -298,14 +294,13 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) NOTE: When calling hb_itemDoC() with no arguments for the Harbour function being called, you must use '(PHB_ITEM *) 0' as the third parameter. +*/ - NOTE: pItemArg1 is needed to workaround a bug in OS2/GCC. */ - -PHB_ITEM hb_itemDoC( char * szFunc, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) +PHB_ITEM hb_itemDoC( char * szFunc, ULONG ulPCount, ... ) { PHB_ITEM pResult; - HB_TRACE(HB_TR_DEBUG, ("hb_itemDoC(%s, %hu, %p, ...)", szFunc, uiPCount, pItemArg1)); + HB_TRACE(HB_TR_DEBUG, ("hb_itemDoC(%s, %hu, ...)", szFunc, ulPCount)); if( szFunc ) { @@ -313,16 +308,15 @@ PHB_ITEM hb_itemDoC( char * szFunc, USHORT uiPCount, PHB_ITEM pItemArg1, ... ) if( pDynSym ) { - USHORT uiParam; + ULONG ulParam; va_list va; - va_start( va, pItemArg1 ); + va_start( va, ulPCount ); hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); - if( uiPCount >= 1 ) hb_vmPush( pItemArg1 ); - for( uiParam = 2; uiParam <= uiPCount; uiParam++ ) + for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); - hb_vmDo( uiPCount ); + hb_vmDo( ulPCount ); va_end( va ); pResult = hb_itemNew( NULL );