gbranden pushed a commit to branch master
in repository groff.
commit f29ae72a46bddc3b81e0457abc246f64efa6f62a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 24 22:41:50 2026 -0500
[troff]: hcode request handler throws more errors.
* src/roff/troff/input.cpp (set_hyphenation_codes): Throw error if
either the "source" or "destination" operand of a hyphenation code
assignment pair it not a character token.
Illustration:
$ printf '.hcode \\&a\n' | ./build/test-groff
troff:<standard input>:1: error: cannot apply a hyphenation code to an
escaped '&'
$ printf '.hcode a\\&\n' | ./build/test-groff
troff:<standard input>:1: error: cannot copy the hyphenation code of a
non-character (an escaped '&')
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index bb5a15dd2..34c3f742c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-05-24 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (set_hyphenation_codes): Throw error
+ if either the "source" or "destination" operand of a hyphenation
+ code assignment pair it not a character token.
+
2026-05-24 G. Branden Robinson <[email protected]>
* src/roff/troff/node.cpp
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8a7c74e4b..a27a5cb79 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8888,6 +8888,10 @@ static void set_hyphenation_codes() // .hcode
}
while (has_arg()) {
unsigned char cdst = tok.ch();
+ if (!tok.is_any_character()) {
+ error("cannot apply a hyphenation code to %1", tok.description());
+ break;
+ }
if (csdigit(cdst)) {
error("cannot apply a hyphenation code to a numeral");
break;
@@ -8905,6 +8909,11 @@ static void set_hyphenation_codes() // .hcode
error("hyphenation codes must be specified in pairs");
break;
}
+ if (!tok.is_any_character()) {
+ error("cannot copy the hyphenation code of a non-character (%1)",
+ tok.description());
+ break;
+ }
unsigned char csrc = tok.ch();
if (csdigit(csrc)) {
error("cannot use the hyphenation code of a numeral");
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit