gbranden pushed a commit to branch master
in repository groff.
commit 106f3b48121a369b801fa630e4e4e1d0b7c2a1ff
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Jun 7 11:34:50 2026 -0500
[troff]: Fix Savannah #68430.
* src/roff/troff/input.cpp (decode_macro_call_arguments): Handle
right-brace escape sequences in macro arguments consistently with past
groffs, and Solaris 10, DWB 3.3, and Heirloom Doctools troffs (but not
_quite_ like Plan 9 troff, whose macro argument handling differs from
all the others).
Fixes <https://savannah.gnu.org/bugs/?68430>. Problem introduced by me
in commit ebf943aa66, 2026-04-20.
Also completes fixing <https://savannah.gnu.org/bugs/?42675>.
---
ChangeLog | 13 +++++++++++++
src/roff/troff/input.cpp | 30 ++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 8085998a6..e5d2465a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2026-06-07 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (decode_macro_call_arguments): Handle
+ right-brace escape sequences in macro arguments consistently
+ with past groffs, and Solaris 10, DWB 3.3, and Heirloom Doctools
+ troffs (but not _quite_ like Plan 9 troff, whose macro argument
+ handling differs from all the others).
+
+ Fixes <https://savannah.gnu.org/bugs/?68430>. Problem
+ introduced by me in commit ebf943aa66, 2026-04-20.
+
+ Also completes fixing <https://savannah.gnu.org/bugs/?42675>.
+
2026-06-07 G. Branden Robinson <[email protected]>
[groff]: Regression-test Savannah #68430.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d218847d5..babf1fb4a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4755,6 +4755,36 @@ static void interpolate_macro_or_invoke_request(symbol
nm,
static void decode_macro_call_arguments(macro_iterator *mi)
{
+ // Discard right-brace escape sequences until hitting something else.
+ // Doing so enables us to ignore a newline that occurs right after a
+ // right-brace escape sequence. Nobody documents this, but it's what
+ // all AT&T-descended troffs do.
+ //
+ // Scenario:
+ // .de aa
+ // A
+ // ..
+ // .if 1 \{.aa\}
+ // B
+ //
+ // If we read the newline at the end of the macro definition and the
+ // newline at the end of the `if` control line adjacently, that's a
+ // blank line. No AT&T-descended troff acts that way, so we shouldn't
+ // either, and must discard one of the newlines.
+ //
+ // Further, Seventh Edition Unix (Ossanna) troff and early versions of
+ // Kernighan troff have a related bug. When making an argumentless
+ // macro call within a branch of a control flow request and following
+ // the call with a right brace escape sequence, these older troffs
+ // would miscount the arguments, making the value of the `.$` register
+ // incorrect. GBR infers that the bug survived into DWB 2.0 and thus
+ // propagated into System V troff, and thence Solaris troff. DWB 3.3
+ // and Heirloom Doctools fixed it. Carsten Kunze also fixed the bug
+ // in the "Solaris10-ditroff" GitHub project. Plan 9 troff, however,
+ // still manifests the bug. So did GNU troff, through version 1.24.1.
+ // See Savannah #42675.
+ while (tok.is_right_brace())
+ tok.next();
if (!tok.is_terminator()) {
node *n;
int c = read_character_in_copy_mode(&n);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit