[前][次][番号順一覧][スレッド一覧]

ruby-changes:13911

From: usa <ko1@a...>
Date: Wed, 11 Nov 2009 12:20:36 +0900 (JST)
Subject: [ruby-changes:13911] Ruby:r25715 (trunk): * hash.c (ruby_setenv): also set CRT workarea. ref

usa	2009-11-11 12:20:21 +0900 (Wed, 11 Nov 2009)

  New Revision: 25715

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25715

  Log:
    * hash.c (ruby_setenv): also set CRT workarea.  ref [ruby-core:25010]

  Modified files:
    trunk/ChangeLog
    trunk/hash.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25714)
+++ ChangeLog	(revision 25715)
@@ -1,3 +1,7 @@
+Wed Nov 11 12:19:27 2009  NAKAMURA Usaku  <usa@r...>
+
+	* hash.c (ruby_setenv): also set CRT workarea.  ref [ruby-core:25010]
+
 Wed Nov 11 09:36:02 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* marshal.c (w_object, r_object0): use RHASH_IFNONE but not ifnone
Index: hash.c
===================================================================
--- hash.c	(revision 25714)
+++ hash.c	(revision 25715)
@@ -2032,24 +2032,24 @@
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]