diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | dir.c | 2 | ||||
-rw-r--r-- | file.c | 17 | ||||
-rw-r--r-- | internal.h | 7 | ||||
-rw-r--r-- | io.c | 15 |
5 files changed, 21 insertions, 25 deletions
@@ -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 @@ -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 @@ -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); @@ -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); |