From 5f45cb05f11031ded8ffb6355bf91b900da37f54 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 21 Sep 2019 07:57:49 +0200 Subject: [PATCH] diagnostics: don't print ellipsis on the caret line From 9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKL | ... ^~~~~~~~~~~~~~~~~~~~~~~~~~ to 9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHI... | ^~~~~~~~~~~~~~~~~~~~~~~~~~ * src/location.c (location_caret): here. * tests/diagnostics.at: Adjust expectations. --- src/location.c | 5 ++--- tests/diagnostics.at | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/location.c b/src/location.c index b0d9f015..a7824557 100644 --- a/src/location.c +++ b/src/location.c @@ -388,9 +388,8 @@ location_caret (location loc, const char *style, FILE *out) /* Print the carets with the same indentation as above. */ { - fprintf (out, " | %s%*s", - skip ? "..." : "", - loc.start.column - 1 - skip, ""); + fprintf (out, " | %*s", + loc.start.column - 1 - skip + (skip ? 3 : 0), ""); begin_use_class (style, out); putc ('^', out); /* Underlining a multiline location ends with the first diff --git a/tests/diagnostics.at b/tests/diagnostics.at index 5eba7bad..03960d5f 100644 --- a/tests/diagnostics.at +++ b/tests/diagnostics.at @@ -363,7 +363,7 @@ input.y:9.8-33: previous declaration | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.92-117: warning: symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ redeclared [-Wother] 9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ - | ... ^~~~~~~~~~~~~~~~~~~~~~~~~~ + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.8-33: previous declaration 9 | %token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEF... | ^~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -384,13 +384,13 @@ input.y:9.8-33: previous declaration | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.64-89: warning: symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ redeclared [-Wother] 9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHI... - | ... ^~~~~~~~~~~~~~~~~~~~~~~~~~ + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.8-33: previous declaration 9 | %token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMN... | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.92-117: warning: symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ redeclared [-Wother] 9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ - | ... ^~~~~~~~~~~~~~~~~~~~~~~~~~ + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ input.y:9.8-33: previous declaration 9 | %token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMN... | ^~~~~~~~~~~~~~~~~~~~~~~~~~