gbranden pushed a commit to branch master
in repository groff.
commit 5a215b4d8d72b84a50c58c2bde0db3510d4871a1
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Aug 19 16:06:10 2024 -0500
[troff]: Fix Savannah #66113 (bad `\B` diag).
Fix misleading `\B` diagnostic.
* src/roff/troff/input.cpp (do_expr_test): Advance the input token
pointer at the end of the endless for loop, not the beginning, since
`get_number_rigidly()` already left it at the next input character to
be processed. (Most parameterized escape sequence reading functions
don't call an input reading function before entering this sort of
loop, so they correctly advance the token pointer _first_.)
---
ChangeLog | 12 ++++++++++++
src/roff/troff/input.cpp | 7 +++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 28de0e25c..f700723e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-08-19 G. Branden Robinson <[email protected]>
+
+ [troff]: Fix Savannah #66113 (misleading `\B` diagnostic).
+
+ * src/roff/troff/input.cpp (do_expr_test): Advance the input
+ token pointer at the end of the endless for loop, not the
+ beginning, since `get_number_rigidly()` already left it at the
+ next input character to be processed. (Most parameterized
+ escape sequence reading functions don't call an input reading
+ function before entering this sort of loop, so they correctly
+ advance the token pointer _first_.)
+
2024-08-19 G. Branden Robinson <[email protected]>
[troff]: Fix Savannah #63142 (newlines as delims).
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;
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit