]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/utilsunx.cpp
make wxSetEnv compatible with ANSI and Unicode, deprecate passing NULL to it in favou...
[wxWidgets.git] / src / unix / utilsunx.cpp
index 25b1558c73500c7add00c24ef3a00f8a3c017bbb..88e0e5101f82f58a7b1387532024c2f85c14a293 100644 (file)
@@ -1064,13 +1064,10 @@ bool wxGetEnv(const wxString& var, wxString *value)
     return true;
 }
 
-bool wxSetEnv(const wxString& variable, const wxChar *value)
+static bool wxDoSetEnv(const wxString& variable, const char *value)
 {
 #if defined(HAVE_SETENV)
-    return setenv(variable.mb_str(),
-                  value ? (const char *)wxString(value).mb_str()
-                        : NULL,
-                  1 /* overwrite */) == 0;
+    return setenv(variable.mb_str(), value, 1 /* overwrite */) == 0;
 #elif defined(HAVE_PUTENV)
     wxString s = variable;
     if ( value )
@@ -1089,6 +1086,16 @@ bool wxSetEnv(const wxString& variable, const wxChar *value)
 #endif
 }
 
+bool wxSetEnv(const wxString& variable, const wxString& value)
+{
+    return wxDoSetEnv(variable, value.mb_str());
+}
+
+bool wxUnsetEnv(const wxString& variable)
+{
+    return wxDoSetEnv(variable, NULL);
+}
+
 // ----------------------------------------------------------------------------
 // signal handling
 // ----------------------------------------------------------------------------