diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8384aae562..17fe5a48dc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +2001-07-22 20:15 UTC+0100 Ryszard Glab + + *include/hbapi.h + *include/hbexprb.c + *source/vm/hvm.c + *source/vm/macro.c + *source/compiler/exproptb.c + *source/macro/macrob.c + * fixed to support nested aliases in macro, eg. + LOCAL cAlias + cAlias := "&area" + PRIVATE area + area := "MyAlias" + ? &cAlias->someFile + ? &cAlias->( someExpr ) + 2001-07-22 08:40 GMT -3 Luiz Rafael Culik *source/rtl/getsys.prg *Now if an get has an message it will display properly diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index fa25c4ac83..a5fb16aa88 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -539,6 +539,7 @@ extern BOOL hb_macroIsIdent( char * szString ); /* determine if a string is a extern void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar ); /* compiles and evaluates an aliased macro expression */ extern void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar ); /* compiles and evaluates an aliased macro expression */ extern char * hb_macroGetType( HB_ITEM_PTR pItem ); /* determine the type of an expression */ +extern char * hb_macroExpandString( char *szString, ULONG ulLength, BOOL *pbNewString ); /* expands valid '&' operator */ /* garbage collector */ #define HB_GARBAGE_FUNC( hbfunc ) void hbfunc( void * Cargo ) /* callback function for cleaning garbage memory pointer */ diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index f7172a4688..5f8a7a63ea 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1062,11 +1062,13 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) case HB_EA_DELETE: if( pSelf->value.asMacro.pExprList ) HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMacro.pExprList ); -/* NOTE: This will be released during releasing of symbols' table - * - * if( pSelf->value.asMacro.szMacro ); - * HB_XFREE( pSelf->value.asMacro.szMacro ); - */ + +#if defined( HB_MACRO_SUPPORT ) + if( pSelf->value.asMacro.szMacro ); + HB_XFREE( pSelf->value.asMacro.szMacro ); +#else + /* NOTE: This will be released during releasing of symbols' table */ +#endif break; } return pSelf; diff --git a/harbour/source/compiler/exproptb.c b/harbour/source/compiler/exproptb.c index 30e7ad04d1..934192ad68 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) - * 0 - ignore this magic number - this is used to force compilation + * 1 - ignore this magic number - this is used to force compilation */ #include "hbexprb.c" diff --git a/harbour/source/macro/macrob.c b/harbour/source/macro/macrob.c index 0c3b433c2c..c54b1e0508 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 - ignore this magic number - this is used to force compilation + * 2 - ignore this magic number - this is used to force compilation */ #define HB_MACRO_SUPPORT diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index a0ea0721fc..f14a6d8a2b 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -2839,8 +2839,17 @@ static ERRCODE hb_vmSelectWorkarea( PHB_ITEM pAlias ) case HB_IT_STRING: /* Alias was evaluated from an expression, for example: (cVar)->field */ - bSuccess = hb_rddSelectWorkAreaAlias( pAlias->item.asString.value ); - hb_itemClear( pAlias ); + { + /* expand '&' operator if exists */ + char *cAlias; + BOOL bNewString; + + cAlias = hb_macroExpandString( pAlias->item.asString.value, pAlias->item.asString.length, &bNewString ); + bSuccess = hb_rddSelectWorkAreaAlias( cAlias ); + if( bNewString ) + hb_xfree( cAlias ); + hb_itemClear( pAlias ); + } break; default: diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 23ddf76047..754247b85b 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -625,6 +625,24 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag } } +/* Check for '&' operator and replace it with a macro variable value + * Returns: the passed string if there is no '&' operator (pbNewString:=FALSE) + * new string if a valid macro text substitution was found (and sets + * pbNewString to TRUE) +*/ +char * hb_macroExpandString( char *szString, ULONG ulLength, BOOL *pbNewString ) +{ + char *szResultString; + HB_TRACE(HB_TR_DEBUG, ("hb_macroExpandString(%p)", pItem)); + + if( szString ) + szResultString = hb_macroTextSubst( szString, &ulLength ); + else + szResultString = szString; + *pbNewString = ( szString != szResultString ); + return szResultString; +} + /* compile a string and return a pcode to push a value of expression * NOTE: it can be called to implement an index key evaluation * use hb_macroRun() to evaluate a compiled pcode