Project

General

Profile

Feature #12944 ยป 0001-Change-Kernel-warn-to-call-Warning.warn.patch

jeremyevans0 (Jeremy Evans), 11/26/2016 03:55 AM

View differences:

error.c
276 276
 * call-seq:
277 277
 *    warn(msg, ...)   -> nil
278 278
 *
279
 * Displays each of the given messages followed by a record separator on
280
 * STDERR unless warnings have been disabled (for example with the
281
 * <code>-W0</code> flag).
282
 *
279
 * If warnings have been disabled (for example with the
280
 * <code>-W0</code> flag), does nothing.  Otherwise, 
281
 * converts each of the messages to strings, appends a newline
282
 * character to the string if the string does not end in a newline,
283
 * and calls <code>Warning.warn</code> with the string.
284
 * 
283 285
 *    warn("warning 1", "warning 2")
284 286
 *
285 287
 *  <em>produces:</em>
......
292 294
rb_warn_m(int argc, VALUE *argv, VALUE exc)
293 295
{
294 296
    if (!NIL_P(ruby_verbose) && argc > 0) {
295
	rb_io_puts(argc, argv, rb_stderr);
297
	int i;
298
	VALUE str;
299
	long len;
300
	const char *ptr;
301
	for(i = 0; i < argc; i++) {
302
	    str = rb_obj_as_string(argv[i]);
303
	    len = RSTRING_LEN(str);
304
	    ptr = RSTRING_PTR(str);
305
	    if (len == 0 || ptr[len-1] != '\n') {
306
		str = rb_str_cat(rb_str_dup(str), "\n", 1);
307
	    }
308
	    rb_write_warning_str(str);
309
	}
296 310
    }
297 311
    return Qnil;
298 312
}
299
-