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 | de13a30d32943b2aa3eb45c2b84eaa8902c09f4b (patch) | |
tree | b453d66ad81b2ca0c97ea4116367915914e57eeb /hash.c | |
parent | c07e7d167d57492ff5dfaa495537d6bb9776062e (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/trunk@25766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -2011,7 +2011,18 @@ rb_env_path_tainted(void) 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(const char *str) +{ + char **env; + for (env = origenviron; *env; ++env) { + if (*env == str) return 1; + } + return 0; +} +#else static int envix(const char *nam) { @@ -2057,6 +2068,21 @@ ruby_setenv(const char *name, const char *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? */ |