gbranden pushed a commit to branch master
in repository groff.
commit bff7782f332f4dc37f84f322dfce9fc417da1f77
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Oct 22 10:39:10 2026 -0500
[troff]: Revise `als` input validation.
* src/roff/troff/input.cpp (alias_macro): Use `has_arg()` to check for
arguments after the first, more reliably issuing warning in category
"missing". Since per the previous change to this function, we have
returned early if the `s1` symbol `is_null()`, we no longer need a
`!s1.is_null()` condition here--that is tautologically true. Drop the
conditional, putting collection of second argument on main execution
trace. Check the second identifier for bogosity just as we checked
the first.
Before:
$ printf '.als\n' | ./build/test-groff -ww
troff:<standard input>:1: warning: name aliasing request expects arguments
[-w missing]
$ printf '.als .T\n' | ./build/test-groff -ww
$ printf '.als .T \002\n' | ./build/test-groff -ww
troff:<standard input>:1: error: ignoring identifier containing invalid
character code 2
After:
$ printf '.als\n' | ./build/test-groff -ww
troff:<standard input>:1: warning: name aliasing request expects arguments
[-w missing]
$ printf '.als .T\n' | ./build/test-groff -ww
troff:<standard input>:1: warning: name aliasing request expects two
arguments [-w missing]
$ printf '.als .T \002\n' | ./build/test-groff -ww
troff:<standard input>:1: error: ignoring identifier containing invalid
character code 2
---
src/roff/troff/input.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 9a9357d48..dc05f131c 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5892,6 +5892,12 @@ static void alias_macro() // .als
skip_line();
return;
}
+ if (!has_arg()) {
+ warning(WARN_MISSING, "name aliasing request"
+ " expects two arguments");
+ skip_line();
+ return;
+ }
symbol s2 = read_identifier();
if (s2.is_null()) {
// The identifier was garbage, like `a\&b`.
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit