bison-patches
[Top][All Lists]
Advanced

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

diagnostics: fix handling of style in limit cases


From: Akim Demaille
Subject: diagnostics: fix handling of style in limit cases
Date: Sun, 24 Mar 2019 18:42:38 +0100

commit 22a413ce9f171979f03f3c78e5fd04ed6b07c9da
Author: Akim Demaille <address@hidden>
Date:   Sat Mar 23 07:11:26 2019 +0100

   diagnostics: fix handling of style in limit cases

   * src/location.c (location_caret): Beware of the cases where the start
   and end columns are the same, or when the location is multilines.

diff --git a/src/location.c b/src/location.c
index 38c84693..38e09459 100644
--- a/src/location.c
+++ b/src/location.c
@@ -192,10 +192,15 @@ location_caret (location loc, const char *style, FILE 
*out)
            if (col == loc.start.column)
              begin_use_class (style, out);
            fputc (c, out);
-            if (col + 1 == loc.end.column)
+            if (loc.start.column == loc.end.column
+                ? col == loc.end.column
+                : col + 1 == loc.end.column)
              end_use_class (style, out);
          }
        while ((c = getc (caret_info.source)) != EOF && c != '\n');
+        /* Close the style, in the case of a multiline location.  */
+        if (loc.start.line != loc.end.line)
+          end_use_class (style, out);
        putc ('\n', out);

        {
@@ -211,7 +216,7 @@ location_caret (location loc, const char *style, FILE *out)
          for (i = loc.start.column; i == loc.start.column || i < len; ++i)
            putc (i == loc.start.column ? '^' : '~', out);
          end_use_class (style, out);
-          }
+        }
        putc ('\n', out);
      }
  }




reply via email to

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