aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-15 05:51:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-15 05:51:37 +0000
commit0d3d9eff4d59d36f1545c4fe9f00916bcfd417ac (patch)
tree572360a07d4b8376e197fb665e86874afbc80046
parentbfd52c985ccc3b2e245c87c197d73150d2b8d5df (diff)
downloadruby-0d3d9eff4d59d36f1545c4fe9f00916bcfd417ac.tar.gz
file.c: rb_sys_fail_path_with_func
* file.c (rb_sys_fail_path_with_func): share same function, and path may be nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--dir.c2
-rw-r--r--file.c17
-rw-r--r--internal.h7
-rw-r--r--io.c15
5 files changed, 21 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index db2fa79f82..e141b698db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Mar 15 14:51:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (rb_sys_fail_path_with_func): share same function, and path
+ may be nil.
+
Fri Mar 15 08:24:51 2013 NARUSE, Yui <naruse@ruby-lang.org>
* file.c (rb_sys_fail_path): define & use rb_sys_fail_path0 like r39752
diff --git a/dir.c b/dir.c
index 27f16ebc4b..5af16ea39a 100644
--- a/dir.c
+++ b/dir.c
@@ -79,8 +79,6 @@ char *strchr(char*,char);
#define opendir(p) rb_w32_uopendir(p)
#endif
-#define rb_sys_fail_path(path) rb_sys_fail_str(path)
-
#define FNM_NOESCAPE 0x01
#define FNM_PATHNAME 0x02
#define FNM_DOTMATCH 0x04
diff --git a/file.c b/file.c
index 5cc4b53c6a..6e30c067f3 100644
--- a/file.c
+++ b/file.c
@@ -103,18 +103,19 @@ int flock(int, int);
#endif
#ifdef RUBY_FUNCTION_NAME_STRING
-# define rb_sys_fail_path(path) rb_sys_fail_path0(RUBY_FUNCTION_NAME_STRING, path)
-NORETURN(static void rb_sys_fail_path0(const char *,VALUE));
-static void
-rb_sys_fail_path0(const char *func_name, VALUE path)
+void
+rb_sys_fail_path_with_func(const char *func_name, VALUE path)
{
VALUE mesg = rb_str_new_cstr(func_name);
- rb_str_buf_cat2(mesg, ": ");
- rb_str_buf_append(mesg, path);
+ if (!NIL_P(path)) {
+ /* RUBY_FUNCTION_NAME_STRING, aka __func__/__FUNCTION__ is not a
+ * preprocessor macro but a static constant array, so string
+ * literal concatenation is not allowed */
+ rb_str_buf_cat2(mesg, ": ");
+ rb_str_buf_append(mesg, path);
+ }
rb_sys_fail_str(mesg);
}
-#else
-# define rb_sys_fail_path(path) rb_sys_fail_str(path)
#endif
#if defined(__BEOS__) || defined(__HAIKU__) /* should not change ID if -1 */
diff --git a/internal.h b/internal.h
index bcc0b3667f..0902ac05c2 100644
--- a/internal.h
+++ b/internal.h
@@ -122,6 +122,13 @@ VALUE rb_get_path_check_to_string(VALUE, int);
VALUE rb_get_path_check_convert(VALUE, VALUE, int);
void Init_File(void);
+#ifdef RUBY_FUNCTION_NAME_STRING
+NORETURN(void rb_sys_fail_path_with_func(const char *func_name, VALUE path));
+# define rb_sys_fail_path(path) rb_sys_fail_path_with_func(RUBY_FUNCTION_NAME_STRING, path)
+#else
+# define rb_sys_fail_path(path) rb_sys_fail_str(path)
+#endif
+
#ifdef _WIN32
/* file.c, win32/file.c */
void rb_w32_init_file(void);
diff --git a/io.c b/io.c
index 837c1b6ded..f3dd3e3814 100644
--- a/io.c
+++ b/io.c
@@ -399,21 +399,6 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
# endif
#endif
-#ifdef RUBY_FUNCTION_NAME_STRING
-# define rb_sys_fail_path(path) rb_sys_fail_path0(RUBY_FUNCTION_NAME_STRING, path)
-NORETURN(static void rb_sys_fail_path0(const char *,VALUE));
-static void
-rb_sys_fail_path0(const char *func_name, VALUE path)
-{
- VALUE mesg = rb_str_new_cstr(func_name);
- rb_str_buf_cat2(mesg, ": ");
- rb_str_buf_append(mesg, path);
- rb_sys_fail_str(mesg);
-}
-#else
-# define rb_sys_fail_path(path) rb_sys_fail_str(path)
-#endif
-
static int io_fflush(rb_io_t *);
static rb_io_t *flush_before_seek(rb_io_t *fptr);