From c540aafa3f55b3f4e58c1ae98256fec1b53f0d62 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 8 Jul 2003 21:00:01 +0000 Subject: Update to version 1.29. --- man/help2man | 81 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 26 deletions(-) (limited to 'man') diff --git a/man/help2man b/man/help2man index e7441359c..55490a03c 100755 --- a/man/help2man +++ b/man/help2man @@ -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 @@ -17,25 +18,25 @@ # 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 +# Written by Brendan O'Dea # 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 = < +Written by Brendan O'Dea EOT my $help_info = <. 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 <