lib/Pod/Perldoc.pm

filter: Statementstmt 43.9% 413 / 940 Branchbran 24.0% 157 / 652 Conditioncond 22.2% 89 / 400 MC/DCmcdc 0.9% 2 / 211 Subroutinesub 59.5% 53 / 89 Podpod 0.0% 0 / 71 totaltotal 30.2% 714 / 2363 CC 475 SCAR 54.2
CC
475
Cov
33%
search_perlfunc
1332.0
search_perlvar
650.0
minus_f_nocase
524.2
CRAP 226.0
↑ Summary lib/Pod/Perldoc/GetOptsOO.pm »
1 3 ▶use 5.006; # we use some open(X, "<", $y) syntax
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Pod::Perldoc;
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Config '%Config';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Fcntl; # for sysopen
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use File::Basename qw(basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use File::Spec::Functions qw(catfile catdir splitdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use vars qw($VERSION @Pagers $Bindir $Pod2man
Subroutine BEGIN: called CC=1 SCAR=0.0
13 $Temp_Files_Created $Temp_File_Lifetime
14 3 );
15 3 $VERSION = '3.28';
16  
17 #..........................................................................
18  
19 3 ▶BEGIN { # Make a DEBUG constant very first thing...
Subroutine BEGIN: called CC=5 SCAR=21.9
20 3 ▶ unless(defined &DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &Pod::Perldoc::DEBUG) 3 0 3
21 3 ▶ if(($ENV{'PERLDOCDEBUG'} || '') =~ m/^(\d+)/) { # untaint
Branch: 1 branch
BranchTrueFalseTotal
if (($ENV{'PERLDOCDEBUG'} || '') =~ /^(\d+)/) { } 0 3 3
Condition50%1/2
$ENV{'PERLDOCDEBUG'} || ''
l!l
03
MC/DC0%0/1
$ENV{'PERLDOCDEBUG'} || ''
$ENV{'PERLDOCDEBUG'}
Truth table50%1/2
A
A= $ENV{'PERLDOCDEBUG'}
Aresult
11
00
22 0 eval("sub DEBUG () {$1}");
23 0 ▶ die "WHAT? Couldn't eval-up a DEBUG constant!? $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
24 } else {
25 3 *DEBUG = sub () {0};
26 }
27 }
28 }
29  
30 3 ▶use Pod::Perldoc::GetOptsOO; # uses the DEBUG.
Subroutine BEGIN: called CC=1 SCAR=0.0
31 3 ▶use Carp qw(croak carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 # these are also in BaseTo, which I don't want to inherit
34 0 ▶sub debugging {
Subroutine debugging: not called CC=2 SCAR=17.9
Pod undocumented
35 0 my $self = shift;
36  
37 0 ▶ ( defined(&Pod::Perldoc::DEBUG) and &Pod::Perldoc::DEBUG() )
Branch: 1 branch
BranchTrueFalseTotal
defined &Pod::Perldoc::DEBUG and &DEBUG() 0 0 0
38 }
39  
40 0 ▶sub debug {
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
41 0 my( $self, @messages ) = @_;
42 0 ▶ return unless $self->debugging;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->debugging 0 0 0
43 0 print STDERR map { "DEBUG : $_" } @messages;
44 }
45  
46 0 ▶sub warn {
Subroutine warn: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my( $self, @messages ) = @_;
48  
49 0 carp( join "\n", @messages, '' );
50 }
51  
52 0 ▶sub die {
Subroutine die: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my( $self, @messages ) = @_;
54  
55 0 croak( join "\n", @messages, '' );
56 }
57  
58 #..........................................................................
59  
60 sub TRUE () {1}
61 185 ▶sub FALSE () {return}
Subroutine FALSE: called CC=1 SCAR=0.0
Pod undocumented
62 sub BE_LENIENT () {1}
63  
64 3 ▶BEGIN {
Subroutine BEGIN: called CC=17 SCAR=35.7
65 3 ▶ *is_vms = $^O eq 'VMS' ? \&TRUE : \&FALSE unless defined &is_vms;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_vms 3 0 3
$^O eq 'VMS' ? : 0 3 3
66 3 ▶ *is_mswin32 = $^O eq 'MSWin32' ? \&TRUE : \&FALSE unless defined &is_mswin32;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_mswin32 3 0 3
$^O eq 'MSWin32' ? : 0 3 3
67 3 ▶ *is_dos = $^O eq 'dos' ? \&TRUE : \&FALSE unless defined &is_dos;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_dos 3 0 3
$^O eq 'dos' ? : 0 3 3
68 3 ▶ *is_os2 = $^O eq 'os2' ? \&TRUE : \&FALSE unless defined &is_os2;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_os2 3 0 3
$^O eq 'os2' ? : 0 3 3
69 3 ▶ *is_cygwin = $^O eq 'cygwin' ? \&TRUE : \&FALSE unless defined &is_cygwin;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_cygwin 3 0 3
$^O eq 'cygwin' ? : 0 3 3
70 3 ▶ *is_linux = $^O eq 'linux' ? \&TRUE : \&FALSE unless defined &is_linux;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_linux 3 0 3
$^O eq 'linux' ? : 3 0 3
71 3 ▶ *is_hpux = $^O =~ m/hpux/ ? \&TRUE : \&FALSE unless defined &is_hpux;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_hpux 3 0 3
$^O =~ /hpux/ ? : 0 3 3
72 3 ▶ *is_amigaos = $^O eq 'amigaos' ? \&TRUE : \&FALSE unless defined &is_amigaos;
Branch: 2 branches
BranchTrueFalseTotal
unless defined &Pod::Perldoc::is_amigaos 3 0 3
$^O eq 'amigaos' ? : 0 3 3
73 }
74  
75 3 ▶$Temp_File_Lifetime ||= 60 * 60 * 24 * 5;
Condition50%1/2
$Pod::Perldoc::Temp_File_Lifetime ||= 432000
l!l
03
MC/DC0%0/1
$Pod::Perldoc::Temp_File_Lifetime ||= 432000
$Pod::Perldoc::Temp_File_Lifetime
Truth table50%1/2
A
A= $Pod::Perldoc::Temp_File_Lifetime
Aresult
11
00
76 # If it's older than five days, it's quite unlikely
77 # that anyone's still looking at it!!
78 # (Currently used only by the MSWin cleanup routine)
79  
80  
81 #..........................................................................
82 3 { my $pager = $Config{'pager'};
83 3 ▶ push @Pagers, $pager if -x (split /\s+/, $pager)[0] or __PACKAGE__->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if -x (split(/\s+/, $pager, 0))[0] or __PACKAGE__->is_vms 3 0 3
Condition33%1/3
-x (split(/\s+/, $pager, 0))[0] or __PACKAGE__->is_vms
l!l&&r!l&&!r
300
MC/DC0%0/2
-x (split(/\s+/, $pager, 0))[0] or __PACKAGE__->is_vms
-x (split(/\s+/, $pager, 0))[0] __PACKAGE__->is_vms
Truth table33%1/3
A or B
A= -x (split(/\s+/, $pager, 0))[0]B= __PACKAGE__->is_vms
ABresult
1X1
011
000
84 }
85 3 $Bindir = $Config{'scriptdirexp'};
86 3 ▶$Pod2man = "pod2man" . ( $Config{'versiononly'} ? $Config{'version'} : '' );
Branch: 1 branch
BranchTrueFalseTotal
$Pod::Perldoc::Config{'versiononly'} ? : 0 3 3
87  
88 # End of class-init stuff
89 #
90 ###########################################################################
91 #
92 # Option accessors...
93  
94 3 foreach my $subname (map "opt_$_", split '', q{mhlDriFfXqnTdULva}) {
95 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
96 3 ▶ *$subname = do{ use strict 'refs'; sub () { shift->_elem($subname, @_) } };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
97 }
98  
99 # And these are so that GetOptsOO knows they take options:
100 0 ▶sub opt_a_with { shift->_elem('opt_a', @_) }
Subroutine opt_a_with: not called CC=1 SCAR=6.9
Pod undocumented
101 0 ▶sub opt_f_with { shift->_elem('opt_f', @_) }
Subroutine opt_f_with: not called CC=1 SCAR=6.9
Pod undocumented
102 0 ▶sub opt_q_with { shift->_elem('opt_q', @_) }
Subroutine opt_q_with: not called CC=1 SCAR=6.9
Pod undocumented
103 0 ▶sub opt_d_with { shift->_elem('opt_d', @_) }
Subroutine opt_d_with: not called CC=1 SCAR=6.9
Pod undocumented
104 0 ▶sub opt_L_with { shift->_elem('opt_L', @_) }
Subroutine opt_L_with: not called CC=1 SCAR=6.9
Pod undocumented
105 0 ▶sub opt_v_with { shift->_elem('opt_v', @_) }
Subroutine opt_v_with: not called CC=1 SCAR=6.9
Pod undocumented
106  
107 0 ▶sub opt_w_with { # Specify an option for the formatter subclass
Subroutine opt_w_with: not called CC=3 SCAR=24.8
Pod undocumented
108 0 my($self, $value) = @_;
109 0 ▶ if($value =~ m/^([-_a-zA-Z][-_a-zA-Z0-9]*)(?:[=\:](.*?))?$/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([-_a-zA-Z][-_a-zA-Z0-9]*)(?:[=\:](.*?))?$/s) { } 0 0 0
110 0 my $option = $1;
111 0 ▶ my $option_value = defined($2) ? $2 : "TRUE";
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 0 0 0
112 0 $option =~ tr/\-/_/s; # tolerate "foo-bar" for "foo_bar"
113 0 $self->add_formatter_option( $option, $option_value );
114 } else {
115 0 $self->warn( qq("$value" isn't a good formatter option name. I'm ignoring it!\n ) );
116 }
117 0 return;
118 }
119  
120 6 ▶sub opt_M_with { # specify formatter class name(s)
Subroutine opt_M_with: called CC=6 SCAR=19.1
Pod undocumented
121 6 my($self, $classes) = @_;
122 6 ▶ return unless defined $classes and length $classes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $classes and length $classes 0 6 6
Condition33%1/3
defined $classes and length $classes
!ll&&!rl&&r
006
MC/DC0%0/2
defined $classes and length $classes
defined $classes length $classes
Truth table33%1/3
A and B
A= defined $classesB= length $classes
ABresult
0X0
100
111
123 6 DEBUG > 4 and print "Considering new formatter classes -M$classes\n";
124 6 my @classes_to_add;
125 6 foreach my $classname (split m/[,;]+/s, $classes) {
126 50 ▶ next unless $classname =~ m/\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $classname =~ /\S/ 0 50 50
127 50 ▶ if( $classname =~ m/^(\w+(::\w+)+)$/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($classname =~ /^(\w+(::\w+)+)$/s) { } 50 0 50
128 # A mildly restrictive concept of what modulenames are valid.
129 50 push @classes_to_add, $1; # untaint
130 } else {
131 0 $self->warn( qq("$classname" isn't a valid classname. Ignoring.\n) );
132 }
133 }
134  
135 6 unshift @{ $self->{'formatter_classes'} }, @classes_to_add;
136  
137 6 DEBUG > 3 and print(
138 "Adding @classes_to_add to the list of formatter classes, "
139 . "making them @{ $self->{'formatter_classes'} }.\n"
140 );
141  
142 6 return;
143 }
144  
145 0 ▶sub opt_V { # report version and exit
Subroutine opt_V: not called CC=3 SCAR=24.8
Pod undocumented
146 0 ▶ print join '',
Branch: 1 branch
BranchTrueFalseTotal
defined &Win32::BuildNumber && defined &Win32::BuildNumber() ? : 0 0 0
Condition0%0/3
defined &Win32::BuildNumber and defined &Win32::BuildNumber()
!ll&&!rl&&r
000
MC/DC0%0/2
defined &Win32::BuildNumber and defined &Win32::BuildNumber()
defined &Win32::BuildNumber defined &Win32::BuildNumber()
Truth table0%0/3
A and B
A= defined &Win32::BuildNumberB= defined &Win32::BuildNumber()
ABresult
0X0
100
111
147 "Perldoc v$VERSION, under perl v$] for $^O",
148  
149 (defined(&Win32::BuildNumber) and defined &Win32::BuildNumber())
150 ? (" (win32 build ", &Win32::BuildNumber(), ")") : (),
151  
152 (chr(65) eq 'A') ? () : " (non-ASCII)",
153  
154 "\n",
155 ;
156 0 exit;
157 }
158  
159 0 ▶sub opt_t { # choose plaintext as output format
Subroutine opt_t: not called CC=3 SCAR=24.8
Pod undocumented
160 0 my $self = shift;
161 0 ▶ $self->opt_o_with('text') if @_ and $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if @_ and $_[0] 0 0 0
Condition0%0/3
@_ and $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and $_[0]
@_ $_[0]
Truth table0%0/3
A and B
A= @_B= $_[0]
ABresult
0X0
100
111
162 0 return $self->_elem('opt_t', @_);
163 }
164  
165 0 ▶sub opt_u { # choose raw pod as output format
Subroutine opt_u: not called CC=3 SCAR=24.8
Pod undocumented
166 0 my $self = shift;
167 0 ▶ $self->opt_o_with('pod') if @_ and $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if @_ and $_[0] 0 0 0
Condition0%0/3
@_ and $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and $_[0]
@_ $_[0]
Truth table0%0/3
A and B
A= @_B= $_[0]
ABresult
0X0
100
111
168 0 return $self->_elem('opt_u', @_);
169 }
170  
171 0 ▶sub opt_n_with {
Subroutine opt_n_with: not called CC=3 SCAR=24.8
Pod undocumented
172 # choose man as the output format, and specify the proggy to run
173 0 my $self = shift;
174 0 ▶ $self->opt_o_with('man') if @_ and $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if @_ and $_[0] 0 0 0
Condition0%0/3
@_ and $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and $_[0]
@_ $_[0]
Truth table0%0/3
A and B
A= @_B= $_[0]
ABresult
0X0
100
111
175 0 $self->_elem('opt_n', @_);
176 }
177  
178 4 ▶sub opt_o_with { # "o" for output format
Subroutine opt_o_with: called CC=6 SCAR=19.2
Pod undocumented
179 4 my($self, $rest) = @_;
180 4 ▶ return unless defined $rest and length $rest;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rest and length $rest 0 4 4
Condition33%1/3
defined $rest and length $rest
!ll&&!rl&&r
004
MC/DC0%0/2
defined $rest and length $rest
defined $rest length $rest
Truth table33%1/3
A and B
A= defined $restB= length $rest
ABresult
0X0
100
111
181 4 ▶ if($rest =~ m/^(\w+)$/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ /^(\w+)$/s) { } 4 0 4
182 4 $rest = $1; #untaint
183 } else {
184 0 $self->warn( qq("$rest" isn't a valid output format. Skipping.\n") );
185 0 return;
186 }
187  
188 4 $self->aside("Noting \"$rest\" as desired output format...\n");
189  
190 # Figure out what class(es) that could actually mean...
191  
192 4 my @classes;
193 4 foreach my $prefix ("Pod::Perldoc::To", "Pod::Simple::", "Pod::") {
194 # Messy but smart:
195 12 foreach my $stem (
196 $rest, # Yes, try it first with the given capitalization
197 "\L$rest", "\L\u$rest", "\U$rest" # And then try variations
198  
199 ) {
200 48 $self->aside("Considering $prefix$stem\n");
201 48 push @classes, $prefix . $stem;
202 }
203  
204 # Tidier, but misses too much:
205 #push @classes, $prefix . ucfirst(lc($rest));
206 }
207 4 $self->opt_M_with( join ";", @classes );
208 4 return;
209 }
210  
211 ###########################################################################
212 # % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
213  
214 2 ▶sub run { # to be called by the "perldoc" executable
Subroutine run: called CC=2 SCAR=7.1
Pod undocumented
215 2 my $class = shift;
216 2 if(DEBUG > 3) {
217 print "Parameters to $class\->run:\n";
218 my @x = @_;
219 while(@x) {
220 $x[1] = '<undef>' unless defined $x[1];
221 $x[1] = "@{$x[1]}" if ref( $x[1] ) eq 'ARRAY';
222 print " [$x[0]] => [$x[1]]\n";
223 splice @x,0,2;
224 }
225 print "\n";
226 }
227 2 ▶ return $class -> new(@_) -> process() || 0;
Condition50%1/2
$class->new(@_)->process || 0
l!l
01
MC/DC0%0/1
$class->new(@_)->process || 0
$class->new(@_)->process
Truth table50%1/2
A
A= $class->new(@_)->process
Aresult
11
00
228 }
229  
230 # % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
231 ###########################################################################
232  
233 2 ▶sub new { # yeah, nothing fancy
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
234 2 my $class = shift;
235 2 ▶ my $new = bless {@_}, (ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
236 2 DEBUG > 1 and print "New $class object $new\n";
237 2 $new->init();
238 2 $new;
239 }
240  
241 #..........................................................................
242  
243 71 ▶sub aside { # If we're in -D or DEBUG mode, say this.
Subroutine aside: called CC=2 SCAR=9.2
Pod undocumented
244 71 my $self = shift;
245 71 ▶ if( DEBUG or $self->opt_D ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_D) 0 71 71
246 my $out = join( '',
247 0 DEBUG ? do {
248 my $callsub = (caller(1))[3];
249 my $package = quotemeta(__PACKAGE__ . '::');
250 $callsub =~ s/^$package/'/os;
251 # the o is justified, as $package really won't change.
252 $callsub . ": ";
253 } : '',
254 @_,
255 );
256 0 if(DEBUG) { print $out } else { print STDERR $out }
257 }
258 71 return;
259 }
260  
261 #..........................................................................
262  
263 0 ▶sub usage {
Subroutine usage: not called CC=2 SCAR=17.9
Pod undocumented
264 0 my $self = shift;
265 0 ▶ $self->warn( "@_\n" ) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
266  
267 # Erase evidence of previous errors (if any), so exit status is simple.
268 0 $! = 0;
269  
270 0 CORE::die( <<EOF );
271 perldoc [options] PageName|ModuleName|ProgramName|URL...
272 perldoc [options] -f BuiltinFunction
273 perldoc [options] -q FAQRegex
274 perldoc [options] -v PerlVariable
275  
276 Options:
277 -h Display this help message
278 -V Report version
279 -r Recursive search (slow)
280 -i Ignore case
281 -t Display pod using pod2text instead of Pod::Man and groff
282 (-t is the default on win32 unless -n is specified)
283 -u Display unformatted pod text
284 -m Display module's file in its entirety
285 -n Specify replacement for groff
286 -l Display the module's file name
287 -U Don't attempt to drop privs for security
288 -F Arguments are file names, not modules (implies -U)
289 -D Verbosely describe what's going on
290 -T Send output to STDOUT without any pager
291 -d output_filename_to_send_to
292 -o output_format_name
293 -M FormatterModuleNameToUse
294 -w formatter_option:option_value
295 -L translation_code Choose doc translation (if any)
296 -X Use index if present (looks for pod.idx at $Config{archlib})
297 -q Search the text of questions (not answers) in perlfaq[1-9]
298 -f Search Perl built-in functions
299 -a Search Perl API
300 -v Search predefined Perl variables
301  
302 PageName|ModuleName|ProgramName|URL...
303 is the name of a piece of documentation that you want to look at. You
304 may either give a descriptive name of the page (as in the case of
305 `perlfunc') the name of a module, either like `Term::Info' or like
306 `Term/Info', or the name of a program, like `perldoc', or a URL
307 starting with http(s).
308  
309 BuiltinFunction
310 is the name of a perl function. Will extract documentation from
311 `perlfunc' or `perlop'.
312  
313 FAQRegex
314 is a regex. Will search perlfaq[1-9] for and extract any
315 questions that match.
316  
317 Any switches in the PERLDOC environment variable will be used before the
318 command line arguments. The optional pod index file contains a list of
319 filenames, one per line.
320 [Perldoc v$VERSION]
321 EOF
322  
323 }
324  
325 #..........................................................................
326  
327 0 ▶sub program_name {
Subroutine program_name: not called CC=4 SCAR=30.0
Pod undocumented
328 0 my( $self ) = @_;
329  
330 0 ▶ if( my $link = readlink( $0 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $link = readlink $0) 0 0 0
331 0 $self->debug( "The value in $0 is a symbolic link to $link\n" );
332 }
333  
334 0 my $basename = basename( $0 );
335  
336 0 $self->debug( "\$0 is [$0]\nbasename is [$basename]\n" );
337 # possible name forms
338 # perldoc
339 # perldoc-v5.14
340 # perldoc-5.14
341 # perldoc-5.14.2
342 # perlvar # an alias mentioned in Camel 3
343 {
344 0 my( $untainted ) = $basename =~ m/(
345 \A
346 perl
347 (?: doc | func | faq | help | op | toc | var # Camel 3
348 )
349 (?: -? v? \d+ \. \d+ (?:\. \d+)? )? # possible version
350 (?: \. (?: bat | exe | com ) )? # possible extension
351 \z
352 )
353 /x;
354  
355 0 $self->debug($untainted);
356 0 ▶ return $untainted if $untainted;
Branch: 1 branch
BranchTrueFalseTotal
if $untainted 0 0 0
357 }
358  
359 0 $self->warn(<<"HERE");
360 You called the perldoc command with a name that I didn't recognize.
361 This might mean that someone is tricking you into running a
362 program you don't intend to use, but it also might mean that you
363 created your own link to perldoc. I think your program name is
364 [$basename].
365  
366 I'll allow this if the filename only has [a-zA-Z0-9._-].
367 HERE
368  
369 {
370 0 my( $untainted ) = $basename =~ m/(
371 \A [a-zA-Z0-9._-]+ \z
372 )/x;
373  
374 0 $self->debug($untainted);
375 0 ▶ return $untainted if $untainted;
Branch: 1 branch
BranchTrueFalseTotal
if $untainted 0 0 0
376 }
377  
378 0 $self->die(<<"HERE");
379 I think that your name for perldoc is potentially unsafe, so I'm
380 going to disallow it. I'd rather you be safe than sorry. If you
381 intended to use the name I'm disallowing, please tell the maintainers
382 about it. Write to:
383  
384 Pod-Perldoc\@rt.cpan.org
385  
386 HERE
387 }
388  
389 #..........................................................................
390  
391 0 ▶sub usage_brief {
Subroutine usage_brief: not called CC=1 SCAR=6.9
Pod undocumented
392 0 my $self = shift;
393 0 my $program_name = $self->program_name;
394  
395 0 CORE::die( <<"EOUSAGE" );
396 Usage: $program_name [-hVriDtumUFXlT] [-n nroffer_program]
397 [-d output_filename] [-o output_format] [-M FormatterModule]
398 [-w formatter_option:option_value] [-L translation_code]
399 PageName|ModuleName|ProgramName
400  
401 Examples:
402  
403 $program_name -f PerlFunc
404 $program_name -q FAQKeywords
405 $program_name -v PerlVar
406 $program_name -a PerlAPI
407  
408 The -h option prints more help. Also try "$program_name perldoc" to get
409 acquainted with the system. [Perldoc v$VERSION]
410 EOUSAGE
411  
412 }
413  
414 #..........................................................................
415  
416 3 ▶sub pagers { @{ shift->{'pagers'} } }
Subroutine pagers: called CC=1 SCAR=0.0
Pod undocumented
417  
418 #..........................................................................
419  
420 218 ▶sub _elem { # handy scalar meta-accessor: shift->_elem("foo", @_)
Subroutine _elem: called CC=2 SCAR=8.1
421 0 ▶ if(@_ > 2) { return $_[0]{ $_[1] } = $_[2] }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) { } 0 218 218
422 218 else { return $_[0]{ $_[1] } }
423 }
424 #..........................................................................
425 ###########################################################################
426 #
427 # Init formatter switches, and start it off with __bindir and all that
428 # other stuff that ToMan.pm needs.
429 #
430  
431 2 ▶sub init {
Subroutine init: called CC=9 SCAR=22.9
Pod undocumented
432 2 my $self = shift;
433  
434 # Make sure creat()s are neither too much nor too little
435 2 eval { umask(0077) }; # doubtless someone has no mask
436  
437 2 ▶ if ( $] < 5.008 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.008) { } 0 2 2
438 0 $self->aside("Your old perl doesn't have proper unicode support.");
439 }
440 else {
441 # http://www.perl.com/pub/2012/04/perlunicookbook-decode-argv-as-utf8.html
442 # Decode command line arguments as UTF-8. See RT#98906 for example problem.
443 3 ▶ use Encode qw(decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
444 2 @ARGV = map { decode_utf8($_, 1) } @ARGV;
445 }
446  
447 2 ▶ $self->{'args'} ||= \@ARGV;
Condition50%1/2
$self->{"args"} ||= \@ARGV
l!l
02
MC/DC0%0/1
$self->{"args"} ||= \@ARGV
$self->{"args"}
Truth table50%1/2
A
A= $self->{"args"}
Aresult
11
00
448 2 ▶ $self->{'found'} ||= [];
Condition50%1/2
$self->{"found"} ||= []
l!l
02
MC/DC0%0/1
$self->{"found"} ||= []
$self->{"found"}
Truth table50%1/2
A
A= $self->{"found"}
Aresult
11
00
449 2 ▶ $self->{'temp_file_list'} ||= [];
Condition50%1/2
$self->{"temp_file_list"} ||= []
l!l
02
MC/DC0%0/1
$self->{"temp_file_list"} ||= []
$self->{"temp_file_list"}
Truth table50%1/2
A
A= $self->{"temp_file_list"}
Aresult
11
00
450  
451  
452 2 $self->{'target'} = undef;
453  
454 2 $self->init_formatter_class_list;
455  
456 2 ▶ $self->{'pagers' } = [@Pagers] unless exists $self->{'pagers'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"pagers"} 2 0 2
457 2 ▶ $self->{'bindir' } = $Bindir unless exists $self->{'bindir'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"bindir"} 2 0 2
458 2 ▶ $self->{'pod2man'} = $Pod2man unless exists $self->{'pod2man'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"pod2man"} 2 0 2
459 2 ▶ $self->{'search_path'} = [ ] unless exists $self->{'search_path'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"search_path"} 2 0 2
460  
461 2 push @{ $self->{'formatter_switches'} = [] }, (
462 # Yeah, we could use a hashref, but maybe there's some class where options
463 # have to be ordered; so we'll use an arrayref.
464  
465 [ '__bindir' => $self->{'bindir' } ],
466 2 [ '__pod2man' => $self->{'pod2man'} ],
467 );
468  
469 DEBUG > 3 and printf "Formatter switches now: [%s]\n",
470 2 join ' ', map "[@$_]", @{ $self->{'formatter_switches'} };
471  
472 2 $self->{'translators'} = [];
473 2 $self->{'extra_search_dirs'} = [];
474  
475 2 return;
476 }
477  
478 #..........................................................................
479  
480 2 ▶sub init_formatter_class_list {
Subroutine init_formatter_class_list: called CC=8 SCAR=26.5
Pod undocumented
481 2 my $self = shift;
482 2 ▶ $self->{'formatter_classes'} ||= [];
Condition50%1/2
$self->{"formatter_classes"} ||= []
l!l
02
MC/DC0%0/1
$self->{"formatter_classes"} ||= []
$self->{"formatter_classes"}
Truth table50%1/2
A
A= $self->{"formatter_classes"}
Aresult
11
00
483  
484 # Remember, no switches have been read yet, when
485 # we've started this routine.
486  
487 2 $self->opt_M_with('Pod::Perldoc::ToPod'); # the always-there fallthru
488 2 $self->opt_o_with('text');
489 $self->opt_o_with('term')
490 unless $self->is_mswin32 || $self->is_dos || $self->is_amigaos
491 || !($ENV{TERM} && (
492 2 ▶ ($ENV{TERM} || '') !~ /dumb|emacs|none|unknown/i
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_mswin32 or $self->is_dos or $self->is_amigaos or not $ENV{"TERM"} && !(($ENV{"TERM"} || "") =~ /dumb|emacs|none|unknown/i) 2 0 2
Condition35%5/14
$self->is_mswin32 or $self->is_dos or $self->is_amigaos or not $ENV{"TERM"} && !(($ENV{"TERM"} || "") =~ /dumb|emacs|none|unknown/i)
l!l&&r!l&&!r
002
$self->is_mswin32 or $self->is_dos or $self->is_amigaos
l!l&&r!l&&!r
002
$self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
002
$ENV{'TERM'} && !(($ENV{'TERM'} || '') =~ /dumb|emacs|none|unknown/i)
!ll&&!rl&&r
002
$ENV{'TERM'} || ''
l!l
20
MC/DC0%0/5
$self->is_mswin32 or $self->is_dos or $self->is_amigaos or not $ENV{"TERM"} && !(($ENV{"TERM"} || "") =~ /dumb|emacs|none|unknown/i)
$self->is_mswin32 $self->is_dos $self->is_amigaos $ENV{'TERM'} $ENV{'TERM'}
Truth table16%1/6
A or B or C or not(D && not(E))
A= $self->is_mswin32B= $self->is_dosC= $self->is_amigaosD= $ENV{'TERM'}E= $ENV{'TERM'}
ABCDEresult
1XXXX1
01XXX1
001XX1
0000X1
000111
000100
493 ));
494  
495 2 return;
496 }
497  
498 #..........................................................................
499  
500 2 ▶sub process {
Subroutine process: called CC=14 SCAR=30.4
Pod undocumented
501 # if this ever returns, its retval will be used for exit(RETVAL)
502  
503 2 my $self = shift;
504 2 DEBUG > 1 and print " Beginning process.\n";
505 2 DEBUG > 1 and print " Args: @{$self->{'args'}}\n\n";
506 2 if(DEBUG > 3) {
507 print "Object contents:\n";
508 my @x = %$self;
509 while(@x) {
510 $x[1] = '<undef>' unless defined $x[1];
511 $x[1] = "@{$x[1]}" if ref( $x[1] ) eq 'ARRAY';
512 print " [$x[0]] => [$x[1]]\n";
513 splice @x,0,2;
514 }
515 print "\n";
516 }
517  
518 # TODO: make it deal with being invoked as various different things
519 # such as perlfaq".
520  
521 2 ▶ return $self->usage_brief unless @{ $self->{'args'} };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"args"};} 0 2 2
522 2 $self->options_reading;
523 2 $self->pagers_guessing;
524 2 $self->aside(sprintf "$0 => %s v%s\n", ref($self), $self->VERSION);
525 2 ▶ $self->drop_privs_maybe unless ($self->opt_U || $self->opt_F);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->opt_U or $self->opt_F 2 0 2
Condition33%1/3
$self->opt_U or $self->opt_F
l!l&&r!l&&!r
002
MC/DC0%0/2
$self->opt_U or $self->opt_F
$self->opt_U $self->opt_F
Truth table33%1/3
A or B
A= $self->opt_UB= $self->opt_F
ABresult
1X1
011
000
526 2 $self->options_processing;
527  
528 # Hm, we have @pages and @found, but we only really act on one
529 # file per call, with the exception of the opt_q hack, and with
530 # -l things
531  
532 2 $self->aside("\n");
533  
534 2 my @pages;
535 2 $self->{'pages'} = \@pages;
536 0 ▶ if( $self->opt_f) { @pages = qw(perlfunc perlop) }
Branch: 4 branches
BranchTrueFalseTotal
if ($self->opt_f) { } 0 2 2
elsif ($self->opt_q) { } 0 2 2
elsif ($self->opt_v) { } 0 2 2
elsif ($self->opt_a) { } 0 2 2
537 0 elsif( $self->opt_q) { @pages = ("perlfaq1" .. "perlfaq9") }
538 0 elsif( $self->opt_v) { @pages = ("perlvar") }
539 0 elsif( $self->opt_a) { @pages = ("perlapi") }
540 2 else { @pages = @{$self->{'args'}};
541 # @pages = __FILE__
542 # if @pages == 1 and $pages[0] eq 'perldoc';
543 }
544  
545 2 ▶ return $self->usage_brief unless @pages;
Branch: 1 branch
BranchTrueFalseTotal
unless @pages 0 2 2
546  
547 2 $self->find_good_formatter_class();
548 2 $self->formatter_sanity_check();
549  
550 2 $self->maybe_extend_searchpath();
551 # for when we're apparently in a module or extension directory
552  
553 2 my @found = $self->grand_search_init(\@pages);
554 2 ▶ exit ($self->is_vms ? 98962 : 1) unless @found;
Branch: 2 branches
BranchTrueFalseTotal
unless @found 1 1 2
$self->is_vms ? : 0 1 1
555  
556 1 ▶ if ($self->opt_l and not $self->opt_q ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_l and not $self->opt_q) 0 1 1
Condition33%1/3
$self->opt_l and not $self->opt_q
!ll&&!rl&&r
100
MC/DC0%0/2
$self->opt_l and not $self->opt_q
$self->opt_l not $self->opt_q
Truth table33%1/3
A and not(B)
A= $self->opt_lB= not $self->opt_q
ABresult
0X0
100
111
557 0 DEBUG and print "We're in -l mode, so byebye after this:\n";
558 0 print join("\n", @found), "\n";
559 0 return;
560 }
561  
562 1 $self->tweak_found_pathnames(\@found);
563 1 $self->assert_closing_stdout;
564 1 ▶ return $self->page_module_file(@found) if $self->opt_m;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_m 0 1 1
565 1 DEBUG > 2 and print "Found: [@found]\n";
566  
567 1 return $self->render_and_page(\@found);
568 }
569  
570 #..........................................................................
571 {
572  
573 3 my( %class_seen, %class_loaded );
574 2 ▶sub find_good_formatter_class {
Subroutine find_good_formatter_class: called CC=19 SCAR=34.6
Pod undocumented
575 2 my $self = $_[0];
576 2 ▶ my @class_list = @{ $self->{'formatter_classes'} || [] };
Condition50%1/2
$self->{'formatter_classes'} || []
l!l
20
MC/DC0%0/1
$self->{'formatter_classes'} || []
$self->{'formatter_classes'}
Truth table50%1/2
A
A= $self->{'formatter_classes'}
Aresult
11
00
577 2 ▶ $self->die( "WHAT? Nothing in the formatter class list!?" ) unless @class_list;
Branch: 1 branch
BranchTrueFalseTotal
unless @class_list 0 2 2
578  
579 2 local @INC = @INC;
580 2 ▶ pop @INC if $INC[-1] eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 2 0 2
581  
582 2 my $good_class_found;
583 2 foreach my $c (@class_list) {
584 6 DEBUG > 4 and print "Trying to load $c...\n";
585 6 ▶ if($class_loaded{$c}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class_loaded{$c}) 0 6 6
586 0 DEBUG > 4 and print "OK, the already-loaded $c it is!\n";
587 0 $good_class_found = $c;
588 0 last;
589 }
590  
591 6 ▶ if($class_seen{$c}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class_seen{$c}) 2 4 6
592 2 DEBUG > 4 and print
593 "I've tried $c before, and it's no good. Skipping.\n";
594 2 next;
595 }
596  
597 4 $class_seen{$c} = 1;
598  
599 4 ▶ if( $c->can('parse_from_file') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c->can('parse_from_file')) { } 0 4 4
elsif ($self->is_os2 || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $class_seen{lc "~$c"}++) { } 0 4 4
600 0 DEBUG > 4 and print
601 "Interesting, the formatter class $c is already loaded!\n";
602  
603 ▶ } elsif(
Condition33%4/12
$self->is_os2 || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $class_seen{lc "~$c"}++
!ll&&!rl&&r
400
$self->is_os2 or $self->is_mswin32 or $self->is_dos or $self->is_os2
l!l&&r!l&&!r
004
$self->is_os2 or $self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
004
$self->is_os2 or $self->is_mswin32
l!l&&r!l&&!r
004
MC/DC0%0/5
$self->is_os2 || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $class_seen{lc "~$c"}++
$self->is_os2 $self->is_mswin32 $self->is_dos $self->is_os2 $class_seen{lc "~$c"}++
Truth table11%1/9
A or B or C or D and E
A= $self->is_os2B= $self->is_mswin32C= $self->is_dosD= $self->is_os2E= $class_seen{lc "~$c"}++
ABCDEresult
0000X0
1XXX00
01XX00
001X00
000100
1XXX11
01XX11
001X11
000111
604 ( $self->is_os2 or $self->is_mswin32 or $self->is_dos or $self->is_os2)
605 # the always case-insensitive filesystems
606 and $class_seen{lc("~$c")}++
607 ) {
608 0 DEBUG > 4 and print
609 "We already used something quite like \"\L$c\E\", so no point using $c\n";
610 # This avoids redefining the package.
611 } else {
612 4 DEBUG > 4 and print "Trying to eval 'require $c'...\n";
613  
614 4 local $^W = $^W;
615 4 ▶ if(DEBUG() or $self->opt_D) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_D) { } 0 4 4
616 # feh, let 'em see it
617 } else {
618 4 $^W = 0;
619 # The average user just has no reason to be seeing
620 # $^W-suppressible warnings from the require!
621 }
622  
623 4 eval "require $c";
624 4 ▶ if($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 2 4
625 2 DEBUG > 4 and print "Couldn't load $c: $!\n";
626 2 next;
627 }
628 }
629  
630 2 ▶ if( $c->can('parse_from_file') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->can('parse_from_file')) { } 2 0 2
631 2 DEBUG > 4 and print "Settling on $c\n";
632 2 my $v = $c->VERSION;
633 2 ▶ $v = ( defined $v and length $v ) ? " version $v" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $v && length $v ? : 2 0 2
Condition33%1/3
defined $v and length $v
!ll&&!rl&&r
002
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table33%1/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
634 2 $self->aside("Formatter class $c$v successfully loaded!\n");
635 2 $good_class_found = $c;
636 2 last;
637 } else {
638 0 DEBUG > 4 and print "Class $c isn't a formatter?! Skipping.\n";
639 }
640 }
641  
642 2 ▶ $self->die( "Can't find any loadable formatter class in @class_list?!\nAborting" )
Branch: 1 branch
BranchTrueFalseTotal
unless $good_class_found 0 2 2
643 unless $good_class_found;
644  
645 2 $self->{'formatter_class'} = $good_class_found;
646 2 $self->aside("Will format with the class $good_class_found\n");
647  
648 2 return;
649 }
650  
651 }
652 #..........................................................................
653  
654 3 ▶sub formatter_sanity_check {
Subroutine formatter_sanity_check: called CC=9 SCAR=35.7
Pod undocumented
655 2 my $self = shift;
656 2 ▶ my $formatter_class = $self->{'formatter_class'}
Condition33%1/3
$self->{'formatter_class'} || $self->die('NO FORMATTER CLASS YET!?')
l!l&&r!l&&!r
200
MC/DC0%0/2
$self->{'formatter_class'} || $self->die('NO FORMATTER CLASS YET!?')
$self->{'formatter_class'} $self->die('NO FORMATTER CLASS YET!?')
Truth table33%1/3
A || B
A= $self->{'formatter_class'}B= $self->die('NO FORMATTER CLASS YET!?')
ABresult
1X1
011
000
657 || $self->die( "NO FORMATTER CLASS YET!?" );
658  
659 2 ▶ if(!$self->opt_T # so -T can FORCE sending to STDOUT
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->opt_T and $formatter_class->can("is_pageable") and not $formatter_class->is_pageable and not $formatter_class->can("page_for_perldoc")) 0 2 2
Condition33%3/9
not $self->opt_T and $formatter_class->can("is_pageable") and not $formatter_class->is_pageable and not $formatter_class->can("page_for_perldoc")
!ll&&!rl&&r
200
not $self->opt_T and $formatter_class->can("is_pageable") and not $formatter_class->is_pageable
!ll&&!rl&&r
020
not $self->opt_T and $formatter_class->can("is_pageable")
!ll&&!rl&&r
002
MC/DC0%0/4
not $self->opt_T and $formatter_class->can("is_pageable") and not $formatter_class->is_pageable and not $formatter_class->can("page_for_perldoc")
not $self->opt_T $formatter_class->can("is_pageable") not $formatter_class->is_pageable not $formatter_class->can("page_for_perldoc")
Truth table20%1/5
not(A) and B and not(C) and not(D)
A= not $self->opt_TB= $formatter_class->can("is_pageable")C= not $formatter_class->is_pageableD= not $formatter_class->can("page_for_perldoc")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
660 and $formatter_class->can('is_pageable')
661 and !$formatter_class->is_pageable
662 and !$formatter_class->can('page_for_perldoc')
663 ) {
664 0 ▶ my $ext =
Condition0%0/5
$formatter_class->can('output_extension') && $formatter_class->output_extension || ''
l!l
00
$formatter_class->can("output_extension") and $formatter_class->output_extension
!ll&&!rl&&r
000
MC/DC0%0/2
$formatter_class->can('output_extension') && $formatter_class->output_extension || ''
$formatter_class->can("output_extension") $formatter_class->output_extension
Truth table0%0/3
A and B
A= $formatter_class->can("output_extension")B= $formatter_class->output_extension
ABresult
111
0X0
100
665 ($formatter_class->can('output_extension')
666 && $formatter_class->output_extension
667 ) || '';
668 0 ▶ $ext = ".$ext" if length $ext;
Branch: 1 branch
BranchTrueFalseTotal
if length $ext 0 0 0
669  
670 0 my $me = $self->program_name;
671 0 $self->die(
672 "When using Perldoc to format with $formatter_class, you have to\n"
673 . "specify -T or -dsomefile$ext\n"
674 . "See `$me perldoc' for more information on those switches.\n" )
675 ;
676 }
677 }
678  
679 #..........................................................................
680  
681 1 ▶sub render_and_page {
Subroutine render_and_page: called CC=8 SCAR=32.9
Pod undocumented
682 1 my($self, $found_list) = @_;
683  
684 1 $self->maybe_generate_dynamic_pod($found_list);
685  
686 1 my($out, $formatter) = $self->render_findings($found_list);
687  
688 1 ▶ if($self->opt_d) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->opt_d) { } 0 1 1
elsif ($formatter->can('page_for_perldoc') and do { $self->aside(qq[Going to call $formatter->page_for_perldoc("$out")\n]); if ($formatter->page_for_perldoc($out, $self)) { $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n"); 1; } else { $self->aside("page_for_perldoc returned false, so paging with $self instead.\n"); ''; } }) { } 0 1 1
689 printf "Perldoc (%s) output saved to %s\n",
690 0 ▶ $self->{'formatter_class'} || ref($self),
Condition0%0/3
$self->{'formatter_class'} || ref $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'formatter_class'} || ref $self
$self->{'formatter_class'} ref $self
Truth table0%0/3
A || B
A= $self->{'formatter_class'}B= ref $self
ABresult
1X1
011
000
691 $out;
692 0 ▶ print "But notice that it's 0 bytes long!\n" unless -s $out;
Branch: 1 branch
BranchTrueFalseTotal
unless -s $out 0 0 0
693  
694  
695 ▶ } elsif( # Allow the formatter to "page" itself, if it wants.
Condition33%1/3
$formatter->can("page_for_perldoc") and do { $self->aside(qq[Going to call $formatter->page_for_perldoc("$out")\n]); if ($formatter->page_for_perldoc($out, $self)) { $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n"); 1; } else { $self->aside("page_for_perldoc returned false, so paging with $self instead.\n"); ""; } }
!ll&&!rl&&r
100
MC/DC0%0/2
$formatter->can("page_for_perldoc") and do { $self->aside(qq[Going to call $formatter->page_for_perldoc("$out")\n]); if ($formatter->page_for_perldoc($out, $self)) { $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n"); 1; } else { $self->aside("page_for_perldoc returned false, so paging with $self instead.\n"); ""; } }
$formatter->can("page_for_perldoc") do { $self->aside(qq[Going to call $formatter->page_for_perldoc("$out")\n]); if ($formatter->page_for_perldoc($out, $self)) { $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n"); 1; } else { $self->aside("page_for_perldoc returned false, so paging with $self instead.\n"); ""; } }
Truth table33%1/3
A and B
A= $formatter->can("page_for_perldoc")B= do { $self->aside(qq[Going to call $formatter->page_for_perldoc("$out")\n]); if ($formatter->page_for_perldoc($out, $self)) { $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n"); 1; } else { $self->aside("page_for_perldoc returned false, so paging with $self instead.\n"); ""; } }
ABresult
0X0
100
111
696 $formatter->can('page_for_perldoc')
697 and do {
698 0 $self->aside("Going to call $formatter\->page_for_perldoc(\"$out\")\n");
699 0 ▶ if( $formatter->page_for_perldoc($out, $self) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($formatter->page_for_perldoc($out, $self)) { } 0 0 0
700 0 $self->aside("page_for_perldoc returned true, so NOT paging with $self.\n");
701 0 1;
702 } else {
703 0 $self->aside("page_for_perldoc returned false, so paging with $self instead.\n");
704 0 '';
705 }
706 }
707 ) {
708 # Do nothing, since the formatter has "paged" it for itself.
709  
710 } else {
711 # Page it normally (internally)
712  
713 1 ▶ if( -s $out ) { # Usual case:
Branch: 1 branch
BranchTrueFalseTotal
if (-s $out) { } 1 0 1
714 1 $self->page($out, $self->{'output_to_stdout'}, $self->pagers);
715  
716 } else {
717 # Odd case:
718 0 $self->aside("Skipping $out (from $$found_list[0] "
719 . "via $$self{'formatter_class'}) as it is 0-length.\n");
720  
721 0 push @{ $self->{'temp_file_list'} }, $out;
722 0 $self->unlink_if_temp_file($out);
723 }
724 }
725  
726 1 $self->after_rendering(); # any extra cleanup or whatever
727  
728 1 return;
729 }
730  
731 #..........................................................................
732  
733 2 ▶sub options_reading {
Subroutine options_reading: called CC=5 SCAR=19.9
Pod undocumented
734 2 my $self = shift;
735  
736 2 ▶ if( defined $ENV{"PERLDOC"} and length $ENV{"PERLDOC"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'PERLDOC'} and length $ENV{'PERLDOC'}) { } 0 2 2
Condition33%1/3
defined $ENV{"PERLDOC"} and length $ENV{"PERLDOC"}
!ll&&!rl&&r
200
MC/DC0%0/2
defined $ENV{"PERLDOC"} and length $ENV{"PERLDOC"}
defined $ENV{"PERLDOC"} length $ENV{"PERLDOC"}
Truth table33%1/3
A and B
A= defined $ENV{"PERLDOC"}B= length $ENV{"PERLDOC"}
ABresult
0X0
100
111
737 0 require Text::ParseWords;
738 0 $self->aside("Noting env PERLDOC setting of $ENV{'PERLDOC'}\n");
739 # Yes, appends to the beginning
740 0 unshift @{ $self->{'args'} },
741 0 Text::ParseWords::shellwords( $ENV{"PERLDOC"} )
742 ;
743 0 DEBUG > 1 and print " Args now: @{$self->{'args'}}\n\n";
744 } else {
745 2 DEBUG > 1 and print " Okay, no PERLDOC setting in ENV.\n";
746 }
747  
748 2 DEBUG > 1
749 and print " Args right before switch processing: @{$self->{'args'}}\n";
750  
751 2 ▶ Pod::Perldoc::GetOptsOO::getopts( $self, $self->{'args'}, 'YES' )
Branch: 1 branch
BranchTrueFalseTotal
Pod::Perldoc::GetOptsOO::getopts($self, $self->{"args"}, "YES") or return $self->usage 2 0 2
752 or return $self->usage;
753  
754 2 DEBUG > 1
755 and print " Args after switch processing: @{$self->{'args'}}\n";
756  
757 2 ▶ return $self->usage if $self->opt_h;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_h 0 2 2
758  
759 2 return;
760 }
761  
762 #..........................................................................
763  
764 2 ▶sub options_processing {
Subroutine options_processing: called CC=14 SCAR=43.3
Pod undocumented
765 2 my $self = shift;
766  
767 2 ▶ if ($self->opt_X) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_X) 0 2 2
768 0 my $podidx = "$Config{'archlib'}/pod.idx";
769 0 ▶ $podidx = "" unless -f $podidx && -r _ && -M _ <= 7;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $podidx and -r _ and -M _ <= 7 0 0 0
Condition0%0/6
-f $podidx and -r _ and -M _ <= 7
!ll&&!rl&&r
000
-f $podidx and -r _
!ll&&!rl&&r
000
MC/DC0%0/3
-f $podidx and -r _ and -M _ <= 7
-f $podidx -r _ -M _ <= 7
Truth table0%0/4
A and B and C
A= -f $podidxB= -r _C= -M _ <= 7
ABCresult
0XX0
10X0
1100
1111
770 0 $self->{'podidx'} = $podidx;
771 }
772  
773 2 ▶ $self->{'output_to_stdout'} = 1 if $self->opt_T or ! -t STDOUT;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_T or not -t STDOUT 2 0 2
Condition33%1/3
$self->opt_T or not -t STDOUT
l!l&&r!l&&!r
020
MC/DC0%0/2
$self->opt_T or not -t STDOUT
$self->opt_T not -t STDOUT
Truth table33%1/3
A or not(B)
A= $self->opt_TB= not -t STDOUT
ABresult
1X1
011
000
774  
775 2 $self->options_sanity;
776  
777 # This used to set a default, but that's now moved into any
778 # formatter that cares to have a default.
779 2 ▶ if( $self->opt_n ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_n) 0 2 2
780 0 $self->add_formatter_option( '__nroffer' => $self->opt_n );
781 }
782  
783 # Get language from PERLDOC_POD2 environment variable
784 2 ▶ if ( ! $self->opt_L && $ENV{PERLDOC_POD2} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->opt_L and $ENV{"PERLDOC_POD2"}) 0 2 2
Condition33%1/3
not $self->opt_L and $ENV{"PERLDOC_POD2"}
!ll&&!rl&&r
020
MC/DC0%0/2
not $self->opt_L and $ENV{"PERLDOC_POD2"}
not $self->opt_L $ENV{"PERLDOC_POD2"}
Truth table33%1/3
not(A) and B
A= not $self->opt_LB= $ENV{"PERLDOC_POD2"}
ABresult
0X0
100
111
785 0 ▶ if ( $ENV{PERLDOC_POD2} eq '1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERLDOC_POD2'} eq '1') { } 0 0 0
786 0 ▶ $self->_elem('opt_L',(split(/\_/, $ENV{LC_ALL} || $ENV{LC_LANG} || $ENV{LANG}))[0] );
Condition0%0/6
$ENV{'LC_ALL'} || $ENV{'LC_LANG'} || $ENV{'LANG'}
l!l&&r!l&&!r
000
$ENV{"LC_ALL"} or $ENV{"LC_LANG"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{'LC_ALL'} || $ENV{'LC_LANG'} || $ENV{'LANG'}
$ENV{"LC_ALL"} $ENV{"LC_LANG"} $ENV{'LANG'}
Truth table0%0/4
A or B || C
A= $ENV{"LC_ALL"}B= $ENV{"LC_LANG"}C= $ENV{'LANG'}
ABCresult
1XX1
01X1
0011
0000
787 }
788 else {
789 0 $self->_elem('opt_L', $ENV{PERLDOC_POD2});
790 }
791 };
792  
793 # Adjust for using translation packages
794 2 ▶ $self->add_translator(split(/\s+/,$self->opt_L)) if $self->opt_L;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_L 0 2 2
795  
796 2 return;
797 }
798  
799 #..........................................................................
800  
801 2 ▶sub options_sanity {
Subroutine options_sanity: called CC=9 SCAR=39.0
Pod undocumented
802 2 my $self = shift;
803  
804 # The opts-counting stuff interacts quite badly with
805 # the $ENV{"PERLDOC"} stuff. I.e., if I have $ENV{"PERLDOC"}
806 # set to -t, and I specify -u on the command line, I don't want
807 # to be hectored at that -u and -t don't make sense together.
808  
809 #my $opts = grep $_ && 1, # yes, the count of the set ones
810 # $self->opt_t, $self->opt_u, $self->opt_m, $self->opt_l
811 #;
812 #
813 #$self->usage("only one of -t, -u, -m or -l") if $opts > 1;
814  
815  
816 # Any sanity-checking need doing here?
817  
818 # But does not make sense to set either -f or -q in $ENV{"PERLDOC"}
819 2 ▶ if( $self->opt_f or $self->opt_q or $self->opt_a) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_f or $self->opt_q or $self->opt_a) 0 2 2
Condition33%2/6
$self->opt_f or $self->opt_q or $self->opt_a
l!l&&r!l&&!r
002
$self->opt_f or $self->opt_q
l!l&&r!l&&!r
002
MC/DC0%0/3
$self->opt_f or $self->opt_q or $self->opt_a
$self->opt_f $self->opt_q $self->opt_a
Truth table25%1/4
A or B or C
A= $self->opt_fB= $self->opt_qC= $self->opt_a
ABCresult
1XX1
01X1
0011
0000
820 0 my $count;
821 0 ▶ $count++ if $self->opt_f;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_f 0 0 0
822 0 ▶ $count++ if $self->opt_q;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_q 0 0 0
823 0 ▶ $count++ if $self->opt_a;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_a 0 0 0
824 0 ▶ $self->usage("Only one of -f or -q or -a") if $count > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $count > 1 0 0 0
825 $self->warn(
826 "Perldoc is meant for reading one file at a time.\n",
827 "So these parameters are being ignored: ",
828 0 join(' ', @{$self->{'args'}}),
829 "\n" )
830 0 ▶ if @{$self->{'args'}}
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"args"};} 0 0 0
831 }
832 2 return;
833 }
834  
835 #..........................................................................
836  
837 2 ▶sub grand_search_init {
Subroutine grand_search_init: called CC=32 SCAR=59.1
Pod undocumented
838 2 my($self, $pages, @found) = @_;
839  
840 2 foreach (@$pages) {
841 2 ▶ if (/^http(s)?:\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[^http(s)?://]) 0 2 2
842 0 require HTTP::Tiny;
843 0 require File::Temp;
844 0 my $response = HTTP::Tiny->new->get($_);
845 0 ▶ if ($response->{success}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{'success'}) { } 0 0 0
846 0 my ($fh, $filename) = File::Temp::tempfile(UNLINK => 1);
847 0 $fh->print($response->{content});
848 0 push @found, $filename;
849 0 ▶ ($self->{podnames}{$filename} =
Branch: 1 branch
BranchTrueFalseTotal
m[.*/([^/#?]+)] ? : 0 0 0
850 m{.*/([^/#?]+)} ? uc $1 : "UNKNOWN")
851 =~ s/\.P(?:[ML]|OD)\z//;
852 }
853 else {
854 0 ▶ print STDERR "No " .
Branch: 1 branch
BranchTrueFalseTotal
$self->opt_m ? : 0 0 0
855 ($self->opt_m ? "module" : "documentation") . " found for \"$_\".\n";
856 0 ▶ if ( /^https/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^https/) 0 0 0
857 0 print STDERR "You may need an SSL library (such as IO::Socket::SSL) for that URL.\n";
858 }
859 }
860 0 next;
861 }
862 2 ▶ if ($self->{'podidx'} && open(PODIDX, $self->{'podidx'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"podidx"} and open PODIDX, $self->{"podidx"}) 0 2 2
Condition33%1/3
$self->{"podidx"} and open PODIDX, $self->{"podidx"}
!ll&&!rl&&r
200
MC/DC0%0/2
$self->{"podidx"} and open PODIDX, $self->{"podidx"}
$self->{"podidx"} open PODIDX, $self->{"podidx"}
Truth table33%1/3
A and B
A= $self->{"podidx"}B= open PODIDX, $self->{"podidx"}
ABresult
0X0
100
111
863 0 my $searchfor = catfile split '::', $_;
864 0 $self->aside( "Searching for '$searchfor' in $self->{'podidx'}\n" );
865 0 local $_;
866 0 ▶ while (<PODIDX>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PODIDX)) 0 0 0
867 0 chomp;
868 0 ▶ push(@found, $_) if m,/$searchfor(?:\.(?:pod|pm))?\z,i;
Branch: 1 branch
BranchTrueFalseTotal
if m[/$searchfor(?:\.(?:pod|pm))?\z]i 0 0 0
869 }
870 0 ▶ close(PODIDX) or $self->die( "Can't close $$self{'podidx'}: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close PODIDX or $self->die(qq[Can't close $self->{"podidx"}: $!]) 0 0 0
871 0 next;
872 }
873  
874 2 $self->aside( "Searching for $_\n" );
875  
876 2 ▶ if ($self->opt_F) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_F) 0 2 2
877 0 ▶ next unless -r;
Branch: 1 branch
BranchTrueFalseTotal
unless -r $_ 0 0 0
878 0 ▶ push @found, $_ if $self->opt_l or $self->opt_m or $self->containspod($_);
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_l or $self->opt_m or $self->containspod($_) 0 0 0
Condition0%0/6
$self->opt_l or $self->opt_m or $self->containspod($_)
l!l&&r!l&&!r
000
$self->opt_l or $self->opt_m
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->opt_l or $self->opt_m or $self->containspod($_)
$self->opt_l $self->opt_m $self->containspod($_)
Truth table0%0/4
A or B or C
A= $self->opt_lB= $self->opt_mC= $self->containspod($_)
ABCresult
1XX1
01X1
0011
0000
879 0 next;
880 }
881  
882 2 my @searchdirs;
883  
884 # prepend extra search directories (including language specific)
885 2 push @searchdirs, @{ $self->{'extra_search_dirs'} };
886  
887 # We must look both in @INC for library modules and in $bindir
888 # for executables, like h2xs or perldoc itself.
889 2 push @searchdirs, ($self->{'bindir'}, @{$self->{search_path}}, @INC);
890 2 ▶ unless ($self->opt_m) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->opt_m) 2 0 2
891 2 ▶ if ($self->is_vms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_vms) { } 0 2 2
892 0 my($i,$trn);
893 0 ▶ for ($i = 0; $trn = $ENV{'DCL$PATH;'.$i}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trn = $ENV{'DCL$PATH;' . $i}) 0 0 0
894 0 push(@searchdirs,$trn);
895 }
896 0 push(@searchdirs,'perl_root:[lib.pods]') # installed pods
897 }
898 else {
899 push(@searchdirs, grep(-d, split($Config{path_sep},
900 2 $ENV{'PATH'})));
901 }
902 }
903 2 my @files = $self->searchfor(0,$_,@searchdirs);
904 2 ▶ if (@files) {
Branch: 2 branches
BranchTrueFalseTotal
if (@files) { } 1 1 2
elsif (not /\W/ and @files = $self->searchfor(0, "perl$_", @searchdirs)) { } 0 1 1
905 1 $self->aside( "Found as @files\n" );
906 }
907 # add "perl" prefix, so "perldoc foo" may find perlfoo.pod
908 ▶ elsif (BE_LENIENT and !/\W/ and @files = $self->searchfor(0, "perl$_", @searchdirs)) {
Condition33%1/3
not /\W/ and @files = $self->searchfor(0, "perl$_", @searchdirs)
!ll&&!rl&&r
100
MC/DC0%0/2
not /\W/ and @files = $self->searchfor(0, "perl$_", @searchdirs)
not /\W/ @files = $self->searchfor(0, "perl$_", @searchdirs)
Truth table33%1/3
not(A) and B
A= not /\W/B= @files = $self->searchfor(0, "perl$_", @searchdirs)
ABresult
0X0
100
111
909 0 $self->aside( "Loosely found as @files\n" );
910 }
911 else {
912 # no match, try recursive search
913 1 @searchdirs = grep(!/^\.\z/s,@INC);
914 1 ▶ @files= $self->searchfor(1,$_,@searchdirs) if $self->opt_r;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_r 0 1 1
915 1 ▶ if (@files) {
Branch: 1 branch
BranchTrueFalseTotal
if (@files) { } 0 1 1
916 0 $self->aside( "Loosely found as @files\n" );
917 }
918 else {
919 1 ▶ print STDERR "No " .
Branch: 1 branch
BranchTrueFalseTotal
$self->opt_m ? : 0 1 1
920 ($self->opt_m ? "module" : "documentation") . " found for \"$_\".\n";
921 1 ▶ if ( @{ $self->{'found'} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"found"};}) 0 1 1
922 0 print STDERR "However, try\n";
923 0 my $me = $self->program_name;
924 0 for my $dir (@{ $self->{'found'} }) {
925 0 ▶ opendir(DIR, $dir) or $self->die( "opendir $dir: $!" );
Branch: 1 branch
BranchTrueFalseTotal
opendir DIR, $dir or $self->die("opendir ${dir}: $!") 0 0 0
926 0 ▶ while (my $file = readdir(DIR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir DIR)) 0 0 0
927 0 ▶ next if ($file =~ /^\./s);
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /^\./s 0 0 0
928 0 $file =~ s/\.(pm|pod)\z//; # XXX: badfs
929 0 print STDERR "\t$me $_\::$file\n";
930 }
931 0 ▶ closedir(DIR) or $self->die( "closedir $dir: $!" );
Branch: 1 branch
BranchTrueFalseTotal
closedir DIR or $self->die("closedir ${dir}: $!") 0 0 0
932 }
933 }
934 }
935 }
936 2 push(@found,@files);
937 }
938 2 return @found;
939 }
940  
941 #..........................................................................
942  
943 1 ▶sub maybe_generate_dynamic_pod {
Subroutine maybe_generate_dynamic_pod: called CC=19 SCAR=51.4
Pod undocumented
944 1 my($self, $found_things) = @_;
945 1 my @dynamic_pod;
946  
947 1 ▶ $self->search_perlapi($found_things, \@dynamic_pod) if $self->opt_a;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_a 0 1 1
948  
949 1 ▶ $self->search_perlfunc($found_things, \@dynamic_pod) if $self->opt_f;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_f 0 1 1
950  
951 1 ▶ $self->search_perlvar($found_things, \@dynamic_pod) if $self->opt_v;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_v 0 1 1
952  
953 1 ▶ $self->search_perlfaqs($found_things, \@dynamic_pod) if $self->opt_q;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_q 0 1 1
954  
955 1 ▶ if( ! $self->opt_f and ! $self->opt_q and ! $self->opt_v and ! $self->opt_a) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->opt_f || $self->opt_q || $self->opt_v || $self->opt_a) { } 1 0 1
elsif (@dynamic_pod) { } 0 0 0
Condition33%3/9
$self->opt_f || $self->opt_q || $self->opt_v || $self->opt_a
l!l&&r!l&&!r
001
$self->opt_f or $self->opt_q or $self->opt_v
l!l&&r!l&&!r
001
$self->opt_f or $self->opt_q
l!l&&r!l&&!r
001
MC/DC0%0/4
$self->opt_f || $self->opt_q || $self->opt_v || $self->opt_a
$self->opt_f $self->opt_q $self->opt_v $self->opt_a
Truth table20%1/5
A or B or C || D
A= $self->opt_fB= $self->opt_qC= $self->opt_vD= $self->opt_a
ABCDresult
1XXX1
01XX1
001X1
00011
00000
956 1 DEBUG > 4 and print "That's a non-dynamic pod search.\n";
957 } elsif ( @dynamic_pod ) {
958 0 $self->aside("Hm, I found some Pod from that search!\n");
959 0 my ($buffd, $buffer) = $self->new_tempfile('pod', 'dyn');
960 0 ▶ if ( $] >= 5.008 && $self->opt_L ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.008" and $self->opt_L) 0 0 0
Condition0%0/3
$] >= "5.008" and $self->opt_L
!ll&&!rl&&r
000
MC/DC0%0/2
$] >= "5.008" and $self->opt_L
$] >= "5.008" $self->opt_L
Truth table0%0/3
A and B
A= $] >= "5.008"B= $self->opt_L
ABresult
0X0
100
111
961 0 binmode($buffd, ":encoding(UTF-8)");
962 0 print $buffd "=encoding utf8\n\n";
963 }
964  
965 0 push @{ $self->{'temp_file_list'} }, $buffer;
966 # I.e., it MIGHT be deleted at the end.
967  
968 0 ▶ my $in_list = !$self->not_dynamic && $self->opt_f || $self->opt_v || $self->opt_a;
Condition0%0/9
!$self->not_dynamic && $self->opt_f || $self->opt_v || $self->opt_a
l!l&&r!l&&!r
000
not $self->not_dynamic and $self->opt_f or $self->opt_v
l!l&&r!l&&!r
000
not $self->not_dynamic and $self->opt_f
!ll&&!rl&&r
000
MC/DC0%0/4
!$self->not_dynamic && $self->opt_f || $self->opt_v || $self->opt_a
not $self->not_dynamic $self->opt_f $self->opt_v $self->opt_a
Truth table0%0/7
not(A) and B or C || D
A= not $self->not_dynamicB= $self->opt_fC= $self->opt_vD= $self->opt_a
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
969  
970 0 ▶ print $buffd "=over 8\n\n" if $in_list;
Branch: 1 branch
BranchTrueFalseTotal
if $in_list 0 0 0
971 0 ▶ print $buffd @dynamic_pod or $self->die( "Can't print $buffer: $!" );
Branch: 1 branch
BranchTrueFalseTotal
print $buffd @dynamic_pod or $self->die("Can't print ${buffer}: $!") 0 0 0
972 0 ▶ print $buffd "=back\n" if $in_list;
Branch: 1 branch
BranchTrueFalseTotal
if $in_list 0 0 0
973  
974 0 ▶ close $buffd or $self->die( "Can't close $buffer: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $buffd or $self->die("Can't close ${buffer}: $!") 0 0 0
975  
976 0 @$found_things = $buffer;
977 # Yes, so found_things never has more than one thing in
978 # it, by time we leave here
979  
980 0 $self->add_formatter_option('__filter_nroff' => 1);
981  
982 } else {
983 0 @$found_things = ();
984 0 $self->aside("I found no Pod from that search!\n");
985 }
986  
987 1 return;
988 }
989  
990 #..........................................................................
991  
992 0 ▶sub not_dynamic {
Subroutine not_dynamic: not called CC=2 SCAR=17.9
Pod undocumented
993 0 my ($self,$value) = @_;
994 0 ▶ $self->{__not_dynamic} = $value if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 0 0 0
995 0 return $self->{__not_dynamic};
996 }
997  
998 #..........................................................................
999  
1000 0 ▶sub add_formatter_option { # $self->add_formatter_option('key' => 'value');
Subroutine add_formatter_option: not called CC=2 SCAR=17.9
Pod undocumented
1001 0 my $self = shift;
1002 0 ▶ push @{ $self->{'formatter_switches'} }, [ @_ ] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
1003  
1004 DEBUG > 3 and printf "Formatter switches now: [%s]\n",
1005 0 join ' ', map "[@$_]", @{ $self->{'formatter_switches'} };
1006  
1007 0 return;
1008 }
1009  
1010 #.........................................................................
1011  
1012 0 ▶sub new_translator { # $tr = $self->new_translator($lang);
Subroutine new_translator: not called CC=5 SCAR=34.0
Pod undocumented
1013 0 my $self = shift;
1014 0 my $lang = shift;
1015  
1016 0 local @INC = @INC;
1017 0 ▶ pop @INC if $INC[-1] eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 0 0 0
1018 0 my $pack = 'POD2::' . uc($lang);
1019 0 eval "require $pack";
1020 0 ▶ if ( !$@ && $pack->can('new') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $@ and $pack->can("new")) 0 0 0
Condition0%0/3
not $@ and $pack->can("new")
!ll&&!rl&&r
000
MC/DC0%0/2
not $@ and $pack->can("new")
not $@ $pack->can("new")
Truth table0%0/3
not(A) and B
A= not $@B= $pack->can("new")
ABresult
0X0
100
111
1021 0 return $pack->new();
1022 }
1023  
1024 0 eval { require POD2::Base };
1025 0 ▶ return if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1026  
1027 0 return POD2::Base->new({ lang => $lang });
1028 }
1029  
1030 #.........................................................................
1031  
1032 0 ▶sub add_translator { # $self->add_translator($lang);
Subroutine add_translator: not called CC=3 SCAR=24.8
Pod undocumented
1033 0 my $self = shift;
1034 0 for my $lang (@_) {
1035 0 my $tr = $self->new_translator($lang);
1036 0 ▶ if ( defined $tr ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tr) { } 0 0 0
1037 0 push @{ $self->{'translators'} }, $tr;
1038 0 push @{ $self->{'extra_search_dirs'} }, $tr->pod_dirs;
1039  
1040 0 $self->aside( "translator for '$lang' loaded\n" );
1041 } else {
1042 # non-installed or bad translator package
1043 0 $self->warn( "Perldoc cannot load translator package for '$lang': ignored\n" );
1044 }
1045  
1046 }
1047 0 return;
1048 }
1049  
1050 #..........................................................................
1051  
1052 2 ▶sub open_fh {
Subroutine open_fh: called CC=2 SCAR=7.1
Pod undocumented
1053 2 my ($self, $op, $path) = @_;
1054  
1055 2 ▶ open my $fh, $op, $path or $self->die("Couldn't open $path: $!");
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $op, $path or $self->die("Couldn't open ${path}: $!") 2 0 2
1056 2 return $fh;
1057 }
1058  
1059 0 ▶sub set_encoding {
Subroutine set_encoding: not called CC=3 SCAR=24.8
Pod undocumented
1060 0 my ($self, $fh, $encoding) = @_;
1061  
1062 0 ▶ if ( $encoding =~ /utf-?8/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($encoding =~ /utf-?8/i) { } 0 0 0
1063 0 $encoding = ":encoding(UTF-8)";
1064 }
1065 else {
1066 0 $encoding = ":encoding($encoding)";
1067 }
1068  
1069 0 ▶ if ( $] < 5.008 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.008) { } 0 0 0
1070 0 $self->aside("Your old perl doesn't have proper unicode support.");
1071 }
1072 else {
1073 0 binmode($fh, $encoding);
1074 }
1075  
1076 0 return $fh;
1077 }
1078  
1079 0 ▶sub search_perlvar {
Subroutine search_perlvar: not called CC=25 SCAR=64.8
Pod undocumented
1080 0 my($self, $found_things, $pod) = @_;
1081  
1082 0 my $opt = $self->opt_v;
1083  
1084 0 ▶ if ( $opt !~ /^ (?: [\@\%\$]\S+ | [A-Z]\w* ) $/x ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^ (?: [\@\%\$]\S+ | [A-Z]\w* ) $/x) 0 0 0
1085 0 CORE::die( "'$opt' does not look like a Perl variable\n" );
1086 }
1087  
1088 0 DEBUG > 2 and print "Search: @$found_things\n";
1089  
1090 0 my $perlvar = shift @$found_things;
1091 0 my $fh = $self->open_fh("<", $perlvar);
1092  
1093 0 ▶ if ( $opt ne '$0' && $opt =~ /^\$\d+$/ ) { # handle $1, $2, ...
Branch: 1 branch
BranchTrueFalseTotal
if ($opt ne "\$0" and $opt =~ /^\$\d+$/) 0 0 0
Condition0%0/3
$opt ne "\$0" and $opt =~ /^\$\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$opt ne "\$0" and $opt =~ /^\$\d+$/
$opt ne "\$0" $opt =~ /^\$\d+$/
Truth table0%0/3
A and B
A= $opt ne "\$0"B= $opt =~ /^\$\d+$/
ABresult
0X0
100
111
1094 0 $opt = '$<I<digits>>';
1095 }
1096 0 my $search_re = quotemeta($opt);
1097  
1098 0 DEBUG > 2 and
1099 print "Going to perlvar-scan for $search_re in $perlvar\n";
1100  
1101 # Skip introduction
1102 0 local $_;
1103 0 my $enc;
1104 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1105 0 ▶ $enc = $1 if /^=encoding\s+(\S+)/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=encoding\s+(\S+)/ 0 0 0
1106 0 ▶ last if /^=over 8/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=over 8/ 0 0 0
1107 }
1108  
1109 0 ▶ $fh = $self->set_encoding($fh, $enc) if $enc;
Branch: 1 branch
BranchTrueFalseTotal
if $enc 0 0 0
1110  
1111 # Look for our variable
1112 0 my $found = 0;
1113 0 my $inheader = 1;
1114 0 my $inlist = 0;
1115 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1116 0 ▶ last if /^=head2 Error Indicators/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=head2 Error Indicators/ 0 0 0
1117 # \b at the end of $` and friends borks things!
1118 0 ▶ if ( m/^=item\s+$search_re\s/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^=item\s+$search_re\s/) { } 0 0 0
elsif (/^=item/) { } 0 0 0
elsif (not /^\s+$/) { } 0 0 0
1119 0 $found = 1;
1120 }
1121 elsif (/^=item/) {
1122 0 ▶ last if $found && !$inheader && !$inlist;
Branch: 1 branch
BranchTrueFalseTotal
if $found and not $inheader and not $inlist 0 0 0
Condition0%0/6
$found and not $inheader and not $inlist
!ll&&!rl&&r
000
$found and not $inheader
!ll&&!rl&&r
000
MC/DC0%0/3
$found and not $inheader and not $inlist
$found not $inheader not $inlist
Truth table0%0/4
A and not(B) and not(C)
A= $foundB= not $inheaderC= not $inlist
ABCresult
0XX0
10X0
1100
1111
1123 }
1124 elsif (!/^\s+$/) { # not a blank line
1125 0 ▶ if ( $found ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found) { } 0 0 0
1126 0 $inheader = 0; # don't accept more =item (unless inlist)
1127 }
1128 else {
1129 0 @$pod = (); # reset
1130 0 $inheader = 1; # start over
1131 0 next;
1132 }
1133 }
1134  
1135 0 ▶ if (/^=over/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^=over/) { } 0 0 0
elsif (/^=back/) { } 0 0 0
1136 0 ++$inlist;
1137 }
1138 elsif (/^=back/) {
1139 0 ▶ last if $found && !$inheader && !$inlist;
Branch: 1 branch
BranchTrueFalseTotal
if $found and not $inheader and not $inlist 0 0 0
Condition0%0/6
$found and not $inheader and not $inlist
!ll&&!rl&&r
000
$found and not $inheader
!ll&&!rl&&r
000
MC/DC0%0/3
$found and not $inheader and not $inlist
$found not $inheader not $inlist
Truth table0%0/4
A and not(B) and not(C)
A= $foundB= not $inheaderC= not $inlist
ABCresult
0XX0
10X0
1100
1111
1140 0 --$inlist;
1141 }
1142 0 push @$pod, $_;
1143 # ++$found if /^\w/; # found descriptive text
1144 }
1145 0 ▶ @$pod = () unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1146 0 ▶ if (!@$pod) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pod) 0 0 0
1147 0 CORE::die( "No documentation for perl variable '$opt' found\n" );
1148 }
1149 0 ▶ close $fh or $self->die( "Can't close $perlvar: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't close ${perlvar}: $!") 0 0 0
1150  
1151 0 return;
1152 }
1153  
1154 #..........................................................................
1155  
1156 0 ▶sub search_perlop {
Subroutine search_perlop: not called CC=14 SCAR=53.5
Pod undocumented
1157 0 my ($self,$found_things,$pod) = @_;
1158  
1159 0 $self->not_dynamic( 1 );
1160  
1161 0 my $perlop = shift @$found_things;
1162 # XXX FIXME: getting filehandles should probably be done in a single place
1163 # especially since we need to support UTF8 or other encoding when dealing
1164 # with perlop, perlfunc, perlapi, perlfaq[1-9]
1165 0 my $fh = $self->open_fh('<', $perlop);
1166  
1167 0 my $thing = $self->opt_f;
1168  
1169 0 my $previous_line;
1170 0 my $push = 0;
1171 0 my $seen_item = 0;
1172 0 my $skip = 1;
1173  
1174 0 ▶ while( my $line = <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 0 0 0
1175 0 ▶ $line =~ /^=encoding\s+(\S+)/ && $self->set_encoding($fh, $1);
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^=encoding\s+(\S+)/ and $self->set_encoding($fh, $1) 0 0 0
1176 # only start search after we hit the operator section
1177 0 ▶ if ($line =~ m!^X<operator, regexp>!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^X<operator, regexp>/) 0 0 0
1178 0 $skip = 0;
1179 }
1180  
1181 0 ▶ next if $skip;
Branch: 1 branch
BranchTrueFalseTotal
if $skip 0 0 0
1182  
1183 # strategy is to capture the previous line until we get a match on X<$thingy>
1184 # if the current line contains X<$thingy>, then we push "=over", the previous line,
1185 # the current line and keep pushing current line until we see a ^X<some-other-thing>,
1186 # then we chop off final line from @$pod and add =back
1187 #
1188 # At that point, Bob's your uncle.
1189  
1190 0 ▶ if ( $line =~ m!X<+\s*\Q$thing\E\s*>+!) {
Branch: 4 branches
BranchTrueFalseTotal
if ($line =~ /X<+\s*\Q$thing\E\s*>+/) { } 0 0 0
elsif ($push and $line =~ /^=item\s*.*$/) { } 0 0 0
elsif ($push and $seen_item and $line =~ /^X<+\s*[ a-z,?-]+\s*>+/) { } 0 0 0
elsif ($push) { } 0 0 0
1191 0 ▶ if ( $previous_line ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous_line) 0 0 0
1192 0 push @$pod, "=over 8\n\n", $previous_line;
1193 0 $previous_line = "";
1194 }
1195 0 push @$pod, $line;
1196 0 $push = 1;
1197  
1198 }
1199 ▶ elsif ( $push and $line =~ m!^=item\s*.*$! ) {
Condition0%0/3
$push and $line =~ /^=item\s*.*$/
!ll&&!rl&&r
000
MC/DC0%0/2
$push and $line =~ /^=item\s*.*$/
$push $line =~ /^=item\s*.*$/
Truth table0%0/3
A and B
A= $pushB= $line =~ /^=item\s*.*$/
ABresult
0X0
100
111
1200 0 $seen_item = 1;
1201 }
1202 ▶ elsif ( $push and $seen_item and $line =~ m!^X<+\s*[ a-z,?-]+\s*>+!) {
Condition0%0/6
$push and $seen_item and $line =~ /^X<+\s*[ a-z,?-]+\s*>+/
!ll&&!rl&&r
000
$push and $seen_item
!ll&&!rl&&r
000
MC/DC0%0/3
$push and $seen_item and $line =~ /^X<+\s*[ a-z,?-]+\s*>+/
$push $seen_item $line =~ /^X<+\s*[ a-z,?-]+\s*>+/
Truth table0%0/4
A and B and C
A= $pushB= $seen_itemC= $line =~ /^X<+\s*[ a-z,?-]+\s*>+/
ABCresult
0XX0
10X0
1100
1111
1203 0 $push = 0;
1204 0 $seen_item = 0;
1205 0 last;
1206 }
1207 elsif ( $push ) {
1208 0 push @$pod, $line;
1209 }
1210  
1211 else {
1212 0 $previous_line = $line;
1213 }
1214  
1215 } #end while
1216  
1217 # we overfilled by 1 line, so pop off final array element if we have any
1218 0 ▶ if ( scalar @$pod ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$pod) { } 0 0 0
1219 0 pop @$pod;
1220  
1221 # and add the =back
1222 0 push @$pod, "\n\n=back\n";
1223 0 DEBUG > 8 and print "PERLOP POD --->" . (join "", @$pod) . "<---\n";
1224 }
1225 else {
1226 0 DEBUG > 4 and print "No pod from perlop\n";
1227 }
1228  
1229 0 close $fh;
1230  
1231 0 return;
1232 }
1233  
1234 #..........................................................................
1235  
1236 0 ▶sub search_perlapi {
Subroutine search_perlapi: not called CC=21 SCAR=61.4
Pod undocumented
1237 0 my($self, $found_things, $pod) = @_;
1238  
1239 0 DEBUG > 2 and print "Search: @$found_things\n";
1240  
1241 0 my $perlapi = shift @$found_things;
1242 0 my $fh = $self->open_fh('<', $perlapi);
1243  
1244 0 my $search_re = quotemeta($self->opt_a);
1245  
1246 0 DEBUG > 2 and
1247 print "Going to perlapi-scan for $search_re in $perlapi\n";
1248  
1249 0 local $_;
1250  
1251 # Look for our function
1252 0 my $found = 0;
1253 0 my $inlist = 0;
1254  
1255 0 my @related;
1256 my $related_re;
1257 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1258 0 ▶ /^=encoding\s+(\S+)/ && $self->set_encoding($fh, $1);
Branch: 1 branch
BranchTrueFalseTotal
/^=encoding\s+(\S+)/ and $self->set_encoding($fh, $1) 0 0 0
1259  
1260 0 ▶ if ( m/^=item\s+$search_re\b/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^=item\s+$search_re\b/) { } 0 0 0
elsif (@related > 1 and /^=item/) { } 0 0 0
elsif (/^=item/) { } 0 0 0
elsif ($found and /^X<[^>]+>/) { } 0 0 0
1261 0 $found = 1;
1262 }
1263 ▶ elsif (@related > 1 and /^=item/) {
Condition0%0/3
@related > 1 and /^=item/
!ll&&!rl&&r
000
MC/DC0%0/2
@related > 1 and /^=item/
@related > 1 /^=item/
Truth table0%0/3
A and B
A= @related > 1B= /^=item/
ABresult
0X0
100
111
1264 0 ▶ $related_re ||= join "|", @related;
Condition0%0/3
$related_re ||= join("|", @related)
l!l&&r!l&&!r
000
MC/DC0%0/2
$related_re ||= join("|", @related)
$related_re join("|", @related)
Truth table0%0/3
A ||= B
A= $related_reB= join("|", @related)
ABresult
1X1
011
000
1265 0 ▶ if (m/^=item\s+(?:$related_re)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^=item\s+(?:$related_re)\b/) { } 0 0 0
1266 0 $found = 1;
1267 }
1268 else {
1269 0 last;
1270 }
1271 }
1272 elsif (/^=item/) {
1273 0 ▶ last if $found > 1 and not $inlist;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 and not $inlist 0 0 0
Condition0%0/3
$found > 1 and not $inlist
!ll&&!rl&&r
000
MC/DC0%0/2
$found > 1 and not $inlist
$found > 1 not $inlist
Truth table0%0/3
A and not(B)
A= $found > 1B= not $inlist
ABresult
0X0
100
111
1274 }
1275 ▶ elsif ($found and /^X<[^>]+>/) {
Condition0%0/3
$found and /^X<[^>]+>/
!ll&&!rl&&r
000
MC/DC0%0/2
$found and /^X<[^>]+>/
$found /^X<[^>]+>/
Truth table0%0/3
A and B
A= $foundB= /^X<[^>]+>/
ABresult
0X0
100
111
1276 0 push @related, m/X<([^>]+)>/g;
1277 }
1278 0 ▶ next unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1279 0 ▶ if (/^=over/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^=over/) { } 0 0 0
elsif (/^=back/) { } 0 0 0
1280 0 ++$inlist;
1281 }
1282 elsif (/^=back/) {
1283 0 ▶ last if $found > 1 and not $inlist;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 and not $inlist 0 0 0
Condition0%0/3
$found > 1 and not $inlist
!ll&&!rl&&r
000
MC/DC0%0/2
$found > 1 and not $inlist
$found > 1 not $inlist
Truth table0%0/3
A and not(B)
A= $found > 1B= not $inlist
ABresult
0X0
100
111
1284 0 --$inlist;
1285 }
1286 0 push @$pod, $_;
1287 0 ▶ ++$found if /^\w/; # found descriptive text
Branch: 1 branch
BranchTrueFalseTotal
if /^\w/ 0 0 0
1288 }
1289  
1290 0 ▶ if (!@$pod) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pod) 0 0 0
1291 0 CORE::die( sprintf
1292 "No documentation for perl api function '%s' found\n",
1293 $self->opt_a )
1294 ;
1295 }
1296 0 ▶ close $fh or $self->die( "Can't open $perlapi: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't open ${perlapi}: $!") 0 0 0
1297  
1298 0 return;
1299 }
1300  
1301 #..........................................................................
1302  
1303 0 ▶sub search_perlfunc {
Subroutine search_perlfunc: not called CC=36 SCAR=71.9
Pod undocumented
1304 0 my($self, $found_things, $pod) = @_;
1305  
1306 0 DEBUG > 2 and print "Search: @$found_things\n";
1307  
1308 0 my $pfunc = shift @$found_things;
1309 0 my $fh = $self->open_fh("<", $pfunc); # "Funk is its own reward"
1310  
1311 # Functions like -r, -e, etc. are listed under `-X'.
1312 0 ▶ my $search_re = ($self->opt_f =~ /^-[rwxoRWXOeszfdlpSbctugkTBMAC]$/)
Branch: 1 branch
BranchTrueFalseTotal
$self->opt_f =~ /^-[rwxoRWXOeszfdlpSbctugkTBMAC]$/ ? : 0 0 0
1313 ? '(?:I<)?-X' : quotemeta($self->opt_f) ;
1314  
1315 0 DEBUG > 2 and
1316 print "Going to perlfunc-scan for $search_re in $pfunc\n";
1317  
1318 0 my $re = 'Alphabetical Listing of Perl Functions';
1319  
1320 # Check available translator or backup to default (english)
1321 0 ▶ if ( $self->opt_L && defined $self->{'translators'}->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_L and defined $self->{"translators"}[0]) 0 0 0
Condition0%0/3
$self->opt_L and defined $self->{"translators"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->opt_L and defined $self->{"translators"}[0]
$self->opt_L defined $self->{"translators"}[0]
Truth table0%0/3
A and B
A= $self->opt_LB= defined $self->{"translators"}[0]
ABresult
0X0
100
111
1322 0 my $tr = $self->{'translators'}->[0];
1323 0 ▶ $re = $tr->search_perlfunc_re if $tr->can('search_perlfunc_re');
Branch: 1 branch
BranchTrueFalseTotal
if $tr->can("search_perlfunc_re") 0 0 0
1324 0 ▶ if ( $] < 5.008 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.008") 0 0 0
1325 0 $self->aside("Your old perl doesn't really have proper unicode support.");
1326 }
1327 }
1328  
1329 # Skip introduction
1330 0 local $_;
1331 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1332 0 ▶ /^=encoding\s+(\S+)/ && $self->set_encoding($fh, $1);
Branch: 1 branch
BranchTrueFalseTotal
/^=encoding\s+(\S+)/ and $self->set_encoding($fh, $1) 0 0 0
1333 0 ▶ last if /^=head2 (?:$re|Alphabetical Listing of Perl Functions)/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=head2 (?:$re|Alphabetical Listing of Perl Functions)/ 0 0 0
1334 }
1335  
1336 # Look for our function
1337 0 my $found = 0;
1338 0 my $inlist = 0;
1339  
1340 0 my @perlops = qw(m q qq qr qx qw s tr y);
1341  
1342 0 my @related;
1343 my $related_re;
1344 0 ▶ while (<$fh>) { # "The Mothership Connection is here!"
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1345 0 ▶ last if( grep{ $self->opt_f eq $_ }@perlops );
Branch: 1 branch
BranchTrueFalseTotal
if grep {$self->opt_f eq $_;} @perlops 0 0 0
1346  
1347 0 ▶ if ( /^=over/ and not $found ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^=over/ and not $found) { } 0 0 0
elsif (/^=back/ and not $found and $inlist) { } 0 0 0
Condition0%0/3
/^=over/ and not $found
!ll&&!rl&&r
000
MC/DC0%0/2
/^=over/ and not $found
/^=over/ not $found
Truth table0%0/3
A and not(B)
A= /^=over/B= not $found
ABresult
0X0
100
111
1348 0 ++$inlist;
1349 }
1350 ▶ elsif ( /^=back/ and not $found and $inlist ) {
Condition0%0/6
/^=back/ and not $found and $inlist
!ll&&!rl&&r
000
/^=back/ and not $found
!ll&&!rl&&r
000
MC/DC0%0/3
/^=back/ and not $found and $inlist
/^=back/ not $found $inlist
Truth table0%0/4
A and not(B) and C
A= /^=back/B= not $foundC= $inlist
ABCresult
0XX0
10X0
1100
1111
1351 0 --$inlist;
1352 }
1353  
1354  
1355 0 ▶ if ( m/^=item\s+$search_re\b/ and $inlist < 2 ) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^=item\s+$search_re\b/ and $inlist < 2) { } 0 0 0
elsif (@related > 1 and /^=item/) { } 0 0 0
elsif (/^=item|^=back/) { } 0 0 0
elsif ($found and /^X<[^>]+>/) { } 0 0 0
Condition0%0/3
/^=item\s+$search_re\b/ and $inlist < 2
!ll&&!rl&&r
000
MC/DC0%0/2
/^=item\s+$search_re\b/ and $inlist < 2
/^=item\s+$search_re\b/ $inlist < 2
Truth table0%0/3
A and B
A= /^=item\s+$search_re\b/B= $inlist < 2
ABresult
0X0
100
111
1356 0 $found = 1;
1357 }
1358 ▶ elsif (@related > 1 and /^=item/) {
Condition0%0/3
@related > 1 and /^=item/
!ll&&!rl&&r
000
MC/DC0%0/2
@related > 1 and /^=item/
@related > 1 /^=item/
Truth table0%0/3
A and B
A= @related > 1B= /^=item/
ABresult
0X0
100
111
1359 0 ▶ $related_re ||= join "|", @related;
Condition0%0/3
$related_re ||= join("|", @related)
l!l&&r!l&&!r
000
MC/DC0%0/2
$related_re ||= join("|", @related)
$related_re join("|", @related)
Truth table0%0/3
A ||= B
A= $related_reB= join("|", @related)
ABresult
1X1
011
000
1360 0 ▶ if (m/^=item\s+(?:$related_re)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^=item\s+(?:$related_re)\b/) { } 0 0 0
1361 0 $found = 1;
1362 }
1363 else {
1364 0 ▶ last if $found > 1 and $inlist < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 and $inlist < 2 0 0 0
Condition0%0/3
$found > 1 and $inlist < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$found > 1 and $inlist < 2
$found > 1 $inlist < 2
Truth table0%0/3
A and B
A= $found > 1B= $inlist < 2
ABresult
0X0
100
111
1365 }
1366 }
1367 elsif (/^=item|^=back/) {
1368 0 ▶ last if $found > 1 and $inlist < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 and $inlist < 2 0 0 0
Condition0%0/3
$found > 1 and $inlist < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$found > 1 and $inlist < 2
$found > 1 $inlist < 2
Truth table0%0/3
A and B
A= $found > 1B= $inlist < 2
ABresult
0X0
100
111
1369 }
1370 ▶ elsif ($found and /^X<[^>]+>/) {
Condition0%0/3
$found and /^X<[^>]+>/
!ll&&!rl&&r
000
MC/DC0%0/2
$found and /^X<[^>]+>/
$found /^X<[^>]+>/
Truth table0%0/3
A and B
A= $foundB= /^X<[^>]+>/
ABresult
0X0
100
111
1371 0 push @related, m/X<([^>]+)>/g;
1372 }
1373 0 ▶ next unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1374 0 ▶ if (/^=over/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^=over/) { } 0 0 0
elsif (/^=back/) { } 0 0 0
1375 0 ++$inlist;
1376 }
1377 elsif (/^=back/) {
1378 0 --$inlist;
1379 }
1380 0 push @$pod, $_;
1381 0 ▶ ++$found if /^\w/; # found descriptive text
Branch: 1 branch
BranchTrueFalseTotal
if /^\w/ 0 0 0
1382 }
1383  
1384 0 ▶ if( !@$pod ){
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pod) 0 0 0
1385 0 $self->search_perlop( $found_things, $pod );
1386 }
1387  
1388 0 ▶ if (!@$pod) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pod) 0 0 0
1389 0 CORE::die( sprintf
1390 "No documentation for perl function '%s' found\n",
1391 $self->opt_f )
1392 ;
1393 }
1394 0 ▶ close $fh or $self->die( "Can't close $pfunc: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't close ${pfunc}: $!") 0 0 0
1395  
1396 0 return;
1397 }
1398  
1399 #..........................................................................
1400  
1401 0 ▶sub search_perlfaqs {
Subroutine search_perlfaqs: not called CC=12 SCAR=50.5
Pod undocumented
1402 0 my( $self, $found_things, $pod) = @_;
1403  
1404 0 my $found = 0;
1405 0 my %found_in;
1406 0 my $search_key = $self->opt_q;
1407  
1408 0 ▶ my $rx = eval { qr/$search_key/ }
Branch: 1 branch
BranchTrueFalseTotal
my $rx = eval { do { qr/$search_key/ } } or $self->die("Invalid regular expression '${search_key}' given as -q pattern:\n$@\nDid you mean \\Q$search_key ?\n\n") 0 0 0
1409 or $self->die( <<EOD );
1410 Invalid regular expression '$search_key' given as -q pattern:
1411 $@
1412 Did you mean \\Q$search_key ?
1413  
1414 EOD
1415  
1416 0 local $_;
1417 0 foreach my $file (@$found_things) {
1418 0 ▶ $self->die( "invalid file spec: $!" ) if $file =~ /[<>|]/;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /[<>|]/ 0 0 0
1419 0 my $fh = $self->open_fh("<", $file);
1420 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1421 0 ▶ /^=encoding\s+(\S+)/ && $self->set_encoding($fh, $1);
Branch: 1 branch
BranchTrueFalseTotal
/^=encoding\s+(\S+)/ and $self->set_encoding($fh, $1) 0 0 0
1422 0 ▶ if ( m/^=head2\s+.*(?:$search_key)/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^=head2\s+.*(?:$search_key)/i) { } 0 0 0
elsif (/^=head[12]/) { } 0 0 0
1423 0 $found = 1;
1424 0 ▶ push @$pod, "=head1 Found in $file\n\n" unless $found_in{$file}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $found_in{$file}++ 0 0 0
1425 }
1426 elsif (/^=head[12]/) {
1427 0 $found = 0;
1428 }
1429 0 ▶ next unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1430 0 push @$pod, $_;
1431 }
1432 0 close($fh);
1433 }
1434 0 ▶ CORE::die("No documentation for perl FAQ keyword '$search_key' found\n")
Branch: 1 branch
BranchTrueFalseTotal
unless @$pod 0 0 0
1435 unless @$pod;
1436  
1437 0 ▶ if ( $self->opt_l ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_l) 0 0 0
1438 0 CORE::die((join "\n", keys %found_in) . "\n");
1439 }
1440 0 return;
1441 }
1442  
1443  
1444 #..........................................................................
1445  
1446 1 ▶sub render_findings {
Subroutine render_findings: called CC=25 SCAR=44.2
Pod undocumented
1447 # Return the filename to open
1448  
1449 1 my($self, $found_things) = @_;
1450  
1451 1 ▶ my $formatter_class = $self->{'formatter_class'}
Condition33%1/3
$self->{'formatter_class'} || $self->die('No formatter class set!?')
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{'formatter_class'} || $self->die('No formatter class set!?')
$self->{'formatter_class'} $self->die('No formatter class set!?')
Truth table33%1/3
A || B
A= $self->{'formatter_class'}B= $self->die('No formatter class set!?')
ABresult
1X1
011
000
1452 || $self->die( "No formatter class set!?" );
1453 1 ▶ my $formatter = $formatter_class->can('new')
Branch: 1 branch
BranchTrueFalseTotal
$formatter_class->can('new') ? : 1 0 1
1454 ? $formatter_class->new
1455 : $formatter_class
1456 ;
1457  
1458 1 ▶ if(! @$found_things) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @$found_things) { } 0 1 1
elsif (@$found_things > 1) { } 0 1 1
1459 0 $self->die( "Nothing found?!" );
1460 # should have been caught before here
1461 } elsif(@$found_things > 1) {
1462 0 $self->warn(
1463 "Perldoc is only really meant for reading one document at a time.\n",
1464 "So these parameters are being ignored: ",
1465 join(' ', @$found_things[1 .. $#$found_things] ),
1466 "\n" );
1467 }
1468  
1469 1 my $file = $found_things->[0];
1470  
1471 DEBUG > 3 and printf "Formatter switches now: [%s]\n",
1472 1 join ' ', map "[@$_]", @{ $self->{'formatter_switches'} };
1473  
1474 # Set formatter options:
1475 1 ▶ if( ref $formatter ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $formatter) 1 0 1
1476 1 ▶ foreach my $f (@{ $self->{'formatter_switches'} || [] }) {
Condition50%1/2
$self->{'formatter_switches'} || []
l!l
10
MC/DC0%0/1
$self->{'formatter_switches'} || []
$self->{'formatter_switches'}
Truth table50%1/2
A
A= $self->{'formatter_switches'}
Aresult
11
00
1477 2 my($switch, $value, $silent_fail) = @$f;
1478 2 ▶ if( $formatter->can($switch) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($formatter->can($switch)) { } 0 2 2
1479 0 ▶ eval { $formatter->$switch( defined($value) ? $value : () ) };
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
1480 0 ▶ $self->warn( "Got an error when setting $formatter_class\->$switch:\n$@\n" )
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1481 if $@;
1482 } else {
1483 2 ▶ if( $silent_fail or $switch =~ m/^__/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($silent_fail or $switch =~ /^__/s) { } 2 0 2
Condition33%1/3
$silent_fail or $switch =~ /^__/s
l!l&&r!l&&!r
020
MC/DC0%0/2
$silent_fail or $switch =~ /^__/s
$silent_fail $switch =~ /^__/s
Truth table33%1/3
A or B
A= $silent_failB= $switch =~ /^__/s
ABresult
1X1
011
000
1484 2 DEBUG > 2 and print "Formatter $formatter_class doesn't support $switch\n";
1485 } else {
1486 0 $self->warn( "$formatter_class doesn't recognize the $switch switch.\n" );
1487 }
1488 }
1489 }
1490 }
1491  
1492 1 ▶ $self->{'output_is_binary'} =
Condition33%1/3
$formatter->can('write_with_binmode') && $formatter->write_with_binmode
!ll&&!rl&&r
010
MC/DC0%0/2
$formatter->can('write_with_binmode') && $formatter->write_with_binmode
$formatter->can('write_with_binmode') $formatter->write_with_binmode
Truth table33%1/3
A && B
A= $formatter->can('write_with_binmode')B= $formatter->write_with_binmode
ABresult
0X0
100
111
1493 $formatter->can('write_with_binmode') && $formatter->write_with_binmode;
1494  
1495 1 ▶ if( $self->{podnames} and exists $self->{podnames}{$file} and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"podnames"} and exists $self->{"podnames"}{$file} and $formatter->can("name")) 0 1 1
Condition33%2/6
$self->{"podnames"} and exists $self->{"podnames"}{$file} and $formatter->can("name")
!ll&&!rl&&r
100
$self->{"podnames"} and exists $self->{"podnames"}{$file}
!ll&&!rl&&r
100
MC/DC0%0/3
$self->{"podnames"} and exists $self->{"podnames"}{$file} and $formatter->can("name")
$self->{"podnames"} exists $self->{"podnames"}{$file} $formatter->can("name")
Truth table25%1/4
A and B and C
A= $self->{"podnames"}B= exists $self->{"podnames"}{$file}C= $formatter->can("name")
ABCresult
0XX0
10X0
1100
1111
1496 $formatter->can('name') ) {
1497 0 $formatter->name($self->{podnames}{$file});
1498 }
1499  
1500 1 ▶ my ($out_fh, $out) = $self->new_output_file(
Condition40%2/5
$formatter->can('output_extension') && $formatter->output_extension || undef
l!l
10
$formatter->can("output_extension") and $formatter->output_extension
!ll&&!rl&&r
001
MC/DC0%0/2
$formatter->can('output_extension') && $formatter->output_extension || undef
$formatter->can("output_extension") $formatter->output_extension
Truth table33%1/3
A and B
A= $formatter->can("output_extension")B= $formatter->output_extension
ABresult
111
0X0
100
1501 ( $formatter->can('output_extension') && $formatter->output_extension )
1502 || undef,
1503 $self->useful_filename_bit,
1504 );
1505  
1506 # Now, finally, do the formatting!
1507 {
1508 1 local $^W = $^W;
1509 1 ▶ if(DEBUG() or $self->opt_D) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_D) { } 0 1 1
1510 # feh, let 'em see it
1511 } else {
1512 1 $^W = 0;
1513 # The average user just has no reason to be seeing
1514 # $^W-suppressible warnings from the formatting!
1515 }
1516  
1517 1 eval { $formatter->parse_from_file( $file, $out_fh ) };
1518 }
1519  
1520 1 ▶ $self->warn( "Error while formatting with $formatter_class:\n $@\n" ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
1521 1 DEBUG > 2 and print "Back from formatting with $formatter_class\n";
1522  
1523 1 ▶ close $out_fh
Branch: 1 branch
BranchTrueFalseTotal
close $out_fh or $self->warn("Can't close ${out}: $!\n(Did $formatter already close it?)") 1 0 1
1524 or $self->warn( "Can't close $out: $!\n(Did $formatter already close it?)" );
1525 1 sleep 0; sleep 0; sleep 0;
1526 # Give the system a few timeslices to meditate on the fact
1527 # that the output file does in fact exist and is closed.
1528  
1529 1 $self->unlink_if_temp_file($file);
1530  
1531 1 ▶ unless( -s $out ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-s $out) 0 1 1
1532 0 ▶ if( $formatter->can( 'if_zero_length' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($formatter->can('if_zero_length')) { } 0 0 0
1533 # Basically this is just a hook for Pod::Simple::Checker; since
1534 # what other class could /happily/ format an input file with Pod
1535 # as a 0-length output file?
1536 0 $formatter->if_zero_length( $file, $out, $out_fh );
1537 } else {
1538 0 $self->warn( "Got a 0-length file from $$found_things[0] via $formatter_class!?\n" );
1539 }
1540 }
1541  
1542 1 DEBUG and print "Finished writing to $out.\n";
1543 1 ▶ return($out, $formatter) if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
1544 0 return $out;
1545 }
1546  
1547 #..........................................................................
1548  
1549 2 ▶sub unlink_if_temp_file {
Subroutine unlink_if_temp_file: called CC=6 SCAR=22.9
Pod undocumented
1550 # Unlink the specified file IFF it's in the list of temp files.
1551 # Really only used in the case of -f / -q things when we can
1552 # throw away the dynamically generated source pod file once
1553 # we've formatted it.
1554 #
1555 2 my($self, $file) = @_;
1556 2 ▶ return unless defined $file and length $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file and length $file 0 2 2
Condition33%1/3
defined $file and length $file
!ll&&!rl&&r
002
MC/DC0%0/2
defined $file and length $file
defined $file length $file
Truth table33%1/3
A and B
A= defined $fileB= length $file
ABresult
0X0
100
111
1557  
1558 2 ▶ my $temp_file_list = $self->{'temp_file_list'} || return;
Condition50%1/2
$self->{'temp_file_list'} || (return)
l!l
20
MC/DC0%0/1
$self->{'temp_file_list'} || (return)
$self->{'temp_file_list'}
Truth table50%1/2
A
A= $self->{'temp_file_list'}
Aresult
11
00
1559 2 ▶ if(grep $_ eq $file, @$temp_file_list) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(($_ eq $file), @$temp_file_list)) { } 0 2 2
1560 0 $self->aside("Unlinking $file\n");
1561 0 ▶ unlink($file) or $self->warn( "Odd, couldn't unlink $file: $!" );
Branch: 1 branch
BranchTrueFalseTotal
unlink $file or $self->warn("Odd, couldn't unlink ${file}: $!") 0 0 0
1562 } else {
1563 2 DEBUG > 1 and print "$file isn't a temp file, so not unlinking.\n";
1564 }
1565 2 return;
1566 }
1567  
1568 #..........................................................................
1569  
1570  
1571 1 ▶sub after_rendering {
Subroutine after_rendering: called CC=5 SCAR=17.2
Pod undocumented
1572 1 my $self = $_[0];
1573 1 ▶ $self->after_rendering_VMS if $self->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_vms 0 1 1
1574 1 ▶ $self->after_rendering_MSWin32 if $self->is_mswin32;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_mswin32 0 1 1
1575 1 ▶ $self->after_rendering_Dos if $self->is_dos;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_dos 0 1 1
1576 1 ▶ $self->after_rendering_OS2 if $self->is_os2;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_os2 0 1 1
1577 1 return;
1578 }
1579  
1580 0 ▶sub after_rendering_VMS { return }
Subroutine after_rendering_VMS: not called CC=1 SCAR=6.9
Pod undocumented
1581 0 ▶sub after_rendering_Dos { return }
Subroutine after_rendering_Dos: not called CC=1 SCAR=6.9
Pod undocumented
1582 0 ▶sub after_rendering_OS2 { return }
Subroutine after_rendering_OS2: not called CC=1 SCAR=6.9
Pod undocumented
1583 0 ▶sub after_rendering_MSWin32 { return }
Subroutine after_rendering_MSWin32: not called CC=1 SCAR=6.9
Pod undocumented
1584  
1585 #..........................................................................
1586 # : : : : : : : : :
1587 #..........................................................................
1588  
1589 68 ▶sub minus_f_nocase { # i.e., do like -f, but without regard to case
Subroutine minus_f_nocase: called CC=28 SCAR=62.6
Pod undocumented
1590  
1591 68 my($self, $dir, $file) = @_;
1592 68 my $path = catfile($dir,$file);
1593 68 ▶ return $path if -f $path and -r _;
Branch: 1 branch
BranchTrueFalseTotal
if -f $path and -r _ 0 68 68
Condition33%1/3
-f $path and -r _
!ll&&!rl&&r
6800
MC/DC0%0/2
-f $path and -r _
-f $path -r _
Truth table33%1/3
A and B
A= -f $pathB= -r _
ABresult
0X0
100
111
1594  
1595 68 ▶ if(!$self->opt_i
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->opt_i or $self->is_vms or $self->is_mswin32 or $self->is_dos or $self->is_os2) 68 0 68
Condition33%4/12
not $self->opt_i or $self->is_vms or $self->is_mswin32 or $self->is_dos or $self->is_os2
l!l&&r!l&&!r
6800
not $self->opt_i or $self->is_vms or $self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
6800
not $self->opt_i or $self->is_vms or $self->is_mswin32
l!l&&r!l&&!r
6800
not $self->opt_i or $self->is_vms
l!l&&r!l&&!r
6800
MC/DC0%0/5
not $self->opt_i or $self->is_vms or $self->is_mswin32 or $self->is_dos or $self->is_os2
not $self->opt_i $self->is_vms $self->is_mswin32 $self->is_dos $self->is_os2
Truth table16%1/6
not(A) or B or C or D or E
A= not $self->opt_iB= $self->is_vmsC= $self->is_mswin32D= $self->is_dosE= $self->is_os2
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
1596 or $self->is_vms or $self->is_mswin32
1597 or $self->is_dos or $self->is_os2
1598 ) {
1599 # On a case-forgiving file system, or if case is important,
1600 # that is it, all we can do.
1601 68 ▶ $self->warn( "Ignored $path: unreadable\n" ) if -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -f _ 0 68 68
1602 68 return '';
1603 }
1604  
1605 0 local *DIR;
1606 0 my @p = ($dir);
1607 0 my($p,$cip);
1608 0 foreach $p (splitdir $file){
1609 0 my $try = catfile @p, $p;
1610 0 $self->aside("Scrutinizing $try...\n");
1611 0 stat $try;
1612 0 ▶ if (-d _) {
Branch: 4 branches
BranchTrueFalseTotal
if (-d _) { } 0 0 0
elsif (-f _ and -r _ and lc $try eq lc $path) { } 0 0 0
elsif (-f _) { } 0 0 0
elsif (-d catdir(@p)) { } 0 0 0
1613 0 push @p, $p;
1614 0 ▶ if ( $p eq $self->{'target'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq $self->{"target"}) 0 0 0
1615 0 my $tmp_path = catfile @p;
1616 0 my $path_f = 0;
1617 0 for (@{ $self->{'found'} }) {
1618 0 ▶ $path_f = 1 if $_ eq $tmp_path;
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $tmp_path 0 0 0
1619 }
1620 0 ▶ push (@{ $self->{'found'} }, $tmp_path) unless $path_f;
Branch: 1 branch
BranchTrueFalseTotal
unless $path_f 0 0 0
1621 0 $self->aside( "Found as $tmp_path but directory\n" );
1622 }
1623 }
1624 ▶ elsif (-f _ && -r _ && lc($try) eq lc($path)) {
Condition0%0/6
-f _ and -r _ and lc $try eq lc $path
!ll&&!rl&&r
000
-f _ and -r _
!ll&&!rl&&r
000
MC/DC0%0/3
-f _ and -r _ and lc $try eq lc $path
-f _ -r _ lc $try eq lc $path
Truth table0%0/4
A and B and C
A= -f _B= -r _C= lc $try eq lc $path
ABCresult
0XX0
10X0
1100
1111
1625 0 return $try;
1626 }
1627 elsif (-f _) {
1628 0 $self->warn( "Ignored $try: unreadable or file/dir mismatch\n" );
1629 }
1630 elsif (-d catdir(@p)) { # at least we see the containing directory!
1631 0 my $found = 0;
1632 0 my $lcp = lc $p;
1633 0 my $p_dirspec = catdir(@p);
1634 0 ▶ opendir DIR, $p_dirspec or $self->die( "opendir $p_dirspec: $!" );
Branch: 1 branch
BranchTrueFalseTotal
opendir DIR, $p_dirspec or $self->die("opendir ${p_dirspec}: $!") 0 0 0
1635 0 ▶ while(defined( $cip = readdir(DIR) )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($cip = readdir DIR)) 0 0 0
1636 0 ▶ if (lc $cip eq $lcp){
Branch: 1 branch
BranchTrueFalseTotal
if (lc $cip eq $lcp) 0 0 0
1637 0 $found++;
1638 0 last; # XXX stop at the first? what if there's others?
1639 }
1640 }
1641 0 ▶ closedir DIR or $self->die( "closedir $p_dirspec: $!" );
Branch: 1 branch
BranchTrueFalseTotal
closedir DIR or $self->die("closedir ${p_dirspec}: $!") 0 0 0
1642 0 ▶ return "" unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1643  
1644 0 push @p, $cip;
1645 0 my $p_filespec = catfile(@p);
1646 0 ▶ return $p_filespec if -f $p_filespec and -r _;
Branch: 1 branch
BranchTrueFalseTotal
if -f $p_filespec and -r _ 0 0 0
Condition0%0/3
-f $p_filespec and -r _
!ll&&!rl&&r
000
MC/DC0%0/2
-f $p_filespec and -r _
-f $p_filespec -r _
Truth table0%0/3
A and B
A= -f $p_filespecB= -r _
ABresult
0X0
100
111
1647 0 ▶ $self->warn( "Ignored $p_filespec: unreadable\n" ) if -f _;
Branch: 1 branch
BranchTrueFalseTotal
if -f _ 0 0 0
1648 }
1649 }
1650 0 return "";
1651 }
1652  
1653 #..........................................................................
1654  
1655 2 ▶sub pagers_guessing {
Subroutine pagers_guessing: called CC=18 SCAR=45.0
Pod undocumented
1656 # TODO: This whole subroutine needs to be rewritten. It's semi-insane
1657 # right now.
1658  
1659 2 my $self = shift;
1660  
1661 2 my @pagers;
1662 2 push @pagers, $self->pagers;
1663 2 $self->{'pagers'} = \@pagers;
1664  
1665 2 ▶ if ($self->is_mswin32) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->is_mswin32) { } 0 2 2
elsif ($self->is_vms) { } 0 2 2
elsif ($self->is_dos) { } 0 2 2
elsif ($self->is_amigaos) { } 0 2 2
1666 0 push @pagers, qw( more< less notepad );
1667 0 ▶ unshift @pagers, $ENV{PAGER} if $ENV{PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGER"} 0 0 0
1668 }
1669 elsif ($self->is_vms) {
1670 0 push @pagers, qw( most more less type/page );
1671 }
1672 elsif ($self->is_dos) {
1673 0 push @pagers, qw( less.exe more.com< );
1674 0 ▶ unshift @pagers, $ENV{PAGER} if $ENV{PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGER"} 0 0 0
1675 }
1676 elsif ( $self->is_amigaos) {
1677 0 push @pagers, qw( /SYS/Utilities/MultiView /SYS/Utilities/More /C/TYPE );
1678 0 ▶ unshift @pagers, "$ENV{PAGER}" if $ENV{PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGER"} 0 0 0
1679 }
1680 else {
1681 2 ▶ if ($self->is_os2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_os2) 0 2 2
1682 0 unshift @pagers, 'less', 'cmd /c more <';
1683 }
1684 2 push @pagers, qw( more less pg view cat );
1685 2 ▶ unshift @pagers, "$ENV{PAGER} <" if $ENV{PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGER"} 0 2 2
1686 }
1687  
1688 2 ▶ if ($self->is_cygwin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_cygwin) 0 2 2
1689 0 ▶ if (($pagers[0] eq 'less') || ($pagers[0] eq '/usr/bin/less')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pagers[0] eq "less" or $pagers[0] eq "/usr/bin/less") 0 0 0
Condition0%0/3
$pagers[0] eq "less" or $pagers[0] eq "/usr/bin/less"
l!l&&r!l&&!r
000
MC/DC0%0/2
$pagers[0] eq "less" or $pagers[0] eq "/usr/bin/less"
$pagers[0] eq "less" $pagers[0] eq "/usr/bin/less"
Truth table0%0/3
A or B
A= $pagers[0] eq "less"B= $pagers[0] eq "/usr/bin/less"
ABresult
1X1
011
000
1690 0 unshift @pagers, '/usr/bin/less -isrR';
1691 0 ▶ unshift @pagers, $ENV{PAGER} if $ENV{PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGER"} 0 0 0
1692 }
1693 }
1694  
1695 2 ▶ if ( $self->opt_m ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt_m) { } 0 2 2
1696 unshift @pagers, "$ENV{PERLDOC_SRC_PAGER}" if $ENV{PERLDOC_SRC_PAGER}
1697 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERLDOC_SRC_PAGER"} 0 0 0
1698 else {
1699 2 ▶ unshift @pagers, "$ENV{MANPAGER} <" if $ENV{MANPAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"MANPAGER"} 0 2 2
1700 2 ▶ unshift @pagers, "$ENV{PERLDOC_PAGER} <" if $ENV{PERLDOC_PAGER};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERLDOC_PAGER"} 0 2 2
1701 }
1702  
1703 2 $self->aside("Pagers: ", (join ", ", @pagers));
1704  
1705 2 return;
1706 }
1707  
1708 #..........................................................................
1709  
1710 0 ▶sub page_module_file {
Subroutine page_module_file: not called CC=2 SCAR=17.9
Pod undocumented
1711 0 my($self, @found) = @_;
1712  
1713 # Security note:
1714 # Don't ever just pass this off to anything like MSWin's "start.exe",
1715 # since we might be calling on a .pl file, and we wouldn't want that
1716 # to actually /execute/ the file that we just want to page thru!
1717 # Also a consideration if one were to use a web browser as a pager;
1718 # doing so could trigger the browser's MIME mapping for whatever
1719 # it thinks .pm/.pl/whatever is. Probably just a (useless and
1720 # annoying) "Save as..." dialog, but potentially executing the file
1721 # in question -- particularly in the case of MSIE and it's, ahem,
1722 # occasionally hazy distinction between OS-local extension
1723 # associations, and browser-specific MIME mappings.
1724  
1725 0 ▶ if(@found > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@found > 1) 0 0 0
1726 0 $self->warn(
1727 "Perldoc is only really meant for reading one document at a time.\n" .
1728 "So these files are being ignored: " .
1729 join(' ', @found[1 .. $#found] ) .
1730 "\n" )
1731 }
1732  
1733 0 return $self->page($found[0], $self->{'output_to_stdout'}, $self->pagers);
1734  
1735 }
1736  
1737 #..........................................................................
1738  
1739 154 ▶sub check_file {
Subroutine check_file: called CC=7 SCAR=23.8
Pod undocumented
1740 154 my($self, $dir, $file) = @_;
1741  
1742 154 ▶ unless( ref $self ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 154 154
1743 # Should never get called:
1744 0 $Carp::Verbose = 1;
1745 0 require Carp;
1746 0 Carp::croak( join '',
1747 "Crazy ", __PACKAGE__, " error:\n",
1748 "check_file must be an object_method!\n",
1749 "Aborting"
1750 );
1751 }
1752  
1753 154 ▶ if(length $dir and not -d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $dir and not -d $dir) 86 68 154
Condition66%2/3
length $dir and not -d $dir
!ll&&!rl&&r
06886
MC/DC50%1/2
length $dir and not -d $dir
length $dir not -d $dir
Truth table66%2/3
A and not(B)
A= length $dirB= not -d $dir
ABresult
0X0
100
111
1754 86 DEBUG > 3 and print " No dir $dir -- skipping.\n";
1755 86 return "";
1756 }
1757  
1758 68 my $path = $self->minus_f_nocase($dir,$file);
1759 68 ▶ if( length $path and ($self->opt_m ? $self->isprintable($path)
Branch: 2 branches
BranchTrueFalseTotal
if (length $path and $self->opt_m ? $self->isprintable($path) : $self->containspod($path)) 0 68 68
$self->opt_m ? : 0 0 0
Condition33%1/3
length $path and $self->opt_m ? $self->isprintable($path) : $self->containspod($path)
!ll&&!rl&&r
6800
MC/DC0%0/2
length $path and $self->opt_m ? $self->isprintable($path) : $self->containspod($path)
length $path $self->opt_m ? $self->isprintable($path) : $self->containspod($path)
Truth table33%1/3
A and B
A= length $pathB= $self->opt_m ? $self->isprintable($path) : $self->containspod($path)
ABresult
0X0
100
111
1760 : $self->containspod($path)) ) {
1761 0 DEBUG > 3 and print
1762 " The file $path indeed looks promising!\n";
1763 0 return $path;
1764 }
1765 68 DEBUG > 3 and print " No good: $file in $dir\n";
1766  
1767 68 return "";
1768 }
1769  
1770 0 ▶sub isprintable {
Subroutine isprintable: not called CC=3 SCAR=24.8
Pod undocumented
1771 0 my($self, $file, $readit) = @_;
1772 0 my $size= 1024;
1773 0 my $maxunprintfrac= 0.2; # tolerate some unprintables for UTF-8 comments etc.
1774  
1775 0 ▶ return 1 if !$readit && $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if not $readit and $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i 0 0 0
Condition0%0/3
not $readit and $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i
!ll&&!rl&&r
000
MC/DC0%0/2
not $readit and $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i
not $readit $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i
Truth table0%0/3
not(A) and B
A= not $readitB= $file =~ /\.(?:pl|pm|pod|cmd|com|bat)\z/i
ABresult
0X0
100
111
1776  
1777 0 my $data;
1778 0 local($_);
1779 0 my $fh = $self->open_fh("<", $file);
1780 0 read $fh, $data, $size;
1781 0 close $fh;
1782 0 $size= length($data);
1783 0 $data =~ tr/\x09-\x0D\x20-\x7E//d;
1784 0 return length($data) <= $size*$maxunprintfrac;
1785 }
1786  
1787 #..........................................................................
1788  
1789 1 ▶sub containspod {
Subroutine containspod: called CC=11 SCAR=32.6
Pod undocumented
1790 1 my($self, $file, $readit) = @_;
1791 1 ▶ return 1 if !$readit && $file =~ /\.pod\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if not $readit and $file =~ /\.pod\z/i 0 1 1
Condition33%1/3
not $readit and $file =~ /\.pod\z/i
!ll&&!rl&&r
010
MC/DC0%0/2
not $readit and $file =~ /\.pod\z/i
not $readit $file =~ /\.pod\z/i
Truth table33%1/3
not(A) and B
A= not $readitB= $file =~ /\.pod\z/i
ABresult
0X0
100
111
1792  
1793  
1794 # Under cygwin the /usr/bin/perl is legal executable, but
1795 # you cannot open a file with that name. It must be spelled
1796 # out as "/usr/bin/perl.exe".
1797 #
1798 # The following if-case under cygwin prevents error
1799 #
1800 # $ perldoc perl
1801 # Cannot open /usr/bin/perl: no such file or directory
1802 #
1803 # This would work though
1804 #
1805 # $ perldoc perl.pod
1806  
1807 1 ▶ if ( $self->is_cygwin and -x $file and -f "$file.exe" )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_cygwin and -x $file and -f "$file.exe") 0 1 1
Condition33%2/6
$self->is_cygwin and -x $file and -f "$file.exe"
!ll&&!rl&&r
100
$self->is_cygwin and -x $file
!ll&&!rl&&r
100
MC/DC0%0/3
$self->is_cygwin and -x $file and -f "$file.exe"
$self->is_cygwin -x $file -f "$file.exe"
Truth table25%1/4
A and B and C
A= $self->is_cygwinB= -x $fileC= -f "$file.exe"
ABCresult
0XX0
10X0
1100
1111
1808 {
1809 0 ▶ $self->warn( "Cygwin $file.exe search skipped\n" ) if DEBUG or $self->opt_D;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt_D 0 0 0
1810 0 return 0;
1811 }
1812  
1813 1 local($_);
1814 1 my $fh = $self->open_fh("<", $file);
1815 1 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 2112 0 2112
1816 2112 ▶ if (/^=head/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^=head/) 1 2111 2112
1817 1 ▶ close($fh) or $self->die( "Can't close $file: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't close ${file}: $!") 1 0 1
1818 1 return 1;
1819 }
1820 }
1821 0 ▶ close($fh) or $self->die( "Can't close $file: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't close ${file}: $!") 0 0 0
1822 0 return 0;
1823 }
1824  
1825 #..........................................................................
1826  
1827 2 ▶sub maybe_extend_searchpath {
Subroutine maybe_extend_searchpath: called CC=8 SCAR=25.1
Pod undocumented
1828 2 my $self = shift;
1829  
1830 # Does this look like a module or extension directory?
1831  
1832 2 ▶ if (-f "Makefile.PL" || -f "Build.PL") {
Branch: 1 branch
BranchTrueFalseTotal
if (-f "Makefile.PL" or -f "Build.PL") 2 0 2
Condition33%1/3
-f "Makefile.PL" or -f "Build.PL"
l!l&&r!l&&!r
200
MC/DC0%0/2
-f "Makefile.PL" or -f "Build.PL"
-f "Makefile.PL" -f "Build.PL"
Truth table33%1/3
A or B
A= -f "Makefile.PL"B= -f "Build.PL"
ABresult
1X1
011
000
1833  
1834 2 push @{$self->{search_path} }, '.','lib';
1835  
1836 # don't add if superuser
1837 2 ▶ if ($< && $> && -d "blib") { # don't be looking too hard now!
Branch: 1 branch
BranchTrueFalseTotal
if ($< and $> and -d "blib") 2 0 2
Condition33%2/6
$< and $> and -d "blib"
!ll&&!rl&&r
002
$< and $>
!ll&&!rl&&r
002
MC/DC0%0/3
$< and $> and -d "blib"
$< $> -d "blib"
Truth table25%1/4
A and B and C
A= $<B= $>C= -d "blib"
ABCresult
0XX0
10X0
1100
1111
1838 2 push @{ $self->{search_path} }, 'blib';
1839 2 ▶ $self->warn( $@ ) if $@ && $self->opt_D;
Branch: 1 branch
BranchTrueFalseTotal
if $@ and $self->opt_D 0 2 2
Condition33%1/3
$@ and $self->opt_D
!ll&&!rl&&r
200
MC/DC0%0/2
$@ and $self->opt_D
$@ $self->opt_D
Truth table33%1/3
A and B
A= $@B= $self->opt_D
ABresult
0X0
100
111
1840 }
1841 }
1842  
1843 2 return;
1844 }
1845  
1846 #..........................................................................
1847  
1848 1 ▶sub new_output_file {
Subroutine new_output_file: called CC=4 SCAR=21.7
Pod undocumented
1849 1 my $self = shift;
1850 1 my $outspec = $self->opt_d; # Yes, -d overrides all else!
1851 # So don't call this twice per format-job!
1852  
1853 1 ▶ return $self->new_tempfile(@_) unless defined $outspec and length $outspec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $outspec and length $outspec 1 0 1
Condition33%1/3
defined $outspec and length $outspec
!ll&&!rl&&r
100
MC/DC0%0/2
defined $outspec and length $outspec
defined $outspec length $outspec
Truth table33%1/3
A and B
A= defined $outspecB= length $outspec
ABresult
0X0
100
111
1854  
1855 # Otherwise open a write-handle on opt_d!f
1856  
1857 0 DEBUG > 3 and print "About to try writing to specified output file $outspec\n";
1858 0 my $fh = $self->open_fh(">", $outspec);
1859  
1860 0 DEBUG > 3 and print "Successfully opened $outspec\n";
1861 0 ▶ binmode($fh) if $self->{'output_is_binary'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"output_is_binary"} 0 0 0
1862 0 return($fh, $outspec);
1863 }
1864  
1865 #..........................................................................
1866  
1867 1 ▶sub useful_filename_bit {
Subroutine useful_filename_bit: called CC=6 SCAR=18.9
Pod undocumented
1868 # This tries to provide a meaningful bit of text to do with the query,
1869 # such as can be used in naming the file -- since if we're going to be
1870 # opening windows on temp files (as a "pager" may well do!) then it's
1871 # better if the temp file's name (which may well be used as the window
1872 # title) isn't ALL just random garbage!
1873 # In other words "perldoc_LWPSimple_2371981429" is a better temp file
1874 # name than "perldoc_2371981429". So this routine is what tries to
1875 # provide the "LWPSimple" bit.
1876 #
1877 1 my $self = shift;
1878 1 ▶ my $pages = $self->{'pages'} || return undef;
Condition50%1/2
$self->{'pages'} || (return undef)
l!l
10
MC/DC0%0/1
$self->{'pages'} || (return undef)
$self->{'pages'}
Truth table50%1/2
A
A= $self->{'pages'}
Aresult
11
00
1879 1 ▶ return undef unless @$pages;
Branch: 1 branch
BranchTrueFalseTotal
unless @$pages 0 1 1
1880  
1881 1 my $chunk = $pages->[0];
1882 1 ▶ return undef unless defined $chunk;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chunk 0 1 1
1883 1 $chunk =~ s/:://g;
1884 1 $chunk =~ s/\.\w+$//g; # strip any extension
1885 1 ▶ if( $chunk =~ m/([^\#\\:\/\$]+)$/s ) { # get basename, if it's a file
Branch: 1 branch
BranchTrueFalseTotal
if ($chunk =~ m[([^\#\\:/\$]+)$]s) { } 1 0 1
1886 1 $chunk = $1;
1887 } else {
1888 0 return undef;
1889 }
1890 1 $chunk =~ s/[^a-zA-Z0-9]+//g; # leave ONLY a-zA-Z0-9 things!
1891 1 ▶ $chunk = substr($chunk, -10) if length($chunk) > 10;
Branch: 1 branch
BranchTrueFalseTotal
if length $chunk > 10 0 1 1
1892 1 return $chunk;
1893 }
1894  
1895 #..........................................................................
1896  
1897 1 ▶sub new_tempfile { # $self->new_tempfile( [$suffix, [$infix] ] )
Subroutine new_tempfile: called CC=1 SCAR=0.0
Pod undocumented
1898 1 my $self = shift;
1899  
1900 1 ++$Temp_Files_Created;
1901  
1902 1 require File::Temp;
1903 1 return File::Temp::tempfile(UNLINK => 1);
1904 }
1905  
1906 #..........................................................................
1907  
1908 1 ▶sub page { # apply a pager to the output file
Subroutine page: called CC=16 SCAR=46.8
Pod undocumented
1909 1 my ($self, $output, $output_to_stdout, @pagers) = @_;
1910 1 ▶ if ($output_to_stdout) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output_to_stdout) { } 1 0 1
1911 1 $self->aside("Sending unpaged output to STDOUT.\n");
1912 1 my $fh = $self->open_fh("<", $output);
1913 1 local $_;
1914 1 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 30 1 31
1915 30 ▶ print or $self->die( "Can't print to stdout: $!" );
Branch: 1 branch
BranchTrueFalseTotal
print $_ or $self->die("Can't print to stdout: $!") 30 0 30
1916 }
1917 1 ▶ close $fh or $self->die( "Can't close while $output: $!" );
Branch: 1 branch
BranchTrueFalseTotal
close $fh or $self->die("Can't close while ${output}: $!") 1 0 1
1918 1 $self->unlink_if_temp_file($output);
1919 } else {
1920 # On VMS, quoting prevents logical expansion, and temp files with no
1921 # extension get the wrong default extension (such as .LIS for TYPE)
1922  
1923 0 ▶ $output = VMS::Filespec::rmsexpand($output, '.') if $self->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_vms 0 0 0
1924  
1925 0 ▶ $output =~ s{/}{\\}g if $self->is_mswin32 || $self->is_dos;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_mswin32 or $self->is_dos 0 0 0
Condition0%0/3
$self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->is_mswin32 or $self->is_dos
$self->is_mswin32 $self->is_dos
Truth table0%0/3
A or B
A= $self->is_mswin32B= $self->is_dos
ABresult
1X1
011
000
1926 # Altho "/" under MSWin is in theory good as a pathsep,
1927 # many many corners of the OS don't like it. So we
1928 # have to force it to be "\" to make everyone happy.
1929  
1930 # if we are on an amiga convert unix path to an amiga one
1931 0 ▶ $output =~ s/^\/(.*)\/(.*)/$1:$2/ if $self->is_amigaos;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_amigaos 0 0 0
1932  
1933 0 foreach my $pager (@pagers) {
1934 0 $self->aside("About to try calling $pager $output\n");
1935 0 ▶ if ($self->is_vms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->is_vms) { } 0 0 0
elsif ($self->is_amigaos) { } 0 0 0
1936 0 ▶ last if system("$pager $output") == 0;
Branch: 1 branch
BranchTrueFalseTotal
if system("$pager $output") == 0 0 0 0
1937 } elsif($self->is_amigaos) {
1938 0 ▶ last if system($pager, $output) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if system($pager, $output) == 0 0 0 0
1939 } else {
1940 0 my $formatter = $self->{'formatter_class'};
1941 0 ▶ if ( $formatter->can('pager_configuration') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($formatter->can("pager_configuration")) 0 0 0
1942 0 $self->aside("About to call $formatter" . "->pager_configuration(\"$pager\")\n");
1943 0 $formatter->pager_configuration($pager, $self);
1944 }
1945 0 ▶ last if system("$pager \"$output\"") == 0;
Branch: 1 branch
BranchTrueFalseTotal
if system(qq[$pager "$output"]) == 0 0 0 0
1946 }
1947 }
1948 }
1949 1 return;
1950 }
1951  
1952 #..........................................................................
1953  
1954 2 ▶sub searchfor {
Subroutine searchfor: called CC=30 SCAR=53.9
Pod undocumented
1955 2 my($self, $recurse,$s,@dirs) = @_;
1956 2 $s =~ s!::!/!g;
1957 2 ▶ $s = VMS::Filespec::unixify($s) if $self->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_vms 0 2 2
1958 2 ▶ return $s if -f $s && $self->containspod($s);
Branch: 1 branch
BranchTrueFalseTotal
if -f $s and $self->containspod($s) 1 1 2
Condition66%2/3
-f $s and $self->containspod($s)
!ll&&!rl&&r
101
MC/DC50%1/2
-f $s and $self->containspod($s)
-f $s $self->containspod($s)
Truth table66%2/3
A and B
A= -f $sB= $self->containspod($s)
ABresult
0X0
100
111
1959 1 $self->aside( "Looking for $s in @dirs\n" );
1960 1 my $ret;
1961 my $i;
1962 1 my $dir;
1963 1 $self->{'target'} = (splitdir $s)[-1]; # XXX: why not use File::Basename?
1964 1 ▶ for ($i=0; $i<@dirs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @dirs) 22 1 23
1965 22 $dir = $dirs[$i];
1966 22 ▶ next unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 22 22
1967 22 ▶ ($dir = VMS::Filespec::unixpath($dir)) =~ s!/\z!! if $self->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_vms 0 22 22
1968 22 ▶ if ( (! $self->opt_m && ( $ret = $self->check_file($dir,"$s.pod")))
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod") or $ret = $self->check_file("$dir/pod", $s) or $ret = $self->check_file("$dir/pods", "$s.pod") or $ret = $self->check_file("$dir/pods", $s)) 0 22 22
Condition33%15/45
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod") or $ret = $self->check_file("$dir/pod", $s) or $ret = $self->check_file("$dir/pods", "$s.pod") or $ret = $self->check_file("$dir/pods", $s)
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod") or $ret = $self->check_file("$dir/pod", $s) or $ret = $self->check_file("$dir/pods", "$s.pod")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod") or $ret = $self->check_file("$dir/pod", $s)
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s)
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm")
l!l&&r!l&&!r
0022
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod")
!ll&&!rl&&r
0220
$self->is_vms and $ret = $self->check_file($dir, "$s.com")
!ll&&!rl&&r
2200
$self->is_os2 and $ret = $self->check_file($dir, "$s.cmd")
!ll&&!rl&&r
2200
$self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat")
!ll&&!rl&&r
2200
$self->is_mswin32 or $self->is_dos or $self->is_os2
l!l&&r!l&&!r
0022
$self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
0022
MC/DC0%0/16
not $self->opt_m and $ret = $self->check_file($dir, "$s.pod") or $ret = $self->check_file($dir, "$s.pm") or $ret = $self->check_file($dir, $s) or $self->is_vms and $ret = $self->check_file($dir, "$s.com") or $self->is_os2 and $ret = $self->check_file($dir, "$s.cmd") or $self->is_mswin32 || $self->is_dos || $self->is_os2 and $ret = $self->check_file($dir, "$s.bat") or $ret = $self->check_file("$dir/pod", "$s.pod") or $ret = $self->check_file("$dir/pod", $s) or $ret = $self->check_file("$dir/pods", "$s.pod") or $ret = $self->check_file("$dir/pods", $s)
not $self->opt_m $ret = $self->check_file($dir, "$s.pod") $ret = $self->check_file($dir, "$s.pm") $ret = $self->check_file($dir, $s) $self->is_vms $ret = $self->check_file($dir, "$s.com") $self->is_os2 $ret = $self->check_file($dir, "$s.cmd") $self->is_mswin32 $self->is_dos $self->is_os2 $ret = $self->check_file($dir, "$s.bat") $ret = $self->check_file("$dir/pod", "$s.pod") $ret = $self->check_file("$dir/pod", $s) $ret = $self->check_file("$dir/pods", "$s.pod") $ret = $self->check_file("$dir/pods", $s)
Truth table0%1/195
not(A) and B or C or D or E and F or G and H or I or J or K and L or M or N or O or P
A= not $self->opt_mB= $ret = $self->check_file($dir, "$s.pod")C= $ret = $self->check_file($dir, "$s.pm")D= $ret = $self->check_file($dir, $s)E= $self->is_vmsF= $ret = $self->check_file($dir, "$s.com")G= $self->is_os2H= $ret = $self->check_file($dir, "$s.cmd")I= $self->is_mswin32J= $self->is_dosK= $self->is_os2L= $ret = $self->check_file($dir, "$s.bat")M= $ret = $self->check_file("$dir/pod", "$s.pod")N= $ret = $self->check_file("$dir/pod", $s)O= $ret = $self->check_file("$dir/pods", "$s.pod")P= $ret = $self->check_file("$dir/pods", $s)
ABCDEFGHIJKLMNOPresult
11XXXXXXXXXXXXXX1
0X1XXXXXXXXXXXXX1
101XXXXXXXXXXXXX1
0X01XXXXXXXXXXXX1
1001XXXXXXXXXXXX1
0X0011XXXXXXXXXX1
100011XXXXXXXXXX1
0X000X11XXXXXXXX1
0X001011XXXXXXXX1
10000X11XXXXXXXX1
10001011XXXXXXXX1
0X000X0X1XX1XXXX1
0X000X0X01X1XXXX1
0X000X0X0011XXXX1
0X000X101XX1XXXX1
0X000X1001X1XXXX1
0X000X100011XXXX1
0X00100X1XX1XXXX1
0X00100X01X1XXXX1
0X00100X0011XXXX1
0X0010101XX1XXXX1
0X00101001X1XXXX1
0X0010100011XXXX1
10000X0X1XX1XXXX1
10000X0X01X1XXXX1
10000X0X0011XXXX1
10000X101XX1XXXX1
10000X1001X1XXXX1
10000X100011XXXX1
1000100X1XX1XXXX1
1000100X01X1XXXX1
1000100X0011XXXX1
100010101XX1XXXX1
1000101001X1XXXX1
100010100011XXXX1
0X000X0X000X1XXX1
0X000X0X1XX01XXX1
0X000X0X01X01XXX1
0X000X0X00101XXX1
0X000X10000X1XXX1
0X000X101XX01XXX1
0X000X1001X01XXX1
0X000X1000101XXX1
0X00100X000X1XXX1
0X00100X1XX01XXX1
0X00100X01X01XXX1
0X00100X00101XXX1
0X001010000X1XXX1
0X0010101XX01XXX1
0X00101001X01XXX1
0X00101000101XXX1
10000X0X000X1XXX1
10000X0X1XX01XXX1
10000X0X01X01XXX1
10000X0X00101XXX1
10000X10000X1XXX1
10000X101XX01XXX1
10000X1001X01XXX1
10000X1000101XXX1
1000100X000X1XXX1
1000100X1XX01XXX1
1000100X01X01XXX1
1000100X00101XXX1
10001010000X1XXX1
100010101XX01XXX1
1000101001X01XXX1
1000101000101XXX1
0X000X0X000X01XX1
0X000X0X1XX001XX1
0X000X0X01X001XX1
0X000X0X001001XX1
0X000X10000X01XX1
0X000X101XX001XX1
0X000X1001X001XX1
0X000X10001001XX1
0X00100X000X01XX1
0X00100X1XX001XX1
0X00100X01X001XX1
0X00100X001001XX1
0X001010000X01XX1
0X0010101XX001XX1
0X00101001X001XX1
0X001010001001XX1
10000X0X000X01XX1
10000X0X1XX001XX1
10000X0X01X001XX1
10000X0X001001XX1
10000X10000X01XX1
10000X101XX001XX1
10000X1001X001XX1
10000X10001001XX1
1000100X000X01XX1
1000100X1XX001XX1
1000100X01X001XX1
1000100X001001XX1
10001010000X01XX1
100010101XX001XX1
1000101001X001XX1
10001010001001XX1
0X000X0X000X001X1
0X000X0X1XX0001X1
0X000X0X01X0001X1
0X000X0X0010001X1
0X000X10000X001X1
0X000X101XX0001X1
0X000X1001X0001X1
0X000X100010001X1
0X00100X000X001X1
0X00100X1XX0001X1
0X00100X01X0001X1
0X00100X0010001X1
0X001010000X001X1
0X0010101XX0001X1
0X00101001X0001X1
0X0010100010001X1
10000X0X000X001X1
10000X0X1XX0001X1
10000X0X01X0001X1
10000X0X0010001X1
10000X10000X001X1
10000X101XX0001X1
10000X1001X0001X1
10000X100010001X1
1000100X000X001X1
1000100X1XX0001X1
1000100X01X0001X1
1000100X0010001X1
10001010000X001X1
100010101XX0001X1
1000101001X0001X1
100010100010001X1
0X000X0X000X00011
0X000X0X1XX000011
0X000X0X01X000011
0X000X0X001000011
0X000X10000X00011
0X000X101XX000011
0X000X1001X000011
0X000X10001000011
0X00100X000X00011
0X00100X1XX000011
0X00100X01X000011
0X00100X001000011
0X001010000X00011
0X0010101XX000011
0X00101001X000011
0X001010001000011
10000X0X000X00011
10000X0X1XX000011
10000X0X01X000011
10000X0X001000011
10000X10000X00011
10000X101XX000011
10000X1001X000011
10000X10001000011
1000100X000X00011
1000100X1XX000011
1000100X01X000011
1000100X001000011
10001010000X00011
100010101XX000011
1000101001X000011
10001010001000011
0X000X0X000X00000
0X000X0X1XX000000
0X000X0X01X000000
0X000X0X001000000
0X000X10000X00000
0X000X101XX000000
0X000X1001X000000
0X000X10001000000
0X00100X000X00000
0X00100X1XX000000
0X00100X01X000000
0X00100X001000000
0X001010000X00000
0X0010101XX000000
0X00101001X000000
0X001010001000000
10000X0X000X00000
10000X0X1XX000000
10000X0X01X000000
10000X0X001000000
10000X10000X00000
10000X101XX000000
10000X1001X000000
10000X10001000000
1000100X000X00000
1000100X1XX000000
1000100X01X000000
1000100X001000000
10001010000X00000
100010101XX000000
1000101001X000000
10001010001000000
1969 or ( $ret = $self->check_file($dir,"$s.pm"))
1970 or ( $ret = $self->check_file($dir,$s))
1971 or ( $self->is_vms and
1972 $ret = $self->check_file($dir,"$s.com"))
1973 or ( $self->is_os2 and
1974 $ret = $self->check_file($dir,"$s.cmd"))
1975 or ( ($self->is_mswin32 or $self->is_dos or $self->is_os2) and
1976 $ret = $self->check_file($dir,"$s.bat"))
1977 or ( $ret = $self->check_file("$dir/pod","$s.pod"))
1978 or ( $ret = $self->check_file("$dir/pod",$s))
1979 or ( $ret = $self->check_file("$dir/pods","$s.pod"))
1980 or ( $ret = $self->check_file("$dir/pods",$s))
1981 ) {
1982 0 DEBUG > 1 and print " Found $ret\n";
1983 0 return $ret;
1984 }
1985  
1986 22 ▶ if ($recurse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recurse) 0 22 22
1987 0 ▶ opendir(D,$dir) or $self->die( "Can't opendir $dir: $!" );
Branch: 1 branch
BranchTrueFalseTotal
opendir D, $dir or $self->die("Can't opendir ${dir}: $!") 0 0 0
1988 my @newdirs = map catfile($dir, $_), grep {
1989 0 ▶ not /^\.\.?\z/s and
Condition0%0/6
!(/^\.\.?\z/s || /^auto\z/s) && -d catfile($dir, $_)
!ll&&!rl&&r
000
/^\.\.?\z/s || /^auto\z/s
l!l&&r!l&&!r
000
MC/DC0%0/3
!(/^\.\.?\z/s || /^auto\z/s) && -d catfile($dir, $_)
/^\.\.?\z/s /^auto\z/s -d catfile($dir, $_)
Truth table0%0/4
not(A || B) && C
A= /^\.\.?\z/sB= /^auto\z/sC= -d catfile($dir, $_)
ABCresult
1XX0
01X0
0000
0011
1990 not /^auto\z/s and # save time! don't search auto dirs
1991 -d catfile($dir, $_)
1992 } readdir D;
1993 0 ▶ closedir(D) or $self->die( "Can't closedir $dir: $!" );
Branch: 1 branch
BranchTrueFalseTotal
closedir D or $self->die("Can't closedir ${dir}: $!") 0 0 0
1994 0 ▶ next unless @newdirs;
Branch: 1 branch
BranchTrueFalseTotal
unless @newdirs 0 0 0
1995 # what a wicked map!
1996 0 ▶ @newdirs = map((s/\.dir\z//,$_)[1],@newdirs) if $self->is_vms;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_vms 0 0 0
1997 0 $self->aside( "Also looking in @newdirs\n" );
1998 0 push(@dirs,@newdirs);
1999 }
2000 }
2001 1 return ();
2002 }
2003  
2004 #..........................................................................
2005 {
2006 3 my $already_asserted;
2007 1 ▶ sub assert_closing_stdout {
Subroutine assert_closing_stdout: called CC=3 SCAR=11.3
Pod undocumented
2008 1 my $self = shift;
2009  
2010 1 ▶ return if $already_asserted;
Branch: 1 branch
BranchTrueFalseTotal
if $already_asserted 0 1 1
2011  
2012 1 ▶ eval q~ END { close(STDOUT) || CORE::die "Can't close STDOUT: $!" } ~;
Subroutine END: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
close STDOUT or CORE::die "Can't close STDOUT: $!" 1 0 1
2013 # What for? to let the pager know that nothing more will come?
2014  
2015 1 ▶ $self->die( $@ ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
2016 1 $already_asserted = 1;
2017 1 return;
2018 }
2019 }
2020  
2021 #..........................................................................
2022  
2023 3 ▶sub tweak_found_pathnames {
Subroutine tweak_found_pathnames: called CC=4 SCAR=14.9
Pod undocumented
2024 1 my($self, $found) = @_;
2025 1 ▶ if ($self->is_mswin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_mswin32) 0 1 1
2026 0 foreach (@$found) { s,/,\\,g }
2027 }
2028 1 foreach (@$found) { s,',\\',g } # RT 37347
2029 1 return;
2030 }
2031  
2032 #..........................................................................
2033 # : : : : : : : : :
2034 #..........................................................................
2035  
2036 0 ▶sub am_taint_checking {
Subroutine am_taint_checking: not called CC=2 SCAR=17.9
Pod undocumented
2037 0 my $self = shift;
2038 0 ▶ $self->die( "NO ENVIRONMENT?!?!" ) unless keys %ENV; # reset iterator along the way
Branch: 1 branch
BranchTrueFalseTotal
unless keys %ENV 0 0 0
2039 0 my($k,$v) = each %ENV;
2040 0 return is_tainted($v);
2041 }
2042  
2043 #..........................................................................
2044  
2045 0 ▶sub is_tainted { # just a function
Subroutine is_tainted: not called CC=1 SCAR=6.9
Pod undocumented
2046 0 my $arg = shift;
2047 0 my $nada = substr($arg, 0, 0); # zero-length!
2048 0 local $@; # preserve the caller's version of $@
2049 0 eval { eval "# $nada" };
2050 0 return length($@) != 0;
2051 }
2052  
2053 #..........................................................................
2054  
2055 2 ▶sub drop_privs_maybe {
Subroutine drop_privs_maybe: called CC=14 SCAR=47.0
Pod undocumented
2056 2 my $self = shift;
2057  
2058 2 DEBUG and print "Attempting to drop privs...\n";
2059  
2060 # Attempt to drop privs if we should be tainting and aren't
2061 2 ▶ if (!( $self->is_vms || $self->is_mswin32 || $self->is_dos
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->is_vms || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $> == 0 || $< == 0 and not $self->am_taint_checking) 0 2 2
Condition33%6/18
not $self->is_vms || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $> == 0 || $< == 0 and not $self->am_taint_checking
!ll&&!rl&&r
200
not $self->is_vms || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $> == 0 || $< == 0
!ll&&!rl&&r
020
$self->is_vms || $self->is_mswin32 || $self->is_dos || $self->is_os2
l!l&&r!l&&!r
002
$self->is_vms or $self->is_mswin32 or $self->is_dos
l!l&&r!l&&!r
002
$self->is_vms or $self->is_mswin32
l!l&&r!l&&!r
002
$> == 0 or $< == 0
l!l&&r!l&&!r
002
MC/DC0%0/7
not $self->is_vms || $self->is_mswin32 || $self->is_dos || $self->is_os2 and $> == 0 || $< == 0 and not $self->am_taint_checking
$self->is_vms $self->is_mswin32 $self->is_dos $self->is_os2 $> == 0 $< == 0 not $self->am_taint_checking
Truth table11%1/9
not(A or B or C || D) and E or F and not(G)
A= $self->is_vmsB= $self->is_mswin32C= $self->is_dosD= $self->is_os2E= $> == 0F= $< == 0G= not $self->am_taint_checking
ABCDEFGresult
1XXXXXX0
01XXXXX0
001XXXX0
0001XXX0
000000X0
00001X00
00000100
00001X11
00000111
2062 || $self->is_os2
2063 )
2064 && ($> == 0 || $< == 0)
2065 && !$self->am_taint_checking()
2066 ) {
2067 0 my $id = eval { getpwnam("nobody") };
2068 0 ▶ $id = eval { getpwnam("nouser") } unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
2069 0 ▶ $id = -2 unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
2070 #
2071 # According to Stevens' APUE and various
2072 # (BSD, Solaris, HP-UX) man pages, setting
2073 # the real uid first and effective uid second
2074 # is the way to go if one wants to drop privileges,
2075 # because if one changes into an effective uid of
2076 # non-zero, one cannot change the real uid any more.
2077 #
2078 # Actually, it gets even messier. There is
2079 # a third uid, called the saved uid, and as
2080 # long as that is zero, one can get back to
2081 # uid of zero. Setting the real-effective *twice*
2082 # helps in *most* systems (FreeBSD and Solaris)
2083 # but apparently in HP-UX even this doesn't help:
2084 # the saved uid stays zero (apparently the only way
2085 # in HP-UX to change saved uid is to call setuid()
2086 # when the effective uid is zero).
2087 #
2088 0 eval {
2089 0 $< = $id; # real uid
2090 0 $> = $id; # effective uid
2091 0 $< = $id; # real uid
2092 0 $> = $id; # effective uid
2093 };
2094 0 ▶ if( !$@ && $< && $> ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $@ and $< and $>) { } 0 0 0
elsif ($self->opt_U) { } 0 0 0
Condition0%0/6
not $@ and $< and $>
!ll&&!rl&&r
000
not $@ and $<
!ll&&!rl&&r
000
MC/DC0%0/3
not $@ and $< and $>
not $@ $< $>
Truth table0%0/4
not(A) and B and C
A= not $@B= $<C= $>
ABCresult
0XX0
10X0
1100
1111
2095 0 DEBUG and print "OK, I dropped privileges.\n";
2096 } elsif( $self->opt_U ) {
2097 0 DEBUG and print "Couldn't drop privileges, but in -U mode, so feh."
2098 } else {
2099 0 DEBUG and print "Hm, couldn't drop privileges. Ah well.\n";
2100 # We used to die here; but that seemed pointless.
2101 }
2102 }
2103 2 return;
2104 }
2105  
2106 #..........................................................................
2107  
2108 3 1;
2109  
2110 __END__
↑ Summary lib/Pod/Perldoc/GetOptsOO.pm »