summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-26 08:11:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-26 08:11:32 +0000
commitec7833ef3617eb9c2812503283732bd182c70e84 (patch)
tree28f42e366d0d7d45f4839a49d644a99b67aca02d /error.c
parent6c8852c1d3672cbf61ed5fd1b79fd73d8df87e13 (diff)
error.c: splat warn arguments
* error.c (rb_warn_m): print array arguments with splatting. it is often used with `caller`. [ruby-core:80849] [Feature #12944] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/error.c b/error.c
index 0ca6544bac..6603ee075b 100644
--- a/error.c
+++ b/error.c
@@ -302,18 +302,7 @@ static VALUE
rb_warn_m(int argc, VALUE *argv, VALUE exc)
{
if (!NIL_P(ruby_verbose) && argc > 0) {
- int i;
- VALUE str;
- for (i = 0; i < argc; i++) {
- str = rb_obj_as_string(argv[i]);
- if (RSTRING_LEN(str) == 0) {
- str = rb_default_rs;
- }
- else if (!rb_str_end_with_asciichar(str, '\n')) {
- str = rb_str_cat(rb_str_dup(str), "\n", 1);
- }
- rb_write_warning_str(str);
- }
+ rb_io_puts(argc, argv, rb_mWarning);
}
return Qnil;
}
@@ -2187,6 +2176,7 @@ Init_Exception(void)
rb_mWarning = rb_define_module("Warning");
rb_define_method(rb_mWarning, "warn", rb_warning_s_warn, 1);
+ rb_define_method(rb_mWarning, "write", rb_warning_s_warn, 1);
rb_extend_object(rb_mWarning, rb_mWarning);
rb_define_global_function("warn", rb_warn_m, -1);