summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-28 11:48:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-28 11:48:45 +0000
commit754b3342fe3660a14b90c7514312fcfbb45dcc29 (patch)
tree78ff40b059385576fa85bdee6ebda7344150a334 /file.c
parentd93855e6ef372d892cc6770c64a289ebbbe4d163 (diff)
file.c: syserr_fail2_in
* file.c (syserr_fail2_in): pass errno from callers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/file.c b/file.c
index f4ba59acc3..01f00bfe23 100644
--- a/file.c
+++ b/file.c
@@ -2694,13 +2694,14 @@ rb_file_s_utime(int argc, VALUE *argv)
}
#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, VALUE s2)
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, VALUE s2)
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, VALUE to)
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, VALUE to)
return INT2FIX(0);
}
#endif
- sys_fail2(from, to);
+ syserr_fail2(e, from, to);
}
return INT2FIX(0);