groff-commit
[Top][All Lists]
Advanced

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

[groff] 10/14: [grog]: Drop filename extension-based inference.


From: G. Branden Robinson
Subject: [groff] 10/14: [grog]: Drop filename extension-based inference.
Date: Mon, 28 Jun 2021 00:44:52 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 34989a37b3313ad97cce42d9839b8955b8697e77
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Jun 27 16:08:56 2021 +1000

    [grog]: Drop filename extension-based inference.
    
    * src/utils/grog/grog.pl (handle_file_ext): Delete.
    
      (top level): Drop call site.
    
    I feel this subroutine was poorly judged.  Many of the filename
    extensions it uses are seldom if ever seen outside of this file and the
    groff_filenames(5) man page (also by Bernd).  I also regard the project
    of the subroutine as exceeding grog's proper scope, which is to _make
    heuristic inferences based on the contents on an input stream_.
    
    Admittedly, this does regress one of the smoke tests; doc/webpage.ms is
    no longer detected as an ms(7) document.  It's an interesting case,
    loaded with groff_www(7) macros; all of the ms macros it calls happened
    to have names that man(7) _also_ uses.  Perhaps this why Bernd resorted
    to file name extensions, but I have another idea.
---
 ChangeLog              |  7 ++++
 src/utils/grog/grog.pl | 96 --------------------------------------------------
 2 files changed, 7 insertions(+), 96 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f270630..fb439c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2021-06-27  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [grog]: Discard filename extension-based inference.
+
+       * src/utils/grog/grog.pl (handle_file_ext): Delete.
+       (top level): Drop call site.
+
+2021-06-27  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        * src/utils/grog/grog.pl (handle_args): Complain less noisily
        and more comprehensibly when given unrecognized groff options.
 
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index a89834e..4c2c193 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -293,101 +293,6 @@ sub handle_args {
 } # handle_args()
 
 
-sub handle_file_ext {
-  # get tmac from file name extension
-  # output number of found single tmac
-
-  # globals: @filespec, $tmac_ext;
-
-  foreach my $file ( @filespec ) {
-    # We will complain about unopenable files in &handle_whole_files.
-    next unless ( open(FILE, $file eq "-" ? $file : "< $file") );
-    next unless ( $file =~ /\./ ); # file name has no dot '.'
-
-    # get extension
-    my $ext = $file;
-    $ext =~ s/^
-             .*
-             \.
-             ([^.]*)
-             $
-            /$1/x;
-    next unless ( $ext );
-
-    # these extensions are correct, but not based on a tmac
-    next if ( $ext =~ /^(
-                        chem|
-                        eqn|
-                        g|
-                        grap|
-                        grn|
-                        groff|
-                        hdtbl|
-                        pdfroff|
-                        pic|
-                        pinyin|
-                        ref|
-                        roff|
-                        t|
-                        tbl|
-                        tr|
-                        www
-                      )$/x );
-
-    # extensions for man tmac
-    if ( $ext =~ /^(
-                     [1-9lno]|
-                     man|
-                     n|
-                     1b
-                   )$/x ) {
-      # 'man|n' from 'groff' source
-      # '1b' from 'heirloom'
-      # '[1-9lno]' from man-pages
-      if ( $tmac_ext && $tmac_ext ne 'man' ) {
-       # found tmac is not 'man'
-       print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-         '2 different file name extensions found ' .
-           $tmac_ext . ' and ' . $ext;
-       $tmac_ext = '';
-       next;
-      }
-
-      $tmac_ext = 'man';
-      next;
-    }
-
-    if ( $ext =~ /^(
-                   mandoc|
-                   mdoc|
-                   me|
-                   mm|
-                   mmse|
-                   mom|
-                   ms|
-                   $)/x ) {
-      if ( $tmac_ext && $tmac_ext ne $ext ) {
-       # found tmac is not identical to former found tmac
-       print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-         '2 different file name extensions found ' .
-           $tmac_ext . ' and ' . $ext;
-       $tmac_ext = '';
-       next;
-      }
-
-      $tmac_ext = $ext;
-      next;
-    }
-
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'Unknown file name extension '. $file . '.';
-    next;
-  } # end foreach file
-
-  1;
-} # handle_file_ext()
-
-
 sub handle_whole_files {
   # globals: @filespec
 
@@ -1179,7 +1084,6 @@ if ($before_make) {
 }
 
 &handle_args();
-&handle_file_ext(); # see $tmac_ext for gotten value
 &handle_whole_files();
 
 if ($have_any_valid_args) {



reply via email to

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