зеркало из https://github.com/github/ruby.git
[Bug #19635] Preserve `errno`
The following functions are turned into macros and no longer can be used as expressions in core. - rb_sys_fail - rb_sys_fail_str - rb_sys_fail_path
This commit is contained in:
Родитель
a1b01e7701
Коммит
e3385f8783
2
error.c
2
error.c
|
@ -3312,12 +3312,14 @@ rb_syserr_fail_str(int e, VALUE mesg)
|
|||
rb_exc_raise(rb_syserr_new_str(e, mesg));
|
||||
}
|
||||
|
||||
#undef rb_sys_fail
|
||||
void
|
||||
rb_sys_fail(const char *mesg)
|
||||
{
|
||||
rb_exc_raise(make_errno_exc(mesg));
|
||||
}
|
||||
|
||||
#undef rb_sys_fail_str
|
||||
void
|
||||
rb_sys_fail_str(VALUE mesg)
|
||||
{
|
||||
|
|
|
@ -29,15 +29,31 @@
|
|||
#define rb_raise_static(e, m) \
|
||||
rb_raise_cstr_i((e), rb_str_new_static((m), rb_strlen_lit(m)))
|
||||
#ifdef RUBY_FUNCTION_NAME_STRING
|
||||
# define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
|
||||
# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
|
||||
# define rb_syserr_new_path(err, path) rb_syserr_new_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
|
||||
#else
|
||||
# define rb_sys_fail_path(path) rb_sys_fail_str(path)
|
||||
# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
|
||||
# define rb_syserr_new_path(err, path) rb_syserr_new_str((err), (path))
|
||||
#endif
|
||||
|
||||
#define rb_sys_fail(mesg) \
|
||||
do { \
|
||||
int errno_to_fail = errno; \
|
||||
rb_syserr_fail(errno_to_fail, (mesg)); \
|
||||
} while (0)
|
||||
|
||||
#define rb_sys_fail_str(mesg) \
|
||||
do { \
|
||||
int errno_to_fail = errno; \
|
||||
rb_syserr_fail_str(errno_to_fail, (mesg)); \
|
||||
} while (0)
|
||||
|
||||
#define rb_sys_fail_path(path) \
|
||||
do { \
|
||||
int errno_to_fail = errno; \
|
||||
rb_syserr_fail_path(errno_to_fail, (path)); \
|
||||
} while (0)
|
||||
|
||||
/* error.c */
|
||||
extern long rb_backtrace_length_limit;
|
||||
extern VALUE rb_eEAGAIN;
|
||||
|
|
Загрузка…
Ссылка в новой задаче