gbranden pushed a commit to branch master
in repository groff.
commit 9817934c4757bca56a46e7a576487de973efd5c4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Oct 18 21:23:09 2026 -0500
[troff]: `pcolor` req advances past invalid args.
* src/roff/troff/input.cpp (print_color_request): If a request argument
is an invalid identifier, skip over it instead of giving up on the
control line. This change improves symmetry with `pm` and `pnr`. (We
don't report the names of invalid identifiers because we have defined
no convention for encoding unprintable characters in this context.)
Before:
$ printf '.pcolor red \002 blue\n' | ./build/test-groff -ww
red rgb 1.00f 0.00f 0.00f
troff:<standard input>:1: error: ignoring identifier containing invalid
character code 2
After:
$ printf '.pcolor red \002 blue\n' | ./build/test-groff -ww
red rgb 1.00f 0.00f 0.00f
troff:<standard input>:1: error: ignoring identifier containing invalid
character code 2
blue rgb 0.00f 0.00f 1.00f
---
ChangeLog | 11 +++++++++++
src/roff/troff/input.cpp | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 7b0159cb1..3be2210e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-10-18 G. Branden Robinson <[email protected]>
+
+ [troff]: `pcolor` req advances past invalid args.
+
+ * src/roff/troff/input.cpp (print_color_request): If a request
+ argument is an invalid identifier, skip over it instead of
+ giving up on the control line. This change improves symmetry
+ with `pm` and `pnr`. (We don't report the names of invalid
+ identifiers because we have defined no convention for encoding
+ unprintable characters in this context.)
+
2026-10-18 G. Branden Robinson <[email protected]>
[troff]: Clarify "color" warning diagnostics.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 2ebfac421..87d9943a5 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1748,6 +1748,11 @@ static void print_color_request() // .pcolor
if (has_arg()) {
do {
key = read_identifier();
+ if (key.is_null()) {
+ // The identifier was garbage, like `a\&b`.
+ skip_rest_of_argument();
+ continue;
+ }
value = static_cast<color *>(color_dictionary.lookup(key));
if (value != 0 /* nullptr */)
errprint("%1\t%2\n", key.contents(), value->print_color());
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit