* 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
This commit is contained in:
nobu 2015-08-28 11:48:45 +00:00
Родитель d93855e6ef
Коммит 754b3342fe
1 изменённых файлов: 11 добавлений и 9 удалений

20
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);