bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 10/11] diagnostics: don't print ellipsis on the caret line


From: Akim Demaille
Subject: [PATCH 10/11] diagnostics: don't print ellipsis on the caret line
Date: Sat, 21 Sep 2019 12:00:03 +0200

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
       |        <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
 input.y:9.92-117: <warning>warning:</warning> symbol 
ABCDEFGHIJKLMNOPQRSTUVWXYZ redeclared [<warning>-Wother</warning>]
     9 | ...TUVWXYZ  <warning>ABCDEFGHIJKLMNOPQRSTUVWXYZ</warning>
-      | ...         <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
+      |             <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
 input.y:9.8-33:       previous declaration
     9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note>  
ABCDEFGHIJKLMNOPQRSTUVWXYZ  ABCDEF...
       |        <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
@@ -384,13 +384,13 @@ input.y:9.8-33:      previous declaration
       |        <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
 input.y:9.64-89: <warning>warning:</warning> symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ 
redeclared [<warning>-Wother</warning>]
     9 | ...TUVWXYZ  <warning>ABCDEFGHIJKLMNOPQRSTUVWXYZ</warning>  ABCDEFGHI...
-      | ...         <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
+      |             <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
 input.y:9.8-33:      previous declaration
     9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note>  ABCDEFGHIJKLMN...
       |        <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
 input.y:9.92-117: <warning>warning:</warning> symbol 
ABCDEFGHIJKLMNOPQRSTUVWXYZ redeclared [<warning>-Wother</warning>]
     9 | ...TUVWXYZ  <warning>ABCDEFGHIJKLMNOPQRSTUVWXYZ</warning>
-      | ...         <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
+      |             <warning>^~~~~~~~~~~~~~~~~~~~~~~~~~</warning>
 input.y:9.8-33:       previous declaration
     9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note>  ABCDEFGHIJKLMN...
       |        <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]