diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3ed4232033..ad6f483539 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,26 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-01 16:42 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * include/hbapi.h + * src/common/hbver.c + + Added hb_verPlatformMacro(), which returns string as it appears + in __PLATFORM__* macro. + This function will have to be extended for each new platform + Harbour is getting ported to. + + * src/pp/ppcore.c + ! Changed to use hb_verPlatformMacro() value to form __PLATFORM__* + macro, instead of using hb_verPlatform(), which offers no + guarantee for the value on *nix systems and it's was hack + on other platforms too (f.e. it got messed up when Windows + version string was changed to show "wine" at the beginning + of the human readable platform string). + % Made forming of __PLATFORM__* macros simpler, using hb_snprintf(). + ! Now WINCE builds of pp will also defined __PLATFORM__WINDOWS. + + ; Please review/test. + 2010-11-01 13:53 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/vm/Makefile * src/vm/mainwin.c diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 77f1b23d60..8065788d32 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -1139,6 +1139,7 @@ extern HB_EXPORT void hb_dynCall( int iFuncFlags, void * pFunction, int /* misc */ extern HB_EXPORT const char * hb_verCPU( void ); /* retrieves a constant string with CPU architecture */ +extern HB_EXPORT const char * hb_verPlatformMacro( void ); /* retrieves a constant string with OS platform (as it appears in __PLATFORM__* macro) */ extern HB_EXPORT char * hb_verPlatform( void ); /* retrieves a newly allocated buffer containing platform version */ extern HB_EXPORT char * hb_verCompiler( void ); /* retrieves a newly allocated buffer containing compiler version */ extern HB_EXPORT char * hb_verHarbour( void ); /* retrieves a newly allocated buffer containing harbour version */ diff --git a/harbour/src/common/hbver.c b/harbour/src/common/hbver.c index 3e279fb02a..8f4e7598bd 100644 --- a/harbour/src/common/hbver.c +++ b/harbour/src/common/hbver.c @@ -161,6 +161,42 @@ const char * hb_verHostCPU( void ) will in fact be formed from the string returned by this function. [vszakats] */ +/* NOTE: As it appears in __PLATFORM__* macro */ +const char * hb_verPlatformMacro( void ) +{ +#if defined( HB_OS_WIN_CE ) /* Must precede HB_OS_WIN */ + return "WINCE"; /* TODO: Change this to WCE for consistency? */ +#elif defined( HB_OS_WIN ) + return "WINDOWS"; /* TODO: Change this to WIN for consistency? */ +#elif defined( HB_OS_DOS ) + return "DOS"; +#elif defined( HB_OS_OS2 ) + return "OS2"; +#elif defined( HB_OS_LINUX ) + return "LINUX"; +#elif defined( HB_OS_DARWIN ) + return "DARWIN"; +#elif defined( HB_OS_BSD ) + return "BSD"; +#elif defined( HB_OS_SUNOS ) + return "SUNOS"; +#elif defined( HB_OS_HPUX ) + return "HPUX"; +#elif defined( HB_OS_BEOS ) + return "BEOS"; +#elif defined( HB_OS_QNX ) + return "QNX"; +#elif defined( HB_OS_VXWORKS ) + return "VXWORKS"; +#elif defined( HB_OS_SYMBIAN ) + return "SYMBIAN"; +#elif defined( HB_OS_CYGWIN ) + return "CYGWIN"; +#else + return NULL; +#endif +} + /* NOTE: Must be larger than 128, which is the maximum size of osVer.szCSDVersion (Windows). [vszakats] */ #define PLATFORM_BUF_SIZE 255 diff --git a/harbour/src/pp/ppcore.c b/harbour/src/pp/ppcore.c index d9115d158f..be99a0214a 100644 --- a/harbour/src/pp/ppcore.c +++ b/harbour/src/pp/ppcore.c @@ -5533,40 +5533,24 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState, HB_BOOL fArchDefs ) { char szDefine[ 65 ]; char szResult[ 65 ]; - char * pSrc, * pDst, * szPlatform; int iYear, iMonth, iDay, i; long lDate, lTime; if( fArchDefs ) { - /* __PLATFORM__* */ - pSrc = szPlatform = hb_verPlatform(); - pDst = hb_strncpy( szDefine, "__PLATFORM__", sizeof( szDefine ) - 1 ); - i = 12; - while( pSrc[ 0 ] > ' ' && i < ( int ) sizeof( szDefine ) - 1 ) + static const char * szPlatform = "__PLATFORM__%s"; + + if( hb_verPlatformMacro() ) { - if( HB_PP_ISNEXTIDCHAR( pSrc[ 0 ] ) ) - pDst[ i++ ] = HB_PP_UPPER( pSrc[ 0 ] ); - pSrc++; + hb_snprintf( szDefine, sizeof( szDefine ), szPlatform, hb_verPlatformMacro() ); + hb_pp_addDefine( pState, szDefine, szResult ); } - pDst[ i ] = '\0'; - - i = 0; - pDst = szResult; - pDst[ i++ ] = '"'; - if( pSrc[ 0 ] == ' ' ) - { - while( *( ++pSrc ) && i < ( int ) sizeof( szResult ) - 2 ) - pDst[ i++ ] = pSrc[ 0 ]; - } - pDst[ i++ ] = '"'; - pDst[ i ] = '\0'; - - hb_xfree( szPlatform ); - - hb_pp_addDefine( pState, szDefine, szResult ); #if defined( HB_OS_UNIX ) - hb_strncpy( szDefine + 12, "UNIX", sizeof( szDefine ) - 13 ); + hb_snprintf( szDefine, sizeof( szDefine ), szPlatform, "UNIX" ); + hb_pp_addDefine( pState, szDefine, szResult ); +#endif +#if defined( HB_OS_WIN_CE ) + hb_snprintf( szDefine, sizeof( szDefine ), szPlatform, "WINDOWS" ); hb_pp_addDefine( pState, szDefine, szResult ); #endif