ruby-changes:46079
From: nobu <ko1@a...>
Date: Mon, 27 Mar 2017 22:15:54 +0900 (JST)
Subject: [ruby-changes:46079] nobu:r58150 (trunk): error.c: warning functions
nobu 2017-03-27 22:15:48 +0900 (Mon, 27 Mar 2017) New Revision: 58150 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58150 Log: error.c: warning functions * error.c: define warning functions in all combinations of * no errno, system errno, argument * without/with encoding * enabled/disabled by default Modified files: trunk/error.c trunk/internal.h Index: internal.h =================================================================== --- internal.h (revision 58149) +++ internal.h (revision 58150) @@ -1100,9 +1100,17 @@ VALUE rb_check_backtrace(VALUE); https://github.com/ruby/ruby/blob/trunk/internal.h#L1100 NORETURN(void rb_async_bug_errno(const char *,int)); const char *rb_builtin_type_name(int t); const char *rb_builtin_class_name(VALUE x); +PRINTF_ARGS(void rb_sys_warn(const char *fmt, ...), 1, 2); +PRINTF_ARGS(void rb_syserr_warn(int err, const char *fmt, ...), 2, 3); PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3); +PRINTF_ARGS(void rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3); +PRINTF_ARGS(void rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...), 3, 4); +PRINTF_ARGS(void rb_sys_warning(const char *fmt, ...), 1, 2); +PRINTF_ARGS(void rb_syserr_warning(int err, const char *fmt, ...), 2, 3); PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3); PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3); +PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4); + VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method); #define rb_name_err_raise_str(mesg, recv, name) \ rb_exc_raise(rb_name_err_new(mesg, recv, name)) Index: error.c =================================================================== --- error.c (revision 58149) +++ error.c (revision 58150) @@ -2388,6 +2388,52 @@ syserr_warning(VALUE mesg, int err) https://github.com/ruby/ruby/blob/trunk/error.c#L2388 rb_write_warning_str(mesg); } +#if 0 +void +rb_sys_warn(const char *fmt, ...) +{ + if (!NIL_P(ruby_verbose)) { + int errno_save = errno; + with_warning_string(mesg, 0, fmt) { + syserr_warning(mesg, errno_save); + } + errno = errno_save; + } +} + +void +rb_syserr_warn(int err, const char *fmt, ...) +{ + if (!NIL_P(ruby_verbose)) { + with_warning_string(mesg, 0, fmt) { + syserr_warning(mesg, err); + } + } +} + +void +rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...) +{ + if (!NIL_P(ruby_verbose)) { + int errno_save = errno; + with_warning_string(mesg, enc, fmt) { + syserr_warning(mesg, errno_save); + } + errno = errno_save; + } +} + +void +rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...) +{ + if (!NIL_P(ruby_verbose)) { + with_warning_string(mesg, enc, fmt) { + syserr_warning(mesg, err); + } + } +} +#endif + void rb_sys_warning(const char *fmt, ...) { @@ -2400,6 +2446,18 @@ rb_sys_warning(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/error.c#L2446 } } +#if 0 +void +rb_syserr_warning(int err, const char *fmt, ...) +{ + if (RTEST(ruby_verbose)) { + with_warning_string(mesg, 0, fmt) { + syserr_warning(mesg, err); + } + } +} +#endif + void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...) { @@ -2412,6 +2470,18 @@ rb_sys_enc_warning(rb_encoding *enc, con https://github.com/ruby/ruby/blob/trunk/error.c#L2470 } } +#if 0 +void +rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...) +{ + if (RTEST(ruby_verbose)) { + with_warning_string(mesg, enc, fmt) { + syserr_warning(mesg, err); + } + } +} +#endif + void rb_load_fail(VALUE path, const char *err) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/