aboutsummaryrefslogtreecommitdiffstats
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-13 03:40:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-13 03:40:10 +0000
commitb07e4af86935780887944432542f0d4b8a2ab62f (patch)
tree9018cd82b319ba0cd83a1c14bb10e778bca9e654 /eval_error.c
parente537dc331ef0c3b4a5db9b9124ba750f6ddb6eb2 (diff)
downloadruby-b07e4af86935780887944432542f0d4b8a2ab62f.tar.gz
eval_error.c: last newline
* eval_error.c (print_errinfo): do not print an empty line at the end when the message ends with a newline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/eval_error.c b/eval_error.c
index d909125fbd..d630f47014 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -153,14 +153,16 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
write_warn2(str, "\n", 1);
}
if (tail) {
- if (highlight) {
- if (einfo[elen-1] == '\n') --elen;
- write_warn(str, bold);
+ int eol = einfo[elen-1] == '\n';
+ if (eol && highlight) --elen;
+ if (tail < einfo+elen) {
+ if (highlight) write_warn(str, bold);
+ write_warn2(str, tail, einfo+elen-tail);
+ if (highlight) write_warn(str, reset);
+ if (highlight || !eol) write_warn2(str, "\n", 1);
}
- if (tail < einfo+elen) write_warn2(str, tail, einfo+elen-tail);
}
- if (tail ? (highlight || einfo[elen-1] != '\n') : !epath) {
- if (highlight) write_warn(str, reset);
+ else if (!epath) {
write_warn2(str, "\n", 1);
}
}