diagnostics: give m4 precise locations

Currently we pass only the columns based on the screen-width, which is
important for the carets.  But we don't pass the bytes-based columns,
which is important for the colors.  Pass both.

* src/muscle-tab.c (muscle_boundary_grow): Also pass the byte-based column.
* src/location.c (location_caret): Clarify.
(boundary_set_from_string): Adjust to the new format.
* tests/diagnostics.at (Tabulations and multibyte characters from M4): New.
This commit is contained in:
Akim Demaille
2019-04-27 16:29:07 +02:00
parent a514c51e55
commit 386cf25088
4 changed files with 65 additions and 25 deletions

View File

@@ -33,16 +33,18 @@ AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]], [$2])
AT_DATA([experr], [$4])
AT_DATA([experr.orig], [$4])
# When no style, same messages, but without style.
AT_CHECK([perl -p -e 's{</?\w+>}{}g' <experr.orig >experr])
# Cannot use AT_BISON_CHECK easily as we need to change the
# environment.
# FIXME: Enhance AT_BISON_CHECK.
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --style=debug -Wall input.y], [$3], [], [experr])
# When no style, same messages, but without style.
AT_CHECK([perl -pi -e 's{</?\w+>}{}g' experr])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret -Wall input.y], [$3], [], [experr])
AT_CHECK([cp experr.orig experr])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --style=debug -Wall input.y], [$3], [], [experr])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -212,4 +214,29 @@ input.y:9.1-24: previous definition
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]])
## ---------------------------------------------- ##
## Tabulations and multibyte characters from M4. ##
## ---------------------------------------------- ##
# Locations coming from m4 need the byte-column for diagnostics.
AT_TEST([[Locations from M4]],
[[%define api.prefix {sun}
%define api.prefix {🌞}
%%
exp:;
]],
[1],
[[input.y:10.1-35: <error>error:</error> %define variable 'api.prefix' redefined
10 | <error>%define api.prefix {🌞}</error>
| <error>^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</error>
input.y:9.1-37: previous definition
9 | <note>%define api.prefix {sun}</note>
| <note>^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</note>
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]])
m4_popdef([AT_TEST])