From 21b74912aa06acd6e562c9d17c24c521c8c40e11 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 14 Dec 2009 02:46:50 +0000 Subject: [PATCH] merge revision(s) 25766: * hash.c (ruby_setenv): get rid of crash in Solaris 8 and 10. [ruby-core:26668] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7@26087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 29 ++++++++++++++++++++++++++++- version.h | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4390ef6d7..22ce5b29f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Dec 14 11:40:35 2009 Nobuyoshi Nakada + + * 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 * lib/cgi.rb: fix command-line option of diff --git a/hash.c b/hash.c index 5574476ff..8086e22ef 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 a9b449e8f..09ee69e60 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