mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 13:53:03 +00:00
diagnostics: also show truncation at the end of line with "..."
From
9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKL
| ... ^~~~~~~~~~~~~~~~~~~~~~~~~~
to
9 | ...TUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHI...
| ... ^~~~~~~~~~~~~~~~~~~~~~~~~~
* src/location.c (location_caret): here.
* tests/diagnostics.at: Adjust expectations.
This commit is contained in:
@@ -322,6 +322,10 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
/* If we skip the initial part, we insert "..." before. */
|
||||
if (skip)
|
||||
width -= 3;
|
||||
/* If the end of line does not fit, we also need to truncate the
|
||||
end, and leave "..." there. */
|
||||
if (width < line_len - skip)
|
||||
width -= 3;
|
||||
|
||||
/* Go back to the beginning of line. */
|
||||
fseek (caret_info.file, caret_info.offset, SEEK_SET);
|
||||
@@ -374,7 +378,10 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
opened = false;
|
||||
}
|
||||
if (width < caret_info.pos.column - skip)
|
||||
break;
|
||||
{
|
||||
fprintf (out, "...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
putc ('\n', out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user