gbranden pushed a commit to branch master
in repository groff.

commit f014f3ef28703c441115346972326fa44eb0a127
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Oct 29 05:52:10 2025 -0500

    [mdoc]: Fix Savannah #67646 (`.T` as macro arg).
    
    * tmac/doc.tmac (doc-get-arg-type*): Handle the *roff internal string
      '.T' specially in an mdoc macro argument sequence; it is defined in
      the formatter, which _also_ defines a '.T' _register_, colliding
      perfectly with mdoc's argument type system.  This change prevents `.T`
      from being called as a macro and interpolating its value, a surprising
      outcome to mdoc users.
    
    Fixes <https://savannah.gnu.org/bugs/?67646>.  Thanks to onf for the
    report.  Problem dates back "all the way"; not only does groff 1.22.3
    (November 2014) have it, but the 4.4BSD-Lite2 implementation of mdoc
    does as well.  mdoc as a *roff macro package implements its own bespoke
    type system to accompany its bespoke macro processor; the type of a
    macro argument (a string or macro) is determined by looking up its name
    as a _register_.  mandoc(1) does not exhibit this problem, likely
    because it lacks a *roff formatter that defines both a `.T` register and
    a `.T` string; rather it simulates both of these.
---
 ChangeLog     | 20 ++++++++++++++++++++
 tmac/doc.tmac | 15 +++++++++++----
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bf37e3c8d..9f85a9a87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-10-29  G. Branden Robinson <[email protected]>
+
+       * tmac/doc.tmac (doc-get-arg-type*): Handle the *roff internal
+       string '.T' specially in an mdoc macro argument sequence; it is
+       defined in the formatter, which _also_ defines a '.T'
+       _register_, colliding perfectly with mdoc's argument type
+       system.  This change prevents `.T` from being called as a macro
+       and interpolating its value, a surprising outcome to mdoc users.
+
+       Fixes <https://savannah.gnu.org/bugs/?67646>.  Thanks to onf for
+       the report.  Problem dates back "all the way"; not only does
+       groff 1.22.3 (November 2014) have it, but the 4.4BSD-Lite2
+       implementation of mdoc does as well.  mdoc as a *roff macro
+       package implements its own bespoke type system to accompany its
+       bespoke macro processor; the type of a macro argument (a string
+       or macro) is determined by looking up its name as a _register_.
+       mandoc(1) does not exhibit this problem, likely because it lacks
+       a *roff formatter that defines both a `.T` register and a `.T`
+       string; rather it simulates both of these.
+
 2025-10-29  G. Branden Robinson <[email protected]>
 
        [mdoc]: Regression-test Savannah #67646.
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index 47064f9c6..6f61f45d8 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -2644,10 +2644,17 @@
 .      if r doc-punct\*[doc-arg\$1] \
 .        nr doc-arg-type \n[doc-punct\*[doc-arg\$1]]
 .    \}
-.    el \
-.      if r \*[doc-arg\$1] \
-.        if d \*[doc-arg\$1] \
-.          nr doc-arg-type 1
+.    el \{\
+.      \" Handle the *roff internal string '.T' specially; it is defined
+.      \" in the formatter, which _also_ defines a '.T' _register_,
+.      \" colliding perfectly with mdoc's argument type system.
+.      ie !'\?\*[doc-arg\$1]\?'\?.T\?' \
+.        if r \*[doc-arg\$1] \
+.          if d \*[doc-arg\$1] \
+.            nr doc-arg-type 1
+.      el \
+.        nr doc-arg-type 2
+.    \}
 .  \}
 ..
 .ec

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to