summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-21 05:31:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-21 05:31:41 +0000
commit79031be8803e17a375fe72e7c7c6028771e672f8 (patch)
treec00e694b60bb139cba45bdd39b53dd5f782b302f /hash.c
parentb9c94bce7f4afd03d78d48062466aed56e6b820f (diff)
hash.c: refine error message
* hash.c (ruby_setenv): refine error message so include the variable name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/hash.c b/hash.c
index 40ccf9eef3..606dc4d5ac 100644
--- a/hash.c
+++ b/hash.c
@@ -2489,8 +2489,7 @@ ruby_setenv(const char *name, const char *value)
int failed = 0;
if (strchr(name, '=')) {
fail:
- errno = EINVAL;
- rb_sys_fail("ruby_setenv");
+ rb_syserr_fail_str(EINVAL, rb_sprintf("ruby_setenv(%s)", name));
}
if (value) {
const char* p = GetEnvironmentStringsA();
@@ -2518,21 +2517,20 @@ ruby_setenv(const char *name, const char *value)
#undef unsetenv
if (value) {
if (setenv(name, value, 1))
- rb_sys_fail("setenv");
+ rb_sys_fail_str(rb_sprintf("setenv(%s)", name));
} else {
#ifdef VOID_UNSETENV
unsetenv(name);
#else
if (unsetenv(name))
- rb_sys_fail("unsetenv");
+ rb_sys_fail_str(rb_sprintf("unsetenv(%s)", name));
#endif
}
#elif defined __sun
size_t len;
char **env_ptr, *str;
if (strchr(name, '=')) {
- errno = EINVAL;
- rb_sys_fail("ruby_setenv");
+ rb_syserr_fail_str(EINVAL, rb_sprintf("ruby_setenv(%s)", name));
}
len = strlen(name);
for (env_ptr = GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
@@ -2546,14 +2544,13 @@ ruby_setenv(const char *name, const char *value)
str = malloc(len += strlen(value) + 2);
snprintf(str, len, "%s=%s", name, value);
if (putenv(str))
- rb_sys_fail("putenv");
+ rb_sys_fail_str(rb_sprintf("putenv(%s)", name));
}
#else /* WIN32 */
size_t len;
int i;
if (strchr(name, '=')) {
- errno = EINVAL;
- rb_sys_fail("ruby_setenv");
+ rb_syserr_fail_str(EINVAL, rb_sprintf("ruby_setenv(%s)", name));
}
i=envix(name); /* where does it go? */