groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 09/09: [grog]: Fix Savannah #61520.


From: G. Branden Robinson
Subject: [groff] 09/09: [grog]: Fix Savannah #61520.
Date: Tue, 23 Nov 2021 09:04:48 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit c89f1a91651109bb27f25bc9b15c7db29e899723
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Nov 24 00:48:42 2021 +1100

    [grog]: Fix Savannah #61520.
    
    * src/utils/grog/grog.pl: Move hash `preprocessor_for_macro` to global
      scope since it is now mutable across `do_line` subroutine calls.
    
      (do_line): Adjust regex matching an end macro to work better.  Check
      names of macros being defined by the document; if they start with '['
      or ']', stop attempting to detect refer(1) usage, by deleting its key
      from the `preprocessor_for_macro` hash.
    
    Fixes <https://savannah.gnu.org/bugs/?61520>.
---
 ChangeLog              | 14 ++++++++++++++
 src/utils/grog/grog.pl | 34 +++++++++++++++++++---------------
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d8f1761..27d5508 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2021-11-24  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [grog]: Fix Savannah #61520.
+
+       * src/utils/grog/grog.pl: Move hash `preprocessor_for_macro` to
+       global scope since it is now mutable across `do_line` subroutine
+       calls.
+       (do_line): Adjust regex matching an end macro to work better.
+       Check names of macros being defined by the document; if they
+       start with '[' or ']', stop attempting to detect refer(1) usage,
+       by deleting its key from the `preprocessor_for_macro` hash.
+
+       Fixes <https://savannah.gnu.org/bugs/?61520>.
+
+2021-11-24  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [grog]: Add regression test for Savannah #61520.
 
        * src/utils/grog/tests/avoid-refer-fakeout.sh: Do it.
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index b1da77f..e98c89c 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -46,6 +46,20 @@ my $selected_main_package;   # full-service package we go 
with
 my $do_run = 0;                        # run generated 'groff' command
 my $use_compatibility_mode = 0;        # is -C being passed to groff?
 
+my %preprocessor_for_macro = (
+  'EQ', 'eqn',
+  'G1', 'grap',
+  'GS', 'grn',
+  'PS', 'pic',
+  '[',  'refer',
+  #'so', 'soelim', # Can't be inferred this way; see grog man page.
+  'TS', 'tbl',
+  'cstart',   'chem',
+  'lilypond', 'glilypond',
+  'Perl',     'gperl',
+  'pinyin',   'gpinyin',
+);
+
 my $program_name = $0;
 {
   my ($v, $d, $f) = File::Spec->splitpath($program_name);
@@ -237,20 +251,6 @@ sub do_line {
   # compatibility mode, no space (or newline!) is required after the
   # macro name, either.  We mimic the preprocessors themselves; eqn(1),
   # for instance, does not recognize '.EN' if '.EQ' has not been seen.
-  my %preprocessor_for_macro = (
-    'EQ', 'eqn',
-    'G1', 'grap',
-    'GS', 'grn',
-    'PS', 'pic',
-    '[',  'refer',
-    #'so', 'soelim', # Can't be inferred this way; see grog man page.
-    'TS', 'tbl',
-    'cstart',   'chem',
-    'lilypond', 'glilypond',
-    'Perl',     'gperl',
-    'pinyin',   'gpinyin',
-  );
-
   my $boundary = '\\b';
   $boundary = '' if ($use_compatibility_mode);
 
@@ -338,7 +338,11 @@ sub do_line {
   if ($command =~ /^(de|am)1?$/) {
     my $name = $args;
     # Strip off any end macro.
-    $name =~ s/\W*$//;
+    $name =~ s/\s+.*$//;
+    # Handle special cases of macros starting with '[' or ']'.
+    if ($name =~ /^[][]/) {
+      delete $preprocessor_for_macro{'['};
+    }
     # XXX: If the macro name shadows a standard macro name, maybe we
     # should delete the latter from our lists and hashes.  This might
     # depend on whether the document is trying to remain compatibile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]