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

ruby-changes:39637

From: nobu <ko1@a...>
Date: Fri, 28 Aug 2015 20:48:59 +0900 (JST)
Subject: [ruby-changes:39637] nobu:r51718 (trunk): file.c: syserr_fail2_in

nobu	2015-08-28 20:48:45 +0900 (Fri, 28 Aug 2015)

  New Revision: 51718

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

  Log:
    file.c: syserr_fail2_in
    
    * file.c (syserr_fail2_in): pass errno from callers.

  Modified files:
    trunk/file.c
Index: file.c
===================================================================
--- file.c	(revision 51717)
+++ file.c	(revision 51718)
@@ -2694,13 +2694,14 @@ rb_file_s_utime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/file.c#L2694
 }
 
 #ifdef RUBY_FUNCTION_NAME_STRING
-# define sys_fail2(s1, s2) sys_fail2_in(RUBY_FUNCTION_NAME_STRING, s1, s2)
+# define syserr_fail2(e, s1, s2) syserr_fail2_in(RUBY_FUNCTION_NAME_STRING, e, s1, s2)
 #else
-# define sys_fail2_in(func, s1, s2) sys_fail2(s1, s2)
+# define syserr_fail2_in(func, e, s1, s2) syserr_fail2(e, s1, s2)
 #endif
-NORETURN(static void sys_fail2_in(const char *,VALUE,VALUE));
+#define sys_fail2(s1, s2) syserr_fail2(errno, s1, s2)
+NORETURN(static void syserr_fail2_in(const char *,int,VALUE,VALUE));
 static void
-sys_fail2_in(const char *func, VALUE s1, VALUE s2)
+syserr_fail2_in(const char *func, int e, VALUE s1, VALUE s2)
 {
     VALUE str;
 #ifdef MAX_PATH
@@ -2709,7 +2710,7 @@ sys_fail2_in(const char *func, VALUE s1, https://github.com/ruby/ruby/blob/trunk/file.c#L2710
     const int max_pathlen = MAXPATHLEN;
 #endif
 
-    if (errno == EEXIST) {
+    if (e == EEXIST) {
 	rb_sys_fail_path(rb_str_ellipsize(s2, max_pathlen));
     }
     str = rb_str_new_cstr("(");
@@ -2718,9 +2719,9 @@ sys_fail2_in(const char *func, VALUE s1, https://github.com/ruby/ruby/blob/trunk/file.c#L2719
     rb_str_append(str, rb_str_ellipsize(s2, max_pathlen));
     rb_str_cat2(str, ")");
 #ifdef RUBY_FUNCTION_NAME_STRING
-    rb_sys_fail_path_in(func, str);
+    rb_syserr_fail_path_in(func, e, str);
 #else
-    rb_sys_fail_path(str);
+    rb_syserr_fail_path(e, str);
 #endif
 }
 
@@ -2889,8 +2890,9 @@ rb_file_s_rename(VALUE klass, VALUE from https://github.com/ruby/ruby/blob/trunk/file.c#L2890
     errno = 0;
 #endif
     if (rename(src, dst) < 0) {
+	int e = errno;
 #if defined DOSISH
-	switch (errno) {
+	switch (e) {
 	  case EEXIST:
 #if defined (__EMX__)
 	  case EACCES:
@@ -2901,7 +2903,7 @@ rb_file_s_rename(VALUE klass, VALUE from https://github.com/ruby/ruby/blob/trunk/file.c#L2903
 		return INT2FIX(0);
 	}
 #endif
-	sys_fail2(from, to);
+	syserr_fail2(e, from, to);
     }
 
     return INT2FIX(0);

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

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