gbranden pushed a commit to branch master
in repository groff.

commit 8c4788c44d277814e744a1bacfcc4b10a8b4907b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jun 20 18:56:35 2024 -0500

    [grog]: Fix Savannah #65902 (detect use of chem(1)).
    
    * src/utils/grog/grog.pl: Take `cstart` and `cend` tokens out of
      `preprocessor_for_macro` hash.  They don't work with the existing
      logic.  Also drop tokens used by preprocessors that don't have
      corresponding groff(1) options and therefore don't influence the
      output grog(1) can emit.
    
      (do_line): Add bespoke handling for `cstart` and `cend`.  Not only are
      they the only AT&T troff preprocessor tokens that are longer than two
      characters, but their names collide in those first two characters with
      the names of troff requests.
    
    Fixes Savannah #65902.  Thanks to Morten Bo Johansen for the report.
    Problem introduced by me in commit 53a9964497, 31 July 2021.
    
    ANNOUNCE: Acknowledge Morten.
---
 ANNOUNCE               |  1 +
 ChangeLog              | 18 ++++++++++++++++++
 src/utils/grog/grog.pl | 14 ++++++++++----
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/ANNOUNCE b/ANNOUNCE
index d0607dcd7..560a1113d 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -180,6 +180,7 @@ Ingo Schwarze
 Lennart Jablonka
 MichaƂ Kruszewski
 Mike Fulton
+Morten Bo Johansen
 Nikita Ivanov
 Patrice Dumas
 Paul Eggert
diff --git a/ChangeLog b/ChangeLog
index fdcfd8177..89a939a24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-06-20  G. Branden Robinson <[email protected]>
+
+       [grog]: Fix Savannah #65902 (detect use of chem(1)).
+
+       * src/utils/grog/grog.pl: Take `cstart` and `cend` tokens out of
+       `preprocessor_for_macro` hash.  They don't work with the
+       existing logic.  Also drop tokens used by preprocessors that
+       don't have corresponding groff(1) options and therefore don't
+       influence the output grog(1) can emit.
+       (do_line): Add bespoke handling for `cstart` and `cend`.  Not
+       only are they the only AT&T troff preprocessor tokens that are
+       longer than two characters, but their names collide in those
+       first two characters with the names of troff requests.
+
+       Fixes Savannah #65902.  Thanks to Morten Bo Johansen for the
+       report.  Problem introduced by me in commit 53a9964497, 31 July
+       2021.
+
 2024-06-20  G. Branden Robinson <[email protected]>
 
        Regression-test Savannah #65902.
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index 4820c2b87..d7e623aac 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -38,6 +38,7 @@ my @inferred_main_package = ();       # full-service 
package(s) detected
 my $main_package;              # full-service package we go with
 my $use_compatibility_mode = 0;        # is -C being passed to groff?
 
+# See subroutine do_line below for chem(1) handling.
 my %preprocessor_for_macro = (
   'EQ', 'eqn',
   'G1', 'grap',
@@ -46,10 +47,6 @@ my %preprocessor_for_macro = (
   '[',  'refer',
   #'so', 'soelim', # Can't be inferred this way; see grog man page.
   'TS', 'tbl',
-  'cstart',   'chem',
-  'lilypond', 'glilypond',
-  'Perl',     'gperl',
-  'pinyin',   'gpinyin',
 );
 
 (undef, undef, my $program_name) = File::Spec->splitpath($0);
@@ -247,6 +244,15 @@ sub do_line {
     }
   }
 
+  # Handle "chem" as a special case, since its start/end tokens collide
+  # with AT&T troff request names in their first two characters.
+  if ($line =~ /^\.(cstart|cend)\b/) {
+    my $preproc = 'chem';
+    if (!grep(/$preproc/, @inferred_preprocessor)) {
+      push @inferred_preprocessor, $preproc;
+    }
+  }
+
   # Normalize control lines; convert no-break control character to the
   # regular one and remove unnecessary whitespace.
   $line =~ s/^['.]\s*/./;

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

Reply via email to