From 403fd7f29e03dccf2db09edb0ee0c92a21a13d3a Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sat, 18 Nov 2006 14:37:18 +0000 Subject: [PATCH] 2006-11-18 15:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexpra.c * harbour/include/hbexprb.c * harbour/include/hbexprc.c * harbour/source/macro/macro.y * harbour/source/macro/macrolex.c * do not allocate separate memory in macro compiler for terminal symbols which needs string representation - it fixes some set of memory leaks and increase a little bit macro compilation ! fixed accessing freed memory in: private cMacro := "cEarly", cEarly := {"Early"} @ 12,10 GET &cMacro[1] ! fixed GPF in: p:=@left() and similar expressions * harbour/source/common/expropt2.c % minor modification * harbour/source/compiler/harbour.c ! fixed HB_TRACE message --- harbour/ChangeLog | 22 ++++++++ harbour/include/hbexpra.c | 85 +++++++++---------------------- harbour/include/hbexprb.c | 46 ++++------------- harbour/include/hbexprc.c | 51 ++++++++----------- harbour/source/common/expropt2.c | 5 +- harbour/source/compiler/harbour.c | 2 +- harbour/source/macro/macro.y | 13 ++--- harbour/source/macro/macrolex.c | 22 +------- 8 files changed, 83 insertions(+), 163 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c27e5fe527..f823b1f403 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,28 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + to lower cases will be better. Please think about it. + +2006-11-20 15:20 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/macro/macrolex.c + ! fixed bad typo in NIL, IIF, .AND., .NOT. tokens parsing + +2006-11-18 15:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbexpra.c + * harbour/include/hbexprb.c + * harbour/include/hbexprc.c + * harbour/source/macro/macro.y + * harbour/source/macro/macrolex.c + * do not allocate separate memory in macro compiler for terminal + symbols which needs string representation - it fixes some set + of memory leaks and increase a little bit macro compilation + ! fixed accessing freed memory in: + private cMacro := "cEarly", cEarly := {"Early"} + @ 12,10 GET &cMacro[1] + ! fixed GPF in: + p:=@left() + and similar expressions + * harbour/source/common/expropt2.c % minor modification diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index 2beed743ea..dd751b9cff 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -377,27 +377,20 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) #ifndef HB_MACRO_SUPPORT if( ! hb_compFunCallCheck( pName->value.asSymbol, iCount ) ) { - hb_compExprDelete( pName ); - if( pParms ) - hb_compExprDelete( pParms ); - return NULL; + /* skip any farther modifications which can depend on valid number + of parameters */ + ; } + else #endif - /* TODO: EMPTY() (not done by Clipper) */ - if( ( strcmp( "EVAL", pName->value.asSymbol ) == 0 ) && iCount ) { HB_EXPR_PTR pEval; /* Optimize Eval( bBlock, [ArgList] ) to: bBlock:Eval( [ArgList] ) */ pEval = hb_compExprNewMethodCall( -#ifndef HB_MACRO_SUPPORT - hb_compExprNewSend( pParms->value.asList.pExprList, hb_compIdentifierNew( "EVAL", TRUE ), NULL ), -#else - hb_compExprNewSend( pParms->value.asList.pExprList, hb_strdup("EVAL"), NULL ), -#endif + hb_compExprNewSend( pParms->value.asList.pExprList, "EVAL", NULL ), hb_compExprNewArgList( pParms->value.asList.pExprList->pNext ) ); - pParms->value.asList.pExprList = NULL; HB_EXPR_PCODE1( hb_compExprDelete, pParms ); HB_EXPR_PCODE1( hb_compExprDelete, pName ); @@ -421,17 +414,12 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) HB_EXPR_PTR pIndex, pVar; HB_EXPR_PTR pBase; -#ifdef HB_MACRO_SUPPORT - HB_XFREE( pName->value.asSymbol ); - pName->value.asSymbol = hb_strdup( "__GETA" ); -#else - pName->value.asSymbol = hb_compIdentifierNew( "__GETA", TRUE ); -#endif + pName->value.asSymbol = "__GETA"; /* NOTE: a[ i, j ] is stored as: (pExprList)->(pIndex) * ((a->[ i ])->[ j ]) */ pVar = HB_EXPR_USE( pArg->value.asList.pExprList, HB_EA_REDUCE ); - pBase = pVar; + pBase = pVar->ExprType == HB_ET_ARRAYAT ? pVar : NULL; pIndex = HB_EXPR_USE( pArg->value.asList.pIndex, HB_EA_REDUCE ); pIndex->pNext = NULL; while( pVar->ExprType == HB_ET_ARRAYAT ) @@ -469,7 +457,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) hb_compExprClear( pArg ); /* Create an array with index elements */ - pIndex = HB_EXPR_PCODE1(hb_compExprNewArray, hb_compExprNewList( pIndex ) ); + pIndex = HB_EXPR_PCODE1( hb_compExprNewArray, hb_compExprNewList( pIndex ) ); /* The array with index elements have to be the sixth argument * of __GETA() call */ @@ -508,12 +496,15 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) } } /* clear expressions no longer used */ - while( pBase->ExprType == HB_ET_ARRAYAT ) + if( pBase ) { - pVar = pBase->value.asList.pExprList; - pBase->value.asList.pExprList = NULL; - hb_compExprClear( pBase ); - pBase = pVar; + while( pBase->ExprType == HB_ET_ARRAYAT ) + { + pVar = pBase->value.asList.pExprList; + pBase->value.asList.pExprList = NULL; + hb_compExprClear( pBase ); + pBase = pVar; + } } } else if( pArg->ExprType == HB_ET_MACRO ) @@ -521,12 +512,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) /* @ 0,0 GET &var => __GET( NIL, var,... ) * @ 0,0 GET var&var => __GET( NIL, "var&var",... ) */ -#ifdef HB_MACRO_SUPPORT - HB_XFREE( pName->value.asSymbol ); - pName->value.asSymbol = hb_strdup( "__GET" ); -#else - pName->value.asSymbol = hb_compIdentifierNew( "__GET", TRUE ); -#endif + pName->value.asSymbol = "__GET"; if( pArg->value.asMacro.pExprList == NULL ) { /* Simple macro expansion (not a parenthesized expressions) @@ -546,11 +532,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) /* simple &variable - replace the second argument with * a variable name */ -#ifdef HB_MACRO_SUPPORT - char *szName = hb_strdup( pFirst->value.asMacro.szMacro ); -#else - char *szName = hb_compIdentifierNew( pFirst->value.asMacro.szMacro, FALSE ); -#endif + char *szName = pFirst->value.asMacro.szMacro; if( pFirst->pNext ) HB_EXPR_PCODE1( hb_compExprDelete, pFirst->pNext ); /* delete a second argument */ pArg->pNext = hb_compExprNewVar( szName ); @@ -565,11 +547,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) if( pArg->pNext == NULL ) { /* no second argument */ -#ifdef HB_MACRO_SUPPORT - char *szText = hb_strdup( pFirst->value.asMacro.szMacro ); -#else - char *szText = hb_compIdentifierNew( pFirst->value.asMacro.szMacro, FALSE ); -#endif + char *szText = pFirst->value.asMacro.szMacro; pArg->pNext = hb_compExprNewString( szText, strlen(szText) ); pArg->pNext->pNext = pNext; } @@ -586,12 +564,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms ) else { HB_EXPR_PTR pNext; -#ifdef HB_MACRO_SUPPORT - HB_XFREE( pName->value.asSymbol ); - pName->value.asSymbol = hb_strdup( "__GET" ); -#else - pName->value.asSymbol = hb_compIdentifierNew( "__GET", TRUE ); -#endif + pName->value.asSymbol = "__GET"; /* store second and a rest of arguments */ pNext = pArg->pNext; pArg->pNext = NULL; @@ -714,11 +687,7 @@ HB_EXPR_PTR hb_compExprNewString( char *szValue, ULONG ulLen ) pExpr =hb_compExprNew( HB_ET_STRING ); pExpr->value.asString.string = szValue; -#ifdef HB_MACRO_SUPPORT - pExpr->value.asString.dealloc = TRUE; -#else pExpr->value.asString.dealloc = FALSE; -#endif pExpr->ulLength = ulLen; pExpr->ValType = HB_EV_STRING; @@ -1034,9 +1003,6 @@ void hb_compExprCBVarDel( HB_CBVAR_PTR pVars ) { pDel = pVars; pVars = pVars->pNext; -#ifdef HB_MACRO_SUPPORT - HB_XFREE( pDel->szName ); -#endif HB_XFREE( pDel ); } } @@ -1066,11 +1032,10 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr ) * NOTE: this is not a valid variable name so there will be no collisions */ /* create var==NIL */ + pIIF =hb_compExprNewVar( "~1" ); #ifdef HB_MACRO_SUPPORT - pIIF =hb_compExprNewVar( hb_strdup("~1") ); pIIF = hb_compExprSetOperand( hb_compExprNewEQ( pIIF ), hb_compExprNewNil(), HB_MACRO_PARAM ); #else - pIIF =hb_compExprNewVar( hb_compIdentifierNew("~1",TRUE) ); pIIF = hb_compExprSetOperand( hb_compExprNewEQ( pIIF ), hb_compExprNewNil() ); #endif /* create ( var==NIL, */ @@ -1078,11 +1043,7 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr ) /* create ( var==NIL, , */ pIIF = hb_compExprAddListExpr( pIIF, pExpr ); /* create var */ -#ifdef HB_MACRO_SUPPORT - pSet =hb_compExprNewVar( hb_strdup("~1") ); -#else - pSet =hb_compExprNewVar( hb_compIdentifierNew("~1",TRUE) ); -#endif + pSet =hb_compExprNewVar( "~1" ); /* create :=var */ pSet = hb_compExprAssign( hb_compExprClone( pExpr ), pSet ); /* create ( var==nil, , :=var ) */ @@ -1092,7 +1053,7 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr ) /* create a codeblock */ #ifdef HB_MACRO_SUPPORT - return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( hb_compExprNewCodeBlock(NULL,0,0), hb_strdup("~1"), HB_MACRO_PARAM ), pIIF ); + return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( hb_compExprNewCodeBlock(NULL,0,0), "~1", HB_MACRO_PARAM ), pIIF ); #else return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( hb_compExprNewCodeBlock(NULL,0,0), "~1", ' ' ), pIIF ); #endif diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 64019bd9c4..49f2d60fef 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -859,10 +859,6 @@ static HB_EXPR_FUNC( hb_compExprUseVarRef ) case HB_EA_STATEMENT: hb_compWarnMeaningless( pSelf ); case HB_EA_DELETE: - /* NOTE: variable name should be released if macro compilation */ -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asSymbol ); -#endif break; } return pSelf; @@ -900,10 +896,6 @@ static HB_EXPR_FUNC( hb_compExprUseFunRef ) case HB_EA_STATEMENT: hb_compWarnMeaningless( pSelf ); case HB_EA_DELETE: - /* NOTE: function name should be released if macro compilation */ -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asSymbol ); -#endif break; } return pSelf; @@ -1622,13 +1614,6 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) case HB_EA_DELETE: if( pSelf->value.asMacro.pExprList ) HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMacro.pExprList ); - -#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; @@ -2056,9 +2041,6 @@ static HB_EXPR_FUNC( hb_compExprUseAlias ) break; case HB_EA_DELETE: -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asSymbol ); -#endif break; } return pSelf; @@ -2082,9 +2064,6 @@ static HB_EXPR_FUNC( hb_compExprUseFunName ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: case HB_EA_DELETE: -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asSymbol ); -#endif break; } return pSelf; @@ -2176,10 +2155,6 @@ static HB_EXPR_FUNC( hb_compExprUseVariable ) break; case HB_EA_DELETE: - /* NOTE: variable name should be released if macro compilation */ -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asSymbol ); -#endif break; } return pSelf; @@ -2351,9 +2326,6 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) { HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMessage.pMessage ); } -#if defined( HB_MACRO_SUPPORT ) - HB_XFREE( pSelf->value.asMessage.szMessage ); -#endif } break; } @@ -3150,7 +3122,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) break; case HB_EA_STATEMENT: - hb_compErrorSyntax( pSelf ); + hb_compErrorSyntax( pSelf ); break; case HB_EA_DELETE: @@ -3200,8 +3172,8 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) } else { - HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } break; @@ -3817,9 +3789,9 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) case HB_EA_PUSH_POP: if( HB_SUPPORT_HARBOUR ) { - /* NOTE: This will not generate a runtime error if incompatible - * data type is used - */ + /* NOTE: This will not generate a runtime error if incompatible + * data type is used + */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_POP ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_POP ); } @@ -3886,9 +3858,9 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) case HB_EA_PUSH_POP: if( HB_SUPPORT_HARBOUR ) { - /* NOTE: This will not generate a runtime error if incompatible - * data type is used - */ + /* NOTE: This will not generate a runtime error if incompatible + * data type is used + */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_POP ); } else diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index 9bed0836b1..44a2ee99fc 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -787,42 +787,31 @@ BOOL hb_compExprIsValidMacro( char * szText, BOOL *pbUseTextSubst, HB_MACRO_DECL * pExpr is the first expression on the list */ HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_MACRO_DECL ) -#if defined( HB_MACRO_SUPPORT ) { - pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 ); - pLeft->value.asString.dealloc = TRUE; - memcpy( pLeft->value.asString.string + pLeft->ulLength, - pRight->value.asString.string, pRight->ulLength ); - pLeft->ulLength += pRight->ulLength; - pLeft->value.asString.string[ pLeft->ulLength ] = '\0'; - hb_compExprFree( pRight, HB_MACRO_PARAM ); - - HB_SYMBOL_UNUSED( HB_MACRO_VARNAME ); /* to suppress BCC warning */ - return pLeft; -} -#else -{ - /* NOTE: compiler uses the hash table for storing identifiers and literals - * Strings passed for reduction can be referenced by other expressions - * then we cannot resize them or deallocate - */ - char *szString; - - szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 ); - memcpy( szString, pLeft->value.asString.string, pLeft->ulLength ); - memcpy( szString + pLeft->ulLength, pRight->value.asString.string, pRight->ulLength ); - pLeft->ulLength += pRight->ulLength; - szString[ pLeft->ulLength ] = '\0'; if( pLeft->value.asString.dealloc ) - hb_xfree( pLeft->value.asString.string ); - pLeft->value.asString.string = szString; - pLeft->value.asString.dealloc = TRUE; - hb_compExprFree( pRight, HB_MACRO_PARAM ); - + { + pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 ); + memcpy( pLeft->value.asString.string + pLeft->ulLength, + pRight->value.asString.string, pRight->ulLength ); + pLeft->ulLength += pRight->ulLength; + pLeft->value.asString.string[ pLeft->ulLength ] = '\0'; + hb_compExprFree( pRight, HB_MACRO_PARAM ); + } + else + { + char *szString; + szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 ); + memcpy( szString, pLeft->value.asString.string, pLeft->ulLength ); + memcpy( szString + pLeft->ulLength, pRight->value.asString.string, pRight->ulLength ); + pLeft->ulLength += pRight->ulLength; + szString[ pLeft->ulLength ] = '\0'; + pLeft->value.asString.string = szString; + pLeft->value.asString.dealloc = TRUE; + hb_compExprFree( pRight, HB_MACRO_PARAM ); + } HB_SYMBOL_UNUSED( HB_MACRO_VARNAME ); /* to suppress BCC warning */ return pLeft; } -#endif #ifdef __WATCOMC__ /* enable warnings for unreferenced symbols */ diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 7a2e348bc0..94cb508239 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1214,9 +1214,8 @@ BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) if( bVal == 0 && pArg->value.asNum.lVal != 0 ) { - pExpr->value.asString.string = ( char * ) hb_xgrab( 1 ); - pExpr->value.asString.string[ 0 ] = '\0'; - pExpr->value.asString.dealloc = TRUE; + pExpr->value.asString.string = ""; + pExpr->value.asString.dealloc = FALSE; pExpr->ulLength = 0; } else diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index f008972dc2..e33db1b0eb 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -4655,7 +4655,7 @@ int hb_compCompile( char * szPrg, BOOL bSingleFile ) { int iStatus = EXIT_SUCCESS; - HB_TRACE(HB_TR_DEBUG, ("hb_pp_compCompile(%s,%i)", szPrg, argc)); + HB_TRACE(HB_TR_DEBUG, ("hb_pp_compCompile(%s,%d)", szPrg, bSingleFile)); hb_comp_pMainFileName = hb_fsFNameSplit( szPrg ); hb_comp_pFileName = hb_comp_pMainFileName; diff --git a/harbour/source/macro/macro.y b/harbour/source/macro/macro.y index fe62a1fc5b..0381173fae 100644 --- a/harbour/source/macro/macro.y +++ b/harbour/source/macro/macro.y @@ -330,7 +330,6 @@ MacroVar : MACROVAR { $$ = hb_compExprNewMacro( NULL, '&', $1 ); if( hb_macroIsIdent( szVarName ) ) { $$ = hb_compExprNewVar( szVarName ); - hb_xfree( $1 ); HB_MACRO_CHECK( $$ ); } else @@ -338,8 +337,6 @@ MacroVar : MACROVAR { $$ = hb_compExprNewMacro( NULL, '&', $1 ); /* invalid variable name */ HB_TRACE(HB_TR_DEBUG, ("macro -> invalid variable name: %s", $1)); - - hb_xfree( $1 ); YYABORT; } } @@ -360,7 +357,7 @@ MacroExprAlias : MacroExpr ALIASOP { $$ = $1; } */ /* special case: _FIELD-> and FIELD-> can be nested */ -FieldAlias : FIELD ALIASOP { $$ = hb_compExprNewAlias( hb_strdup( "FIELD" ) ); } +FieldAlias : FIELD ALIASOP { $$ = hb_compExprNewAlias( "FIELD" ); } | FIELD ALIASOP FieldAlias { $$ = $3; } ; @@ -888,17 +885,17 @@ int hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) return NIL; hb_pp_tokenUpper( pToken ); - yylval_ptr->string = hb_strdup( pToken->value ); + yylval_ptr->string = pToken->value; return IDENTIFIER; case HB_PP_TOKEN_MACROVAR: hb_pp_tokenUpper( pToken ); - yylval_ptr->string = hb_strdup( pToken->value ); + yylval_ptr->string = pToken->value; return MACROVAR; case HB_PP_TOKEN_MACROTEXT: hb_pp_tokenUpper( pToken ); - yylval_ptr->string = hb_strdup( pToken->value ); + yylval_ptr->string = pToken->value; return MACROTEXT; case HB_PP_TOKEN_NUMBER: @@ -933,7 +930,7 @@ int hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) return NUM_DATE; case HB_PP_TOKEN_STRING: - yylval_ptr->string = hb_strdup( pToken->value ); + yylval_ptr->string = pToken->value; return LITERAL; case HB_PP_TOKEN_LOGICAL: diff --git a/harbour/source/macro/macrolex.c b/harbour/source/macro/macrolex.c index 538872d9db..2f6f2fb014 100644 --- a/harbour/source/macro/macrolex.c +++ b/harbour/source/macro/macrolex.c @@ -151,7 +151,7 @@ static int hb_lexNumConv( YYSTYPE *yylval_ptr, PHB_MACRO_LEX pLex, ULONG ulLen ) } } -static int _hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) +int hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) { PHB_MACRO_LEX pLex = ( PHB_MACRO_LEX ) pMacro->pLex; @@ -640,23 +640,3 @@ static int _hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) return 0; } - -/* - this function is temporary hack which makes this code compatible - with the one generated by FLEX. In fact we do not need to allocate - memory for terminal symbols which need string representation because - memory pointed by yylval_ptr->string is never destroyed until - hb_macroLexDelete() is executed. When we update include/hbexpr*.c - files to not execute hb_xfree() then we can safly remove this function - and change the type and name of function above from: - static _int hb_complex(...) to: int hb_complex(...) - */ -int hb_complex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) -{ - int i = _hb_complex( yylval_ptr, pMacro ); - - if( i == IDENTIFIER || i == MACROVAR || i == MACROTEXT || i == LITERAL ) - yylval_ptr->string = hb_strdup( yylval_ptr->string ); - - return i; -}