2009-01-22 18:20 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/source/compiler/hbmain.c
* harbour/source/pp/hbpp.c
* harbour/source/pp/ppcore.c
+ added __FILE__ define for .prg code
; Please, look if this is implemented the right and optimal way.
I'm a little confused about PP initialization order, and how
__DATE__, etc, survive after hb_pp_reset in compiler.
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-01-22 18:20 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
|
||||
* harbour/source/compiler/hbmain.c
|
||||
* harbour/source/pp/hbpp.c
|
||||
* harbour/source/pp/ppcore.c
|
||||
+ added __FILE__ define for .prg code
|
||||
; Please, look if this is implemented the right and optimal way.
|
||||
I'm a little confused about PP initialization order, and how
|
||||
__DATE__, etc, survive after hb_pp_reset in compiler.
|
||||
|
||||
2009-01-22 10:15 UTC+0100 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com)
|
||||
* bin/hb-func.sh
|
||||
* fix darwin detection
|
||||
|
||||
@@ -3921,6 +3921,26 @@ 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;
|
||||
|
||||
@@ -243,6 +243,7 @@ static void hb_pp_undefCompilerRules( PHB_PP_STATE pState )
|
||||
const char * szRules[] = { "__HARBOUR__",
|
||||
"__DATE__",
|
||||
"__TIME__",
|
||||
"__FILE__",
|
||||
"__HB_MAIN__",
|
||||
"__ARCH16BIT__",
|
||||
"__ARCH32BIT__",
|
||||
|
||||
@@ -5296,6 +5296,28 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState )
|
||||
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_snprintf( szResult, sizeof( szResult ), "%d", ( int ) sizeof( void * ) );
|
||||
#if defined( HB_ARCH_16BIT )
|
||||
hb_pp_addDefine( pState, "__ARCH16BIT__", szResult );
|
||||
|
||||
Reference in New Issue
Block a user