[前][次][番号順一覧][スレッド一覧]

ruby-changes:29468

From: nobu <ko1@a...>
Date: Fri, 21 Jun 2013 14:33:01 +0900 (JST)
Subject: [ruby-changes:29468] nobu:r41520 (trunk): hash.c: refine error message

nobu	2013-06-21 14:31:41 +0900 (Fri, 21 Jun 2013)

  New Revision: 41520

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41520

  Log:
    hash.c: refine error message
    
    * hash.c (ruby_setenv): refine error message so include the variable
      name.

  Modified files:
    trunk/ChangeLog
    trunk/hash.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41519)
+++ ChangeLog	(revision 41520)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun 21 14:31:29 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* hash.c (ruby_setenv): refine error message so include the variable
+	  name.
+
 Fri Jun 21 14:15:08 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c: fix to use total_allocated_object_num and heaps_used
Index: hash.c
===================================================================
--- hash.c	(revision 41519)
+++ hash.c	(revision 41520)
@@ -2489,8 +2489,7 @@ ruby_setenv(const char *name, const char https://github.com/ruby/ruby/blob/trunk/hash.c#L2489
     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 https://github.com/ruby/ruby/blob/trunk/hash.c#L2517
 #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 https://github.com/ruby/ruby/blob/trunk/hash.c#L2544
 	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? */
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]