diff options
author | Nobuyoshi Nakada <[email protected]> | 2019-12-17 17:17:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-12-19 09:52:17 +0900 |
commit | c6c67254fb17b3196a7b0d3fda4650f6b20a467d (patch) | |
tree | 8991858d6822ea27d9bc492080d2af00236c5ea5 /error.c | |
parent | 7aa8a786740fd84bd718b0c055f190b25a8f0277 (diff) |
Added rb_warn_deprecated
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -325,6 +325,22 @@ rb_enc_warning(rb_encoding *enc, const char *fmt, ...) } #endif +void +rb_warn_deprecated(const char *fmt, const char *suggest, ...) +{ + if (NIL_P(ruby_verbose)) return; + if (!rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) return; + va_list args; + va_start(args, suggest); + VALUE mesg = warning_string(0, fmt, args); + va_end(args); + rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1); + rb_str_cat_cstr(mesg, " is deprecated"); + if (suggest) rb_str_catf(mesg, "; use %s instead", suggest); + rb_str_cat_cstr(mesg, "\n"); + rb_write_warning_str(mesg); +} + static inline int end_with_asciichar(VALUE str, int c) { |