Project

General

Profile

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

Use rb_ary_join - jeremyevans0 (Jeremy Evans), 12/13/2016 04:23 PM

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
 * joins all strings with a newline, makes sure
283
 * the resulting string ends with a newline, and calls
284
 * <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
	VALUE str;
299
	str = rb_ary_new_from_values(argc, argv);
300
	str = rb_ary_join(str, rb_str_new("\n", 1));
301
	if (RSTRING_LEN(str) == 0 || !str_end_with_asciichar(str, '\n')) {
302
	    rb_str_cat(str, "\n", 1);
303
	}
304
	rb_write_warning_str(str);
296 305
    }
297 306
    return Qnil;
298 307
}
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
-