mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 06:13:02 +00:00
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:
@@ -49,15 +49,21 @@ typedef struct
|
||||
*/
|
||||
int column;
|
||||
|
||||
/* If nonnegative, (origin-0) bytes number in the current line.
|
||||
Never displayed, used when printing error messages with colors to
|
||||
know where colors start and ends. */
|
||||
int byte;
|
||||
|
||||
} boundary;
|
||||
|
||||
/* Set the position of \a a. */
|
||||
/* Set the position of \a p. */
|
||||
static inline void
|
||||
boundary_set (boundary *b, const char *f, int l, int c)
|
||||
boundary_set (boundary *p, const char *f, int l, int c, int b)
|
||||
{
|
||||
b->file = f;
|
||||
b->line = l;
|
||||
b->column = c;
|
||||
p->file = f;
|
||||
p->line = l;
|
||||
p->column = c;
|
||||
p->byte = b;
|
||||
}
|
||||
|
||||
/* Return -1, 0, 1, depending whether a is before, equal, or
|
||||
@@ -95,7 +101,7 @@ typedef struct
|
||||
|
||||
# define GRAM_LTYPE location
|
||||
|
||||
# define EMPTY_LOCATION_INIT {{NULL, 0, 0}, {NULL, 0, 0}}
|
||||
# define EMPTY_LOCATION_INIT {{NULL, 0, 0, 0}, {NULL, 0, 0, 0}}
|
||||
extern location const empty_location;
|
||||
|
||||
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
|
||||
|
||||
Reference in New Issue
Block a user