bug-groff
[Top][All Lists]
Advanced

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

[bug #59676] [PATCH] grog/subs.pl: Don't use "exists" on array values


From: Bjarni Ingi Gislason
Subject: [bug #59676] [PATCH] grog/subs.pl: Don't use "exists" on array values
Date: Sun, 13 Dec 2020 14:24:16 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

URL:
  <https://savannah.gnu.org/bugs/?59676>

                 Summary: [PATCH] grog/subs.pl: Don't use "exists" on array
values
                 Project: GNU troff
            Submitted by: bjarniig
            Submitted on: Sun 13 Dec 2020 07:24:14 PM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

src/roff/grog/subs.pl: Don't use "exists" on array values

1) perlfunc(1) warns against using "exists" on array values.
Use "defined" instead.

  This avoids the use of defined macros as indicators for a
particular macro package.

  The ".TL" macro for 'ms'-files is thus available as an indicator.

  This is a correction of patch #59664, 3th item.

2) Remove inline comments.

  Otherwise the comment can be included in the name of a defined macro.
  Seen in the file "doc/meref.me" with the line

.de TL                  \" *** title line

3) Do not remove the beginning line of a macro definition (.de...).

  Defined macros must be excluded from being used as indicators for a
particular macro package.

  A correction of the patch in #59622.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 src/roff/grog/subs.pl | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index 54d195b5..db5bc10a 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -563,16 +563,18 @@ sub do_line {
 
   $line =~ s/^['.]\s*/./;      # let only a dot as leading character,
                                # remove spaces after the leading dot
+  $line =~ s/\\".*$//;         # remove inline comments (for '.de ...' lines)
   $line =~ s/\s+$//;           # remove final spaces
 
   return if ( $line =~ /^\.$/ );       # ignore .
   return if ( $line =~ /^\.\.$/ );     # ignore ..
 
   # Ignore "Standard preamble" from perl module "Pod::Man"
-  # Keep commands, that are in me files
+  # Keep macros in me files and defined macros
   if ( $line !~ /^\.(
                    [ilnp]p|
-                   sh
+                   sh|
+                   de1?\s+.*
                  )$/x ) {
     return if ( $line =~ /^\.[[:lower:]]/ );
     return if ( $line =~ /^\.\s*\\}/ );
@@ -618,14 +620,14 @@ sub do_line {
     # this line is a macro definition, add it to %macros
     my $macro = $line;
     $macro =~ s/^\.de1?\s+(\w+)\W*/.$1/;
-    return if ( exists $macros{$macro} );
+    return if ( defined $macros{$macro} );
     $macros{$macro} = 1;
     return;
   }
 
 
   # if line command is a defined macro, just ignore this line
-  return if ( exists $macros{$command} );
+  return if ( defined $macros{$command} );
 
 
   ######################################################################
@@ -766,10 +768,10 @@ sub do_line {
     $Groff{'NH'}++;            # for ms
     return;
   }
-#  if ( $command =~ /^\.TL$/ ) {
-#    $Groff{'TL'}++;           # for ms
-#    return;
-#  }
+  if ( $command =~ /^\.TL$/ ) {
+    $Groff{'TL'}++;            # for ms
+    return;
+  }
   if ( $command =~ /^\.XP$/ ) {
     $Groff{'XP'}++;            # for ms
     return;
-- 
2.29.2






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59676>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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