diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-15 11:43:27 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-15 11:43:27 +0000 |
commit | b5c27d1cabde475d6fe6306e927707f10442af0e (patch) | |
tree | 2fdf5a0a2a6b2b19cfcedcd6b9f9349bd57ab659 /hash.c | |
parent | b3c17635c2ad52b7afa76af39868613e2edf47c2 (diff) |
merged r29225 but just warning instead of raising an exception. c.f. [ruby-core:32250].
--
* hash.c (ruby_setenv): raise if putenv and SetEnvironmentVariable
failed, because of the restriction of the size on Windows.
based on a patch from Peter Weldon at [ruby-core:32304]. fix:
Bug#3812, [ruby-core:32250]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -2135,6 +2135,7 @@ ruby_setenv(const char *name, const char *value) #if defined(_WIN32) int len; char *buf; + int failed = 0; if (strchr(name, '=')) { errno = EINVAL; rb_sys_fail("ruby_setenv"); @@ -2143,18 +2144,21 @@ ruby_setenv(const char *name, const char *value) len = strlen(name) + 1 + strlen(value) + 1; buf = ALLOCA_N(char, len); snprintf(buf, len, "%s=%s", name, value); - putenv(buf); + failed = putenv(buf); /* putenv() doesn't handle empty value */ if (!*value) - SetEnvironmentVariable(name,value); + failed = !SetEnvironmentVariable(name,value); } else { len = strlen(name) + 1 + 1; buf = ALLOCA_N(char, len); snprintf(buf, len, "%s=", name); putenv(buf); - SetEnvironmentVariable(name, 0); + failed = !SetEnvironmentVariable(name, 0); + } + if (failed) { + rb_warn("failed to set environment variable. Ruby 1.9.3 will raise SystemCallError in this case."); } #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) #undef setenv |