2009-02-13 11:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbpp.h
* harbour/source/pp/hbpp.c
* harbour/source/pp/ppcore.c
* harbour/source/compiler/hbmain.c
+ added support for dynamically calculated #define results
! removed old code which was adding __FILE__ #define constant
It was not working correctly like in other compilers ignoring
#include
+ added __FILE__ and __LINE__ #define directives using dynamically
calculated results - now it works as expected respecting #include
directives and the implementation is local to PP without any hacks
in core compiler code.
* harbour/contrib/hbct/files.c
* added support for optional milliseconds part in HB_FSETDATETIME()/
HB_FGETDATETIME().
* harbour/source/rtl/philes.c
! minor fix in return value
This commit is contained in:
@@ -8,6 +8,27 @@
|
||||
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-02-13 11:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbpp.h
|
||||
* harbour/source/pp/hbpp.c
|
||||
* harbour/source/pp/ppcore.c
|
||||
* harbour/source/compiler/hbmain.c
|
||||
+ added support for dynamically calculated #define results
|
||||
! removed old code which was adding __FILE__ #define constant
|
||||
It was not working correctly like in other compilers ignoring
|
||||
#include
|
||||
+ added __FILE__ and __LINE__ #define directives using dynamically
|
||||
calculated results - now it works as expected respecting #include
|
||||
directives and the implementation is local to PP without any hacks
|
||||
in core compiler code.
|
||||
|
||||
* harbour/contrib/hbct/files.c
|
||||
* added support for optional milliseconds part in HB_FSETDATETIME()/
|
||||
HB_FGETDATETIME().
|
||||
|
||||
* harbour/source/rtl/philes.c
|
||||
! minor fix in return value
|
||||
|
||||
2009-02-13 10:51 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* include/hbdefs.h
|
||||
* contrib/gtwvg/gtwvg.h
|
||||
|
||||
@@ -260,7 +260,7 @@ HB_FUNC( SETFDATI )
|
||||
}
|
||||
SystemTimeToFileTime( &st, &local_ft );
|
||||
LocalFileTimeToFileTime( &local_ft, &ft );
|
||||
hb_retl( SetFileTime( f, NULL, &ft, &ft ) );
|
||||
hb_retl( SetFileTime( f, NULL, &ft, &ft ) != 0 );
|
||||
_lclose( ( HFILE ) f );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ typedef HB_PP_SWITCH_FUNC * PHB_PP_SWITCH_FUNC;
|
||||
#define HB_PP_RMARKER_LOGICAL 16
|
||||
#define HB_PP_RMARKER_NUL 17
|
||||
#define HB_PP_RMARKER_OPTIONAL 18
|
||||
#define HB_PP_RMARKER_DYNVAL 19
|
||||
|
||||
/* keywords, pseudo keywords and PP only tokens */
|
||||
#define HB_PP_TOKEN_KEYWORD 21
|
||||
|
||||
@@ -3921,26 +3921,6 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
{
|
||||
BOOL bSkipGen = FALSE ;
|
||||
|
||||
/* Add __FILE__ define */
|
||||
hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, "__FILE__" );
|
||||
if( iFileType == HB_COMP_SINGLEFILE )
|
||||
{
|
||||
char* pBuf;
|
||||
ULONG ulLen = strlen( szFileName );
|
||||
|
||||
pBuf = ( char* ) hb_xgrab( ulLen + 3 );
|
||||
pBuf[ 0 ] = '"';
|
||||
memcpy( pBuf + 1, szFileName, ulLen );
|
||||
pBuf[ ulLen + 1 ] = '"';
|
||||
pBuf[ ulLen + 2 ] = '\0';
|
||||
hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, "__FILE__", pBuf );
|
||||
hb_xfree( pBuf );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, "__FILE__", "\"\"" );
|
||||
}
|
||||
|
||||
HB_COMP_PARAM->szFile = HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
@@ -244,6 +244,7 @@ static void hb_pp_undefCompilerRules( PHB_PP_STATE pState )
|
||||
"__DATE__",
|
||||
"__TIME__",
|
||||
"__FILE__",
|
||||
"__LINE__",
|
||||
"__HB_MAIN__",
|
||||
"__ARCH16BIT__",
|
||||
"__ARCH32BIT__",
|
||||
|
||||
@@ -208,6 +208,8 @@ static const HB_PP_OPERATOR s_operators[] =
|
||||
/* illegal in Clipper: ~ */
|
||||
};
|
||||
|
||||
static const char s_pp_dynamicResult = 0;
|
||||
|
||||
static void hb_pp_disp( PHB_PP_STATE pState, const char * szMessage )
|
||||
{
|
||||
if( !pState->pDispFunc )
|
||||
@@ -4028,6 +4030,26 @@ static PHB_PP_TOKEN * hb_pp_patternStuff( PHB_PP_STATE pState,
|
||||
pResultPtr );
|
||||
}
|
||||
}
|
||||
else if( HB_PP_TOKEN_TYPE( pResultPattern->type ) == HB_PP_RMARKER_DYNVAL )
|
||||
{
|
||||
if( hb_pp_tokenValueCmp( pResultPattern, "__FILE__", HB_PP_CMP_CASE ) )
|
||||
{
|
||||
const char * szFileName = pState->pFile ? pState->pFile->szFileName : NULL;
|
||||
if( !szFileName )
|
||||
szFileName = "";
|
||||
* pResultPtr = hb_pp_tokenNew( szFileName, strlen( szFileName ), 0,
|
||||
HB_PP_TOKEN_STRING );
|
||||
pResultPtr = &( * pResultPtr )->pNext;
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pResultPattern, "__LINE__", HB_PP_CMP_CASE ) )
|
||||
{
|
||||
char line[ 16 ];
|
||||
hb_snprintf( line, sizeof( line ), "%d", pState->pFile ? pState->pFile->iCurrentLine : 0 );
|
||||
* pResultPtr = hb_pp_tokenNew( line, strlen( line ), 0,
|
||||
HB_PP_TOKEN_NUMBER );
|
||||
pResultPtr = &( * pResultPtr )->pNext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
* pResultPtr = hb_pp_tokenClone( pResultPattern );
|
||||
@@ -5295,28 +5317,8 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState )
|
||||
szResult[ 9 ] = '"';
|
||||
szResult[ 10 ] = '\0';
|
||||
hb_pp_addDefine( pState, "__TIME__", szResult );
|
||||
|
||||
/* __FILE__ */
|
||||
if( pState->pFile )
|
||||
{
|
||||
char* pBuf;
|
||||
ULONG ulLen = strlen( pState->pFile->szFileName );
|
||||
|
||||
pBuf = ( char* ) hb_xgrab( ulLen + 3 );
|
||||
pBuf[ 0 ] = '"';
|
||||
memcpy( pBuf + 1, pState->pFile->szFileName, ulLen );
|
||||
pBuf[ ulLen + 1 ] = '"';
|
||||
pBuf[ ulLen + 2 ] = '\0';
|
||||
hb_pp_addDefine( pState, "__FILE__", pBuf );
|
||||
hb_xfree( pBuf );
|
||||
}
|
||||
else
|
||||
{
|
||||
szResult[ 0 ] = '"';
|
||||
szResult[ 1 ] = '"';
|
||||
szResult[ 2 ] = '\0';
|
||||
hb_pp_addDefine( pState, "__FILE__", szResult );
|
||||
}
|
||||
hb_pp_addDefine( pState, "__FILE__", &s_pp_dynamicResult );
|
||||
hb_pp_addDefine( pState, "__LINE__", &s_pp_dynamicResult );
|
||||
|
||||
hb_snprintf( szResult, sizeof( szResult ), "%d", ( int ) sizeof( void * ) );
|
||||
#if defined( HB_ARCH_16BIT )
|
||||
@@ -5568,13 +5570,21 @@ void hb_pp_addDefine( PHB_PP_STATE pState, const char * szDefName,
|
||||
|
||||
if( szDefValue && !pState->fError )
|
||||
{
|
||||
pFile->pLineBuf = szDefValue;
|
||||
pFile->ulLineBufLen = strlen( szDefValue );
|
||||
hb_pp_getLine( pState );
|
||||
pResult = pState->pFile->pTokenList;
|
||||
pState->pFile->pTokenList = NULL;
|
||||
pToken = hb_pp_tokenResultEnd( &pResult, TRUE );
|
||||
hb_pp_tokenListFree( &pToken );
|
||||
if( szDefValue == &s_pp_dynamicResult )
|
||||
{
|
||||
pResult = hb_pp_tokenNew( szDefName, strlen( szDefName ), 0,
|
||||
HB_PP_RMARKER_DYNVAL | HB_PP_TOKEN_STATIC );
|
||||
}
|
||||
else
|
||||
{
|
||||
pFile->pLineBuf = szDefValue;
|
||||
pFile->ulLineBufLen = strlen( szDefValue );
|
||||
hb_pp_getLine( pState );
|
||||
pResult = pState->pFile->pTokenList;
|
||||
pState->pFile->pTokenList = NULL;
|
||||
pToken = hb_pp_tokenResultEnd( &pResult, TRUE );
|
||||
hb_pp_tokenListFree( &pToken );
|
||||
}
|
||||
}
|
||||
else
|
||||
pResult = NULL;
|
||||
|
||||
@@ -391,14 +391,18 @@ HB_FUNC( HB_FSETATTR )
|
||||
|
||||
HB_FUNC( HB_FSETDATETIME )
|
||||
{
|
||||
int iHour, iMinutes, iSeconds;
|
||||
const char * szTime = hb_parc( 3 );
|
||||
LONG lTime = -1;
|
||||
|
||||
hb_timeStrGet( hb_parcx( 3 ), &iHour, &iMinutes, &iSeconds, NULL );
|
||||
if( szTime )
|
||||
{
|
||||
int iHour, iMinutes, iSeconds, iMSec;
|
||||
hb_timeStrGet( szTime, &iHour, &iMinutes, &iSeconds, &iMSec );
|
||||
lTime = hb_timeStampEncode( iHour, iMinutes, iSeconds, iMSec );
|
||||
}
|
||||
|
||||
hb_retl( hb_fsSetFileTime(
|
||||
( UCHAR * ) hb_parcx( 1 ),
|
||||
ISDATE( 2 ) ? hb_pardl( 2 ) : -1,
|
||||
ISCHAR( 3 ) ? hb_timeStampEncode( iHour, iMinutes, iSeconds, 0 ) : -1 ) );
|
||||
hb_retl( hb_fsSetFileTime( ( UCHAR * ) hb_parcx( 1 ),
|
||||
ISDATE( 2 ) ? hb_pardl( 2 ) : -1, lTime ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_FGETDATETIME )
|
||||
@@ -412,7 +416,8 @@ HB_FUNC( HB_FGETDATETIME )
|
||||
hb_stordl( lJulian, 2 );
|
||||
|
||||
hb_timeStampStr( buf, lMillisec );
|
||||
buf[ 8 ] = '\0';
|
||||
if( lMillisec % 1000 == 0 )
|
||||
buf[ 8 ] = '\0';
|
||||
hb_storc( buf, 3 );
|
||||
|
||||
/* hb_stornl( lMillisec, 4 ); */
|
||||
|
||||
Reference in New Issue
Block a user