| 1 | #!/usr/local/bin/perl -w | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | # Generate a short man page from --help and --version output. | ||||||||||||||||||||||||||||||||
| 4 | # Copyright © 1997, 98, 99 Free Software Foundation, Inc. | ||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||
| 7 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||
| 8 | # the Free Software Foundation; either version 2, or (at your option) | ||||||||||||||||||||||||||||||||
| 9 | # any later version. | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||
| 14 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||
| 17 | # along with this program; if not, write to the Free Software Foundation, | ||||||||||||||||||||||||||||||||
| 18 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | # Written by Brendan O'Dea <bod@compusol.com.au> | ||||||||||||||||||||||||||||||||
| 21 | # Available from ftp://ftp.gnu.org/gnu/help2man/ | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Text::Tabs qw(expand); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use POSIX qw(strftime setlocale LC_TIME); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 1 | my $this_program = 'help2man'; | |||||||||||||||||||||||||||||||
| 30 | 1 | my $this_version = '1.021'; | |||||||||||||||||||||||||||||||
| 31 | 1 | my $version_info = <<EOT; | |||||||||||||||||||||||||||||||
| 32 | $this_program $this_version | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | Copyright (C) 1997, 98, 99 Free Software Foundation, Inc. | ||||||||||||||||||||||||||||||||
| 35 | This is free software; see the source for copying conditions. There is NO | ||||||||||||||||||||||||||||||||
| 36 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | Written by Brendan O'Dea <bod\@compusol.com.au> | ||||||||||||||||||||||||||||||||
| 39 | EOT | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 1 | my $help_info = <<EOT; | |||||||||||||||||||||||||||||||
| 42 | `$this_program' generates a man page out of `--help' and `--version' output. | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | Usage: $this_program [OPTION]... EXECUTABLE | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | -n, --name=STRING use `STRING' as the description for the NAME paragraph | ||||||||||||||||||||||||||||||||
| 47 | -s, --section=SECTION use `SECTION' as the section for the man page | ||||||||||||||||||||||||||||||||
| 48 | -i, --include=FILE include material from `FILE' | ||||||||||||||||||||||||||||||||
| 49 | -I, --opt-include=FILE include material from `FILE' if it exists | ||||||||||||||||||||||||||||||||
| 50 | -o, --output=FILE send output to `FILE' | ||||||||||||||||||||||||||||||||
| 51 | -N, --no-info suppress pointer to Texinfo manual | ||||||||||||||||||||||||||||||||
| 52 | --help print this help, then exit | ||||||||||||||||||||||||||||||||
| 53 | --version print version number, then exit | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | EXECUTABLE should accept `--help' and `--version' options. | ||||||||||||||||||||||||||||||||
| 56 | EOT | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 1 | my $section = 1; | |||||||||||||||||||||||||||||||
| 59 | 1 | my ($opt_name, @opt_include, $opt_output, $opt_no_info); | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | # Parse options. | ||||||||||||||||||||||||||||||||
| 62 | 1 | Getopt::Long::config('bundling'); | |||||||||||||||||||||||||||||||
| 63 | GetOptions ( | ||||||||||||||||||||||||||||||||
| 64 | 'n|name=s' => \$opt_name, | ||||||||||||||||||||||||||||||||
| 65 | 's|section=s' => \$section, | ||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | 'i|include=s' => sub { push @opt_include, [ pop, 1 ] }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | 'I|opt-include=s' => sub { push @opt_include, [ pop, 0 ] }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 68 | 'o|output=s' => \$opt_output, | ||||||||||||||||||||||||||||||||
| 69 | 'N|no-info' => \$opt_no_info, | ||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | help => sub { print $help_info; exit }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | version => sub { print $version_info; exit }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | ) or die $help_info; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | die $help_info unless @ARGV == 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | my %include = (); | |||||||||||||||||||||||||||||||
| 77 | 0 | my %append = (); | |||||||||||||||||||||||||||||||
| 78 | 0 | my @include = (); # retain order given in include file | |||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | # Provide replacement `quote-regex' operator for pre-5.005. | ||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | BEGIN { eval q(sub qr { '' =~ $_[0]; $_[0] }) if $] < 5.005 } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | # Process include file (if given). Format is: | ||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||
| 85 | # [section name] | ||||||||||||||||||||||||||||||||
| 86 | # verbatim text | ||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||
| 88 | # or | ||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||
| 90 | # /pattern/ | ||||||||||||||||||||||||||||||||
| 91 | # verbatim text | ||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 0 | for (@opt_include) | |||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||
| 96 | 0 | my ($inc, $required) = @$_; | |||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | next unless -f $inc or $required; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $inc or $required
MC/DC0%0/2
-f $inc or $required
-f $inc
$required
Truth table0%0/3
A or B
A= -f $incB= $required
| |||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | die "$this_program: can't open `$inc' ($!)\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | unless open INC, $inc; | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 0 | my $key; | |||||||||||||||||||||||||||||||
| 103 | 0 | my $hash = \%include; | |||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | while (<INC>) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||
| 107 | # [section] | ||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (/^\[([^]]+)\]/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||
| 110 | 0 | $key = uc $1; | |||||||||||||||||||||||||||||||
| 111 | 0 | $key =~ s/^\s+//; | |||||||||||||||||||||||||||||||
| 112 | 0 | $key =~ s/\s+$//; | |||||||||||||||||||||||||||||||
| 113 | 0 | $hash = \%include; | |||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | push @include, $key unless $include{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 0 | next; | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | # /pattern/ | ||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (m!^/(.*)/([ims]*)!) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $pat = $2 ? "(?$2)$1" : $1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | # Check pattern. | ||||||||||||||||||||||||||||||||
| 124 | 0 | eval { $key = qr($pat) }; | |||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||
| 127 | 0 | $@ =~ s/ at .*? line \d.*//; | |||||||||||||||||||||||||||||||
| 128 | 0 | die "$inc:$.:$@"; | |||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | 0 | $hash = \%append; | |||||||||||||||||||||||||||||||
| 132 | 0 | next; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | # Silently ignore anything before the first | ||||||||||||||||||||||||||||||||
| 136 | # section--allows for comments and revision info. | ||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | next unless $key; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $hash->{$key} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$hash->{$key} ||= ""
MC/DC0%0/1
$hash->{$key} ||= ""
$hash->{$key}
Truth table0%0/2
A
A= $hash->{$key}
| |||||||||||||||||||||||||||||||||
| 140 | 0 | $hash->{$key} .= $_; | |||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 0 | close INC; | |||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | die "$this_program: no valid information found in `$inc'\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | unless $key; | ||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | # Compress trailing blank lines. | ||||||||||||||||||||||||||||||||
| 150 | 0 | for my $hash (\(%include, %append)) | |||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||
| 152 | 0 | for (keys %$hash) { $hash->{$_} =~ s/\n+$/\n/ } | |||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | # Turn off localisation of executable's ouput. | ||||||||||||||||||||||||||||||||
| 156 | 0 | @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; | |||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | # Turn off localisation of date (for strftime). | ||||||||||||||||||||||||||||||||
| 159 | 0 | setlocale LC_TIME, 'C'; | |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | # Grab help and version info from executable. | ||||||||||||||||||||||||||||||||
| 162 | my ($help_text, $version_text) = map { | ||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | join '', map { s/ +$//; expand $_ } `$ARGV[0] --$_ 2>/dev/null` | ||||||||||||||||||||||||||||||
|
Condition0%0/2
join('', map({s/ +$//;
expand($_);} `$ARGV[0] --$_ 2>/dev/null`)) || die("${this_program}: can't get `--${_}' info from $ARGV[0]\n")
MC/DC0%0/1
join('', map({s/ +$//;
expand($_);} `$ARGV[0] --$_ 2>/dev/null`)) || die("${this_program}: can't get `--${_}' info from $ARGV[0]\n")
join('', map({s/ +$//;
expand($_);} `$ARGV[0] --$_ 2>/dev/null`))
Truth table0%0/2
A
A= join('', map({s/ +$//;
expand($_);} `$ARGV[0] --$_ 2>/dev/null`))
| |||||||||||||||||||||||||||||||||
| 164 | or die "$this_program: can't get `--$_' info from $ARGV[0]\n" | ||||||||||||||||||||||||||||||||
| 165 | } qw(help version); | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 0 | my $date = strftime "%B %Y", localtime; | |||||||||||||||||||||||||||||||
| 168 | 0 | (my $program = $ARGV[0]) =~ s!.*/!!; | |||||||||||||||||||||||||||||||
| 169 | 0 | my $package = $program; | |||||||||||||||||||||||||||||||
| 170 | 0 | my $version; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($opt_output) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unlink $opt_output | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
-e $opt_output && (unlink($opt_output) || die("${this_program}: can't unlink $opt_output ($!)\n"))
unlink $opt_output or die "${this_program}: can't unlink $opt_output ($!)\n"
MC/DC0%0/2
-e $opt_output && (unlink($opt_output) || die("${this_program}: can't unlink $opt_output ($!)\n"))
-e $opt_output
unlink $opt_output
Truth table0%0/3
A && B
A= -e $opt_outputB= unlink $opt_output
| |||||||||||||||||||||||||||||||||
| 175 | or die "$this_program: can't unlink $opt_output ($!)\n" | ||||||||||||||||||||||||||||||||
| 176 | if -e $opt_output; | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | open STDOUT, ">$opt_output" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 179 | or die "$this_program: can't create $opt_output ($!)\n"; | ||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||
| 182 | # The first line of the --version information is assumed to be in one | ||||||||||||||||||||||||||||||||
| 183 | # of the following formats: | ||||||||||||||||||||||||||||||||
| 184 | # | ||||||||||||||||||||||||||||||||
| 185 | # <version> | ||||||||||||||||||||||||||||||||
| 186 | # <program> <version> | ||||||||||||||||||||||||||||||||
| 187 | # {GNU,Free} <program> <version> | ||||||||||||||||||||||||||||||||
| 188 | # <program> ({GNU,Free} <package>) <version> | ||||||||||||||||||||||||||||||||
| 189 | # <program> - {GNU,Free} <package> <version> | ||||||||||||||||||||||||||||||||
| 190 | # | ||||||||||||||||||||||||||||||||
| 191 | # and seperated from any copyright/author details by a blank line. | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ($_, $version_text) = split /\n+/, $version_text, 2; | |||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if (/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or /^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/
MC/DC0%0/2
/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or /^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/
/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/
/^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/
Truth table0%0/3
A or B
A= /^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/B= /^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/
| |||||||||||||||||||||||||||||||||
| 196 | /^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/) | ||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||
| 198 | 0 | $program = $1; | |||||||||||||||||||||||||||||||
| 199 | 0 | $package = $2; | |||||||||||||||||||||||||||||||
| 200 | 0 | $version = $3; | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | elsif (/^((?:GNU|Free) +)?(\S+) +(.*)/) | ||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||
| 204 | 0 | $program = $2; | |||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $package = $1 ? "$1$2" : $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 0 | $version = $3; | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | else | ||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||
| 210 | 0 | $version = $_; | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | 0 | $program =~ s!.*/!!; | |||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | # No info for `info' itself. | ||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $opt_no_info = 1 if $program eq 'info'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | # --name overrides --include contents. | ||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $include{NAME} = "$program \\- $opt_name\n" if $opt_name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | # Default (useless) NAME paragraph. | ||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $include{NAME} ||= "$program \\- manual page for $program $version\n"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$include{"NAME"} ||= "$program \\- manual page for $program $version\n"
MC/DC0%0/1
$include{"NAME"} ||= "$program \\- manual page for $program $version\n"
$include{"NAME"}
Truth table0%0/2
A
A= $include{"NAME"}
| |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | # Man pages traditionally have the page title in caps. | ||||||||||||||||||||||||||||||||
| 225 | 0 | my $PROGRAM = uc $program; | |||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||
| 227 | # Extract usage clause(s) [if any] for SYNOPSIS. | ||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ($help_text =~ s/^Usage:( +(\S+))(.*)((?:\n(?: {6}\1| *or: +\S).*)*)//m) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||
| 230 | 0 | my @syn = $2 . $3; | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ($_ = $4) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||
| 234 | 0 | s/^\n//; | |||||||||||||||||||||||||||||||
| 235 | 0 | for (split /\n/) { s/^ *(or: +)?//; push @syn, $_ } | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | 0 | my $synopsis = ''; | |||||||||||||||||||||||||||||||
| 239 | 0 | for (@syn) | |||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $synopsis .= ".br\n" if $synopsis; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 242 | 0 | s!^\S*/!!; | |||||||||||||||||||||||||||||||
| 243 | 0 | s/^(\S+) *//; | |||||||||||||||||||||||||||||||
| 244 | 0 | $synopsis .= ".B $1\n"; | |||||||||||||||||||||||||||||||
| 245 | 0 | s/\s+$//; | |||||||||||||||||||||||||||||||
| 246 | 0 | s/(([][]|\.\.+)+)/\\fR$1\\fI/g; | |||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | s/^/\\fI/ unless s/^\\fR//; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | 0 | $_ .= '\fR'; | |||||||||||||||||||||||||||||||
| 249 | 0 | s/(\\fI)( *)/$2$1/g; | |||||||||||||||||||||||||||||||
| 250 | 0 | s/\\fI\\fR//g; | |||||||||||||||||||||||||||||||
| 251 | 0 | s/^\\fR//; | |||||||||||||||||||||||||||||||
| 252 | 0 | s/\\fI$//; | |||||||||||||||||||||||||||||||
| 253 | 0 | s/^\./\\&./; | |||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | 0 | $synopsis .= "$_\n"; | |||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $include{SYNOPSIS} ||= $synopsis; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$include{"SYNOPSIS"} ||= $synopsis
MC/DC0%0/2
$include{"SYNOPSIS"} ||= $synopsis
$include{"SYNOPSIS"}
$synopsis
Truth table0%0/3
A ||= B
A= $include{"SYNOPSIS"}B= $synopsis
| |||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | # Process text, initial section is DESCRIPTION. | ||||||||||||||||||||||||||||||||
| 262 | 0 | my $sect = 'DESCRIPTION'; | |||||||||||||||||||||||||||||||
| 263 | 0 | $_ = "$help_text\n\n$version_text"; | |||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | # Normalise paragraph breaks. | ||||||||||||||||||||||||||||||||
| 266 | 0 | s/^\n+//; | |||||||||||||||||||||||||||||||
| 267 | 0 | s/\n*$/\n/; | |||||||||||||||||||||||||||||||
| 268 | 0 | s/\n\n+/\n\n/g; | |||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | # Temporarily exchange leading dots and backslashes for tokens. | ||||||||||||||||||||||||||||||||
| 271 | 0 | s/^\./\x80/mg; | |||||||||||||||||||||||||||||||
| 272 | 0 | s/\\/\x81/g; | |||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | # Start a new paragraph (if required) for these. | ||||||||||||||||||||||||||||||||
| 275 | 0 | s/([^\n])\n(Report +bugs|Email +bug +reports +to|Written +by)/$1\n\n$2/g; | |||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | sub convert_option; | ||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | while (length) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||
| 281 | # Convert some standard paragraph names. | ||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if (s/^(Options|Examples): *\n//) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||
| 284 | 0 | $sect = uc $1; | |||||||||||||||||||||||||||||||
| 285 | 0 | next; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | # Copyright section | ||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if (/^Copyright +[(\xa9]/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||
| 291 | 0 | $sect = 'COPYRIGHT'; | |||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $include{$sect} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$include{$sect} ||= ""
MC/DC0%0/1
$include{$sect} ||= ""
$include{$sect}
Truth table0%0/2
A
A= $include{$sect}
| |||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | $include{$sect} .= ".PP\n" if $include{$sect}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 0 | my $copy; | |||||||||||||||||||||||||||||||
| 296 | 0 | ($copy, $_) = split /\n\n/, $_, 2; | |||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||
| 298 | 0 | for ($copy) | |||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||
| 300 | # Add back newline | ||||||||||||||||||||||||||||||||
| 301 | 0 | s/\n*$/\n/; | |||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | # Convert iso9959-1 copyright symbol or (c) to nroff | ||||||||||||||||||||||||||||||||
| 304 | # character. | ||||||||||||||||||||||||||||||||
| 305 | 0 | s/^Copyright +(?:\xa9|\([Cc]\))/Copyright \\(co/mg; | |||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | # Insert line breaks before additional copyright messages | ||||||||||||||||||||||||||||||||
| 308 | # and the disclaimer. | ||||||||||||||||||||||||||||||||
| 309 | 0 | s/(.)\n(Copyright |This +is +free +software)/$1\n.br\n$2/g; | |||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | # Join hyphenated lines. | ||||||||||||||||||||||||||||||||
| 312 | 0 | s/([A-Za-z])-\n */$1/g; | |||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 0 | $include{$sect} .= $copy; | |||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $_ ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ ||= ""
MC/DC0%0/1
$_ ||= ""
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||
| 317 | 0 | next; | |||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | # Catch bug report text. | ||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if (/^(Report +bugs|Email +bug +reports +to) /) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||
| 323 | 0 | $sect = 'REPORTING BUGS'; | |||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | # Author section. | ||||||||||||||||||||||||||||||||
| 327 | elsif (/^Written +by/) | ||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||
| 329 | 0 | $sect = 'AUTHOR'; | |||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | # Examples, indicated by an indented leading $, % or > are | ||||||||||||||||||||||||||||||||
| 333 | # rendered in a constant width font. | ||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (/^( +)([\$\%>] )\S/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 335 | { | ||||||||||||||||||||||||||||||||
| 336 | 0 | my $indent = $1; | |||||||||||||||||||||||||||||||
| 337 | 0 | my $prefix = $2; | |||||||||||||||||||||||||||||||
| 338 | 0 | my $break = '.IP'; | |||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $include{$sect} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$include{$sect} ||= ""
MC/DC0%0/1
$include{$sect} ||= ""
$include{$sect}
Truth table0%0/2
A
A= $include{$sect}
| |||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | while (s/^$indent\Q$prefix\E(\S.*)\n*//) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||
| 342 | 0 | $include{$sect} .= "$break\n\\f(CW$prefix$1\\fR\n"; | |||||||||||||||||||||||||||||||
| 343 | 0 | $break = '.br'; | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | 0 | next; | |||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | 0 | my $matched = ''; | |||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | $include{$sect} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$include{$sect} ||= ""
MC/DC0%0/1
$include{$sect} ||= ""
$include{$sect}
Truth table0%0/2
A
A= $include{$sect}
| |||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | # Sub-sections have a trailing colon and the second line indented. | ||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if (s/^(\S.*:) *\n / /) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 356 | 0 | $include{$sect} .= qq(.SS "$1"\n); | |||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | 0 | my $indent = 0; | |||||||||||||||||||||||||||||||
| 360 | 0 | my $content = ''; | |||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||
| 362 | # Option with description. | ||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if (s/^( {1,10}([+-]\S.*?))(?:( +)|\n( {20,}))(\S.*)\n//) | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | $indent = length ($4 || "$1$3"); | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$4 || "$1$3"
MC/DC0%0/2
$4 || "$1$3"
$4
"$1$3"
Truth table0%0/3
A || B
A= $4B= "$1$3"
| |||||||||||||||||||||||||||||||||
| 367 | 0 | $content = ".TP\n\x82$2\n\x82$5\n"; | |||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | unless ($4) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||
| 370 | # Indent may be different on second line. | ||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $indent = length $& if /^ {20,}/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | # Option without description. | ||||||||||||||||||||||||||||||||
| 376 | elsif (s/^ {1,10}([+-]\S.*)\n//) | ||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 379 | 0 | $content = ".HP\n\x82$1\n"; | |||||||||||||||||||||||||||||||
| 380 | 0 | $indent = 80; # not continued | |||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | # Indented paragraph with tag. | ||||||||||||||||||||||||||||||||
| 384 | elsif (s/^( +(\S.*?) +)(\S.*)\n//) | ||||||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 387 | 0 | $indent = length $1; | |||||||||||||||||||||||||||||||
| 388 | 0 | $content = ".TP\n\x82$2\n\x82$3\n"; | |||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||
| 391 | # Indented paragraph. | ||||||||||||||||||||||||||||||||
| 392 | elsif (s/^( +)(\S.*)\n//) | ||||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 395 | 0 | $indent = length $1; | |||||||||||||||||||||||||||||||
| 396 | 0 | $content = ".IP\n\x82$2\n"; | |||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||
| 399 | # Left justified paragraph. | ||||||||||||||||||||||||||||||||
| 400 | else | ||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||
| 402 | 0 | s/(.*)\n//; | |||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $content = ".PP\n" if $include{$sect}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 405 | 0 | $content .= "$1\n"; | |||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||
| 408 | # Append continuations. | ||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | while (s/^ {$indent}(\S.*)\n//) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $matched .= $& if %append; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 412 | 0 | $content .= "\x82$1\n" | |||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | # Move to next paragraph. | ||||||||||||||||||||||||||||||||
| 416 | 0 | s/^\n+//; | |||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | 0 | for ($content) | |||||||||||||||||||||||||||||||
| 419 | { | ||||||||||||||||||||||||||||||||
| 420 | # Leading dot protection. | ||||||||||||||||||||||||||||||||
| 421 | 0 | s/\x82\./\x80/g; | |||||||||||||||||||||||||||||||
| 422 | 0 | s/\x82//g; | |||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||
| 424 | # Convert options. | ||||||||||||||||||||||||||||||||
| 425 | 0 | s/(^| )(-[][\w=-]+)/$1 . convert_option $2/mge; | |||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||
| 428 | # Check if matched paragraph contains /pat/. | ||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if (%append) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||
| 431 | 0 | for my $pat (keys %append) | |||||||||||||||||||||||||||||||
| 432 | { | ||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if ($matched =~ $pat) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 434 | { | ||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $content .= ".PP\n" unless $append{$pat} =~ /^\./; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 436 | 0 | $content .= $append{$pat}; | |||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | 0 | $include{$sect} .= $content; | |||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | # Refer to the real documentation. | ||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | unless ($opt_no_info) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 446 | { | ||||||||||||||||||||||||||||||||
| 447 | 0 | $sect = 'SEE ALSO'; | |||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $include{$sect} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$include{$sect} ||= ""
MC/DC0%0/1
$include{$sect} ||= ""
$include{$sect}
Truth table0%0/2
A
A= $include{$sect}
| |||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | $include{$sect} .= ".PP\n" if $include{$sect}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 450 | 0 | $include{$sect} .= <<EOT; | |||||||||||||||||||||||||||||||
| 451 | The full documentation for | ||||||||||||||||||||||||||||||||
| 452 | .B $program | ||||||||||||||||||||||||||||||||
| 453 | is maintained as a Texinfo manual. If the | ||||||||||||||||||||||||||||||||
| 454 | .B info | ||||||||||||||||||||||||||||||||
| 455 | and | ||||||||||||||||||||||||||||||||
| 456 | .B $program | ||||||||||||||||||||||||||||||||
| 457 | programs are properly installed at your site, the command | ||||||||||||||||||||||||||||||||
| 458 | .IP | ||||||||||||||||||||||||||||||||
| 459 | .B info $program | ||||||||||||||||||||||||||||||||
| 460 | .PP | ||||||||||||||||||||||||||||||||
| 461 | should give you access to the complete manual. | ||||||||||||||||||||||||||||||||
| 462 | EOT | ||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||
| 465 | # Output header. | ||||||||||||||||||||||||||||||||
| 466 | 0 | print <<EOT; | |||||||||||||||||||||||||||||||
| 467 | .\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version. | ||||||||||||||||||||||||||||||||
| 468 | .TH $PROGRAM "$section" "$date" "$package $version" FSF | ||||||||||||||||||||||||||||||||
| 469 | EOT | ||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | # Section ordering. | ||||||||||||||||||||||||||||||||
| 472 | 0 | my @pre = qw(NAME SYNOPSIS DESCRIPTION OPTIONS EXAMPLES); | |||||||||||||||||||||||||||||||
| 473 | 0 | my @post = ('AUTHOR', 'REPORTING BUGS', 'COPYRIGHT', 'SEE ALSO'); | |||||||||||||||||||||||||||||||
| 474 | 0 | my $filter = join '|', @pre, @post; | |||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||
| 476 | # Output content. | ||||||||||||||||||||||||||||||||
| 477 | 0 | for (@pre, (grep ! /^($filter)$/o, @include), @post) | |||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if ($include{$_}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my $quote = /\W/ ? '"' : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 482 | 0 | print ".SH $quote$_$quote\n"; | |||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||
| 484 | 0 | for ($include{$_}) | |||||||||||||||||||||||||||||||
| 485 | { | ||||||||||||||||||||||||||||||||
| 486 | # Replace leading dot an backslash tokens. | ||||||||||||||||||||||||||||||||
| 487 | 0 | s/\x80/\\&./g; | |||||||||||||||||||||||||||||||
| 488 | 0 | s/\x81/\\e/g; | |||||||||||||||||||||||||||||||
| 489 | 0 | print; | |||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||
| 494 | 0 | exit; | |||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | # Convert option dashes to \- to stop nroff from hyphenating 'em, and | ||||||||||||||||||||||||||||||||
| 497 | # embolden. Option arguments get italicised. | ||||||||||||||||||||||||||||||||
| 498 | sub convert_option | ||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
convert_option: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 500 | 0 | local $_ = '\fB' . shift; | |||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||
| 502 | 0 | s/-/\\-/g; | |||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | unless (s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 504 | { | ||||||||||||||||||||||||||||||||
| 505 | 0 | s/=(.)/\\fR=\\fI$1/; | |||||||||||||||||||||||||||||||
| 506 | 0 | s/ (.)/ \\fI$1/; | |||||||||||||||||||||||||||||||
| 507 | 0 | $_ .= '\fR'; | |||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | 0 | $_; | |||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||