diagnostics: fix locations coming from M4

Locations issued from M4 need the byte-based column for the
diagnostics to work properly.  Currently they were unassigned, which
typically resulted in partially non-colored diagnostics.

* src/location.c (boundary_set_from_string): Fix the parsed location.
* src/muscle-tab.c (muscle_percent_define_default): Set the byte values.
* tests/diagnostics.at (Locations from M4): New.
This commit is contained in:
Akim Demaille
2019-04-27 14:39:22 +02:00
parent 91b8f3f171
commit a514c51e55
3 changed files with 39 additions and 12 deletions

View File

@@ -296,7 +296,7 @@ boundary_set_from_string (boundary *bound, char *loc_str)
char *delim = strrchr (loc_str, '.');
aver (delim);
*delim = '\0';
bound->column = atoi (delim+1);
bound->byte = bound->column = atoi (delim+1);
delim = strrchr (loc_str, ':');
aver (delim);
*delim = '\0';

View File

@@ -710,9 +710,11 @@ muscle_percent_define_default (char const *variable, char const *value)
{
uniqstr loc_name = muscle_name (variable, "loc");
location loc;
loc.start.file = loc.end.file = "<default value>";
loc.start.line = loc.end.line = -1;
loc.start.column = loc.end.column = -1;
loc.start.file = "<default value>";
loc.start.line = -1;
loc.start.column = -1;
loc.start.byte = -1;
loc.end = loc.start;
muscle_insert (loc_name, "");
muscle_location_grow (loc_name, loc);
}