gbranden pushed a commit to branch master
in repository groff.

commit 46e62c53d3710075174d08af1f73f67f5407f1e7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Dec 13 12:01:20 2025 -0600

    [grog]: Fix Savannah #67802.
    
    * src/utils/grog/grog.pl: Improve heuristics for distinguishing mm(7)
      documents from those for other packages.  (interpret_line): Recognize
      `APP`, `APPSK`, `AF`, `AS`, `COVEND`, `INITI`, `IND`, `INDP`, `INITR`,
      `SETR`, `GETHN`, `GETPN`, `ISODATE`, `MULB`, `MULN`, and `MULE` as
      unique to mm.  (infer_man_or_ms_package): Stop recognizing `RP`, `TL`,
      `AU`, `ND`, `AE`, `B1`, `B2`, `DS`, `DE`, `1C`, `2C`, and `MC` as
      unique to ms, since mm also defines them.  Stop recognizing `P` and
      `EX` as unique to man, since mm also defines them.
    
    * src/utils/grog/tests/smoke-test.sh: Add most mm examples as test
      cases.  A couple are deeply ambiguous, like "B1B2", which is so
      limited that it is valid (and renders sensibly) with either the mm(7)
      _or_ ms(7) packages, and "story.mm" which uses only macro names that
      are shared variously among man(7), mm(7), mom(7), and ms(7).
    
    Fixes <https://savannah.gnu.org/bugs/?67802>.
---
 ChangeLog                          | 20 ++++++++++++++++++++
 src/utils/grog/grog.pl             | 36 ++++++++++++++++++++++++------------
 src/utils/grog/tests/smoke-test.sh | 17 +++++++++++++----
 3 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ad74067e3..a98f0b174 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-12-12  G. Branden Robinson <[email protected]>
