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

ruby-changes:44391

From: nobu <ko1@a...>
Date: Fri, 21 Oct 2016 16:40:52 +0900 (JST)
Subject: [ruby-changes:44391] nobu:r56464 (trunk): prefer rb_syserr_fail

nobu	2016-10-21 16:40:47 +0900 (Fri, 21 Oct 2016)

  New Revision: 56464

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

  Log:
    prefer rb_syserr_fail
    
    * dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over
      rb_sys_fail.
    
    * io.c (ruby_dup, rb_sysopen): ditto.

  Modified files:
    trunk/dir.c
    trunk/io.c
Index: io.c
===================================================================
--- io.c	(revision 56463)
+++ io.c	(revision 56464)
@@ -889,11 +889,12 @@ ruby_dup(int orig) https://github.com/ruby/ruby/blob/trunk/io.c#L889
 
     fd = rb_cloexec_dup(orig);
     if (fd < 0) {
-	if (rb_gc_for_fd(errno)) {
+	int e = errno;
+	if (rb_gc_for_fd(e)) {
 	    fd = rb_cloexec_dup(orig);
 	}
 	if (fd < 0) {
-	    rb_sys_fail(0);
+	    rb_syserr_fail(e, 0);
 	}
     }
     rb_update_max_fd(fd);
@@ -5468,11 +5469,12 @@ rb_sysopen(VALUE fname, int oflags, mode https://github.com/ruby/ruby/blob/trunk/io.c#L5469
 
     fd = rb_sysopen_internal(&data);
     if (fd < 0) {
-	if (rb_gc_for_fd(errno)) {
+	int e = errno;
+	if (rb_gc_for_fd(e)) {
 	    fd = rb_sysopen_internal(&data);
 	}
 	if (fd < 0) {
-	    rb_sys_fail_path(fname);
+	    rb_syserr_fail_path(e, fname);
 	}
     }
     return fd;
@@ -5488,19 +5490,19 @@ rb_fdopen(int fd, const char *modestr) https://github.com/ruby/ruby/blob/trunk/io.c#L5490
 #endif
     file = fdopen(fd, modestr);
     if (!file) {
+	int e = errno;
 #if defined(__sun)
-	if (errno == 0) {
+	if (e == 0) {
 	    rb_gc();
 	    errno = 0;
 	    file = fdopen(fd, modestr);
 	}
 	else
 #endif
-	if (rb_gc_for_fd(errno)) {
+	if (rb_gc_for_fd(e)) {
 	    file = fdopen(fd, modestr);
 	}
 	if (!file) {
-	    int e = errno;
 #ifdef _WIN32
 	    if (e == 0) e = EINVAL;
 #elif defined(__sun)
Index: dir.c
===================================================================
--- dir.c	(revision 56463)
+++ dir.c	(revision 56464)
@@ -526,11 +526,12 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L526
     path = RSTRING_PTR(dirname);
     dp->dir = opendir(path);
     if (dp->dir == NULL) {
-	if (rb_gc_for_fd(errno)) {
+	int e = errno;
+	if (rb_gc_for_fd(e)) {
 	    dp->dir = opendir(path);
 	}
 #ifdef HAVE_GETATTRLIST
-	else if (errno == EIO) {
+	else if (e == EIO) {
 	    u_int32_t attrbuf[1];
 	    struct attrlist al = {ATTR_BIT_MAP_COUNT, 0};
 	    if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) {
@@ -540,7 +541,7 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L541
 #endif
 	if (dp->dir == NULL) {
 	    RB_GC_GUARD(dirname);
-	    rb_sys_fail_path(orig);
+	    rb_syserr_fail_path(e, orig);
 	}
     }
     dp->path = orig;
@@ -752,7 +753,8 @@ dir_read(VALUE dir) https://github.com/ruby/ruby/blob/trunk/dir.c#L753
 	return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc);
     }
     else {
-	if (errno != 0) rb_sys_fail(0);
+	int e = errno;
+	if (e != 0) rb_syserr_fail(e, 0);
 	return Qnil;		/* end of stream */
     }
 }

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

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