bug-groff
[Top][All Lists]
Advanced

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

[bug #59664] [PATCH] grog/subs.pl: Increase the number of files that are


From: Bjarni Ingi Gislason
Subject: [bug #59664] [PATCH] grog/subs.pl: Increase the number of files that are identified correctly
Date: Fri, 11 Dec 2020 20:48:53 -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/?59664>

                 Summary: [PATCH] grog/subs.pl: Increase the number of files
that are identified correctly
                 Project: GNU troff
            Submitted by: bjarniig
            Submitted on: Sat 12 Dec 2020 01:48:51 AM UTC
                Category: Core
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

Subject: [PATCH] grog/subs.pl: Increase the number of files that are
 identified correctly

src/roff/grog/subs.pl: Increase the number of files that are identified
correctly.

1) Don't remove commands whoes lowercase names are used as a detection
for 'me'-files.

2) The macro ".TH" can also be a part of a table.
Don't interpret that as an indicator for a 'man' or a 'ms' file.

3)  Don't use the macros ".TL", ".PP", and ".SS" as indicators,
as they can lead to a false result.

4) Add the arguments to the regular expression for macros in "mom"
files.

  With this patch, all 'man', 'me', 'mom, and 'ms' files in the
repository are correctly identified.

  The only example of a 'mm'-file is "letter.mm",
which is not recognized correctly.

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

diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index 1c40dd95..54d195b5 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -114,11 +114,11 @@ my %Groff =
    'IP' => 0,          # man and ms
    'LP' => 0,          # man and ms
    'P' => 0,           # man and ms
-   'PP' => 0,          # man and ms
+   'PP' => 0,          # man, mom,  and ms
    'SH' => 0,          # man and ms
 
    'OP' => 0,          # man
-   'SS' => 0,          # man
+   'SS' => 0,          # man and mom
    'SY' => 0,          # man
    'TH_first' => 0,    # TH as 1st command is man
    'TP' => 0,          # man
@@ -569,16 +569,22 @@ sub do_line {
   return if ( $line =~ /^\.\.$/ );     # ignore ..
 
   # Ignore "Standard preamble" from perl module "Pod::Man"
-  return if ( $line =~ /^\.[[:lower:]]/ );
-  return if ( $line =~ /^\.\s*\\}/ );
-  return if ( $line =~ /^\.IX / );
+  # Keep commands, that are in 'me' files
+  if ( $line !~ /^\.(
+                   [ilnp]p|
+                   sh
+                 )$/x ) {
+    return if ( $line =~ /^\.[[:lower:]]/ );
+    return if ( $line =~ /^\.\s*\\}/ );
+    return if ( $line =~ /^\.IX / );
+  }
 
   if ( $before_first_command ) { # so far without 1st command
-    if ( $line =~ /^\.TH/ ) {
+    if ( ($line =~ /^\.TH/ ) && ($Groff{'tbl'} == 0 ) ) {
       # check if .TH is 1st command for man
       $Groff{'TH_first'} = 1 if ( $line =~ /^\.\s*TH/ );
     }
-    if ( $line =~ /^\./ ) {
+    if ( ( $line =~ /^\./ ) && ($Groff{'tbl'} == 0) ) {
       $before_first_command = 0;
     }
   }
@@ -691,7 +697,7 @@ sub do_line {
     return;
   }
   if ( $command =~ /^\.TH$/ ) {
-    unless ( $Groff{'TH_first'} ) {
+    unless ( $Groff{'TH_first'} || ($ext eq 'mom') ) {
       $Groff{'TH_later'}++;            # for tbl
     }
     return;
@@ -760,10 +766,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;
@@ -786,10 +792,10 @@ sub do_line {
     $Groff{'P'}++;             # for man and ms
     return;
   }
-  if ( $command =~ /^\.PP$/ ) {
-    $Groff{'PP'}++;            # for man and ms
-    return;
-  }
+#  if ( $command =~ /^\.PP$/ ) {
+#    $Groff{'PP'}++;           # for man, mom, and ms
+#    return;
+#  }
   if ( $command =~ /^\.SH$/ ) {
     $Groff{'SH'}++;            # for man and ms
     return;
@@ -807,10 +813,10 @@ sub do_line {
     $Groff{'OP'}++;
     return;
   }
-  if ( $command =~ /^\.SS$/ ) {        # for man
-    $Groff{'SS'}++;
-    return;
-  }
+#  if ( $command =~ /^\.SS$/ ) {       # for man and mom
+#    $Groff{'SS'}++;
+#    return;
+#  }
   if ( $command =~ /^\.SY$/ ) {        # for man
     $Groff{'SY'}++;
     return;
@@ -886,7 +892,7 @@ sub do_line {
                   PRINTSTYLE|
                   PT_SIZE|
                   T_MARGIN
-                )$/x ) {
+                ).*$/x ) {
     $Groff{'mom'}++;           # for mom
     return;
   }
-- 
2.29.2






    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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