gbranden pushed a commit to branch master in repository groff. commit f1fd5781779504ee373ee9a344df14348d986d0b Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sun Jul 6 06:15:53 2025 -0500
[eqn]: Fix Savannah #67285. * src/preproc/eqn/main.cpp (read_line): Stop discarding invalid input characters, as this function doesn't know whether we're reading an eqn region. Keep track of whether we've seen the default *roff escape character (`\`) and a `"` or `#` immediately after one. If so, stop throwing warnings about these characters as well. ("lex.cpp"'s `file_input::read_line()` independently checks for invalid character codes encountered when _interpreting_ the input.) Fixes <https://savannah.gnu.org/bugs/?67285>. Problem dates back at least to groff 1.02, 2 June 1991. --- ChangeLog | 16 ++++++++++++++++ src/preproc/eqn/main.cpp | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffbfe7b55..335041b98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2025-07-06 G. Branden Robinson <g.branden.robin...@gmail.com> + + [eqn]: Fix Savannah #67285. + + * src/preproc/eqn/main.cpp (read_line): Stop discarding invalid + input characters, as this function doesn't know whether we're + reading an eqn region. Keep track of whether we've seen the + default *roff escape character (`\`) and a `"` or `#` + immediately after one. If so, stop throwing warnings about + these characters as well. ("lex.cpp"'s + `file_input::read_line()` independently checks for invalid + character codes encountered when _interpreting_ the input.) + + Fixes <https://savannah.gnu.org/bugs/?67285>. Problem dates + back at least to groff 1.02, 2 June 1991. + 2025-07-06 G. Branden Robinson <g.branden.robin...@gmail.com> [eqn]: Regression-test Savannah #67285. diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp index d9759251c..f09d18c5c 100644 --- a/src/preproc/eqn/main.cpp +++ b/src/preproc/eqn/main.cpp @@ -85,10 +85,18 @@ static bool read_line(FILE *fp, string *p) { p->clear(); int c = -1; + bool seen_backslash = false; + bool in_comment = false; while ((c = getc(fp)) != EOF) { - if (!is_invalid_input_char(c)) - *p += char(c); + // Don't throw invalid input errors inside *roff comments. + if (seen_backslash && (('"' == c) || ('#' == c))) + in_comment = true; + if ('\\' == c) + seen_backslash = true; else + seen_backslash = false; + *p += char(c); + if (is_invalid_input_char(c) && !in_comment) error("invalid input (%1)", input_char_description(c)); if (c == '\n') break; _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit