コード例 #1
0
ファイル: error.c プロジェクト: gogotanaka/ruby_svn
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);
}
コード例 #2
0
void
rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...)
{
    VALUE mesg;
    va_list args;
    int errno_save;

    errno_save = errno;

    if (!RTEST(ruby_verbose)) return;

    va_start(args, fmt);
    mesg = warning_string(enc, fmt, args);
    va_end(args);
    rb_str_set_len(mesg, RSTRING_LEN(mesg)-1);
    rb_str_catf(mesg, ": %s\n", strerror(errno_save));
    rb_write_error_str(mesg);
    errno = errno_save;
}