ruby-changes:22737
From: nobu <ko1@a...>
Date: Fri, 24 Feb 2012 16:38:00 +0900 (JST)
Subject: [ruby-changes:22737] nobu:r34786 (trunk): * dir.c, file.c, io.c: use rb_sys_fail_path.
nobu 2012-02-24 16:37:48 +0900 (Fri, 24 Feb 2012) New Revision: 34786 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34786 Log: * dir.c, file.c, io.c: use rb_sys_fail_path. Modified files: trunk/ChangeLog trunk/dir.c trunk/file.c trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34785) +++ ChangeLog (revision 34786) @@ -1,3 +1,7 @@ +Fri Feb 24 16:37:45 2012 Nobuyoshi Nakada <nobu@r...> + + * dir.c, file.c, io.c: use rb_sys_fail_path. + Fri Feb 24 15:49:07 2012 Nobuyoshi Nakada <nobu@r...> * configure.in (__builtin_unreachable): check for clang. Index: io.c =================================================================== --- io.c (revision 34785) +++ io.c (revision 34786) @@ -4968,7 +4968,7 @@ fd = rb_sysopen_internal(&data); } if (fd < 0) { - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } } return fd; @@ -5635,7 +5635,7 @@ fp = popen(cmd, modestr); if (eargp) rb_run_exec_options(&sarg, NULL); - if (!fp) rb_sys_fail(RSTRING_PTR(prog)); + if (!fp) rb_sys_fail_path(prog); fd = fileno(fp); #endif Index: dir.c =================================================================== --- dir.c (revision 34785) +++ dir.c (revision 34786) @@ -75,6 +75,8 @@ #define opendir(p) rb_w32_uopendir(p) #endif +#define rb_sys_fail_path(path) rb_sys_fail(RSTRING_PTR(path)) + #define FNM_NOESCAPE 0x01 #define FNM_PATHNAME 0x02 #define FNM_DOTMATCH 0x04 @@ -414,7 +416,7 @@ dp->dir = opendir(RSTRING_PTR(dirname)); } if (dp->dir == NULL) { - rb_sys_fail(RSTRING_PTR(dirname)); + rb_sys_fail_path(dirname); } } dp->path = rb_str_dup_frozen(dirname); @@ -750,7 +752,7 @@ dir_chdir(VALUE path) { if (chdir(RSTRING_PTR(path)) < 0) - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); } static int chdir_blocking = 0; @@ -927,7 +929,7 @@ { check_dirname(&path); if (chroot(RSTRING_PTR(path)) == -1) - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); return INT2FIX(0); } @@ -965,7 +967,7 @@ check_dirname(&path); if (mkdir(RSTRING_PTR(path), mode) == -1) - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); return INT2FIX(0); } @@ -984,7 +986,7 @@ { check_dirname(&dir); if (rmdir(RSTRING_PTR(dir)) < 0) - rb_sys_fail(RSTRING_PTR(dir)); + rb_sys_fail_path(dir); return INT2FIX(0); } Index: file.c =================================================================== --- file.c (revision 34785) +++ file.c (revision 34786) @@ -94,6 +94,8 @@ #define STAT(p, s) stat((p), (s)) #endif +#define rb_sys_fail_path(path) rb_sys_fail(NIL_P(path) ? 0 : RSTRING_PTR(path)) + #if defined(__BEOS__) || defined(__HAIKU__) /* should not change ID if -1 */ static int be_chown(const char *path, uid_t owner, gid_t group) @@ -879,7 +881,7 @@ rb_secure(4); FilePathValue(fname); if (rb_stat(fname, &st) < 0) { - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return stat_new(&st); } @@ -905,7 +907,6 @@ rb_io_t *fptr; struct stat st; -#define rb_sys_fail_path(path) rb_sys_fail(NIL_P(path) ? 0 : RSTRING_PTR(path)) GetOpenFile(obj, fptr); if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); @@ -937,7 +938,7 @@ FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (lstat(StringValueCStr(fname), &st) == -1) { - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return stat_new(&st); #else @@ -1706,7 +1707,7 @@ if (rb_stat(fname, &st) < 0) { FilePathValue(fname); - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return OFFT2NUM(st.st_size); } @@ -1776,7 +1777,7 @@ FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (lstat(StringValueCStr(fname), &st) == -1) { - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return rb_file_ftype(&st); @@ -1799,7 +1800,7 @@ if (rb_stat(fname, &st) < 0) { FilePathValue(fname); - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return stat_atime(&st); } @@ -1845,7 +1846,7 @@ if (rb_stat(fname, &st) < 0) { FilePathValue(fname); - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return stat_mtime(&st); } @@ -1894,7 +1895,7 @@ if (rb_stat(fname, &st) < 0) { FilePathValue(fname); - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } return stat_ctime(&st); } @@ -3358,7 +3359,7 @@ if (!NIL_P(checkval)) { if (checkval == ID2SYM(resolving)) { errno = ELOOP; - rb_sys_fail(RSTRING_PTR(testpath)); + rb_sys_fail_path(testpath); } else { *resolvedp = rb_str_dup(checkval); @@ -3372,12 +3373,12 @@ if (ret == -1) { if (errno == ENOENT) { if (strict || !last || *unresolved_firstsep) - rb_sys_fail(RSTRING_PTR(testpath)); + rb_sys_fail_path(testpath); *resolvedp = testpath; break; } else { - rb_sys_fail(RSTRING_PTR(testpath)); + rb_sys_fail_path(testpath); } } #ifdef HAVE_READLINK @@ -4001,18 +4002,18 @@ path = rb_str_encode_ospath(path); #ifdef HAVE_TRUNCATE if (truncate(StringValueCStr(path), pos) < 0) - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); #else /* defined(HAVE_CHSIZE) */ { int tmpfd; if ((tmpfd = rb_cloexec_open(StringValueCStr(path), 0, 0)) < 0) { - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); } rb_update_max_fd(tmpfd); if (chsize(tmpfd, pos) < 0) { close(tmpfd); - rb_sys_fail(RSTRING_PTR(path)); + rb_sys_fail_path(path); } close(tmpfd); } @@ -4350,7 +4351,7 @@ CHECK(1); if (rb_stat(fname, &st) == -1) { FilePathValue(fname); - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } switch (cmd) { @@ -4439,7 +4440,7 @@ FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (STAT(StringValueCStr(fname), &st) == -1) { - rb_sys_fail(RSTRING_PTR(fname)); + rb_sys_fail_path(fname); } if (DATA_PTR(obj)) { xfree(DATA_PTR(obj)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/