Feature #12944 » 0001-Change-Kernel-warn-to-call-Warning.warn.patch
| error.c | ||
|---|---|---|
|
* call-seq:
|
||
|
* warn(msg, ...) -> nil
|
||
|
*
|
||
|
* Displays each of the given messages followed by a record separator on
|
||
|
* STDERR unless warnings have been disabled (for example with the
|
||
|
* <code>-W0</code> flag).
|
||
|
*
|
||
|
* If warnings have been disabled (for example with the
|
||
|
* <code>-W0</code> flag), does nothing. Otherwise,
|
||
|
* converts each of the messages to strings, appends a newline
|
||
|
* character to the string if the string does not end in a newline,
|
||
|
* and calls <code>Warning.warn</code> with the string.
|
||
|
*
|
||
|
* warn("warning 1", "warning 2")
|
||
|
*
|
||
|
* <em>produces:</em>
|
||
| ... | ... | |
|
rb_warn_m(int argc, VALUE *argv, VALUE exc)
|
||
|
{
|
||
|
if (!NIL_P(ruby_verbose) && argc > 0) {
|
||
|
rb_io_puts(argc, argv, rb_stderr);
|
||
|
int i;
|
||
|
VALUE str;
|
||
|
long len;
|
||
|
const char *ptr;
|
||
|
for(i = 0; i < argc; i++) {
|
||
|
str = rb_obj_as_string(argv[i]);
|
||
|
len = RSTRING_LEN(str);
|
||
|
ptr = RSTRING_PTR(str);
|
||
|
if (len == 0 || ptr[len-1] != '\n') {
|
||
|
str = rb_str_cat(str, "\n", 1);
|
||
|
}
|
||
|
rb_write_warning_str(str);
|
||
|
}
|
||
|
}
|
||
|
return Qnil;
|
||
|
}
|
||