tony2001                Tue Apr 17 20:33:45 2007 UTC

  Added files:                 
    /php-src/ext/standard/tests/general_functions       putenv.phpt 

  Modified files:              
    /php-src/ext/standard       basic_functions.c 
  Log:
  fix putenv("var") (i.e. unset) on BSD systems
  add test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.854&r2=1.855&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.854 
php-src/ext/standard/basic_functions.c:1.855
--- php-src/ext/standard/basic_functions.c:1.854        Tue Apr 10 09:36:10 2007
+++ php-src/ext/standard/basic_functions.c      Tue Apr 17 20:33:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.854 2007/04/10 09:36:10 tony2001 Exp $ */
+/* $Id: basic_functions.c,v 1.855 2007/04/17 20:33:45 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -4443,8 +4443,15 @@
                 * We try to avoid this by setting our own value first */
                SetEnvironmentVariable(pe.key, "bugbug");
 #endif
-               
-               if (putenv(pe.putenv_string) == 0) {    /* success */
+
+#if HAVE_UNSETENV
+               if (!p) { /* no '=' means we want to unset it */
+                       unsetenv(pe.putenv_string);
+               }
+               if (!p || putenv(pe.putenv_string) == 0) {  /* success */
+#else
+               if (putenv(pe.putenv_string) == 0) {    /* success */
+#endif
                        zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len+1, 
(void **) &pe, sizeof(putenv_entry), NULL);
 #ifdef HAVE_TZSET
                        if (!strncmp(pe.key, "TZ", pe.key_len)) {

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/putenv.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/general_functions/putenv.phpt
+++ php-src/ext/standard/tests/general_functions/putenv.phpt
--TEST--
putenv() basic tests
--FILE--
<?php

$var_name="SUCHVARSHOULDNOTEXIST";

var_dump(getenv($var_name));
var_dump(putenv($var_name."=value"));
var_dump(getenv($var_name));

var_dump(putenv($var_name."="));
var_dump(getenv($var_name));

var_dump(putenv($var_name));
var_dump(getenv($var_name));

echo "Done\n";
?>
--EXPECTF--     
bool(false)
bool(true)
string(5) "value"
bool(true)
string(0) ""
bool(true)
bool(false)
Done
--UEXPECTF--
bool(false)
bool(true)
unicode(5) "value"
bool(true)
unicode(0) ""
bool(true)
bool(false)
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to