From 6b916eba63ce698deca51c5dbb1d899d83514183 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 11 May 2009 12:35:20 +0000 Subject: [PATCH] 2009-05-11 14:43 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexprop.h * harbour/include/hbexprb.c * harbour/source/common/expropt2.c + added compile time optimization for hb_stot() function --- harbour/ChangeLog | 6 ++ harbour/include/hbexprb.c | 4 ++ harbour/include/hbexprop.h | 1 + harbour/source/common/expropt2.c | 96 +++++++++++++++++++++----------- 4 files changed, 73 insertions(+), 34 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 04ae4545a4..3ae31a7eb9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-11 14:43 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbexprop.h + * harbour/include/hbexprb.c + * harbour/source/common/expropt2.c + + added compile time optimization for hb_stot() function + 2009-05-11 14:00 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * INSTALL + Added TROUBLESHOOTING section. Contains only obvious, diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 237624a4e0..d694209727 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1708,6 +1708,10 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( usCount < 2 && HB_SUPPORT_HARBOUR ) hb_compExprReduceSTOD( pSelf, usCount, HB_COMP_PARAM ); } + else if( strcmp( "HB_STOT", pName->value.asSymbol ) == 0 ) + { + hb_compExprReduceSTOT( pSelf, usCount, HB_COMP_PARAM ); + } else if( strcmp( "DTOS", pName->value.asSymbol ) == 0 ) { if( usCount == 1 ) diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index 00c6459581..6e398780ed 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -201,6 +201,7 @@ extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceINT( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceEMPTY( HB_EXPR_PTR, HB_COMP_DECL ); +extern BOOL hb_compExprReduceSTOT( HB_EXPR_PTR, USHORT usCount, HB_COMP_DECL ); extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR, USHORT usCount, HB_COMP_DECL ); extern BOOL hb_compExprReduceDTOS( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceCTOD( HB_EXPR_PTR, HB_COMP_DECL ); diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 078bef86dd..11b6c482d4 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -2152,6 +2152,68 @@ BOOL hb_compExprReduceINT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) return FALSE; } +BOOL hb_compExprReduceSTOT( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) +{ + HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; + HB_EXPR_PTR pArg = pParms ? pParms->value.asList.pExprList : NULL; + HB_EXPR_PTR pExpr = NULL; + + if( usCount == 0 ) + { + pExpr = hb_compExprNewTimeStamp( 0, 0, HB_COMP_PARAM ); + } + else if( pArg && pArg->ExprType == HB_ET_STRING ) + { + long lDate, lTime; + + hb_timeStampStrRawGet( pArg->value.asString.string, &lDate, &lTime ); + pExpr = hb_compExprNewTimeStamp( lDate, lTime, HB_COMP_PARAM ); + } + + if( pExpr ) + { + if( pSelf->value.asFunCall.pParms ) + 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; +} + +BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) +{ + HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; + HB_EXPR_PTR pArg = pParms ? pParms->value.asList.pExprList : NULL; + HB_EXPR_PTR pExpr = NULL; + + if( usCount == 0 ) + { + pExpr = hb_compExprNewDate( 0, HB_COMP_PARAM ); + } + else if( pArg && pArg->ExprType == HB_ET_STRING && + ( pArg->ulLength >= 7 || pArg->ulLength == 0 ) ) + { + pExpr = hb_compExprNewDate( pArg->ulLength == 0 ? 0 : + hb_dateEncStr( pArg->value.asString.string ), + HB_COMP_PARAM ); + } + + if( pExpr ) + { + if( pSelf->value.asFunCall.pParms ) + 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; +} + BOOL hb_compExprReduceDTOS( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; @@ -2176,40 +2238,6 @@ BOOL hb_compExprReduceDTOS( HB_EXPR_PTR pSelf, HB_COMP_DECL ) return FALSE; } -BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) -{ - if( usCount == 1 ) - { - HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; - HB_EXPR_PTR pArg = pParms->value.asList.pExprList; - - if( pArg->ExprType == HB_ET_STRING && ( pArg->ulLength == 8 || pArg->ulLength == 0 ) ) - { - HB_EXPR_PTR pExpr = hb_compExprNewDate( pArg->ulLength == 0 ? 0 : - hb_dateEncStr( pArg->value.asString.string ), - HB_COMP_PARAM ); - - 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; - } - } - else - { - HB_EXPR_PTR pExpr = hb_compExprNewDate( 0, HB_COMP_PARAM ); - - HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pParms ); - HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); - memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - HB_COMP_EXPR_CLEAR( pExpr ); - return TRUE; - } - - return FALSE; -} - BOOL hb_compExprReduceCTOD( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;