File tree 5 files changed +21
-25
lines changed
5 files changed +21
-25
lines changed Original file line number Diff line number Diff line change
1
+ Fri Mar 15 14:51:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
2
+
3
+ * file.c (rb_sys_fail_path_with_func): share same function, and path
4
+ may be nil.
5
+
1
6
Fri Mar 15 08:24:51 2013 NARUSE, Yui <naruse@ruby-lang.org>
2
7
3
8
* file.c (rb_sys_fail_path): define & use rb_sys_fail_path0 like r39752
Original file line number Diff line number Diff line change @@ -79,8 +79,6 @@ char *strchr(char*,char);
79
79
#define opendir (p ) rb_w32_uopendir(p)
80
80
#endif
81
81
82
- #define rb_sys_fail_path (path ) rb_sys_fail_str(path)
83
-
84
82
#define FNM_NOESCAPE 0x01
85
83
#define FNM_PATHNAME 0x02
86
84
#define FNM_DOTMATCH 0x04
Original file line number Diff line number Diff line change @@ -103,18 +103,19 @@ int flock(int, int);
103
103
#endif
104
104
105
105
#ifdef RUBY_FUNCTION_NAME_STRING
106
- # define rb_sys_fail_path (path ) rb_sys_fail_path0(RUBY_FUNCTION_NAME_STRING, path)
107
- NORETURN (static void rb_sys_fail_path0 (const char * ,VALUE ));
108
- static void
109
- rb_sys_fail_path0 (const char * func_name , VALUE path )
106
+ void
107
+ rb_sys_fail_path_with_func (const char * func_name , VALUE path )
110
108
{
111
109
VALUE mesg = rb_str_new_cstr (func_name );
112
- rb_str_buf_cat2 (mesg , ": " );
113
- rb_str_buf_append (mesg , path );
110
+ if (!NIL_P (path )) {
111
+ /* RUBY_FUNCTION_NAME_STRING, aka __func__/__FUNCTION__ is not a
112
+ * preprocessor macro but a static constant array, so string
113
+ * literal concatenation is not allowed */
114
+ rb_str_buf_cat2 (mesg , ": " );
115
+ rb_str_buf_append (mesg , path );
116
+ }
114
117
rb_sys_fail_str (mesg );
115
118
}
116
- #else
117
- # define rb_sys_fail_path (path ) rb_sys_fail_str(path)
118
119
#endif
119
120
120
121
#if defined(__BEOS__ ) || defined(__HAIKU__ ) /* should not change ID if -1 */
Original file line number Diff line number Diff line change @@ -122,6 +122,13 @@ VALUE rb_get_path_check_to_string(VALUE, int);
122
122
VALUE rb_get_path_check_convert (VALUE , VALUE , int );
123
123
void Init_File (void );
124
124
125
+ #ifdef RUBY_FUNCTION_NAME_STRING
126
+ NORETURN (void rb_sys_fail_path_with_func (const char * func_name , VALUE path ));
127
+ # define rb_sys_fail_path (path ) rb_sys_fail_path_with_func(RUBY_FUNCTION_NAME_STRING, path)
128
+ #else
129
+ # define rb_sys_fail_path (path ) rb_sys_fail_str(path)
130
+ #endif
131
+
125
132
#ifdef _WIN32
126
133
/* file.c, win32/file.c */
127
134
void rb_w32_init_file (void );
Original file line number Diff line number Diff line change @@ -399,21 +399,6 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
399
399
# endif
400
400
#endif
401
401
402
- #ifdef RUBY_FUNCTION_NAME_STRING
403
- # define rb_sys_fail_path (path ) rb_sys_fail_path0(RUBY_FUNCTION_NAME_STRING, path)
404
- NORETURN (static void rb_sys_fail_path0 (const char * ,VALUE ));
405
- static void
406
- rb_sys_fail_path0 (const char * func_name , VALUE path )
407
- {
408
- VALUE mesg = rb_str_new_cstr (func_name );
409
- rb_str_buf_cat2 (mesg , ": " );
410
- rb_str_buf_append (mesg , path );
411
- rb_sys_fail_str (mesg );
412
- }
413
- #else
414
- # define rb_sys_fail_path (path ) rb_sys_fail_str(path)
415
- #endif
416
-
417
402
static int io_fflush (rb_io_t * );
418
403
static rb_io_t * flush_before_seek (rb_io_t * fptr );
419
404
You can’t perform that action at this time.
0 commit comments