gbranden pushed a commit to branch master
in repository groff.
commit cdc2a4fa6c447beb0c1f1207f19be550d5d87121
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 23 20:04:38 2025 -0600
[troff]: Improve diagnostic in corner case.
* src/roff/troff/input.cpp (token::description): Add description of the
"empty" token type to which the global `tok` is initialized. This
comes up in a corner case of parser state, because sometimes we have
to read multiple characters to decide what kind of token the very
first one in the input stream is. Consider a delimited escape
sequence whose wheels fall off because it's invalidly delimited.
Also annotate null pointers with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
---
ChangeLog | 10 ++++++++++
src/roff/troff/input.cpp | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 703b43761..856506190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-11-23 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (token::description): Add description
+ of the "empty" token type to which the global `tok` is
+ initialized. This comes up in a corner case of parser state,
+ because sometimes we have to read multiple characters to decide
+ what kind of token the very first one in the input stream is.
+ Consider a delimited escape sequence whose wheels fall off
+ because it's invalidly delimited.
+
2025-11-28 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (read_delimited_number)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d8f16f9ab..937355192 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1991,7 +1991,7 @@ bool token_node::is_tag()
return false;
}
-token::token() : nd(0), type(TOKEN_EMPTY)
+token::token() : nd(0 /* nullptr */), type(TOKEN_EMPTY)
{
}
@@ -2935,6 +2935,8 @@ const char *token::description()
static char buf[bufsz];
(void) memset(buf, 0, bufsz);
switch (type) {
+ case TOKEN_EMPTY:
+ return "an indeterminate token (at start of input?)";
case TOKEN_BACKSPACE:
return "a backspace character";
case TOKEN_CHAR:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit