Project

General

Profile

Feature #12026 » 0001-Support-warning-filters.patch

jeremyevans0 (Jeremy Evans), 01/26/2016 10:12 PM

View differences:

error.c
}
static void
rb_write_warning_str(VALUE str)
{
VALUE filter = rb_gv_get("$WARNING_FILTER");
if (RB_TYPE_P(filter, T_REGEXP) && !NIL_P(rb_reg_match(filter, str)))
return;
rb_write_error_str(str);
}
static void
compile_warn_print(const char *file, int line, const char *fmt, va_list args)
{
VALUE str;
str = compile_snprintf(NULL, "warning: ", file, line, fmt, args);
rb_str_cat2(str, "\n");
rb_write_error_str(str);
rb_write_warning_str(str);
}
void
......
va_start(args, fmt);
mesg = warning_string(0, fmt, args);
va_end(args);
rb_write_error_str(mesg);
rb_write_warning_str(mesg);
}
void
......
va_start(args, fmt);
mesg = warning_string(enc, fmt, args);
va_end(args);
rb_write_error_str(mesg);
rb_write_warning_str(mesg);
}
/* rb_warning() reports only in verbose mode */
......
va_start(args, fmt);
mesg = warning_string(0, fmt, args);
va_end(args);
rb_write_error_str(mesg);
rb_write_warning_str(mesg);
}
#if 0
......
va_start(args, fmt);
mesg = warning_string(enc, fmt, args);
va_end(args);
rb_write_error_str(mesg);
rb_write_warning_str(mesg);
}
#endif
......
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);
rb_write_warning_str(mesg);
errno = errno_save;
}
......
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);
rb_write_warning_str(mesg);
errno = errno_save;
}
......
Init_syserr(void)
{
rb_eNOERROR = set_syserr(0, "NOERROR");
rb_gv_set("$WARNING_FILTER", Qnil);
#define defined_error(name, num) set_syserr((num), (name));
#define undefined_error(name) set_syserr(0, (name));
#include "known_errors.inc"
test/ruby/test_module.rb
end
end
def test_uninitialized_instance_variable_warning_filter
a = AttrTest.new
$WARNING_FILTER = /instance variable @ivar not initialized/
assert_warning '' do
assert_nil(a.ivar)
end
ensure
$WARNING_FILTER = nil
end
def test_uninitialized_attr
a = AttrTest.new
assert_warning '' do
(1-1/2)