mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 21:33:04 +00:00
diagnostics: copy GCC9's format
Currently, when we quote the source file, we indent it with one space, and preserve tabulations, so there is a discrepancy and the visual rendering is bad. One way out is to indent with a tab instead of a space, but then this space can be used for more information. This is what GCC9 does. Let's play copy cats. See https://lists.gnu.org/archive/html/bison-patches/2019-04/msg00025.html https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/ https://gcc.gnu.org/onlinedocs/gccint/Guidelines-for-Diagnostics.html#Guidelines-for-Diagnostics * src/location.c (location_caret): Prefix quoted lines with the line number and a pipe, fitting 8 columns. * tests/actions.at, tests/c++.at, tests/conflicts.at, * tests/diagnostics.at, tests/input.at, tests/java.at, * tests/named-refs.at, tests/reduce.at, tests/regression.at, * tests/sets.at: Adjust expectations. Partly by "./build-aux/update-test tests/testsuite.dir/*/testsuite.log" repeatedly, and partly by hand.
This commit is contained in:
@@ -191,7 +191,7 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
{
|
||||
/* Quote the file (at most first line in the case of multiline
|
||||
location). Indent by a single column. */
|
||||
fputc (' ', out);
|
||||
fprintf (out, "%5d | ", loc.start.line);
|
||||
bool single_line = loc.start.line == loc.end.line;
|
||||
/* Consider that single point location (with equal boundaries)
|
||||
actually denote the character that they follow. */
|
||||
@@ -215,7 +215,7 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
|
||||
{
|
||||
/* Print the carets with the same indentation as above. */
|
||||
fprintf (out, " %*s", loc.start.column - 1, "");
|
||||
fprintf (out, " | %*s", loc.start.column - 1, "");
|
||||
begin_use_class (style, out);
|
||||
putc ('^', out);
|
||||
/* Underlining a multiline location ends with the first
|
||||
|
||||
Reference in New Issue
Block a user