Project

General

Profile

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

jeremyevans0 (Jeremy Evans), 11/26/2016 07:46 AM

View differences:

error.c
38 38

  
39 39
VALUE rb_iseqw_local_variables(VALUE iseqval);
40 40
VALUE rb_iseqw_new(const rb_iseq_t *);
41
int str_end_with_asciichar(VALUE str, int c);
41 42

  
42 43
VALUE rb_eEAGAIN;
43 44
VALUE rb_eEWOULDBLOCK;
......
276 277
 * call-seq:
277 278
 *    warn(msg, ...)   -> nil
278 279
 *
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
 *
280
 * If warnings have been disabled (for example with the
281
 * <code>-W0</code> flag), does nothing.  Otherwise, 
282
 * converts each of the messages to strings, appends a newline
283
 * character to the string if the string does not end in a newline,
284
 * and calls <code>Warning.warn</code> with the string.
285
 * 
283 286
 *    warn("warning 1", "warning 2")
284 287
 *
285 288
 *  <em>produces:</em>
......
292 295
rb_warn_m(int argc, VALUE *argv, VALUE exc)
293 296
{
294 297
    if (!NIL_P(ruby_verbose) && argc > 0) {
295
	rb_io_puts(argc, argv, rb_stderr);
298
	int i;
299
	VALUE str;
300
	for(i = 0; i < argc; i++) {
301
	    str = rb_obj_as_string(argv[i]);
302
	    if (RSTRING_LEN(str) == 0 || !str_end_with_asciichar(str, '\n')) {
303
		str = rb_str_cat(rb_str_dup(str), "\n", 1);
304
	    }
305
	    rb_write_warning_str(str);
306
	}
296 307
    }
297 308
    return Qnil;
298 309
}
io.c
7123 7123
}
7124 7124

  
7125 7125

  
7126
static int
7126
int
7127 7127
str_end_with_asciichar(VALUE str, int c)
7128 7128
{
7129 7129
    long len = RSTRING_LEN(str);
7130
-