diff options
Diffstat (limited to 'man')
-rwxr-xr-x | man/help2man | 75 |
1 files changed, 45 insertions, 30 deletions
diff --git a/man/help2man b/man/help2man index 895069e89..c4ef0c815 100755 --- a/man/help2man +++ b/man/help2man @@ -1,7 +1,7 @@ -#!/usr/bin/perl -w +#!/sw/tools/bin/perl -w # Generate a short man page from --help and --version output. -# Copyright © 1997, 98 Free Software Foundation, Inc. +# Copyright © 1997, 98, 99 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 @@ -25,11 +25,11 @@ use Getopt::Long; use POSIX qw(strftime setlocale LC_TIME); my $this_program = 'help2man'; -my $this_version = '1.007'; +my $this_version = '1.010'; my $version_info = <<EOT; $this_program $this_version -Copyright (C) 1997, 98 Free Software Foundation, Inc. +Copyright (C) 1997, 98, 99 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. @@ -252,11 +252,11 @@ for (@help) next; } - # Catch start of options. - if (/^Options:/) + # Convert some standard paragraph names + if (s/^(Options|Examples):\s*\n//) { - print qq(.SH OPTIONS\n); - s/Options://; + print qq(.SH \U$1\n); + next unless length; } # Catch bug report text. @@ -271,35 +271,50 @@ for (@help) {$1$2$1\\&...=PATTERN }; # Convert options. - s/(\s)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/ge; + s/((?:^|,)\s+)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/mge; # Option subsections have second line indented. print qq(.SS "$1"\n) if s/^(\S.*)\n(\s)/$2/; - # Lines indented more than about 10 spaces may be assumed to be - # continuations of the previous line. - s/\n {10,}/ /g; - - # Lines following dotted (*) or numbered points may also be - # continued if indented to the same level as the text following - # the point. - 1 while s{((?:^|\n)(\s+)(?:[1-9][.)]|\*)(\s+)(?:[^\n]+))\n\2 \3(\S)} - {$1 $4}g; - - # Indented paragraph. - if (/^\s/) + my $ind = 0; + for (split /\n/) { - for (split /\n/) + # indented paragraph + if (/^\s/) { - s/^\s+//; - s/([^,])\s+/$1\n/; - print ".TP\n$_\n" if $_; + # Join continued lines when indented to the same point as + # text following at least two spaces on the previous line. + if ($ind > 0 and /^ {$ind}\S/) + { + s/^\s+//; + print "$_\n" if $_; + } + else + { + # use the words(s) before two or more spaces for the + # tag + s/^(\s+)//; + $ind = length $1; + + if (s/(\s\s+)/\n/) + { + $ind += (length $1) + index $_, "\n"; + } + else + { + $ind = 0; + } + + print ".TP\n$_\n" if $_; + } + } + # Anything else. + else + { + print ".PP\n" unless $ind < 0; + print "$_\n"; + $ind = -1; } - } - # Anything else. - else - { - print ".PP\n$_\n"; } } |