From b5c27d1cabde475d6fe6306e927707f10442af0e Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 15 Nov 2010 11:43:27 +0000 Subject: 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 --- hash.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 84d9eb3aec..7774aacc53 100644 --- a/hash.c +++ b/hash.c @@ -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 -- cgit v1.2.3