summaryrefslogtreecommitdiff
path: root/file.c
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 /file.c
parentbfd52c985ccc3b2e245c87c197d73150d2b8d5df (diff)
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
Diffstat (limited to 'file.c')
-rw-r--r--file.c17
1 files changed, 9 insertions, 8 deletions
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 */