diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d991c4ff65..f0e5d9891a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-18 11:39 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/hbgete.c + * modified hb_getenv_buffer() to return logical value indicating + that environment variable exists even if no buffer is passed + 2008-10-18 10:56 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * common.mak * make_b32.mak diff --git a/harbour/source/common/hbgete.c b/harbour/source/common/hbgete.c index e9df9d7da3..f2bff77b96 100644 --- a/harbour/source/common/hbgete.c +++ b/harbour/source/common/hbgete.c @@ -117,46 +117,40 @@ BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize ) { BOOL bRetVal = FALSE; - if( szBuffer != NULL && nSize != 0 ) - { - szBuffer[ 0 ] = '\0'; - #if defined(HB_OS_WIN_32) - { - bRetVal = GetEnvironmentVariableA( szName, szBuffer, nSize ) != 0; - } + bRetVal = GetEnvironmentVariableA( szName, szBuffer, nSize ) != 0; #elif defined(HB_OS_OS2) - - { + { #ifdef __GNUC__ PSZ EnvValue = ""; #else PCSZ EnvValue = ""; #endif - - if( DosScanEnv( szName, &EnvValue ) == NO_ERROR ) - { - hb_strncpy( szBuffer, EnvValue, nSize - 1 ); - bRetVal = TRUE; - } - } - -#else + if( DosScanEnv( szName, &EnvValue ) == NO_ERROR ) { - char * pszTemp = getenv( szName ); - - if( pszTemp != NULL ) - { - hb_strncpy( szBuffer, pszTemp, nSize - 1 ); - bRetVal = TRUE; - } + bRetVal = TRUE; + if( szBuffer != NULL && nSize != 0 ) + hb_strncpy( szBuffer, EnvValue, nSize - 1 ); } - -#endif } +#else + { + char * pszTemp = getenv( szName ); + + if( pszTemp != NULL ) + { + if( szBuffer != NULL && nSize != 0 ) + hb_strncpy( szBuffer, pszTemp, nSize - 1 ); + bRetVal = TRUE; + } + } +#endif + + if( !bRetVal && szBuffer != NULL && nSize != 0 ) + szBuffer[ 0 ] = '\0'; return bRetVal; }