diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 07:43:26 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 07:43:26 +0000 |
| commit | a06fd21600c467b992782ef9948f02538acdc56b (patch) | |
| tree | fd20397cfe85785d49cd36209380aa7627207263 | |
| parent | 8d877392a42c3a1eb21f65782f1f41890d7079e3 (diff) | |
* 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@25766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | hash.c | 29 |
2 files changed, 33 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Sat Nov 14 16:43:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * hash.c (ruby_setenv): get rid of crash in Solaris 8 and 10. + [ruby-core:26668] + Sat Nov 14 04:07:06 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/lib/tk/variable.rb (TkVariable::coerce): fix bug on a @@ -2001,7 +2001,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; @@ -2050,6 +2062,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? */ |
