mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
c07e7d167d
commit
de13a30d32
2 changed files with 32 additions and 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 09:16:54 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp): Fix comparisons
|
||||
|
|
28
hash.c
28
hash.c
|
@ -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? */
|
||||
|
|
Loading…
Reference in a new issue