diff --git a/ChangeLog.txt b/ChangeLog.txt index 87855ce57f..b5265a7247 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,26 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2016-01-28 15:00 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/hbexprb.c + * src/common/expropt1.c + ! fixed typo in macro alias push/pop operation + * disable multivalue macro expansion for macro expressions enclosed in + parenthesis, i.e.: + s := "1,2,3" + QOut( &s ) // 1, 2, 3 + QOut( &(s) ) // 1, 2, 3 + QOut( (&s) ) // 3 + + * include/hbexprop.h + * src/common/expropt1.c + * src/common/expropt2.c + * src/vm/hvm.c + * return last array item when hb_ArrayToParams() is used in + parenthesis, i.e.: + QOut( hb_ArrayToParams( { 1, 2, 3 } ) ) // 1, 2, 3 + QOut( ( hb_ArrayToParams( { 1, 2, 3 } ) ) ) // 3 + 2016-01-28 13:20 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/hbsocket.c * enabled new socket functions in MSC 18.0 (before was MSC 19.0) diff --git a/include/hbexprb.c b/include/hbexprb.c index f8d72ef088..9105684ffa 100644 --- a/include/hbexprb.c +++ b/include/hbexprb.c @@ -1039,9 +1039,6 @@ static HB_EXPR_FUNC( hb_compExprUseList ) case HB_EA_REDUCE: pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); - if( HB_SUPPORT_HARBOUR ) - pSelf = hb_compExprListStrip( pSelf, HB_COMP_PARAM ); - if( HB_SUPPORT_XBASE && pSelf->ExprType == HB_ET_LIST ) { if( hb_compExprListLen( pSelf ) == 1 ) @@ -1056,6 +1053,9 @@ static HB_EXPR_FUNC( hb_compExprUseList ) } } } + if( HB_SUPPORT_HARBOUR ) + pSelf = hb_compExprListStrip( pSelf, HB_COMP_PARAM ); + break; case HB_EA_ARRAY_AT: @@ -1406,9 +1406,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { if( HB_SUPPORT_XBASE ) { - if( pSelf->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && - pSelf->value.asMacro.SubType != HB_ET_MACRO_REFER && - pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) + if( pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && + pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_REFER && + pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_ALIASED && + ( pSelf->value.asList.pIndex->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 ) { pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST; fMacroIndex = HB_TRUE; @@ -1486,9 +1487,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { if( HB_SUPPORT_XBASE ) { - if( pSelf->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && - pSelf->value.asMacro.SubType != HB_ET_MACRO_REFER && - pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) + if( pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && + pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_REFER && + pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_ALIASED && + ( pSelf->value.asList.pIndex->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 ) { pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST; fMacroIndex = HB_TRUE; diff --git a/include/hbexprop.h b/include/hbexprop.h index 7e441a8a01..ca5c644249 100644 --- a/include/hbexprop.h +++ b/include/hbexprop.h @@ -154,6 +154,7 @@ extern HB_EXPORT_INT HB_SIZE hb_compExprAsStringLen( PHB_EXPR ); extern HB_EXPORT_INT HB_MAXINT hb_compExprAsLongNum( PHB_EXPR ); extern HB_EXPORT_INT const char * hb_compExprAsString( PHB_EXPR ); extern HB_EXPORT_INT const char * hb_compExprAsSymbol( PHB_EXPR ); +extern HB_EXPORT_INT HB_BOOL hb_compExprIsArrayToParams( PHB_EXPR ); extern HB_EXPORT_INT PHB_EXPR hb_compExprListStrip( PHB_EXPR, HB_COMP_DECL ); diff --git a/src/common/expropt1.c b/src/common/expropt1.c index 31ba1d1d63..aaf28ab3a0 100644 --- a/src/common/expropt1.c +++ b/src/common/expropt1.c @@ -1345,6 +1345,15 @@ HB_ULONG hb_compExprParamListLen( PHB_EXPR pExpr ) return nLen; } +/* Check if expression is hb_ArrayToParams( aParams ) function call + */ +HB_BOOL hb_compExprIsArrayToParams( PHB_EXPR pExpr ) +{ + return pExpr->ExprType == HB_ET_FUNCALL && + pExpr->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME && + pExpr->value.asFunCall.pFunName->value.asSymbol.funcid == HB_F_ARRAYTOPARAMS; +} + HB_SIZE hb_compExprParamListCheck( HB_COMP_DECL, PHB_EXPR pExpr ) { HB_SIZE nLen = 0, nItems = 0; @@ -1359,13 +1368,11 @@ HB_SIZE hb_compExprParamListCheck( HB_COMP_DECL, PHB_EXPR pExpr ) if( ( pElem->ExprType == HB_ET_MACRO && HB_SUPPORT_XBASE && pElem->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && pElem->value.asMacro.SubType != HB_ET_MACRO_REFER && - pElem->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) || + pElem->value.asMacro.SubType != HB_ET_MACRO_ALIASED && + ( pElem->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 ) || ( pElem->ExprType == HB_ET_ARGLIST && pElem->value.asList.reference ) || - ( pElem->ExprType == HB_ET_FUNCALL && - pElem->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME && - pElem->value.asFunCall.pFunName->value.asSymbol.funcid == - HB_F_ARRAYTOPARAMS ) ) + hb_compExprIsArrayToParams( pElem ) ) { /* ¯o was passed or optional parameters list passed, f.e.: f(a,b,...) diff --git a/src/common/expropt2.c b/src/common/expropt2.c index f6cb017a07..06841768c5 100644 --- a/src/common/expropt2.c +++ b/src/common/expropt2.c @@ -1960,7 +1960,8 @@ PHB_EXPR hb_compExprListStrip( PHB_EXPR pSelf, HB_COMP_DECL ) { while( pSelf->ExprType == HB_ET_LIST && hb_compExprListLen( pSelf ) == 1 && - pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE ) + pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE && + ! hb_compExprIsArrayToParams( pSelf->value.asList.pExprList ) ) { /* replace the list with a simple expression * ( EXPR ) -> EXPR diff --git a/src/vm/hvm.c b/src/vm/hvm.c index 3e7ceba2f3..d53895e7d2 100644 --- a/src/vm/hvm.c +++ b/src/vm/hvm.c @@ -12443,7 +12443,10 @@ HB_FUNC( HB_ARRAYTOPARAMS ) { HB_STACK_TLS_PRELOAD - hb_retni( 0 ); + PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); + + if( pArray ) + hb_arrayLast( pArray, hb_stackReturnItem() ); } HB_FUNC( ERRORLEVEL )