diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 92dfbc560d..1ead860627 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-06-03 23:03 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/include/hbexprop.h + * harbour/include/hbexprb.c + * harbour/source/common/expropt2.c + * added UPPER("") optimisation. The side effect of this modification + is that Harbour becomes Clipper bug compatible in calculation of + AT(UPPER(""), "test"). Though this optimisation does not introduce + any buggy behaviour itself. + 2007-06-02 12:30 UTC+0200 Enrico Maria Giordano (e.m.giordano@emagsoftware.it) * harbour/contrib/hbzlib * replaced with the one borrowed from xharbour, source modifications by Przemek diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 0014a029e1..a2fc70f664 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1581,6 +1581,10 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( HB_SUPPORT_HARBOUR ) hb_compExprReduceSTOD( pSelf, usCount, HB_COMP_PARAM ); } + else if( ( strcmp( "UPPER", pName->value.asSymbol ) == 0 ) && usCount ) + { + hb_compExprReduceUPPER( pSelf, HB_COMP_PARAM ); + } } } break; diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index 1398ed3c40..b7e891581c 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -195,6 +195,7 @@ extern BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ); +extern BOOL hb_compExprReduceUPPER( HB_EXPR_PTR, HB_COMP_DECL ); HB_EXTERN_END diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 727adc5065..0615e0b442 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1436,3 +1436,27 @@ BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) return FALSE; } + +BOOL hb_compExprReduceUPPER( HB_EXPR_PTR pSelf, HB_COMP_DECL ) +{ + HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; + HB_EXPR_PTR pArg = pParms->value.asList.pExprList; + + if( pArg->ExprType == HB_ET_STRING && pArg->ulLength == 0 ) + { + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING ); + + pExpr->ValType = HB_EV_STRING; + pExpr->value.asString.string = ""; + pExpr->value.asString.dealloc = FALSE; + pExpr->ulLength = 0; + + HB_COMP_EXPR_FREE( pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); + memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); + HB_COMP_EXPR_CLEAR( pExpr ); + return TRUE; + } + return FALSE; +} +