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
This commit is contained in:
parent
6c8852c1d3
commit
ec7833ef36
14
error.c
14
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user