summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--dir.c12
-rw-r--r--file.c33
-rw-r--r--io.c4
4 files changed, 30 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e9fc5180d..69cdabcfcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Feb 24 16:37:45 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dir.c, file.c, io.c: use rb_sys_fail_path.
+
Fri Feb 24 15:49:07 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (__builtin_unreachable): check for clang.
diff --git a/dir.c b/dir.c
index a97f994cab..fdf1672b12 100644
--- a/dir.c
+++ b/dir.c
@@ -75,6 +75,8 @@ char *strchr(char*,char);
#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 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
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 @@ static void
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 @@ dir_s_chroot(VALUE dir, VALUE path)
{
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 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
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 @@ dir_s_rmdir(VALUE obj, VALUE dir)
{
check_dirname(&dir);
if (rmdir(RSTRING_PTR(dir)) < 0)
- rb_sys_fail(RSTRING_PTR(dir));
+ rb_sys_fail_path(dir);
return INT2FIX(0);
}
diff --git a/file.c b/file.c
index 5f0b6f3b5d..64efe07294 100644
--- a/file.c
+++ b/file.c
@@ -94,6 +94,8 @@ int flock(int, int);
#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_file_s_stat(VALUE klass, VALUE fname)
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_stat(VALUE obj)
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 @@ rb_file_s_lstat(VALUE klass, VALUE fname)
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 @@ rb_file_s_size(VALUE klass, VALUE fname)
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 @@ rb_file_s_ftype(VALUE klass, VALUE fname)
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 @@ rb_file_s_atime(VALUE klass, VALUE fname)
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 @@ rb_file_s_mtime(VALUE klass, VALUE fname)
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 @@ rb_file_s_ctime(VALUE klass, VALUE fname)
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 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
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 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
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 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
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 @@ rb_f_test(int argc, VALUE *argv)
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 @@ rb_stat_init(VALUE obj, VALUE fname)
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));
diff --git a/io.c b/io.c
index 223e29ee07..6c7cf2523d 100644
--- a/io.c
+++ b/io.c
@@ -4968,7 +4968,7 @@ rb_sysopen(VALUE fname, int oflags, mode_t perm)
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 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode,
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