merge branch 'maint'

* upstream/maint:
  maint: post-release administrivia
  version 3.5.3
  news: update for 3.5.3
  yacc.c: make sure we properly propagated the user's number for error
  diagnostics: don't crash because of repeated definitions of error
  style: initialize some struct members
  diagnostics: beware of zero-width characters
  diagnostics: be sure to close the styling when lines are too short
  muscles: fix incorrect decoding of $
  code: be robust to reference with invalid tags
  build: fix typo
  doc: update recommandation for libtextstyle
  style: comment changes
  examples: use consistently the GFDL header for readmes
  style: remove useless declarations
  typo: succesful -> successful
  README: point to tests/bison, and document --trace
  gnulib: update
  maint: post-release administrivia
This commit is contained in:
Akim Demaille
2020-03-08 09:52:13 +01:00
13 changed files with 188 additions and 39 deletions

View File

@@ -175,6 +175,8 @@ location_print (location loc, FILE *out)
}
else
{
aver (loc.start.file);
aver (loc.end.file);
int end_col = 0 != loc.end.column ? loc.end.column - 1 : 0;
res += fprintf (out, "%s",
quotearg_n_style (3, escape_quoting_style, loc.start.file));
@@ -317,7 +319,7 @@ caret_getc_internal (mbchar_t *res)
/* Move CARET_INFO (which has a valid FILE) to the line number LINE.
Compute and cache that line's length in CARET_INFO.LINE_LEN.
Return whether successful.*/
Return whether successful. */
static bool
caret_set_line (int line)
{
@@ -423,12 +425,14 @@ location_caret (location loc, const char *style, FILE *out)
{
/* The last column to highlight. Only the first line of
multiline locations are quoted, in which case the ending
column is the end of line. Single point locations (with
equal boundaries) denote the character that they
follow. */
int col_end
column is the end of line.
We used to work with byte offsets, and that was much
easier. However, we went back to using (visual) columns to
support truncating of long lines. */
const int col_end
= loc.start.line == loc.end.line
? loc.end.column + (loc.start.column == loc.end.column)
? loc.end.column
: caret_info.line_len;
/* Quote the file (at most the first line in the case of
multiline locations). */
@@ -438,24 +442,28 @@ location_caret (location loc, const char *style, FILE *out)
expected (maybe the file was changed since the scanner
ran), we might reach the end before we actually saw the
opening column. */
bool opened = false;
enum { before, inside, after } state = before;
while (!mb_iseof (c) && !mb_iseq (c, '\n'))
{
if (caret_info.pos.column == loc.start.column)
// We might have already opened (and even closed!) the
// style and yet have the equality of the columns if we
// just saw zero-width characters.
if (state == before
&& caret_info.pos.column == loc.start.column)
{
begin_use_class (style, out);
opened = true;
state = inside;
}
if (skip < caret_info.pos.column)
mb_putc (c, out);
boundary_compute (&caret_info.pos, mb_ptr (c), mb_len (c));
caret_getc (c);
if (opened
if (state == inside
&& (caret_info.pos.column == col_end
|| width < caret_info.pos.column - skip))
{
end_use_class (style, out);
opened = false;
state = after;
}
if (width < caret_info.pos.column - skip)
{
@@ -463,6 +471,12 @@ location_caret (location loc, const char *style, FILE *out)
break;
}
}
if (state == inside)
{
// The line is shorter than expected.
end_use_class (style, out);
state = after;
}
putc ('\n', out);
}