From 8d0a5f3542d2e0204f46248bcdbaee674b2bdaca Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 11 Jun 2008 02:10:29 +0000 Subject: [PATCH] 2008-06-11 04:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexprop.h * harbour/include/hbexprb.c * harbour/source/common/expropt2.c * added optimization for DTOS( ), f.e.: static s := DTOS( 0d20080611 ) --- harbour/ChangeLog | 7 +++++++ harbour/include/hbexprb.c | 4 ++++ harbour/include/hbexprop.h | 1 + harbour/source/common/expropt2.c | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 13d0b61962..cc2590970a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-11 04:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbexprop.h + * harbour/include/hbexprb.c + * harbour/source/common/expropt2.c + * added optimization for DTOS( ), f.e.: + static s := DTOS( 0d20080611 ) + 2008-06-11 01:17 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/hbwince.c ! fixed typo in GetDriveTypeA() diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index cfb8292a81..927d1a8783 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1638,6 +1638,10 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( HB_SUPPORT_HARBOUR ) hb_compExprReduceSTOD( pSelf, usCount, HB_COMP_PARAM ); } + else if( strcmp( "DTOS", pName->value.asSymbol ) == 0 && usCount == 1 ) + { + hb_compExprReduceDTOS( pSelf, HB_COMP_PARAM ); + } else if( strcmp( "CTOD", pName->value.asSymbol ) == 0 && usCount ) { if( HB_SUPPORT_HARBOUR ) diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index aa495fb45a..19f40f58bd 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -199,6 +199,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_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 ); extern BOOL hb_compExprReduceUPPER( HB_EXPR_PTR, HB_COMP_DECL ); extern BOOL hb_compExprReduceBitFunc( HB_EXPR_PTR, HB_LONG, BOOL, HB_COMP_DECL ); diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 2df1b525ad..d50244be8f 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1671,6 +1671,28 @@ BOOL hb_compExprReduceINT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) return FALSE; } +BOOL hb_compExprReduceDTOS( 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_DATE ) + { + char szBuffer[ 9 ]; + char * szDate = ( char * ) memcpy( hb_xgrab( 9 ), + hb_dateDecStr( szBuffer, pArg->value.asNum.val.l ), 9 ); + HB_EXPR_PTR pExpr = hb_compExprNewString( szDate, 8, TRUE, 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; + } + + return FALSE; +} + BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) { if( usCount == 1 )