You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2012/01/13 11:14:12 UTC

svn commit: r1230973 - /incubator/ooo/trunk/main/sal/osl/w32/process.cxx

Author: hdu
Date: Fri Jan 13 10:14:11 2012
New Revision: 1230973

URL: http://svn.apache.org/viewvc?rev=1230973&view=rev
Log:
#i118021# sync Window's process and crt environment variables

Modified:
    incubator/ooo/trunk/main/sal/osl/w32/process.cxx

Modified: incubator/ooo/trunk/main/sal/osl/w32/process.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sal/osl/w32/process.cxx?rev=1230973&r1=1230972&r2=1230973&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sal/osl/w32/process.cxx (original)
+++ incubator/ooo/trunk/main/sal/osl/w32/process.cxx Fri Jan 13 10:14:11 2012
@@ -404,21 +404,29 @@ oslProcessError SAL_CALL osl_getEnvironm
 
 oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *ustrValue)
 {
+    // set Windows environment variable
     LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
     LPCWSTR lpValue = reinterpret_cast<LPCWSTR>(ustrValue->buffer);
-    if (SetEnvironmentVariableW(lpName, lpValue))
-        return osl_Process_E_None;
-    return osl_Process_E_Unknown;
+    if( !SetEnvironmentVariableW( lpName, lpValue))
+        return osl_Process_E_Unknown;
+
+    // also set the variable in the crt environment
+    _wputenv_s( lpName, lpValue);
+    return osl_Process_E_None;
 }
 
 oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar)
 {
-    //If the second parameter is NULL, the variable is deleted from the current
-    //process's environment.
+    // delete the variable from the current process environment
+    // by setting SetEnvironmentVariable's second parameter to NULL
     LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
-    if (SetEnvironmentVariableW(lpName, NULL))
-        return osl_Process_E_None;
-    return osl_Process_E_Unknown;
+    if( !SetEnvironmentVariableW( lpName, NULL))
+        return osl_Process_E_Unknown;
+
+    // also remove the variable from the crt environment
+    wchar_t aEmptyName = 0;
+    _wputenv_s( lpName, &aEmptyName);
+    return osl_Process_E_None;
 }
 
 /***************************************************************************