diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 81af57698a..f66ac63c2a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,25 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-03-01 11:15 UTC+0100 Ryszard Glab + * include/hbexprb.c + * include/hbmacro.ch + * fixed support for strings as array of bytes + (in macro compiler) + * added a new #define HB_SM_ARRSTR as a flag + for HB_SETMACRO() to disable/enable strings + as array of bytes + + * source/vm/macro.c + * added HB_SM_ARRSTR support + * fixed TYPE() function to return correct value when an + assigment to undeclared variable is checked (Clipper + creates the memvar variable) - thanks to Phil Krylov + + * source/compiler/hbusage.c + * fixed typo for -ks switch + + 2004-04-01 09:09 UTC+0100 Viktor Szakats * source/common/hbffind.c diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index e8b7516dcb..9f335a4c5e 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -84,6 +84,7 @@ #define HB_SUPPORT_XBASE ( HB_COMP_ISSUPPORTED(HB_SM_XBASE) ) #define HB_SUPPORT_HARBOUR ( HB_COMP_ISSUPPORTED(HB_SM_HARBOUR) ) + #define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_SM_ARRSTR) ) #else void hb_compExprDelOperator( HB_EXPR_PTR ); void hb_compExprUseOperEq( HB_EXPR_PTR, BYTE ); @@ -96,6 +97,7 @@ #define HB_SUPPORT_XBASE ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_XBASE) ) #define HB_SUPPORT_HARBOUR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) + #define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) ) #endif @@ -1214,7 +1216,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { BOOL bRemoveRef = FALSE; /* #ifndef HB_C52_STRICT */ - if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) ) + if( HB_SUPPORT_ARRSTR ) /* to manage strings as bytes arrays, they must be pushed by reference */ /* arrays also are passed by reference */ if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE ) @@ -1229,7 +1231,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_ARRAYPOP ); /* #ifndef HB_C52_STRICT */ - if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) ) + if( HB_SUPPORT_ARRSTR ) if( bRemoveRef ) { pSelf->value.asList.pExprList->ExprType = HB_ET_VARIABLE; diff --git a/harbour/include/hbmacro.ch b/harbour/include/hbmacro.ch index 5df32bdc06..80ce5f7414 100644 --- a/harbour/include/hbmacro.ch +++ b/harbour/include/hbmacro.ch @@ -60,6 +60,7 @@ #define HB_SM_XBASE 2 /* extended xbase compatibility */ #define HB_SM_PREPROC 4 /* enable/disable commands preprocessing */ #define HB_SM_SHORTCUTS 8 /* enable/disable sortcuts for logical operators */ +#define HB_SM_ARRSTR 16 /* enable/disable strings as array of bytes */ #define HB_SM_RT_MACRO 64 /* disable automatic setup of macro flag */ #define HB_SM_PARSER 128 /* address of macro parser (TODO) */ diff --git a/harbour/source/compiler/exproptb.c b/harbour/source/compiler/exproptb.c index b88140280d..e62581b334 100644 --- a/harbour/source/compiler/exproptb.c +++ b/harbour/source/compiler/exproptb.c @@ -5,6 +5,6 @@ /* hbexprb.c is also included from ../macro/macro.c * However it produces a slighty different code if used in * macro compiler (there is an additional parameter passed to some functions) - * 1.10 - ignore this magic number - this is used to force compilation + * 1.11 - ignore this magic number - this is used to force compilation */ #include "hbexprb.c" diff --git a/harbour/source/compiler/hbusage.c b/harbour/source/compiler/hbusage.c index a65ba44cac..c9ed301952 100644 --- a/harbour/source/compiler/hbusage.c +++ b/harbour/source/compiler/hbusage.c @@ -119,7 +119,7 @@ void hb_compPrintModes( void ) "\n h Harbour mode (default)", "\n i enable support for HB_INLINE", "\n r runtime settings enabled", - "\n c string as bytes array enabled", + "\n s string as bytes array enabled", "\n x extended xbase mode", "\n J turn off jump optimization in pcode", "\n ? this info", diff --git a/harbour/source/macro/macrob.c b/harbour/source/macro/macrob.c index 4b087119ad..cbf922b8df 100644 --- a/harbour/source/macro/macrob.c +++ b/harbour/source/macro/macrob.c @@ -5,7 +5,7 @@ /* hbexprb.c is also included from ../compiler/exproptb.c * However it produces a slighty different code if used in * macro compiler (there is an additional parameter passed to some functions) - * 1.9 - ignore this magic number - this is used to force compilation + * 1.10 - ignore this magic number - this is used to force compilation */ #define HB_MACRO_SUPPORT diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 1422d08a57..0692426c2e 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -94,6 +94,7 @@ static int hb_macroParse( HB_MACRO_PTR pMacro, char * szString ) pMacro->length = strlen( szString ); pMacro->pos = 0; pMacro->bShortCuts = hb_comp_bShortCuts; + pMacro->pError = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_macroParse(%p, %s)", pMacro, szString)); @@ -176,6 +177,8 @@ static HB_ERROR_HANDLE( hb_macroErrorType ) { HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) ErrorInfo->Cargo; + /* copy error object for later diagnostic usage */ + pMacro->pError = hb_itemNew( ErrorInfo->Error ); pMacro->status &= ~HB_MACRO_CONT; /* ignore rest of compiled code */ @@ -846,14 +849,14 @@ char * hb_macroGetType( HB_ITEM_PTR pItem ) { /* passed string was successfully compiled */ - if( struMacro.exprType == HB_ET_CODEBLOCK ) - { - /* Clipper ignores any undeclared symbols or UDFs if the - * compiled expression is a valid codeblock - */ - szType ="B"; - } - else if( struMacro.status & ( HB_MACRO_UNKN_SYM | HB_MACRO_UNKN_VAR) ) + if( struMacro.exprType == HB_ET_CODEBLOCK ) + { + /* Clipper ignores any undeclared symbols or UDFs if the + * compiled expression is a valid codeblock + */ + szType ="B"; + } + else if( struMacro.status & HB_MACRO_UNKN_SYM ) { /* request for a symbol that is not in a symbol table or * for a variable that is not visible @@ -894,7 +897,21 @@ char * hb_macroGetType( HB_ITEM_PTR pItem ) else { /* something unpleasant happened during macro evaluation */ - szType = "UE"; + if( struMacro.pError ) + { + ULONG ulGenCode; + + ulGenCode = hb_errGetGenCode( struMacro.pError ); + if( ulGenCode == EG_NOVAR ) + { + /* Undeclared variable returns 'U' in Clipper */ + szType = "U"; + } + else + szType = "UE"; + } + else + szType = "UE"; } } else @@ -905,6 +922,9 @@ char * hb_macroGetType( HB_ITEM_PTR pItem ) else szType = "UE"; /* syntax error during compilation */ + if( struMacro.pError ) + hb_itemRelease( struMacro.pError ); + struMacro.pError = NULL; hb_macroDelete( &struMacro ); } else @@ -967,6 +987,17 @@ HB_FUNC( HB_SETMACRO ) hb_macroSetMacro( hb_itemGetL( pValue ), ulFlags ); break; + case HB_SM_ARRSTR : + /* enable/disable processing of strings as an array of bytes */ + hb_retl( s_macroFlags & ulFlags ); + pValue = hb_param( 2, HB_IT_LOGICAL ); + if( pValue ) + { + BOOL bSet = hb_itemGetL( pValue ); + hb_macroSetMacro( bSet && hb_vmFlagEnabled(HB_VMFLAG_ARRSTR), ulFlags ); + } + break; + case HB_SM_SHORTCUTS: /* enable/disable support for shortcut logical operators */ hb_retl( s_macroFlags & ulFlags ); @@ -1108,21 +1139,12 @@ void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_MACRO_DECL ) */ pSym = hb_dynsymFind( szVarName ); if( ! pSym ) - { - HB_MACRO_DATA->status |= HB_MACRO_UNKN_SYM; - HB_MACRO_DATA->status &= ~HB_MACRO_CONT; /* don't run this pcode */ - /* - * NOTE: the compiled pcode will be not executed then we can ignore - * NULL value for pSym - */ - } - } - else - { - /* Find the address of passed symbol - create the symbol if doesn't exist - */ - pSym = hb_dynsymGet( szVarName ); + HB_MACRO_DATA->status |= HB_MACRO_UNKN_VAR; } + /* Find the address of passed symbol - + * create the symbol if doesn't exist (Clipper compatibility) + */ + pSym = hb_dynsymGet( szVarName ); hb_compGenPCode1( bPCode, HB_MACRO_PARAM ); hb_compGenPCodeN( ( BYTE * )( &pSym ), sizeof( pSym ), HB_MACRO_PARAM ); }