eval_error.c: reset attributes
* eval_error.c (print_errinfo): reset all attributes for each lines before newlines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b07e4af869
commit
1032f093cc
32
eval_error.c
32
eval_error.c
@ -152,14 +152,32 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
|
||||
if (highlight) write_warn(str, reset);
|
||||
write_warn2(str, "\n", 1);
|
||||
}
|
||||
if (tail) {
|
||||
int eol = einfo[elen-1] == '\n';
|
||||
if (eol && highlight) --elen;
|
||||
if (tail < einfo+elen) {
|
||||
if (highlight) write_warn(str, bold);
|
||||
if (tail && einfo+elen > tail) {
|
||||
if (!highlight) {
|
||||
write_warn2(str, tail, einfo+elen-tail);
|
||||
if (highlight) write_warn(str, reset);
|
||||
if (highlight || !eol) write_warn2(str, "\n", 1);
|
||||
if (einfo[elen-1] != '\n') write_warn2(str, "\n", 1);
|
||||
}
|
||||
else {
|
||||
elen -= tail - einfo;
|
||||
einfo = tail;
|
||||
while (elen > 0) {
|
||||
tail = memchr(einfo, '\n', elen);
|
||||
if (!tail || tail > einfo) {
|
||||
write_warn(str, bold);
|
||||
write_warn2(str, einfo, tail ? tail-einfo : elen);
|
||||
write_warn(str, reset);
|
||||
if (!tail) {
|
||||
write_warn2(str, "\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
elen -= tail - einfo;
|
||||
einfo = tail;
|
||||
do ++tail; while (tail < einfo+elen && *tail == '\n');
|
||||
write_warn2(str, einfo, tail-einfo);
|
||||
elen -= tail - einfo;
|
||||
einfo = tail;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!epath) {
|
||||
|
@ -1262,5 +1262,12 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
||||
assert_operator(message, :end_with?, "\n")
|
||||
message = message.gsub(/\e\[[\d;]*m/, '')
|
||||
assert_not_operator(message, :end_with?, "\n\n")
|
||||
e = RuntimeError.new("a\n\nb\n\nc")
|
||||
message = assert_nothing_raised(ArgumentError, proc {e.pretty_inspect}) do
|
||||
e.full_message
|
||||
end
|
||||
assert_all?(message.lines) do |m|
|
||||
/\e\[\d[;\d]*m[^\e]*\n/ !~ m
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user