diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 97c7deb342..960524968d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,29 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-17 17:35 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/pp/ppcore.c + + added new predefined macro __TIMESTAMP__ + + * harbour/source/vm/classes.c + ! fixed compilation in MT mode and HB_HASH_MSG_ITEMS macro + + * harbour/source/compiler/compi18n.c + * translate '\' in source code references in .pot files to '/' + + * harbour/contrib/rddsql/sddodbc/odbcdd.c + * cleared non ANSI C initialization + + * harbour/include/hbmacro.h + * harbour/source/vm/macro.c + * harbour/include/hbexprb.c + ! force memvar context to undeclared variables used with array index + operator []. Clipper compatible behavior + + * harbour/contrib/hbwin/hbwinole.h + * harbour/contrib/hbwin/olecore.c + + added hb_oleItemPut() + 2009-05-16 16:55 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/rddsql/hbrddsql.h + added field to connection structure to store database dependent diff --git a/harbour/contrib/hbwin/hbwinole.h b/harbour/contrib/hbwin/hbwinole.h index 1773900be1..f305449a94 100644 --- a/harbour/contrib/hbwin/hbwinole.h +++ b/harbour/contrib/hbwin/hbwinole.h @@ -92,7 +92,8 @@ HB_EXTERN_BEGIN -HB_EXPORT void hb_oleVariantToItem( PHB_ITEM pItem, VARIANT* pVariant ); -HB_EXPORT void hb_oleInit( void ); +HB_EXPORT void hb_oleInit( void ); +HB_EXPORT void hb_oleVariantToItem( PHB_ITEM pItem, VARIANT* pVariant ); +HB_EXPORT PHB_ITEM hb_oleItemPut( PHB_ITEM pItem, IDispatch* pDisp ); HB_EXTERN_END diff --git a/harbour/contrib/hbwin/olecore.c b/harbour/contrib/hbwin/olecore.c index 56ed6dc446..76121aecb1 100644 --- a/harbour/contrib/hbwin/olecore.c +++ b/harbour/contrib/hbwin/olecore.c @@ -278,6 +278,16 @@ static void hb_oleItemToVariant( VARIANT* pVariant, PHB_ITEM pItem ) } +PHB_ITEM hb_oleItemPut( PHB_ITEM pItem, IDispatch* pDisp ) +{ + IDispatch** ppDisp; + + ppDisp = ( IDispatch** ) hb_gcAlloc( sizeof( IDispatch* ), hb_ole_destructor ); + *ppDisp = pDisp; + + return hb_itemPutPtrGC( pItem, ppDisp ); +} + void hb_oleVariantToItem( PHB_ITEM pItem, VARIANT* pVariant ) { switch( pVariant->n1.n2.vt ) diff --git a/harbour/contrib/rddsql/sddodbc/odbcdd.c b/harbour/contrib/rddsql/sddodbc/odbcdd.c index b9b54fb462..13782460b4 100644 --- a/harbour/contrib/rddsql/sddodbc/odbcdd.c +++ b/harbour/contrib/rddsql/sddodbc/odbcdd.c @@ -520,7 +520,7 @@ static HB_ERRCODE odbcGoTo( SQLBASEAREAP pArea, ULONG ulRecNo ) case HB_FT_DATE: { - DATE_STRUCT val = {0}; + DATE_STRUCT val = {0,0,0}; if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_DATE, &val, sizeof( val ), &iLen ) ) ) { pItem = hb_itemPutD( NULL, val.year, val.month, val.day ); @@ -530,7 +530,7 @@ static HB_ERRCODE odbcGoTo( SQLBASEAREAP pArea, ULONG ulRecNo ) case HB_FT_TIME: { - TIME_STRUCT val = {0}; + TIME_STRUCT val = {0,0,0}; if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_TIME, &val, sizeof( val ), &iLen ) ) ) { pItem = hb_itemPutTDT( NULL, 0, hb_timeEncode( val.hour, val.minute, val.second, 0 ) ); @@ -540,7 +540,7 @@ static HB_ERRCODE odbcGoTo( SQLBASEAREAP pArea, ULONG ulRecNo ) case HB_FT_DAYTIME: { - TIMESTAMP_STRUCT val = {0}; + TIMESTAMP_STRUCT val = {0,0,0,0,0,0,0}; if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_TIMESTAMP, &val, sizeof( val ), &iLen ) ) ) { pItem = hb_itemPutTDT( NULL, hb_dateEncode( val.year, val.month, val.day ), diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index d694209727..0b8b18c397 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -146,6 +146,7 @@ static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_COMP_DECL ); static HB_EXPR_PTR hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL ); +static BOOL hb_compExprIsMemvarAlias( const char *szAlias ); const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ] = { @@ -838,11 +839,8 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) } else if( pExp->ExprType == HB_ET_ALIASVAR ) { - const char *szAlias = pExp->value.asAlias.pAlias->value.asSymbol; - int iLen = strlen( szAlias ); - if( ( iLen == 1 || ( iLen >= 4 && iLen <= 6 ) ) && - memcmp( szAlias, "MEMVAR", iLen ) == 0 && - pExp->value.asAlias.pVar->ExprType == HB_ET_VARIABLE ) + if( pExp->value.asAlias.pVar->ExprType == HB_ET_VARIABLE && + hb_compExprIsMemvarAlias( pExp->value.asAlias.pAlias->value.asSymbol ) ) { /* @M-> @MEMVAR-> or @MEMVA-> or @MEMV-> */ HB_GEN_FUNC1( PushMemvarRef, pExp->value.asAlias.pVar->value.asSymbol ); break; @@ -1257,6 +1255,28 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { HB_EXPR_PTR pIdx; + /* Clipper forces memvar context for undeclared variables used with + * array index, f.e.: var[ n ] + * but not for code like: ( var )[ n ] + */ + if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE ) + { +#if !defined( HB_MACRO_SUPPORT ) + int iScope; + hb_compVariableFind( HB_COMP_PARAM, pSelf->value.asList.pExprList->value.asSymbol, NULL, &iScope ); + if( iScope == HB_VS_UNDECLARED ) + { + hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_MEMVAR_ASSUMED, + pSelf->value.asList.pExprList->value.asSymbol, NULL ); +#else + if( hb_macroLocalVarGetPos( pSelf->value.asList.pExprList->value.asSymbol, HB_COMP_PARAM ) == 0 ) + { +#endif + pSelf->value.asList.pExprList = hb_compExprNewAliasVar( + hb_compExprNewAlias( "MEMVAR", HB_COMP_PARAM ), + pSelf->value.asList.pExprList, HB_COMP_PARAM ); + } + } pSelf->value.asList.pExprList = HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_REDUCE ); pSelf->value.asList.pIndex = HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_REDUCE ); pIdx = pSelf->value.asList.pIndex; @@ -1368,33 +1388,40 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) if( pSelf->value.asList.reference && HB_SUPPORT_ARRSTR ) { - if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE ) + HB_EXPR_PTR pList = pSelf->value.asList.pExprList; + if( pList->ExprType == HB_ET_VARIABLE ) { - pSelf->value.asList.pExprList->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->ExprType = HB_ET_VARIABLE; + pList->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->ExprType = HB_ET_VARIABLE; } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_SEND ) + else if( pList->ExprType == HB_ET_ALIASVAR && + pList->value.asAlias.pVar->ExprType == HB_ET_VARIABLE && + hb_compExprIsMemvarAlias( pList->value.asAlias.pAlias->value.asSymbol ) ) { - hb_compExprPushSendPop( pSelf->value.asList.pExprList, HB_COMP_PARAM ); + HB_GEN_FUNC1( PushMemvarRef, pList->value.asAlias.pVar->value.asSymbol ); + } + else if( pList->ExprType == HB_ET_SEND ) + { + hb_compExprPushSendPop( pList, HB_COMP_PARAM ); HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_ARRAYAT && - !pSelf->value.asList.pExprList->value.asList.reference ) + else if( pList->ExprType == HB_ET_ARRAYAT && + !pList->value.asList.reference ) { - pSelf->value.asList.pExprList->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->value.asList.reference = FALSE; + pList->value.asList.reference = TRUE; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->value.asList.reference = FALSE; } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_MACRO && - pSelf->value.asList.pExprList->value.asMacro.SubType == HB_ET_MACRO_VAR ) + else if( pList->ExprType == HB_ET_MACRO && + pList->value.asMacro.SubType == HB_ET_MACRO_VAR ) { - pSelf->value.asList.pExprList->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->value.asMacro.SubType = HB_ET_MACRO_VAR; + pList->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->value.asMacro.SubType = HB_ET_MACRO_VAR; } else - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); } else HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); @@ -1432,33 +1459,40 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) /* arrays also are passed by reference */ if( HB_SUPPORT_ARRSTR ) { - if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE ) + HB_EXPR_PTR pList = pSelf->value.asList.pExprList; + if( pList->ExprType == HB_ET_VARIABLE ) { - pSelf->value.asList.pExprList->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->ExprType = HB_ET_VARIABLE; + pList->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->ExprType = HB_ET_VARIABLE; } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_SEND ) + else if( pList->ExprType == HB_ET_ALIASVAR && + pList->value.asAlias.pVar->ExprType == HB_ET_VARIABLE && + hb_compExprIsMemvarAlias( pList->value.asAlias.pAlias->value.asSymbol ) ) { - hb_compExprPushSendPop( pSelf->value.asList.pExprList, HB_COMP_PARAM ); + HB_GEN_FUNC1( PushMemvarRef, pList->value.asAlias.pVar->value.asSymbol ); + } + else if( pList->ExprType == HB_ET_SEND ) + { + hb_compExprPushSendPop( pList, HB_COMP_PARAM ); HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_ARRAYAT && - !pSelf->value.asList.pExprList->value.asList.reference ) + else if( pList->ExprType == HB_ET_ARRAYAT && + !pList->value.asList.reference ) { - pSelf->value.asList.pExprList->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->value.asList.reference = FALSE; + pList->value.asList.reference = TRUE; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->value.asList.reference = FALSE; } - else if( pSelf->value.asList.pExprList->ExprType == HB_ET_MACRO && - pSelf->value.asList.pExprList->value.asMacro.SubType == HB_ET_MACRO_VAR ) + else if( pList->ExprType == HB_ET_MACRO && + pList->value.asMacro.SubType == HB_ET_MACRO_VAR ) { - pSelf->value.asList.pExprList->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); - pSelf->value.asList.pExprList->value.asMacro.SubType = HB_ET_MACRO_VAR; + pList->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + pList->value.asMacro.SubType = HB_ET_MACRO_VAR; } else - HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); } else HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); @@ -5240,3 +5274,11 @@ static HB_EXPR_PTR hb_compExprReduceList( HB_EXPR_PTR pList, HB_COMP_DECL ) } return pList; } + +static BOOL hb_compExprIsMemvarAlias( const char *szAlias ) +{ + int iLen = strlen( szAlias ); + /* @M-> @MEMVAR-> or @MEMVA-> or @MEMV-> */ + return ( iLen == 1 || ( iLen >= 4 && iLen <= 6 ) ) && + memcmp( szAlias, "MEMVAR", iLen ) == 0; +} diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index e6b5b8ca73..c8ba49bf94 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -157,6 +157,7 @@ extern void hb_macroGenPushString( const char * szText, ULONG ulStrLen, HB_COMP_ extern void hb_macroCodeBlockStart( HB_COMP_DECL ); extern void hb_macroCodeBlockEnd( HB_COMP_DECL ); +extern int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL ); extern BOOL hb_macroIsValidMacroText( const char *, ULONG ); #endif /* HB_MACRO_SUPPORT */ diff --git a/harbour/source/compiler/compi18n.c b/harbour/source/compiler/compi18n.c index 8ebe4f053f..69c779e35b 100644 --- a/harbour/source/compiler/compi18n.c +++ b/harbour/source/compiler/compi18n.c @@ -254,6 +254,28 @@ static void hb_compI18nEscapeString( FILE* file, const char* szText ) } } +static char * hb_compI18nFileName( char* szBuffer, const char* szFileName ) +{ + UINT ui = 0; + char ch; + + do + { + if( ui == HB_PATH_MAX - 1 ) + ch = '\0'; + else + { + ch = szFileName[ ui ]; + if( ch == '\\' ) + ch = '/'; + } + szBuffer[ ui++ ] = ch; + } + while( ch ); + + return szBuffer; +} + BOOL hb_compI18nSave( HB_COMP_DECL, BOOL fFinal ) { PHB_I18NTABLE pI18n; @@ -321,10 +343,12 @@ BOOL hb_compI18nSave( HB_COMP_DECL, BOOL fFinal ) { pString = &pI18n->pString[ uiIndex ]; - fprintf( file, "#: %s:%d", pString->pPos.szFile, pString->pPos.uiLine ); + fprintf( file, "#: %s:%d", hb_compI18nFileName( szFileName, pString->pPos.szFile ), + pString->pPos.uiLine ); for( uiLine = 0; uiLine < pString->uiPosCount; ++uiLine ) - fprintf( file, " %s:%d", pString->pPosLst[ uiLine ].szFile, pString->pPosLst[ uiLine ].uiLine ); + fprintf( file, " %s:%d", hb_compI18nFileName( szFileName, pString->pPosLst[ uiLine ].szFile ), + pString->pPosLst[ uiLine ].uiLine ); fprintf( file, "\n#, c-format\n" ); diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index c9aafd5ab6..3ea3684644 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -5325,6 +5325,7 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState ) char szResult[ 65 ]; char * pSrc, * pDst, * szPlatform; int iYear, iMonth, iDay, i; + LONG lDate, lTime; /* __PLATFORM__* */ pSrc = szPlatform = hb_verPlatform(); @@ -5376,6 +5377,17 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState ) szResult[ 9 ] = '"'; szResult[ 10 ] = '\0'; hb_pp_addDefine( pState, "__TIME__", szResult ); + + /* __TIMESTAMP__ */ + szResult[ 0 ] = 't'; + szResult[ 1 ] = '"'; + hb_timeStampGet( &lDate, &lTime ); + hb_timeStampStr( szResult + 2, lDate, lTime ); + i = ( int ) strlen( szResult ); + szResult[ i++ ] = '"'; + szResult[ i ] = '\0'; + hb_pp_addDefine( pState, "__TIMESTAMP__", szResult ); + hb_pp_addDefine( pState, "__FILE__", &s_pp_dynamicResult ); hb_pp_addDefine( pState, "__LINE__", &s_pp_dynamicResult ); diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index daa5f04e9e..fe9ae0e28d 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -2066,6 +2066,7 @@ BOOL hb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage, #if defined( HB_HASH_MSG_ITEMS ) if( HB_IS_HASH( pObject ) ) { + HB_STACK_TLS_PRELOAD PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), pMessage->szName + 1 ); PHB_ITEM pValue = hb_hashGetItemRefPtr( pObject, pIndex ); hb_stackPop(); diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 6a955d4d6d..777f48c4fb 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -1040,7 +1040,7 @@ HB_FUNC( HB_SETMACRO ) /* ************************************************************************* */ /* returns the order + 1 of a variable if defined or zero */ -static int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL ) +int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL ) { int iVar = 1; HB_CBVAR_PTR pVars = HB_PCODE_DATA->pLocals; @@ -1049,16 +1049,8 @@ static int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL ) { if( pVars->szName && ! strcmp( pVars->szName, szVarName ) ) return iVar; - else - { - if( pVars->pNext ) - { - pVars = pVars->pNext; - iVar++; - } - else - return 0; - } + pVars = pVars->pNext; + iVar++; } return 0; }