URL: <https://savannah.gnu.org/bugs/?66113>
Summary: [troff] `\B` escape sequences misdescribes mismatched ending delimiter Group: GNU roff Submitter: gbranden Submitted: Mon 19 Aug 2024 09:03:00 PM UTC Category: Core Severity: 3 - Normal Item Group: Warning/Suspicious behaviour Status: In Progress Privacy: Public Assigned to: gbranden Open/Closed: Open Discussion Lock: Any _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Mon 19 Aug 2024 09:03:00 PM UTC By: G. Branden Robinson <gbranden> _groff_ 1.23.0: $ printf '\\B@\n' | ~/groff-stable/bin/nroff -z -ww troff: warning: missing closing delimiter in expression test escape sequence (got end of input) ...but that's not true. The token pointer was, or should have been, at the newline when the function `do_expr_test()` became angry at the lack of a missing closing delimiter. Here's the fix. diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 54425a0e3..a7f57650d 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -1708,11 +1708,13 @@ static bool do_expr_test() // \B bool result = get_number_rigidly(&dummy, 'u'); warning_mask = saved_warning_mask; want_errors_inhibited = saved_want_errors_inhibited; + // get_number_rigidly() has left `token` pointing at the input + // character after the end of the expression. if (tok == start_token && input_stack::get_level() == start_level) return result; - // ignore everything up to the delimiter in case we aren't right there + // There may be garbage after the expression but before the closing + // delimiter. Eat it. for (;;) { - tok.next(); if (tok.is_newline() || tok.is_eof()) { char *delimdesc = strdup(start_token.description()); warning(WARN_DELIM, "missing closing delimiter in numeric" @@ -1722,6 +1724,7 @@ static bool do_expr_test() // \B input_stack::push(make_temp_iterator("\n")); break; } + tok.next(); if (tok == start_token && input_stack::get_level() == start_level) break; } Because the `tok.next()` call was at the start of the for loop, we advanced the input pointer past the problematic character before attempting to describe it. Uncovered while hammering on bug #63202. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?66113> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature