diff --git a/harbour/.cvsignore b/harbour/.cvsignore index c560104756..f067600ce8 100644 --- a/harbour/.cvsignore +++ b/harbour/.cvsignore @@ -18,5 +18,3 @@ obj obj/* lib lib/* -myapps -myapps/* diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a8cf64b36c..586130cbed 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,33 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2003-10-20 13:45 UTC+0100 Ryszard Glab + * .cvsignore + * Restored previous version + + * include/hbexpra.c + * include/hbexprb.c + * include/hbexprc.c + * include/hbexprop.h + * source/common/expropt1.c + * source/compiler/exproptb.c + * source/compiler/exproptc.c + * source/compiler/harbour.sly + * fixed declaration mismatch in Simplex version + * fixed generation of string's pcode + (introduced with my previous changes) + + * source/pp/ppcore.c + * fixed support for stringify match markers <""> and <()> in Flex + version (for example &var.1 have to be expanded into "&var.1" + instead of var.1 since this is not a valid Clipper expression) + NOTICE! In Simplex version this is not fixed because it is + used as a hack to correctly support macro variables in GET + command. + + * tests/testget.prg + * MEMVAR declaration was added + 2003-10-20 11:37 UTC+0300 Alexander Kresin * include/hbapi.h * The declaration of hb_objSendMsg() added. diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index b8b360ee5a..63b3c5e5f7 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -380,7 +380,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) /* Search for {|| &(cMacro) }. */ else if( pElem->ExprType == HB_ET_CODEBLOCK ) { - HB_EXPR_PTR pBlock = pElem->value.asList.pExprList; + HB_EXPR_PTR pBlock = pElem->value.asCodeblock.pExprList; /* Search for macros {|| &cMacro }. */ if( pBlock->ExprType == HB_ET_MACRO ) diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 14c0607c7e..a510ce7a50 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -177,8 +177,10 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ); static void hb_compExprCodeblockPush( HB_EXPR_PTR, HB_MACRO_DECL ); #else static void hb_compExprCodeblockPush( HB_EXPR_PTR ); +#if !defined(SIMPLEX) static void hb_compExprCodeblockEarly( HB_EXPR_PTR ); #endif +#endif HB_EXPR_FUNC_PTR hb_comp_ExprTable[] = { hb_compExprUseDummy, @@ -347,13 +349,21 @@ static HB_EXPR_FUNC( hb_compExprUseString ) case HB_EA_PUSH_PCODE: { char *szDupl; + BOOL bUseTextSubst; + BOOL bValidMacro; + szDupl = hb_strupr( hb_strdup( pSelf->value.asString.string ) ); HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asString.string, pSelf->ulLength + 1 ); - HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROTEXT ); - if( ! hb_compExprIsValidMacro( szDupl ) ) - hb_compErrorMacro( pSelf->value.asString.string ); + + bValidMacro = hb_compExprIsValidMacro( szDupl, &bUseTextSubst ); + if( bUseTextSubst ) + { + if( bValidMacro ) + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROTEXT ); + else + hb_compErrorMacro( pSelf->value.asString.string ); + } hb_xfree( szDupl ); - } break; case HB_EA_POP_PCODE: @@ -532,9 +542,10 @@ static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf ) */ HB_EXPR_PTR pNew; char *szDupl; + BOOL bUseTextSubst; szDupl = hb_strupr( hb_strdup( pSelf->value.asCodeblock.string ) ); - if( !hb_compExprIsValidMacro( szDupl ) ) + if( !hb_compExprIsValidMacro( szDupl, &bUseTextSubst ) ) { hb_compErrorCodeblock( pSelf->value.asCodeblock.string ); hb_compErrorMacro( pSelf->value.asCodeblock.string ); diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index 9042515475..3ee4d476ad 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -416,13 +416,14 @@ ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr ) return ulCnt; } -BOOL hb_compExprIsValidMacro( char * szText ) +BOOL hb_compExprIsValidMacro( char * szText, BOOL *pbUseTextSubst ) { char * pTmp = szText; BOOL bTextSubst; BOOL bMacroText = TRUE; - while( (( pTmp = strchr( pTmp, '&' ) ) != NULL) && bMacroText ) + *pbUseTextSubst = FALSE; /* no valid macro expression */ + while( ((pTmp = strchr( pTmp, '&' )) != NULL) && bMacroText ) { /* Check if macro operator is used inside a string * Macro operator is ignored if it is the last char or @@ -464,6 +465,7 @@ BOOL hb_compExprIsValidMacro( char * szText ) *pTmp = cSave; #endif } + *pbUseTextSubst |= bTextSubst; } return bMacroText; diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index 4d9ab771f2..6519f34497 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -309,11 +309,7 @@ HB_EXPR_PTR hb_compExprNewLong( LONG ); HB_EXPR_PTR hb_compExprNewString( char * ); HB_EXPR_PTR hb_compExprNewLogical( int ); HB_EXPR_PTR hb_compExprNewSelf( void ); -#if defined(SIMPLEX) -HB_EXPR_PTR hb_compExprNewCodeBlock( void ); -#else HB_EXPR_PTR hb_compExprNewCodeBlock( char *, BOOL, BOOL ); -#endif HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR ); HB_EXPR_PTR hb_compExprNewVar( char * ); HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR, HB_EXPR_PTR ); @@ -375,7 +371,7 @@ int hb_compExprType( HB_EXPR_PTR ); void hb_compExprFree( HB_EXPR_PTR, HB_MACRO_DECL ); void hb_compExprErrorType( HB_EXPR_PTR, HB_MACRO_DECL ); HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR, HB_MACRO_DECL ); -BOOL hb_compExprIsValidMacro( char * ); +BOOL hb_compExprIsValidMacro( char *, BOOL * ); void hb_compExprCBVarDel( HB_CBVAR_PTR ); HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR, HB_EXPR_PTR, HB_MACRO_DECL ); diff --git a/harbour/source/common/expropt1.c b/harbour/source/common/expropt1.c index 81dd6f89cd..6b5b84cbee 100644 --- a/harbour/source/common/expropt1.c +++ b/harbour/source/common/expropt1.c @@ -216,11 +216,7 @@ HB_EXPR_PTR hb_compExprNewLong( long lValue ) } -#if defined(SIMPLEX) -HB_EXPR_PTR hb_compExprNewCodeBlock( void ) -#else HB_EXPR_PTR hb_compExprNewCodeBlock( char *string, BOOL isMacro, BOOL lateEval ) -#endif { HB_EXPR_PTR pExpr; @@ -231,15 +227,9 @@ HB_EXPR_PTR hb_compExprNewCodeBlock( char *string, BOOL isMacro, BOOL lateEval ) pExpr->value.asCodeblock.pExprList = NULL; pExpr->value.asCodeblock.pLocals = NULL; /* this will hold local variables declarations */ pExpr->ValType = HB_EV_CODEBLOCK; -#if defined(SIMPLEX) - pExpr->value.asCodeblock.string = NULL; - pExpr->value.asCodeblock.isMacro = FALSE; - pExpr->value.asCodeblock.lateEval = FALSE; -#else pExpr->value.asCodeblock.string = string; pExpr->value.asCodeblock.isMacro = isMacro; pExpr->value.asCodeblock.lateEval = lateEval; -#endif return pExpr; } @@ -403,8 +393,10 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, unsigned char cMacroOp, * ? &var.ext // this is invalid */ char *szDupl; + BOOL bUseTextSubst; + szDupl = hb_strupr( hb_strdup( szName ) ); - if( ! hb_compExprIsValidMacro( szDupl ) ) + if( ! hb_compExprIsValidMacro( szDupl, &bUseTextSubst ) ) hb_compErrorMacro( szName ); hb_xfree( szDupl ); diff --git a/harbour/source/compiler/exproptb.c b/harbour/source/compiler/exproptb.c index 6d5f72d91f..0ba2d44ece 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) - * 10 - ignore this magic number - this is used to force compilation + * 11 - ignore this magic number - this is used to force compilation */ #include "hbexprb.c" diff --git a/harbour/source/compiler/exproptc.c b/harbour/source/compiler/exproptc.c index c133257707..cb7afb7036 100644 --- a/harbour/source/compiler/exproptc.c +++ b/harbour/source/compiler/exproptc.c @@ -5,6 +5,6 @@ /* hbexprc.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) - * 2 - ignore this magic number - this is used to force compilation + * 4 - ignore this magic number - this is used to force compilation */ #include "hbexprc.c" diff --git a/harbour/source/compiler/harbour.sly b/harbour/source/compiler/harbour.sly index 029a665b77..5198012692 100644 --- a/harbour/source/compiler/harbour.sly +++ b/harbour/source/compiler/harbour.sly @@ -1049,7 +1049,7 @@ Get : _Get_ GetVar ',' pSetGetBlock = hb_compExprNewCodeBlock(NULL,0,0); pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' ); - hb_compExprAddListExpr( pSetGetBlock, pIIF ); + hb_compExprAddCodeblockExpr( pSetGetBlock, pIIF ); pGetArgList = hb_compExprNewArgList( pSetGetBlock ); } @@ -1142,9 +1142,9 @@ GetA : _Get_ GetVarArray { pGetArgList = hb_compExprNewArgList( $2 ); bTra GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } ; -GetVarArray : Variable ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } - | ObjectData ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } - | AliasVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } +GetVarArray : Variable ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } + | ObjectData ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } + | AliasVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } | MacroVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprNewNil(); diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 023193c646..d6d0a13bdd 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -2754,6 +2754,7 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt lenitem = (ifou)? ifou-1:lenreal; if( *expreal != '\0' ) { +#if defined(SIMPLEX) /* Ron Pinkas added 2000-01-21 */ if( *expreal == '&' ) { @@ -2769,6 +2770,7 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt hb_pp_Stuff( expreal + 1, ptro, lenitem, 0, lenres ); } else /* END Ron Pinkas 2000-01-21 */ +#endif { i = (ifou)? 3:2; pp_rQuotes( expreal, sQuotes ); @@ -2785,6 +2787,14 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt } else { +#if defined(SIMPLEX) + /* rglab 2003-10-19 + * SIMPLEX specific solution guarded with #ifdef + * because this creates incorrect syntax: + * @ 0,0 GET &var.1 => _GET_( &var.1, var.1, ) + * in FLEX we need a correct Clipper syntax: + * @ 0,0 GET &var.1 => _GET_( &var.1, "&var.1", ) + */ /* Ron Pinkas added 2000-01-21 */ if( *expreal == '&' ) { @@ -2797,6 +2807,7 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt hb_pp_Stuff( expreal + 1, ptro, lenreal - 1, 4, lenres ); } else /* END Ron Pinkas 2000-01-21 */ +#endif { pp_rQuotes( expreal, sQuotes ); hb_pp_Stuff( sQuotes, ptro, 2, 4, lenres ); @@ -2817,6 +2828,7 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt lenitem = (ifou)? ifou-1:lenreal; if( *expreal != '\0' ) { +#if defined(SIMPLEX) if( !lenitem || *expreal == '(' || (*expreal=='&' && lenreal>1) || ( *expreal=='\"' && *(expreal+lenitem-1)=='\"' ) || ( *expreal == '\'' && *(expreal+lenitem-1)=='\'' ) ) @@ -2832,6 +2844,14 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt } hb_pp_Stuff( ( *expreal=='&' ) ? expreal + 1 : expreal, ptro, lenitem, 0, lenres ); +#else + if( !lenitem || *expreal == '(' || + ( *expreal=='\"' && *(expreal+lenitem-1)=='\"' ) || + ( *expreal == '\'' && *(expreal+lenitem-1)=='\'' ) ) + { + if( ifou ) lenitem++; + hb_pp_Stuff( expreal, ptro, lenitem, 0, lenres ); +#endif } else { @@ -2850,6 +2870,7 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt } while( ifou > 0 ); } +#if defined(SIMPLEX) else if( !lenreal || *expreal == '(' || (*expreal=='&' && lenreal>1) || ( *expreal == '\"' && *( expreal + lenreal - 1 ) == '\"' ) || ( *expreal == '\'' && *( expreal + lenreal - 1 ) == '\'' ) ) @@ -2866,6 +2887,14 @@ static int ReplacePattern( char patttype, char * expreal, int lenreal, char * pt hb_pp_Stuff( ( *expreal == '&' ) ? expreal + 1 : expreal, ptro, ( *expreal == '&' ) ? lenreal - 1 : lenreal, 4, lenres ); } +#else + else if( !lenreal || *expreal == '(' || + ( *expreal == '\"' && *( expreal + lenreal - 1 ) == '\"' ) || + ( *expreal == '\'' && *( expreal + lenreal - 1 ) == '\'' ) ) + { + hb_pp_Stuff( expreal, ptro, lenreal, 4, lenres ); + } +#endif else { pp_rQuotes( expreal, sQuotes ); diff --git a/harbour/tests/testget.prg b/harbour/tests/testget.prg index 39384dd756..0c1b0f18d3 100644 --- a/harbour/tests/testget.prg +++ b/harbour/tests/testget.prg @@ -1,7 +1,7 @@ Procedure Main() LOCAL GetList := {}, cVar := "Hello" - MEMVAR aVar, nIndex, cMacro + MEMVAR aVar, nIndex, cMacro, cEarly, cEarly2, cLate PRIVATE aVar := { "World", "Again" }, nIndex := 1, cMacro := "cEarly", cEarly := {"Early"}, cLate := "Late!", cEarly2 := {"Early2"} CLS