From: Pierre Joye Date: Wed, 20 Aug 2008 22:19:57 +0000 (+0000) Subject: - work around ENV VC6 bug X-Git-Tag: BEFORE_HEAD_NS_CHANGE~639 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96310b890523b0483505c0126df185a41b24bd18;p=php - work around ENV VC6 bug --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 50edb1a1ac..a65fc0c846 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -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);