summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 03:20:21 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 03:20:21 +0000
commitf3b13d086909823a5f5beb474c92014f206ba492 (patch)
tree4c79e8fb9a98c7b4cba6385fb813ac7156e74969
parentacd158f6d4cb5ddb812b5226c2022ff3ec6d947c (diff)
downloadruby-f3b13d086909823a5f5beb474c92014f206ba492.tar.gz
ruby-f3b13d086909823a5f5beb474c92014f206ba492.tar.xz
ruby-f3b13d086909823a5f5beb474c92014f206ba492.zip
* hash.c (ruby_setenv): also set CRT workarea. ref [ruby-core:25010]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--hash.c36
2 files changed, 22 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index fa9e40580..19a1f4d87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 11 12:19:27 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * hash.c (ruby_setenv): also set CRT workarea. ref [ruby-core:25010]
+
Wed Nov 11 09:36:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (w_object, r_object0): use RHASH_IFNONE but not ifnone
diff --git a/hash.c b/hash.c
index 8b1c68f6f..bc5e5b300 100644
--- a/hash.c
+++ b/hash.c
@@ -2032,24 +2032,24 @@ void
ruby_setenv(const char *name, const char *value)
{
#if defined(_WIN32)
- /* The sane way to deal with the environment.
- * Has these advantages over putenv() & co.:
- * * enables us to store a truly empty value in the
- * environment (like in UNIX).
- * * we don't have to deal with RTL globals, bugs and leaks.
- * * Much faster.
- * Why you may want to enable USE_WIN32_RTL_ENV:
- * * environ[] and RTL functions will not reflect changes,
- * which might be an issue if extensions want to access
- * the env. via RTL. This cuts both ways, since RTL will
- * not see changes made by extensions that call the Win32
- * functions directly, either.
- * GSAR 97-06-07
- *
- * REMARK: USE_WIN32_RTL_ENV is already obsoleted since we don't use
- * RTL's environ global variable directly yet.
- */
- SetEnvironmentVariable(name,value);
+ int len;
+ char *buf;
+ if (value) {
+ len = strlen(name) + 1 + strlen(value) + 1;
+ buf = ALLOCA_N(char, len);
+ snprintf(buf, len, "%s=%s", name, value);
+ putenv(buf);
+
+ /* putenv() doesn't handle empty value */
+ if (*value)
+ SetEnvironmentVariable(name,value);
+ }
+ else {
+ len = strlen(name) + 1 + 1;
+ buf = ALLOCA_N(char, len);
+ snprintf(buf, len, "%s=", name);
+ putenv(buf);
+ }
#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
#undef setenv
#undef unsetenv