gbranden pushed a commit to branch master
in repository groff.

commit ab8c064ee12ae57b8a2690a07539f48cc2c6baeb
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Oct 11 12:03:40 2026 -0500

    [man]: Add AT&T arg count checker to `CHECKSTYLE`.
    
    * tmac/an.tmac (an*check-legacy-argument-count): New macro checks a
      passed-in macro argument count for a value too large to work with AT&T
      troff man.
    
      (SH, SS, B, I, SM, SB, BI, BR, IB, IR, RB, RI): Call it.
    
    * tmac/groff_man.7.man.in (Options <CHECKSTYLE>):
    * NEWS: Document it.
---
 ChangeLog               | 10 ++++++++++
 NEWS                    |  5 +++++
 tmac/an.tmac            | 22 ++++++++++++++++++++++
 tmac/groff_man.7.man.in | 11 ++++++++++-
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a528c8084..411f24c48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-10-11  G. Branden Robinson <[email protected]>
+
+       * tmac/an.tmac (an*check-legacy-argument-count): New macro
+       checks a passed-in macro argument count for a value too large to
+       work with AT&T troff man.
+       (SH, SS, B, I, SM, SB, BI, BR, IB, IR, RB, RI): Call it.
+
+       * tmac/groff_man.7.man.in (Options <CHECKSTYLE>):
+       * NEWS: Document it.
+
 2026-10-11  G. Branden Robinson <[email protected]>
 
        * man/man.am (man/groff.7.man): Pass soelim(1) its new `-x`
diff --git a/NEWS b/NEWS
index 9f34511a2..51504316b 100644
--- a/NEWS
+++ b/NEWS
@@ -133,6 +133,11 @@ Macro packages
    macros, to manage list "compactness" and item indentation with
    existing man(7) package facilities, or to employ both approaches.
 
+*  The an (man) package now checks for certain portability problems to
+   AT&T troff's man(7) if the `CHECKSTYLE` register, introduced in groff
+   1.23.0 and documented in 1.24.0, is given a value of 100 or greater.
+   This feature is experimental and subject to change.
+
 *  The m (mm) macro package's `IA` and `WA` macros--used only with the
    "letter" document type configured by calling the `LT` macro--no
    longer disable the escape character, and their counterparts `IE` and
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 61e2c7a11..74de44023 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -78,6 +78,16 @@
 .    an*style-warn use of deprecated macro: .\\$0
 ..
 .
+.de an*check-legacy-argument-count
+.  nr an*arg-count \\$1
+.  shift
+.  if (\\n[CHECKSTYLE] > 99) \
+.    if (\\n[an*arg-count] > 6) \
+.      an*style-warn .\\$1 called with \\n[an*arg-count] arguments; \
+use of more than 6 is not portable to AT&T troff's man package
+.  rr an*arg-count
+..
+.
 .de1 an-blank-line-trap
 .  if (\\n[CHECKSTYLE] > 2) \
 .    an*style-warn blank line in input
@@ -787,6 +797,7 @@ contains unsupported escape sequence
 .\" Set arguments (or next input line producing written or drawn output
 .\" if none) as a section heading.
 .de1 SH
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.it] .an*warn cannot call .\\$0 while an input trap is pending
 .  if \\n[DEBUG] .tm GBR: mark VALID05: \\$0
 .  an*list-close-all
@@ -818,6 +829,7 @@ contains unsupported escape sequence
 .\" Set arguments (or next input line producing written or drawn output
 .\" if none) as a subsection heading.
 .de1 SS
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.it] .an*warn cannot call .\\$0 while an input trap is pending
 .  if \\n[DEBUG] .tm GBR: mark VALID06: \\$0
 .  an*list-close-all
@@ -847,6 +859,7 @@ contains unsupported escape sequence
 .\" Set arguments (or next input line producing written or drawn output
 .\" if none) in bold style.
 .de1 B
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  it 1 an*input-trap
 .  ft B
 .  if \\n[.$] \&\\$*
@@ -855,6 +868,7 @@ contains unsupported escape sequence
 .\" Set arguments (or next input line producing written or drawn output
 .\" if none) in italic style.
 .de1 I
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  it 1 an*input-trap
 .  ft I
 .  if \\n[.$] \,\\$*\/
@@ -863,6 +877,7 @@ contains unsupported escape sequence
 .\" Set arguments (or next input line producing written or drawn output
 .\" if none) at smaller type size.
 .de1 SM
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  it 1 an*input-trap
 .  ps -1
 .  if \\n[.$] \&\\$*
@@ -886,6 +901,7 @@ contains unsupported escape sequence
 .\" .SB [text]
 .de1 SB
 .  nop \\*[an*deprecation-warn]\\
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  it 1 an*input-trap
 .  ps -1
 .  ft B
@@ -1015,6 +1031,7 @@ contains unsupported escape sequence
 .de1 BI
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
@@ -1032,6 +1049,7 @@ contains unsupported escape sequence
 .de1 BR
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
@@ -1049,6 +1067,7 @@ contains unsupported escape sequence
 .de1 IB
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
@@ -1066,6 +1085,7 @@ contains unsupported escape sequence
 .de1 IR
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
@@ -1083,6 +1103,7 @@ contains unsupported escape sequence
 .de1 RB
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
@@ -1100,6 +1121,7 @@ contains unsupported escape sequence
 .de1 RI
 .  if (\\n[.$] < 2) \
 .    an*style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
+.  an*check-legacy-argument-count \\n[.$] \\$0
 .  if \\n[.$] \{\
 .    ds an*result \&\"
 .    while (\\n[.$] >= 2) \{\
diff --git a/tmac/groff_man.7.man.in b/tmac/groff_man.7.man.in
index c685a98a2..eb5e6c250 100644
--- a/tmac/groff_man.7.man.in
+++ b/tmac/groff_man.7.man.in
@@ -4027,11 +4027,20 @@ at verbosity level
 .IR n ,
 where
 .I n
-is an integer in the range 0\[en]3,
+is an integer,
+normally in the range 0\[en]3,
 inclusive;
 .B 0
 disables the messages and is the default.
 .
+If
+.I n
+is 100 or greater,
+the package furthermore checks the document
+for certain problems of portability to AT&T
+.IR troff 's
+.IR man .
+.
 This feature is a development and debugging aid
 for man page maintainers;
 the problems diagnosed,

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

Reply via email to