diff options
author | Caol?n McNamara <cmc@openoffice.org> | 2010-07-14 12:19:12 +0100 |
---|---|---|
committer | Caol?n McNamara <cmc@openoffice.org> | 2010-07-14 12:19:12 +0100 |
commit | 78e0e85dbde3c7845ba8259c580b2853757d5d21 (patch) | |
tree | 15ab51cf3460e27c27f20d3eb1dbc43ea1835ab3 | |
parent | 6eb9a1ad1a777cb3cb1a3d1ea426d5b2c59a7524 (diff) |
cmcfixes76: #i112656# osl_setEnvironment/osl_clearEnvironment, can't find out of os/2 has setenv/unsetenv, so use putenv which I can definitely see in the ancient emx headersooo/DEV300_m85
-rw-r--r-- | sal/osl/os2/process_impl.cxx | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/sal/osl/os2/process_impl.cxx b/sal/osl/os2/process_impl.cxx index 7e0664995..f689d5bc5 100644 --- a/sal/osl/os2/process_impl.cxx +++ b/sal/osl/os2/process_impl.cxx @@ -306,11 +306,26 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString* pustrEnvVar, rtl_uStrin if (pstr_env_var != 0 && pstr_val != 0) { - if (setenv(rtl_string_getStr(pstr_env_var), rtl_string_getStr(pstr_val), 1) == 0) + //Can't determine if OS/2 EMX has a working setenv or not, so use putenv, + //feel free to use setenv here if its available and works + rtl_String * pBuffer = NULL; + + sal_Int32 nCapacity = rtl_stringbuffer_newFromStringBuffer( &pBuffer, + rtl_string_getLength(pstr_env_var) + rtl_string_getLength(pstr_val) + 1, + pstr_env_var ); + rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length, "=", 1); + rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length, + rtl_string_getStr(pstr_val), rtl_string_getLength(pstr_val) ); + + rtl_string_acquire(pBuffer); // argument to putenv must leak on success + + if (putenv(rtl_string_getStr(pBuffer)) == 0) result = osl_Process_E_None; + else + rtl_string_release(pBuffer); } - if (pstr_val != 0) + if (pstr_val) rtl_string_release(pstr_val); if (pstr_env_var != 0) @@ -337,8 +352,21 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString* pustrEnvVar) if (pstr_env_var) { - if (unsetenv(rtl_string_getStr(pstr_env_var)) == 0) + //Can't determine if OS/2 EMX has a working unsetenv or not, so use putenv, + //feel free to use unsetenv here if its available and works + rtl_String * pBuffer = NULL; + + sal_Int32 nCapacity = rtl_stringbuffer_newFromStringBuffer( &pBuffer, + rtl_string_getLength(pstr_env_var) + 1, pstr_env_var ); + rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length, "=", 1); + + rtl_string_acquire(pBuffer); // argument to putenv must leak on success + + if (putenv(rtl_string_getStr(pBuffer)) == 0) result = osl_Process_E_None; + else + rtl_string_release(pBuffer); + rtl_string_release(pstr_env_var); } |