summaryrefslogtreecommitdiff
path: root/man/help2man
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-11-25 12:37:11 +0000
committerJim Meyering <jim@meyering.net>2004-11-25 12:37:11 +0000
commit21baebf1222166aa23d141a1aa6b81014db72c01 (patch)
treea382b634af7709217d4d96220a89c8ddbce9cd4b /man/help2man
parent6c69127c839af7717bffaf2dc3472ba5fed45007 (diff)
downloadcoreutils-21baebf1222166aa23d141a1aa6b81014db72c01.tar.xz
Import help2man-1.35.1.
Diffstat (limited to 'man/help2man')
-rwxr-xr-xman/help2man83
1 files changed, 41 insertions, 42 deletions
diff --git a/man/help2man b/man/help2man
index e8ea71854..c0244e6a3 100755
--- a/man/help2man
+++ b/man/help2man
@@ -1,8 +1,8 @@
#!/usr/bin/perl -w
# Generate a short man page from --help and --version output.
-# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
-# Foundation, Inc.
+# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# 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
@@ -29,7 +29,7 @@ use POSIX qw(strftime setlocale LC_ALL);
use locale;
my $this_program = 'help2man';
-my $this_version = '1.33';
+my $this_version = '1.35';
my $have_gettext;
BEGIN {
@@ -46,13 +46,6 @@ BEGIN {
}
}
-sub escape_hyphens($)
-{
- my ($s) = @_;
- $s =~ s/-/\\-/g;
- return $s;
-}
-
sub _ { gettext @_ }
sub N_ { $_[0] }
@@ -72,7 +65,7 @@ textdomain $this_program;
my $version_info = sprintf _(<<'EOT'), $this_program, $this_version;
GNU %s %s
-Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 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.
@@ -85,8 +78,6 @@ my $help_info = sprintf _(<<'EOT'), $this_program, $this_program;
Usage: %s [OPTION]... EXECUTABLE
- --program_name=NAME override any name found in output of
- `EXECUTABLE --version'
-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, ...)
@@ -116,10 +107,8 @@ my $locale = 'C';
my $help_option = '--help';
my $version_option = '--version';
my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info);
-my $opt_program_name;
my %opt_def = (
- 'program-name=s' => \$opt_program_name,
'n|name=s' => \$opt_name,
's|section=s' => \$section,
'm|manual=s' => \$manual,
@@ -228,7 +217,7 @@ while (@opt_include)
close INC;
kark N_("%s: no valid information found in `%s'"), $this_program, $inc
- unless $key;
+ unless $key;
}
# Compress trailing blank lines.
@@ -252,7 +241,7 @@ my $version;
if ($opt_output)
{
unlink $opt_output or kark N_("%s: can't unlink %s (%s)"),
- $this_program, $opt_output, $! if -e $opt_output;
+ $this_program, $opt_output, $! if -e $opt_output;
open STDOUT, ">$opt_output"
or kark N_("%s: can't create %s (%s)"), $this_program, $opt_output, $!;
@@ -290,18 +279,26 @@ else
}
$program =~ s!.*/!!;
-$opt_program_name
- and $program = $opt_program_name;
# No info for `info' itself.
$opt_no_info = 1 if $program eq 'info';
-# --name overrides --include contents.
-$include{_('NAME')} = "$program \\- $opt_name\n" if $opt_name;
-
-# Default (useless) NAME paragraph.
-$include{_('NAME')} ||= sprintf _("%s \\- manual page for %s %s") . "\n",
- $program, $program, $version;
+for ($include{_('NAME')})
+{
+ if ($opt_name) # --name overrides --include contents.
+ {
+ $_ = "$program \\- $opt_name\n";
+ }
+ elsif ($_) # Use first name given as $program
+ {
+ $program = $1 if /^([^\s,]+)(?:,?\s*[^\s,\\-]+)*\s+\\?-/;
+ }
+ else # Set a default (useless) NAME paragraph.
+ {
+ $_ = sprintf _("%s \\- manual page for %s %s") . "\n", $program,
+ $program, $version;
+ }
+}
# Man pages traditionally have the page title in caps.
my $PROGRAM = uc $program;
@@ -363,6 +360,9 @@ s/^\n+//;
s/\n*$/\n/;
s/\n\n+/\n\n/g;
+# Join hyphenated lines.
+s/([A-Za-z])-\n *([A-Za-z])/$1$2/g;
+
# Temporarily exchange leading dots, apostrophes and backslashes for
# tokens.
s/^\./\x80/mg;
@@ -416,9 +416,6 @@ while (length)
# Insert line breaks before additional copyright messages
# and the disclaimer.
s/(.)\n(Copyright |$PAT_FREE_SOFTWARE)/$1\n.br\n$2/og;
-
- # Join hyphenated lines.
- s/([A-Za-z])-\n */$1/g;
}
$include{$sect} .= $copy;
@@ -473,7 +470,7 @@ while (length)
{
$matched .= $& if %append;
$indent = length ($4 || "$1$3");
- $content = ".TP\n\x83$2\n\x83$5\n";
+ $content = ".TP\n\x84$2\n\x84$5\n";
unless ($4)
{
# Indent may be different on second line.
@@ -485,7 +482,7 @@ while (length)
elsif (s/^ {1,10}([+-]\S.*)\n//)
{
$matched .= $& if %append;
- $content = ".HP\n\x83$1\n";
+ $content = ".HP\n\x84$1\n";
$indent = 80; # not continued
}
@@ -494,7 +491,7 @@ while (length)
{
$matched .= $& if %append;
$indent = length $1;
- $content = ".TP\n\x83$2\n\x83$3\n";
+ $content = ".TP\n\x84$2\n\x84$3\n";
}
# Indented paragraph.
@@ -502,7 +499,7 @@ while (length)
{
$matched .= $& if %append;
$indent = length $1;
- $content = ".IP\n\x83$2\n";
+ $content = ".IP\n\x84$2\n";
}
# Left justified paragraph.
@@ -518,7 +515,7 @@ while (length)
while ($indent ? s/^ {$indent}(\S.*)\n// : s/^(\S.*)\n//)
{
$matched .= $& if %append;
- $content .= "\x83$1\n"
+ $content .= "\x84$1\n"
}
# Move to next paragraph.
@@ -527,12 +524,15 @@ while (length)
for ($content)
{
# Leading dot and apostrophe protection.
- s/\x83\./\x80/g;
- s/\x83'/\x81/g;
- s/\x83//g;
+ s/\x84\./\x80/g;
+ s/\x84'/\x81/g;
+ s/\x84//g;
# Convert options.
- s/(^| )(-[][\w=-]+)/$1 . convert_option $2/mge;
+ s/(^| |\()(-[][\w=-]+)/$1 . convert_option $2/mge;
+
+ # Escape remaining hyphens
+ s/-/\x83/g;
}
# Check if matched paragraph contains /pat/.
@@ -598,17 +598,16 @@ for my $sect (@pre, (grep ! /^($filter)$/o, @include), @post)
for ($include{$sect})
{
- # Replace leading dot, apostrophe and backslash tokens.
+ # Replace leading dot, apostrophe, backslash and hyphen
+ # tokens.
s/\x80/\\&./g;
s/\x81/\\&'/g;
s/\x82/\\e/g;
+ s/\x83/\\-/g;
# Convert some latin1 chars to troff equivalents
s/\xa0/\\ /g; # non-breaking space
- # Escape hyphens in <>-enclosed email addresses.
- s/(<\S+\@(\S+\.)+\S{2,}>)/escape_hyphens $1/ge;
-
print;
}
}
@@ -625,7 +624,7 @@ sub convert_option
{
local $_ = '\fB' . shift;
- s/-/\\-/g;
+ s/-/\x83/g;
unless (s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/)
{
s/=(.)/\\fR=\\fI$1/;