]> granicus.if.org Git - php/commitdiff
- work around ENV VC6 bug
authorPierre Joye <pajoye@php.net>
Wed, 20 Aug 2008 22:19:57 +0000 (22:19 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 20 Aug 2008 22:19:57 +0000 (22:19 +0000)
ext/standard/basic_functions.c

index 50edb1a1ac497d5e7ae6bdc11a308c941a8eb6ca..a65fc0c8464b6fdbf982687dd3d89da5ac0af806 100644 (file)
@@ -4446,6 +4446,7 @@ PHP_FUNCTION(putenv)
 #ifdef PHP_WIN32
                char *value = NULL;
                int equals = 0;
+               int error_code;
 #endif
 
                pe.putenv_string = estrndup(setting, setting_len);
@@ -4495,7 +4496,14 @@ PHP_FUNCTION(putenv)
 # ifndef PHP_WIN32
                if (putenv(pe.putenv_string) == 0) { /* success */
 # else
-               if (SetEnvironmentVariableA(pe.key, value) != 0) { /* success */
+               error_code = SetEnvironmentVariable(pe.key, value);
+#  if _MSC_VER < 1500
+               /* Yet another VC6 bug, unset may return env not found */
+               if (error_code != 0 || 
+                       (error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
+#  else
+               if (error_code != 0) { /* success */
+#  endif
 # endif
 #endif
                        zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len + 1, (void **) &pe, sizeof(putenv_entry), NULL);