mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
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.
This commit is contained in:
@@ -192,10 +192,15 @@ location_caret (location loc, const char *style, FILE *out)
|
|||||||
if (col == loc.start.column)
|
if (col == loc.start.column)
|
||||||
begin_use_class (style, out);
|
begin_use_class (style, out);
|
||||||
fputc (c, 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);
|
end_use_class (style, out);
|
||||||
}
|
}
|
||||||
while ((c = getc (caret_info.source)) != EOF && c != '\n');
|
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);
|
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)
|
for (i = loc.start.column; i == loc.start.column || i < len; ++i)
|
||||||
putc (i == loc.start.column ? '^' : '~', out);
|
putc (i == loc.start.column ? '^' : '~', out);
|
||||||
end_use_class (style, out);
|
end_use_class (style, out);
|
||||||
}
|
}
|
||||||
putc ('\n', out);
|
putc ('\n', out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user