bison-patches
[Top][All Lists]
Advanced

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

diagnostics: style changes


From: Akim Demaille
Subject: diagnostics: style changes
Date: Sun, 24 Mar 2019 18:45:44 +0100

commit 5de4e79fc8d8725820d30f74a48325446694a439
Author: Akim Demaille <address@hidden>
Date:   Sat Mar 23 07:28:35 2019 +0100

    diagnostics: style changes
    
    * src/location.c (location_caret): Clarify a bit.

diff --git a/src/location.c b/src/location.c
index 38e09459..66162963 100644
--- a/src/location.c
+++ b/src/location.c
@@ -183,7 +183,8 @@ location_caret (location loc, const char *style, FILE *out)
     int c = getc (caret_info.source);
     if (c != EOF)
       {
-        /* Quote the file, indent by a single column.  */
+        /* Quote the file (at most first line in the case of multiline
+           location).  Indent by a single column.  */
         fputc (' ', out);
         int col = 0;
         do
@@ -204,17 +205,17 @@ location_caret (location loc, const char *style, FILE 
*out)
         putc ('\n', out);
 
         {
-          /* The caret of a multiline location ends with the first line.  */
-          size_t len = loc.start.line != loc.end.line
-            ? ftell (caret_info.source) - caret_info.offset
-            : loc.end.column;
-          int i;
-
-          /* Print the carets (at least one), with the same indent as above.*/
+          /* Print the carets with the same indentation as above.  */
           fprintf (out, " %*s", loc.start.column - 1, "");
           begin_use_class (style, out);
-          for (i = loc.start.column; i == loc.start.column || i < len; ++i)
-            putc (i == loc.start.column ? '^' : '~', out);
+          putc ('^', out);
+          /* Underlining a multiline location ends with the first
+             line.  */
+          int len = loc.start.line != loc.end.line
+            ? ftell (caret_info.source) - caret_info.offset
+            : loc.end.column;
+          for (int i = loc.start.column + 1; i < len; ++i)
+            putc ('~', out);
           end_use_class (style, out);
         }
         putc ('\n', out);




reply via email to

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