line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
|
|
1
|
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' |
4
|
|
|
|
|
|
|
if 0; # not running under some shell |
5
|
1
|
50
|
|
|
|
4
|
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' |
6
|
|
|
|
|
|
|
if $running_under_some_shell; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# pod2text -- Convert POD data to formatted ASCII text. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013 |
11
|
|
|
|
|
|
|
# Russ Allbery |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# This program is free software; you may redistribute it and/or modify it |
14
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# The driver script for Pod::Text, Pod::Text::Termcap, and Pod::Text::Color, |
17
|
|
|
|
|
|
|
# invoked by perldoc -t among other things. |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
29
|
require 5.004; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
586
|
use Getopt::Long qw(GetOptions); |
|
1
|
|
|
|
|
9583
|
|
|
1
|
|
|
|
|
5
|
|
22
|
1
|
|
|
1
|
|
702
|
use Pod::Text (); |
|
1
|
|
|
|
|
30499
|
|
|
1
|
|
|
|
|
25
|
|
23
|
1
|
|
|
1
|
|
512
|
use Pod::Usage qw(pod2usage); |
|
1
|
|
|
|
|
1952
|
|
|
1
|
|
|
|
|
50
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1461
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Clean up $0 for error reporting. |
28
|
1
|
|
|
|
|
21
|
$0 =~ s%.*/%%; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Take an initial pass through our options, looking for one of the form |
31
|
|
|
|
|
|
|
# -. We turn that into -w for compatibility with the |
32
|
|
|
|
|
|
|
# original pod2text script. |
33
|
1
|
|
|
|
|
5
|
for (my $i = 0; $i < @ARGV; $i++) { |
34
|
1
|
50
|
|
|
|
5
|
last if $ARGV[$i] =~ /^--$/; |
35
|
1
|
50
|
|
|
|
5
|
if ($ARGV[$i] =~ /^-(\d+)$/) { |
36
|
0
|
|
|
|
|
0
|
splice (@ARGV, $i++, 1, '-w', $1); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Insert -- into @ARGV before any single dash argument to hide it from |
41
|
|
|
|
|
|
|
# Getopt::Long; we want to interpret it as meaning stdin (which Pod::Simple |
42
|
|
|
|
|
|
|
# does correctly). |
43
|
1
|
|
|
|
|
2
|
my $stdin; |
44
|
1
|
50
|
33
|
|
|
2
|
@ARGV = map { $_ eq '-' && !$stdin++ ? ('--', $_) : $_ } @ARGV; |
|
1
|
|
|
|
|
7
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Parse our options. Use the same names as Pod::Text for simplicity, and |
47
|
|
|
|
|
|
|
# default to sentence boundaries turned off for compatibility. |
48
|
1
|
|
|
|
|
2
|
my %options; |
49
|
1
|
|
|
|
|
3
|
$options{sentence} = 0; |
50
|
1
|
|
|
|
|
5
|
Getopt::Long::config ('bundling'); |
51
|
1
|
50
|
|
|
|
38
|
GetOptions (\%options, 'alt|a', 'code', 'color|c', 'errors=s', 'help|h', |
52
|
|
|
|
|
|
|
'indent|i=i', 'loose|l', 'margin|left-margin|m=i', 'nourls', |
53
|
|
|
|
|
|
|
'overstrike|o', 'quotes|q=s', 'sentence|s', 'stderr', 'termcap|t', |
54
|
|
|
|
|
|
|
'utf8|u', 'width|w=i') |
55
|
|
|
|
|
|
|
or exit 1; |
56
|
1
|
50
|
|
|
|
671
|
pod2usage (1) if $options{help}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Figure out what formatter we're going to use. -c overrides -t. |
59
|
1
|
|
|
|
|
3
|
my $formatter = 'Pod::Text'; |
60
|
1
|
50
|
|
|
|
4
|
if ($options{color}) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
$formatter = 'Pod::Text::Color'; |
62
|
0
|
|
|
|
|
0
|
eval { require Term::ANSIColor }; |
|
0
|
|
|
|
|
0
|
|
63
|
0
|
0
|
|
|
|
0
|
if ($@) { die "-c (--color) requires Term::ANSIColor be installed\n" } |
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
|
|
|
0
|
require Pod::Text::Color; |
65
|
|
|
|
|
|
|
} elsif ($options{termcap}) { |
66
|
0
|
|
|
|
|
0
|
$formatter = 'Pod::Text::Termcap'; |
67
|
0
|
|
|
|
|
0
|
require Pod::Text::Termcap; |
68
|
|
|
|
|
|
|
} elsif ($options{overstrike}) { |
69
|
0
|
|
|
|
|
0
|
$formatter = 'Pod::Text::Overstrike'; |
70
|
0
|
|
|
|
|
0
|
require Pod::Text::Overstrike; |
71
|
|
|
|
|
|
|
} |
72
|
1
|
|
|
|
|
4
|
delete @options{'color', 'termcap', 'overstrike'}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# If neither stderr nor errors is set, default to errors = die. |
75
|
1
|
50
|
33
|
|
|
5
|
if (!defined $options{stderr} && !defined $options{errors}) { |
76
|
1
|
|
|
|
|
2
|
$options{errors} = 'die'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Initialize and run the formatter. |
80
|
1
|
|
|
|
|
12
|
my $parser = $formatter->new (%options); |
81
|
1
|
|
|
|
|
167
|
my $status = 0; |
82
|
1
|
|
|
|
|
2
|
do { |
83
|
1
|
|
|
|
|
3
|
my ($input, $output) = splice (@ARGV, 0, 2); |
84
|
1
|
|
|
|
|
4
|
$parser->parse_from_file ($input, $output); |
85
|
1
|
50
|
|
|
|
71154
|
if ($parser->{CONTENTLESS}) { |
86
|
0
|
|
|
|
|
0
|
$status = 1; |
87
|
0
|
|
|
|
|
0
|
warn "$0: unable to format $input\n"; |
88
|
0
|
0
|
0
|
|
|
0
|
if (defined ($output) and $output ne '-') { |
89
|
0
|
0
|
|
|
|
0
|
unlink $output unless (-s $output); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} while (@ARGV); |
93
|
1
|
|
|
|
|
0
|
exit $status; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |