static void hb_pp_undefCompilerRules( PHB_PP_STATE pState ) { int i; PHB_PP_RULE * pRulePtr, pRule; char * szRules[] = { "__HARBOUR__", "__DATE__", "__TIME__", "__HB_MAIN__", "__ARCH16BIT__", "__ARCH32BIT__", "__ARCH64BIT__", "__LITTLE_ENDIAN__", "__BIG_ENDIAN__", "__PDP_ENDIAN__", NULL }; for( i = 0; szRules[ i ]; ++i ) hb_pp_delDefine( pState, szRules[ i ] ); pRulePtr = &pState->pDefinitions; while( *pRulePtr ) { pRule = *pRulePtr; if( ! pRule->pMatch->pNext && strncmp( pRule->pMatch->value, "__PLATFORM__", 12 ) == 0 ) { *pRulePtr = pRule->pPrev; hb_pp_ruleFree( pRule ); pState->iDefinitions--; } else pRulePtr = &pRule->pPrev; } }
void hb_compChkSetDefines( HB_COMP_DECL ) { PHB_PPDEFINE pDefine = HB_COMP_PARAM->ppdefines; while( pDefine ) { if( pDefine->szValue == s_szUndefineMarker ) hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, pDefine->szName ); else hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, pDefine->szName, pDefine->szValue ); pDefine = pDefine->pNext; } }
static void hb_compChkDefineSwitch( HB_COMP_DECL, const char * pszSwitch ) { if( pszSwitch && HB_ISOPTSEP( pszSwitch[ 0 ] ) ) { if( pszSwitch[ 1 ] == 'd' || pszSwitch[ 1 ] == 'D' ) { if( pszSwitch[ 2 ] ) { char * szDefText = hb_strdup( pszSwitch + 2 ), * szAssign; szAssign = strchr( szDefText, '=' ); if( szAssign ) *szAssign++ = '\0'; hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, szDefText, szAssign ); hb_xfree( szDefText ); } } else if( ( pszSwitch[ 1 ] == 'U' || pszSwitch[ 1 ] == 'u' ) && ( pszSwitch[ 2 ] == 'N' || pszSwitch[ 2 ] == 'n' ) && ( pszSwitch[ 3 ] == 'D' || pszSwitch[ 3 ] == 'd' ) && ( pszSwitch[ 4 ] == 'E' || pszSwitch[ 4 ] == 'e' ) && ( pszSwitch[ 5 ] == 'F' || pszSwitch[ 5 ] == 'f' ) && pszSwitch[ 6 ] == ':' ) { char *szDefText = hb_strdup( pszSwitch + 7 ); unsigned int i = 0; while( szDefText[ i ] && ! HB_ISOPTSEP( szDefText[ i ] ) ) { i++; } szDefText[ i ] = '\0'; if( szDefText[ 0 ] ) { if( hb_stricmp( szDefText, ".ARCH." ) == 0 ) hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, szDefText ); } hb_xfree( szDefText ); } } }
static int hb_pp_parseRepoVer( PHB_PP_STATE pState, const char * pszFileName, int iQuiet, char ** pszCommitID, int * piCommitRev, char ** pszCommitInfo ) { FILE * file_in; char szId[ _VALUE_SIZE ]; char szDate[ _VALUE_SIZE ]; char szName[ _VALUE_SIZE ]; char szMail[ _VALUE_SIZE ]; char szCommitInfo[ _VALUE_SIZE ]; int iLen; *szId = *szDate = *szName = *szMail = *szCommitInfo = '\0'; file_in = hb_fopen( pszFileName, "r" ); if( ! file_in ) { if( iQuiet < 2 ) fprintf( stderr, "'%s' not found. Skipping.\n", pszFileName ); } else { char szLine[ 256 ]; char * pszValue; if( iQuiet == 0 ) fprintf( stdout, "Reading repository revision file: %s\n", pszFileName ); for( ;; ) { if( ! fgets( szLine, sizeof( szLine ), file_in ) ) break; if( ! *szId ) pszValue = szId; else if( ! *szDate ) pszValue = szDate; else if( ! *szName ) pszValue = szName; else if( ! *szMail ) pszValue = szMail; else break; { hb_strncpy( pszValue, szLine, _VALUE_SIZE - 1 ); iLen = ( int ) strlen( pszValue ); while( iLen-- && HB_ISSPACE( pszValue[ iLen ] ) ) pszValue[ iLen ] = '\0'; } } fclose( file_in ); } hb_pp_addDefine( pState, "HB_VER_COMMIT_ID", szId ); #if defined( HB_LEGACY_LEVEL4 ) hb_pp_addDefine( pState, "HB_VER_CHLID", szId ); #endif *pszCommitID = hb_strdup( szId ); if( szDate[ 0 ] && szName[ 0 ] && szMail[ 0 ] ) { iLen = ( int ) strlen( szMail ); while( iLen-- ) { if( szMail[ iLen ] == '@' ) szMail[ iLen ] = ' '; } #if defined( __HB_INCLUDE_MORE_COMMIT_INFO ) hb_snprintf( szCommitInfo, sizeof( szCommitInfo ), "%s %s (%s)", szDate, szName, szMail ); #else hb_snprintf( szCommitInfo, sizeof( szCommitInfo ), "%s", szDate ); HB_SYMBOL_UNUSED( szName ); HB_SYMBOL_UNUSED( szMail ); #endif if( *pszCommitInfo ) hb_xfree( *pszCommitInfo ); hb_pp_delDefine( pState, "HB_VER_COMMIT_INFO" ); hb_pp_addDefine( pState, "HB_VER_COMMIT_INFO", szCommitInfo ); *pszCommitInfo = hb_strdup( szCommitInfo ); *piCommitRev = hb_pp_TimeStampToNum( pState, szCommitInfo ); } return 0; }
static int hb_pp_TimeStampToNum( PHB_PP_STATE pState, char * pszLog ) { char szRevID[ 18 ]; int iLen; if( strlen( pszLog ) >= 16 ) { long lJulian = 0, lMilliSec = 0; int iUTC = 0; if( strlen( pszLog ) >= 25 && ( pszLog[ 20 ] == '+' || pszLog[ 20 ] == '-' ) && HB_ISDIGIT( pszLog[ 21 ] ) && HB_ISDIGIT( pszLog[ 22 ] ) && HB_ISDIGIT( pszLog[ 23 ] ) && HB_ISDIGIT( pszLog[ 24 ] ) ) { iUTC = ( ( int ) ( pszLog[ 21 ] - '0' ) * 10 + ( int ) ( pszLog[ 22 ] - '0' ) ) * 60 + ( int ) ( pszLog[ 23 ] - '0' ) * 10 + ( int ) ( pszLog[ 24 ] - '0' ); if( pszLog[ 20 ] == '-' ) iUTC *= -1; } pszLog[ 16 ] = '\0'; if( iUTC != 0 && hb_timeStampStrGetDT( pszLog, &lJulian, &lMilliSec ) ) { hb_timeStampUnpackDT( hb_timeStampPackDT( lJulian, lMilliSec ) - ( double ) iUTC / ( 24 * 60 ), &lJulian, &lMilliSec ); } if( lJulian && lMilliSec ) { hb_timeStampStrRawPut( szRevID, lJulian, lMilliSec ); memmove( szRevID, szRevID + 2, 10 ); } else { szRevID[ 0 ] = pszLog[ 2 ]; szRevID[ 1 ] = pszLog[ 3 ]; szRevID[ 2 ] = pszLog[ 5 ]; szRevID[ 3 ] = pszLog[ 6 ]; szRevID[ 4 ] = pszLog[ 8 ]; szRevID[ 5 ] = pszLog[ 9 ]; szRevID[ 6 ] = pszLog[ 11 ]; szRevID[ 7 ] = pszLog[ 12 ]; szRevID[ 8 ] = pszLog[ 14 ]; szRevID[ 9 ] = pszLog[ 15 ]; } szRevID[ 10 ] = '\0'; } else szRevID[ 0 ] = '\0'; hb_pp_delDefine( pState, "HB_VER_COMMIT_REV" ); hb_pp_addDefine( pState, "HB_VER_COMMIT_REV", szRevID ); #if defined( HB_LEGACY_LEVEL4 ) hb_pp_delDefine( pState, "HB_VER_SVNID" ); hb_pp_addDefine( pState, "HB_VER_SVNID", szRevID ); #endif return ( int ) hb_strValInt( szRevID, &iLen ); }