| 1 | #!/usr/local/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | if $running_under_some_shell; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | #!perl -w | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use vars qw($VERSION $TEST_MODE); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | $VERSION = 0.2; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Pod::Find qw(pod_find simplify_name); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my %opt = ( banner => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # compatibility hack for previous version(s) of pod2html | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my %oldopt; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | die unless(GetOptions(\%opt, qw( | ||||||||||||||||||||||||||||||||||||||||||
| 20 | banner! | ||||||||||||||||||||||||||||||||||||||||||
| 21 | converter=s | ||||||||||||||||||||||||||||||||||||||||||
| 22 | suffix=s | ||||||||||||||||||||||||||||||||||||||||||
| 23 | filesuffix=s | ||||||||||||||||||||||||||||||||||||||||||
| 24 | dir=s | ||||||||||||||||||||||||||||||||||||||||||
| 25 | libpods=s | ||||||||||||||||||||||||||||||||||||||||||
| 26 | navigation! | ||||||||||||||||||||||||||||||||||||||||||
| 27 | localtoc! | ||||||||||||||||||||||||||||||||||||||||||
| 28 | toc! | ||||||||||||||||||||||||||||||||||||||||||
| 29 | idx! | ||||||||||||||||||||||||||||||||||||||||||
| 30 | tocname=s | ||||||||||||||||||||||||||||||||||||||||||
| 31 | idxname=s | ||||||||||||||||||||||||||||||||||||||||||
| 32 | toctitle=s | ||||||||||||||||||||||||||||||||||||||||||
| 33 | idxtitle=s | ||||||||||||||||||||||||||||||||||||||||||
| 34 | idxopt=s | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ps! | ||||||||||||||||||||||||||||||||||||||||||
| 36 | psdir=s | ||||||||||||||||||||||||||||||||||||||||||
| 37 | psfont=s | ||||||||||||||||||||||||||||||||||||||||||
| 38 | papersize=s | ||||||||||||||||||||||||||||||||||||||||||
| 39 | inc! | ||||||||||||||||||||||||||||||||||||||||||
| 40 | script! | ||||||||||||||||||||||||||||||||||||||||||
| 41 | stylesheet=s | ||||||||||||||||||||||||||||||||||||||||||
| 42 | warnings! | ||||||||||||||||||||||||||||||||||||||||||
| 43 | verbose! | ||||||||||||||||||||||||||||||||||||||||||
| 44 | help|h | ||||||||||||||||||||||||||||||||||||||||||
| 45 | version|V), | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'flush' => \$oldopt{flush}, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'htmlroot=s' => \$oldopt{htmlroot}, # can be ignored | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'index!' => \$oldopt{'index'}, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'infile=s' => \$oldopt{infile}, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'netscape!' => \$oldopt{netscape}, # ignore | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'outfile=s' => \$oldopt{outfile}, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'podpath=s' => \$oldopt{podpath}, # can be ignored | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'podroot=s' => \$oldopt{podroot}, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 'recurse!' => \$oldopt{recurse}, # ignored now | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 'title=s' => \$oldopt{title} | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | )); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my %addopts = (); | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | if($oldopt{infile}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | @ARGV = ( $oldopt{infile} ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | if($oldopt{outfile}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $addopts{-outfile} = $oldopt{outfile}; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | if($oldopt{podroot}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | push(@ARGV, $oldopt{podroot}); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | # process libpods | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if($opt{libpods}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | # replace single : with , (old style) | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $opt{libpods} =~ s/(?<!:):(?!:)/,/g; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | if(defined $oldopt{'index'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $opt{localtoc} = $oldopt{'index'}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | if(defined $oldopt{title}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $addopts{-title} = $oldopt{title}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | my $converter = $opt{converter} || 'Marek::Pod::HTML'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt{'converter'} || 'Marek::Pod::HTML'
MC/DC0%0/1
$opt{'converter'} || 'Marek::Pod::HTML'
$opt{'converter'}
Truth table50%1/2
A
A= $opt{'converter'}
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | eval "use $converter qw(pod2html);"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | die "Fatal: Cannot load convertor module '$converter':\n$@\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | if($@); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | if($opt{help}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | exec "$Config{scriptdir}/perldoc -F $0"; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif($opt{version}) { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | print "$0 Version $VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my %pods = (); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my @dirs = (); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | foreach(@ARGV) { | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if(-d) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | push(@dirs,$_); | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | elsif(/[*?]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | foreach (glob($_)) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if(-d) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push(@dirs,$_); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $name = simplify_name($_); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $pods{$_} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $name = simplify_name($_); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $pods{$_} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my %search; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if(@dirs || $opt{inc} || $opt{script}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@dirs or $opt{"inc"} or $opt{"script"}
@dirs or $opt{"inc"}
MC/DC0%0/3
@dirs or $opt{"inc"} or $opt{"script"}
@dirs
$opt{"inc"}
$opt{"script"}
Truth table0%0/4
A or B or C
A= @dirsB= $opt{"inc"}C= $opt{"script"}
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | warn "+++ Searching for POD documents\n"; | |||||||||||||||||||||||||||||||||||||||||
| 127 | %search = pod_find({ | ||||||||||||||||||||||||||||||||||||||||||
| 128 | -inc => $opt{inc}, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | -script => $opt{script}, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | -verbose => $opt{verbose} | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | }, @dirs) | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | map { $pods{$_} = $search{$_} } keys %search; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | # run as a filter | ||||||||||||||||||||||||||||||||||||||||||
| 137 | # we have to save it temporarily because we need two passes | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $tmp; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | unless(%pods) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = $0; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self =~ s:^.*/::; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $tmp = "/tmp/$self.$$"; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | open(TEMP, ">$tmp") || die "Cannot write temp file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | while(<STDIN>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | print TEMP; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | close(TEMP); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $pods{$tmp} = 'stdin'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $addopts{-filter} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $opt{navigation} = 0 unless defined $opt{navigation}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | warn "+++ Starting conversion\n" if($opt{verbose}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | pod2html( { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | -banner => $opt{banner}, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | -converter => $converter, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | -suffix => $opt{suffix}, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | -filesuffix => $opt{filesuffix}, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | -dir => $opt{dir}, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | -libpods => $opt{libpods}, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | -navigation => $opt{navigation}, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | -localtoc => $opt{localtoc}, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | -toc => $opt{toc}, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | -idx => $opt{idx}, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | -tocname => $opt{tocname}, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | -idxname => $opt{idxname}, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | -toctitle => $opt{toctitle}, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | -idxtitle => $opt{idxtitle}, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | -ps => $opt{ps}, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | -psdir => $opt{psdir}, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | -psfont => $opt{psfont}, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | -papersize => $opt{papersize}, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | -warnings => $opt{warnings}, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | -verbose => $opt{verbose}, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | -stylesheet => $opt{stylesheet}, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | -idxopt => $opt{idxopt}, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | %addopts | |||||||||||||||||||||||||||||||||||||||||
| 179 | }, { %pods }); | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | unlink $tmp if($tmp); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | exit 0 unless($TEST_MODE); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | 1; # this is for the module test | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | __END__ | ||||||||||||||||||||||||||||||||||||||||||