+
+       * src/utils/grog/grog.pl: Improve heuristics for distinguishing
+       mm(7) documents from those for other packages.
+       (interpret_line): Recognize `APP`, `APPSK`, `AF`, `AS`,
+       `COVEND`, `INITI`, `IND`, `INDP`, `INITR`, `SETR`, `GETHN`,
+       `GETPN`, `ISODATE`, `MULB`, `MULN`, and `MULE` as unique to mm.
+       (infer_man_or_ms_package): Stop recognizing `RP`, `TL`, `AU`,
+       `ND`, `AE`, `B1`, `B2`, `DS`, `DE`, `1C`, `2C`, and `MC` as
+       unique to ms, since mm also defines them.  Stop recognizing `P`
+       and `EX` as unique to man, since mm also defines them.
+       * src/utils/grog/tests/smoke-test.sh: Add most mm examples as
+       test cases.  A couple are deeply ambiguous, like "B1B2", which
+       is so limited that it is valid (and renders sensibly) with
+       either the mm(7) _or_ ms(7) packages, and "story.mm" which uses
+       only macro names that are shared variously among man(7), mm(7),
+       mom(7), and ms(7).
+
+       Fixes <https://savannah.gnu.org/bugs/?67802>.
+
 2025-12-12  G. Branden Robinson <[email protected]>
 
        * src/utils/xtotroff/xtotroff.c (MapFont): Make fatal error
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index ca1fefe1b..255d3718d 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -395,11 +395,15 @@ sub interpret_line {
   # mm and mmse
   if ($macro =~ /^(
                   AL|BL|BVL|DL|ML|RL|VL|
-                  EPIC|
-                  H|
-                  HU|
+                  APP|APPSK|
+                  AF|AS|
+                  COVEND|EPIC|
+                  H|HU|
+                  INITI|IND|INDP|
+                  INITR|SETR|GETHN|GETPN|
+                  ISODATE|
                   LB|LE
-                  MULB|
+                  MULB|MULN|MULE|
                   LO|
                   LT|
                   NCOL|
@@ -407,7 +411,11 @@ sub interpret_line {
                   SA
                  )$/x) {
     # `LI` is unique to mm among full-service macro packages, but
-    # www.tmac muddies the waters, so omit it.  `MT` also used by man.
+    # www.tmac muddies the waters, so omit it.
+    # P and MT are also used by man.
+    # COVER and SP are also used by mom.
+    # 1C, 2C, AE, AU, B1, B2, DE, DS, MC, ND, TL, and RP are also used
+    # by mm.
     if ($macro =~ /^LO$/) {
       if ($args =~ /^(DNAMN|MDAT|BIL|KOMP|DBET|BET|SIDOR)/) {
        push_main_package('mse');
@@ -455,6 +463,8 @@ sub interpret_line {
                   TOC|
                   T_MARGIN|
                  )$/x) {
+    # PP is also used by man.
+    # SP is also used by mm.
     push_main_package('om');
     return;
   }
@@ -495,29 +505,31 @@ sub infer_preprocessors {
 
 # Return true (1) if either the man or ms package is inferred.
 sub infer_man_or_ms_package {
-  my @macro_ms = ('RP', 'TL', 'AU', 'AI', 'DA', 'ND', 'AB', 'AE',
+  my @macro_ms = ('AI', 'DA', 'AB',
                  'QP', 'QS', 'QE', 'XP',
                  'NH',
                  'R',
                  'CW',
                  'BX', 'UL', 'LG', 'NL',
-                 'KS', 'KF', 'KE', 'B1', 'B2',
-                 'DS', 'DE', 'LD', 'ID', 'BD', 'CD', 'RD',
+                 'KS', 'KF', 'KE',
+                 'LD', 'ID', 'BD', 'CD', 'RD',
                  'FS', 'FE',
                  'OH', 'OF', 'EH', 'EF', 'P1',
-                 'TA', '1C', '2C', 'MC',
+                 'TA',
                  'XS', 'XE', 'XA', 'TC', 'PX',
                  'IX', 'SG');
+  # 1C, 2C, AE, AU, B1, B2, DE, DS, MC, ND, TL, RP are also used by mm.
 
-  my @macro_man = ('BR', 'IB', 'IR', 'RB', 'RI', 'P', 'TP', 'SS',
+  my @macro_man = ('BR', 'IB', 'IR', 'RB', 'RI', 'TP', 'SS',
                   'HP', 'PD',
                   'AT', 'UC',
                   'SB',
-                  'EE', 'EX',
+                  'EE',
                   'OP',
                   'ME', 'SY', 'YS', 'TQ', 'UR', 'UE', 'MR');
   # TH can be used by ms, mm, me, mdoc, and mom.
-  # MT is also used by mm.
+  # EX, P, and MT are also used by mm.
+  # PP is also used by mom.
 
   my @macro_man_or_ms = ('B', 'I', 'BI',
                         'DT',
diff --git a/src/utils/grog/tests/smoke-test.sh 
b/src/utils/grog/tests/smoke-test.sh
index b018ec73c..af1c231cb 100755
--- a/src/utils/grog/tests/smoke-test.sh
+++ b/src/utils/grog/tests/smoke-test.sh
@@ -69,10 +69,19 @@ echo "testing grn(1)- and eqn(1)-using me(7) document $doc" 
>&2
 "$grog" "$doc" | \
     grep -Fqx 'groff -e -g -me '"$doc"
 
-doc=$src/contrib/mm/examples/letter.mm
-echo "testing mm(7) document $doc" >&2
-"$grog" "$doc" | \
-    grep -Fqx 'groff -mm '"$doc"
+for f in APP COVER IND LT ML MOVE MUL NCOL ND References SETR \
+         letter.mm memorandum.mm
+do
+    doc=$src/contrib/mm/examples/$f
+    echo "testing mm(7) document $doc" >&2
+    "$grog" "$doc" | \
+        grep -Fqx 'groff -mm '"$doc"
+done
+
+doc=$src/contrib/mm/examples/LT.se
+echo "testing mmse(7) document $doc" >&2
+"$grog" "$doc" | \
+    grep -Fqx 'groff -mmse '"$doc"
 
 doc=$src/contrib/mom/examples/copyright-chapter.mom
 echo "testing mom(7) document $doc" >&2

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

Reply via email to