From 54a9d778a0e46324ac2a98035cc5c204bf8e7e7b Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sun, 25 Feb 2007 18:26:12 +0000 Subject: [PATCH] 2007-02-25 19:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/expropt2.c % strip nested parenthesis in expressions like: ((())) --- harbour/ChangeLog | 4 ++++ harbour/source/common/expropt2.c | 35 +++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 132c7bbe4d..0a593c5509 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,10 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-02-25 19:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/expropt2.c + % strip nested parenthesis in expressions like: ((())) + 2007-02-25 17:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbstdgen.ch * added #undef HB_COMPAT_XHB diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index f866ca38a5..a013e4419e 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1176,7 +1176,16 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { HB_EXPR_PTR pExpr; - pExpr = pSelf->value.asList.pExprList; /* get conditional expression */ + /* get conditional expression */ + pExpr = pSelf->value.asList.pExprList; + if( pExpr->ExprType == HB_ET_LIST ) + { + HB_EXPR_PTR pNext = pExpr->pNext; + pExpr = hb_compExprListStrip( pExpr, HB_COMP_PARAM ); + pExpr->pNext = pNext; + pSelf->value.asList.pExprList = pExpr; + } + if( pExpr->ExprType == HB_ET_LOGICAL ) { /* the condition was reduced to a logical value: .T. or .F. @@ -1255,22 +1264,20 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) */ HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { - if( pSelf->ExprType == HB_ET_LIST ) + while( pSelf->ExprType == HB_ET_LIST && + pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE && + hb_compExprListLen( pSelf ) == 1 ) { - ULONG ulCount = hb_compExprListLen( pSelf ); + /* replace the list with a simple expression + * ( EXPR ) -> EXPR + */ + HB_EXPR_PTR pExpr = pSelf; - if( ulCount == 1 && pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE ) - { - /* replace the list with a simple expression - * ( EXPR ) -> EXPR - */ - HB_EXPR_PTR pExpr = pSelf; - - pSelf = pSelf->value.asList.pExprList; - pExpr->value.asList.pExprList = NULL; - hb_compExprFree( pExpr, HB_COMP_PARAM ); - } + pSelf = pSelf->value.asList.pExprList; + pExpr->value.asList.pExprList = NULL; + hb_compExprFree( pExpr, HB_COMP_PARAM ); } + return pSelf; }