]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Update to version 1.29.
authorJim Meyering <jim@meyering.net>
Tue, 8 Jul 2003 21:00:01 +0000 (21:00 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 8 Jul 2003 21:00:01 +0000 (21:00 +0000)
man/help2man

index e7441359c50ae154d52e4513578790d732160e2c..55490a03c58ac4380676362f777bb238e55cbc61 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/perl -w
 
 # Generate a short man page from --help and --version output.
-# Copyright © 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+# Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-# Written by Brendan O'Dea <bod@compusol.com.au>
+# Written by Brendan O'Dea <bod@debian.org>
 # Available from ftp://ftp.gnu.org/gnu/help2man/
 
-use 5.004;
+use 5.005;
 use strict;
 use Getopt::Long;
 use Text::Tabs qw(expand);
 use POSIX qw(strftime setlocale LC_TIME);
 
 my $this_program = 'help2man';
-my $this_version = '1.24';
+my $this_version = '1.29';
 my $version_info = <<EOT;
 GNU $this_program $this_version
 
-Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-Written by Brendan O'Dea <bod\@compusol.com.au>
+Written by Brendan O'Dea <bod\@debian.org>
 EOT
 
 my $help_info = <<EOT;
@@ -43,29 +44,46 @@ my $help_info = <<EOT;
 
 Usage: $this_program [OPTION]... EXECUTABLE
 
- -n, --name=STRING       use `STRING' as the description for the NAME paragraph
- -s, --section=SECTION   use `SECTION' as the section for the man page
+ -n, --name=STRING       description for the NAME paragraph
+ -s, --section=SECTION   section number for manual page (1, 6, 8)
+ -m, --manual=TEXT       name of manual (User Commands, ...)
+ -S, --source=TEXT       source of program (FSF, Debian, ...)
  -i, --include=FILE      include material from `FILE'
  -I, --opt-include=FILE  include material from `FILE' if it exists
  -o, --output=FILE       send output to `FILE'
+ -p, --info-page=TEXT    name of Texinfo manual
  -N, --no-info           suppress pointer to Texinfo manual
      --help              print this help, then exit
      --version           print version number, then exit
 
-EXECUTABLE should accept `--help' and `--version' options.
+EXECUTABLE should accept `--help' and `--version' options although
+alternatives may be specified using:
+
+ -h, --help-option=STRING     help option string
+ -v, --version-option=STRING  version option string
 
 Report bugs to <bug-help2man\@gnu.org>.
 EOT
 
 my $section = 1;
-my ($opt_name, @opt_include, $opt_output, $opt_no_info);
+my $manual = '';
+my $source = '';
+my $help_option = '--help';
+my $version_option = '--version';
+my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info);
+
 my %opt_def = (
-    'n|name=s'         => \$opt_name,
-    's|section=s'      => \$section,
-    'i|include=s'      => sub { push @opt_include, [ pop, 1 ] },
-    'I|opt-include=s'  => sub { push @opt_include, [ pop, 0 ] },
-    'o|output=s'       => \$opt_output,
-    'N|no-info'                => \$opt_no_info,
+    'n|name=s'          => \$opt_name,
+    's|section=s'       => \$section,
+    'm|manual=s'        => \$manual,
+    'S|source=s'        => \$source,
+    'i|include=s'       => sub { push @opt_include, [ pop, 1 ] },
+    'I|opt-include=s'   => sub { push @opt_include, [ pop, 0 ] },
+    'o|output=s'        => \$opt_output,
+    'p|info-page=s'     => \$opt_info,
+    'N|no-info'                 => \$opt_no_info,
+    'h|help-option=s'   => \$help_option,
+    'v|version-option=s' => \$version_option,
 );
 
 # Parse options.
@@ -81,9 +99,6 @@ my %include = ();
 my %append = ();
 my @include = (); # retain order given in include file
 
-# Provide replacement `quote-regex' operator for pre-5.005.
-BEGIN { eval q(sub qr { '' =~ $_[0]; $_[0] }) if $] < 5.005 }
-
 # Process include file (if given).  Format is:
 #
 #   [section name]
@@ -175,9 +190,9 @@ setlocale LC_TIME, 'C';
 
 # Grab help and version info from executable.
 my ($help_text, $version_text) = map {
-    join '', map { s/ +$//; expand $_ } `$ARGV[0] --$_ 2>/dev/null`
-       or die "$this_program: can't get `--$_' info from $ARGV[0]\n"
-} qw(help version);
+    join '', map { s/ +$//; expand $_ } `$ARGV[0] $_ 2>/dev/null`
+       or die "$this_program: can't get `$_' info from $ARGV[0]\n"
+} $help_option, $version_option;
 
 my $date = strftime "%B %Y", localtime;
 (my $program = $ARGV[0]) =~ s!.*/!!;
@@ -239,6 +254,18 @@ $include{NAME} ||= "$program \\- manual page for $program $version\n";
 # Man pages traditionally have the page title in caps.
 my $PROGRAM = uc $program;
 
+# Set default page head/footers
+$source ||= "$program $version";
+unless ($manual)
+{
+    for ($section)
+    {
+       if (/^(1[Mm]|8)/) { $manual = 'System Administration Utilities' }
+       elsif (/^6/)      { $manual = 'Games' }
+       else              { $manual = 'User Commands' }
+    }
+}
+
 # Extract usage clause(s) [if any] for SYNOPSIS.
 if ($help_text =~ s/^Usage:( +(\S+))(.*)((?:\n(?: {6}\1| *or: +\S).*)*)//m)
 {
@@ -377,7 +404,7 @@ while (length)
     my $content = '';
 
     # Option with description.
-    if (s/^( {1,10}([+-]\S.*?))(?:(  +)|\n( {20,}))(\S.*)\n//)
+    if (s/^( {1,10}([+-]\S.*?))(?:(  +(?!-))|\n( {20,}))(\S.*)\n//)
     {
        $matched .= $& if %append;
        $indent = length ($4 || "$1$3");
@@ -462,6 +489,8 @@ while (length)
 # Refer to the real documentation.
 unless ($opt_no_info)
 {
+    my $info_page = $opt_info || $program;
+
     $sect = 'SEE ALSO';
     $include{$sect} ||= '';
     $include{$sect} .= ".PP\n" if $include{$sect};
@@ -474,7 +503,7 @@ and
 .B $program
 programs are properly installed at your site, the command
 .IP
-.B info $program
+.B info $info_page
 .PP
 should give you access to the complete manual.
 EOT
@@ -483,7 +512,7 @@ EOT
 # Output header.
 print <<EOT;
 .\\" DO NOT MODIFY THIS FILE!  It was generated by $this_program $this_version.
-.TH $PROGRAM "$section" "$date" "$package $version" FSF
+.TH $PROGRAM "$section" "$date" "$source" "$manual"
 EOT
 
 # Section ordering.
@@ -498,7 +527,7 @@ for (@pre, (grep ! /^($filter)$/o, @include), @post)
     {
        my $quote = /\W/ ? '"' : '';
        print ".SH $quote$_$quote\n";
-
+       
        for ($include{$_})
        {
            # Replace leading dot, apostrophe and backslash tokens.