gbranden pushed a commit to branch master
in repository groff.
commit bfc325f3cf752aca2ddc9dc80ebb284bae3ba4af
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Jun 23 17:56:54 2026 -0500
[eqn]: Fix Savannah #68468.
* src/preproc/eqn/lex.cpp (interpolate_macro_with_args): Declare new
`bool`, `is_ignoring_arguments`. Use it within the macro argument
reading loop to ignore any arguments past the ninth, so that they do
not populate the `argv` array beyond its bounds. Neither AT&T nor GNU
eqn has a syntax for interpolating tenth or subsequent arguments, nor
any `shift` command that would made such arguments addressable. Issue
one warning per macro expansion with excess arguments.
Fixes <https://savannah.gnu.org/bugs/?68468>. Problem reported
apparently by an LLM robot in <https://lists.gnu.org/archive/html/\
bug-groff/2026-06/msg00053.html>.
---
ChangeLog | 15 +++++++++++++++
src/preproc/eqn/lex.cpp | 8 ++++++++
2 files changed, 23 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 7009605de..6b4336c28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2026-06-23 G. Branden Robinson <[email protected]>
+
+ * src/preproc/eqn/lex.cpp (interpolate_macro_with_args): Declare
+ new `bool`, `is_ignoring_arguments`. Use it within the macro
+ argument reading loop to ignore any arguments past the ninth,
+ so that they do not populate the `argv` array beyond its bounds.
+ Neither AT&T nor GNU eqn has a syntax for interpolating tenth or
+ subsequent arguments, nor any `shift` command that would made
+ such arguments addressable. Issue one warning per macro
+ expansion with excess arguments.
+
+ Fixes <https://savannah.gnu.org/bugs/?68468>. Problem reported
+ apparently by an LLM robot in <https://lists.gnu.org/archive/\
+ html/bug-groff/2026-06/msg00053.html>.
+
2026-06-23 G. Branden Robinson <[email protected]>
[eqn]: Regression-test Savannah #68468.
diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index ef6998ca9..91f76e4fa 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -761,6 +761,7 @@ static void interpolate_macro_with_args(const char *body)
argv[i] = 0;
int level = 0;
int c;
+ bool is_ignoring_arguments = false;
do {
token_buffer.clear();
for (;;) {
@@ -770,6 +771,13 @@ static void interpolate_macro_with_args(const char *body)
break;
}
if (level == 0 && (c == ',' || c == ')')) {
+ if (argc >= 9) {
+ if (!is_ignoring_arguments) { // if we didn't already warn
+ lex_warning("excess macro argument(s); ignoring");
+ is_ignoring_arguments = true;
+ }
+ break;
+ }
if (token_buffer.length() > 0) {
token_buffer += '\0';
argv[argc] = strsave(token_buffer.contents());
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit