From 3ef6c5f7243006c87c8dd90b3392ab79baffcf61 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 20 Sep 2006 21:26:13 +0000 Subject: [PATCH] 2006-09-20 23:17 UTC+0100 Viktor Szakats (viktor.szakats syenar.hu) * harbour/include/hbexprb.c * harbour/include/hbexprop.h * harbour/source/common/expropt2.c % Compile-time optimization added for expressions below: SToD(""), SToD(), HB_SToD(), HB_SToD(""), HB_SToD() ! Tabs converted to spaces. * harbour/source/common/hbdate.c * harbour/source/rtl/dates.c * Copyright cosmetic cleanup. --- harbour/ChangeLog | 12 ++++++ harbour/include/hbexprb.c | 5 ++- harbour/include/hbexprop.h | 2 +- harbour/source/common/expropt2.c | 73 +++++++++++++++++++------------- harbour/source/common/hbdate.c | 8 ++++ harbour/source/rtl/dates.c | 6 --- 6 files changed, 67 insertions(+), 39 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 19532406dd..702960fc32 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + or generate compile time error. + + * harbour/source/vm/macro.c + % minor optimizations + +2006-09-21 12:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/itemapi.c + % minor optimization in hb_itemParam() + ! fixed enumerator variable clearing in hb_itemCopy() + +2006-09-21 09:52 UTC+0100 Viktor Szakats (viktor.szakats syenar.hu) + * harbour/source/common/expropt2.c ! Fixed leak introduced in previous commit. 2006-09-20 23:17 UTC+0100 Viktor Szakats (viktor.szakats syenar.hu) diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 5305052804..b347771b59 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1673,10 +1673,11 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) hb_compExprReduceASC( pSelf, HB_MACRO_PARAM ); } - else if( ( strcmp( "STOD", pName->value.asSymbol ) == 0 ) && usCount ) + else if( ( ( strcmp( "STOD", pName->value.asSymbol ) == 0 ) || + ( strcmp( "HB_STOD", pName->value.asSymbol ) == 0 ) ) && usCount < 2 ) { if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) - hb_compExprReduceSTOD( pSelf, HB_MACRO_PARAM ); + hb_compExprReduceSTOD( pSelf, usCount, HB_MACRO_PARAM ); } } } diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index fe16d7a578..80868ba38c 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -393,7 +393,7 @@ BOOL hb_compExprReduceAT( HB_EXPR_PTR, HB_MACRO_DECL ); BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_MACRO_DECL ); BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_MACRO_DECL ); BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_MACRO_DECL ); -BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, HB_MACRO_DECL ); +BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_MACRO_DECL ); BOOL hb_compExprIsValidMacro( char *, BOOL *, HB_MACRO_DECL ); #ifdef HB_MACRO_SUPPORT diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 7f41f50dcc..b5f5c22b05 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1075,7 +1075,7 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) { HB_EXPR_PTR pExpr; - pExpr =pSelf->value.asList.pExprList; /* get conditional expression */ + pExpr = pSelf->value.asList.pExprList; /* get conditional expression */ if( pExpr->ExprType == HB_ET_LOGICAL ) { /* the condition was reduced to a logical value: .T. or .F. @@ -1214,10 +1214,10 @@ BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) if( bVal == 0 && pArg->value.asNum.lVal != 0 ) { - pExpr->value.asString.string = ( char * ) hb_xgrab( 1 ); - pExpr->value.asString.string[ 0 ] = '\0'; - pExpr->value.asString.dealloc = TRUE; - pExpr->ulLength = 0; + pExpr->value.asString.string = ( char * ) hb_xgrab( 1 ); + pExpr->value.asString.string[ 0 ] = '\0'; + pExpr->value.asString.dealloc = TRUE; + pExpr->ulLength = 0; } else { @@ -1225,20 +1225,20 @@ BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) pExpr->value.asString.string[ 0 ] = bVal; pExpr->value.asString.string[ 1 ] = '\0'; pExpr->value.asString.dealloc = TRUE; - pExpr->ulLength = 1; + pExpr->ulLength = 1; } } else { - pExpr->value.asString.string = ( char * ) hb_xgrab( 2 ); - pExpr->value.asString.string[ 0 ] = ( ( unsigned int ) pArg->value.asNum.dVal % 256 ); - pExpr->value.asString.string[ 1 ] = '\0'; - pExpr->value.asString.dealloc = TRUE; - pExpr->ulLength = 1; + pExpr->value.asString.string = ( char * ) hb_xgrab( 2 ); + pExpr->value.asString.string[ 0 ] = ( ( unsigned int ) pArg->value.asNum.dVal % 256 ); + pExpr->value.asString.string[ 1 ] = '\0'; + pExpr->value.asString.dealloc = TRUE; + pExpr->ulLength = 1; } - hb_compExprFree( pParms, HB_MACRO_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); + hb_compExprFree( pParms, HB_MACRO_PARAM ); + hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); hb_compExprClear( pExpr ); return TRUE; @@ -1251,13 +1251,13 @@ BOOL hb_compExprReduceLEN( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) { HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; HB_EXPR_PTR pArg = pParms->value.asList.pExprList; - + if( pArg->ExprType == HB_ET_STRING || pArg->ExprType == HB_ET_ARRAY ) { - HB_EXPR_PTR pExpr = hb_compExprNewLong( pArg->ulLength ); + HB_EXPR_PTR pExpr = hb_compExprNewLong( pArg->ulLength ); - hb_compExprFree( pParms, HB_MACRO_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); + hb_compExprFree( pParms, HB_MACRO_PARAM ); + hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); hb_compExprClear( pExpr ); return TRUE; @@ -1269,13 +1269,13 @@ BOOL hb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) { HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; HB_EXPR_PTR pArg = pParms->value.asList.pExprList; - + if( pArg->ExprType == HB_ET_STRING ) { - HB_EXPR_PTR pExpr = hb_compExprNewLong( (BYTE)pArg->value.asString.string[0] ); + HB_EXPR_PTR pExpr = hb_compExprNewLong( (BYTE)pArg->value.asString.string[0] ); - hb_compExprFree( pParms, HB_MACRO_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); + hb_compExprFree( pParms, HB_MACRO_PARAM ); + hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); hb_compExprClear( pExpr ); return TRUE; @@ -1283,20 +1283,33 @@ BOOL hb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) return FALSE; } -BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, HB_MACRO_DECL ) +BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_MACRO_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 == 8 ) + if( usCount == 1 ) { - HB_EXPR_PTR pExpr = hb_compExprNewDate( hb_dateEncStr( pArg->value.asString.string ) ); - - hb_compExprFree( pParms, HB_MACRO_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); + 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_compExprFree( pSelf->value.asFunCall.pParms, HB_MACRO_PARAM ); + hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); + memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); + hb_compExprClear( pExpr ); + return TRUE; + } + } + else + { + HB_EXPR_PTR pExpr = hb_compExprNewDate( 0 ); + + hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_MACRO_PARAM ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); hb_compExprClear( pExpr ); return TRUE; } + return FALSE; } diff --git a/harbour/source/common/hbdate.c b/harbour/source/common/hbdate.c index 3a39b4ae1e..fac0d8bd62 100644 --- a/harbour/source/common/hbdate.c +++ b/harbour/source/common/hbdate.c @@ -48,12 +48,20 @@ * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. * + */ + +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * * Copyright 1999-2001 Viktor Szakats * hb_dateEncStr() * hb_dateDecStr() * hb_dateStrPut() * hb_dateStrGet() * + * See doc/license.txt for licensing terms. + * */ #include "hbapi.h" diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index 733f232d88..6e41d498f1 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -60,12 +60,6 @@ * Copyright 1999 David G. Holm * hb_dateFormat() * - * Copyright 1999-2001 Viktor Szakats - * hb_dateEncStr() - * hb_dateDecStr() - * hb_dateStrPut() - * hb_dateStrGet() - * * See doc/license.txt for licensing terms. * */