summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-14 02:46:50 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-14 02:46:50 +0000
commitd4ad42a6f1fba9899b5e4cc2a286d959d1584a9d (patch)
tree67bc0fec1e85501b2c264d34ef8eabc7b2229ab0
parent25c243bf2f5e01e91a1e3ccf17fdeb1897623488 (diff)
merge revision(s) 25766:
* hash.c (ruby_setenv): get rid of crash in Solaris 8 and 10. [ruby-core:26668] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@26087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--hash.c29
-rw-r--r--version.h2
3 files changed, 34 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4390ef6d76..22ce5b29fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 14 11:40:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * hash.c (ruby_setenv): get rid of crash in Solaris 8 and 10.
+ [ruby-core:26668]
+
Mon Dec 14 11:31:58 2009 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi.rb: fix command-line option of
diff --git a/hash.c b/hash.c
index 5574476ff1..8086e22ef7 100644
--- a/hash.c
+++ b/hash.c
@@ -1947,7 +1947,19 @@ rb_env_path_tainted()
return path_tainted;
}
-#if !defined(_WIN32) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
+#if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
+#elif defined __sun__
+static int
+in_origenv(str)
+ const char *str;
+{
+ char **env;
+ for (env = origenviron; *env; ++env) {
+ if (*env == str) return 1;
+ }
+ return 0;
+}
+#else
static int
envix(nam)
const char *nam;
@@ -2002,6 +2014,21 @@ ruby_setenv(name, value)
setenv(name,value,1);
else
unsetenv(name);
+#elif defined __sun__
+ size_t len = strlen(name);
+ char **env_ptr, *str;
+ for (env_ptr = GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
+ if (!strncmp(str, name, len) && str[len] == '=') {
+ if (!in_origenv(str)) free(str);
+ while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
+ break;
+ }
+ }
+ if (value) {
+ str = malloc(len += strlen(value) + 2);
+ snprintf(str, len, "%s=%s", name, value);
+ putenv(str);
+ }
#else /* WIN32 */
size_t len;
int i=envix(name); /* where does it go? */
diff --git a/version.h b/version.h
index a9b449e8fd..09ee69e604 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-12-14"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20091214
-#define RUBY_PATCHLEVEL 231
+#define RUBY_PATCHLEVEL 232
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8