diagnostics: fix styling issues

Single point locations (equal boundaries) are troublesome, and we were
incorrectly ending the style in their case.  Which results in an abort
in libtextstyle.

There is also a confusion between columns as displayed on the
screen (which take into account multibyte characters and tabulations),
and the number of bytes.  Counting the screen-column
incrementally (character by character) is uneasy (because of multibyte
characters), and I don't want to maintain a buffer of the current line
when displaying the diagnostic.  So I believe the simplest solution is
to track the byte number in addition to the screen column.

* src/location.h, src/location.c (boundary): Add the byte-column.
Adjust dependencies.
* src/getargs.c, src/scan-gram.l: Adjust.
* tests/diagnostics.at: Check zero-width locations.
This commit is contained in:
Akim Demaille
2019-04-20 18:25:21 +02:00
parent 520d474ec6
commit 1b70f687fa
8 changed files with 86 additions and 29 deletions

View File

@@ -1787,8 +1787,8 @@ YYLTYPE yylloc = yyloc_default;
{
/* Bison's grammar can initial empty locations, hence a default
location is needed. */
boundary_set (&yylloc.start, current_file, 1, 1);
boundary_set (&yylloc.end, current_file, 1, 1);
boundary_set (&yylloc.start, current_file, 1, 1, 1);
boundary_set (&yylloc.end, current_file, 1, 1, 1);
}