-#!/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
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.
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.
{$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";
}
}