static VALUE warning_string(rb_encoding *enc, const char *fmt, va_list args) { VALUE str = rb_enc_str_new(0, 0, enc); VALUE file = rb_sourcefilename(); if (!NIL_P(file)) { int line = rb_sourceline(); str = rb_str_append(str, file); if (line) rb_str_catf(str, ":%d", line); rb_str_cat2(str, ": "); } rb_str_cat2(str, "warning: "); rb_str_vcatf(str, fmt, args); rb_str_cat2(str, "\n"); return str; }
static void warn_print(const char *fmt, va_list args) { VALUE str = rb_str_new(0, 0); VALUE file = rb_sourcefilename(); if (!NIL_P(file)) { int line = rb_sourceline(); str = rb_str_append(str, file); if (line) rb_str_catf(str, ":%d", line); rb_str_cat2(str, ": "); } rb_str_cat2(str, "warning: "); rb_str_vcatf(str, fmt, args); rb_str_cat2(str, "\n"); rb_write_error_str(str); }
static void error_pos(void) { VALUE sourcefile = rb_sourcefilename(); int sourceline = rb_sourceline(); if (sourcefile) { ID caller_name; if (sourceline == 0) { warn_printf("%"PRIsVALUE, sourcefile); } else if ((caller_name = rb_frame_callee()) != 0) { warn_printf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'", sourcefile, sourceline, rb_id2str(caller_name)); } else { warn_printf("%"PRIsVALUE":%d", sourcefile, sourceline); } } }