| 1 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | my @dir = do { | |||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | if ($ENV{DEBUG_INC}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | print STDERR "\$0=$0, rel2abs->", File::Spec->rel2abs($0), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | my @d = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-r $0 and -l $0
MC/DC0%0/2
-r $0 and -l $0
-r $0
-l $0
Truth table33%1/3
A and B
A= -r $0B= -l $0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | $_[0], | ||||||||||||||||||||||||||||||||||||||||||
| 12 | dirname(File::Spec->rel2abs($0)), | ||||||||||||||||||||||||||||||||||||||||||
| 13 | (-r $0 and -l $0) ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 14 | dirname(File::Spec->rel2abs(readlink($0), dirname($0))), | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 16 | $FindBin::Bin, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | $FindBin::Bin, # Just to avoid warning. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | Carp::cluck("d=".join(", ", map {$_ // 'undef'} @d)) if $ENV{DEBUG_INC}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_ // "undef"
MC/DC0%0/1
$_ // "undef"
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | my %dup; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | ▶ | map {defined $_ && -d $_ && !$dup{$_}++ ? untaint_any($_) : ()} @d; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $_ and -d $_ and not $dup{$_}++
defined $_ and -d $_
MC/DC66%2/3
defined $_ and -d $_ and not $dup{$_}++
defined $_
-d $_
not $dup{$_}++
Truth table75%3/4
A and B and not(C)
A= defined $_B= -d $_C= not $dup{$_}++
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | unless (@dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | Carp::croak("Can't find bindir!"); | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | ▶ | Carp::cluck("dir=@dir\n") if $ENV{DEBUG_INC}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 28 | ▶ | sub untaint_any {$_[0] =~ m{(.*)} and $1} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_any: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | ▶ | use base qw/File::Spec/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 11 | my (@libdir); | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 11 | foreach my $dir (@dir) { | |||||||||||||||||||||||||||||||||||||||||
| 36 | 22 | ▶ | if (grep {$_ eq 'YATT'} File::Spec->splitdir($dir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | push @libdir, dirname(dirname($dir)); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 22 | ▶ | if (-d (my $d = "$dir/../blib/lib")."/YATT") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 22 | push @libdir, $d; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 810 | ▶ | my $hook = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=32.6
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 810 | my ($this, $orig_modfn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 810 | ▶ | return unless (my $modfn = $orig_modfn) =~ s!^YATT/!!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | Carp::cluck("orig_modfn=$orig_modfn\n") if $ENV{DEBUG_INC}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | return unless -r (my $realfn = "$dir[0]/../$modfn"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | warn "=> found $realfn" if $ENV{DEBUG_INC}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | open my $fh, '<', $realfn or die "Can't open $realfn:$!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $fh; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 11 | unshift @INC, $hook; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | ▶ | my $ins = $INC[$#INC] eq "." ? $#INC : @INC; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 11 | splice @INC, $ins, 0, $hook, $hook; | |||||||||||||||||||||||||||||||||||||||||
| 59 | # XXX: Why I need to put this into @INC-hook 3times?! | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 11 | require lib; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 11 | ▶ | if (@libdir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 11 | import lib @libdir; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | ▶ | print STDERR join("\n", @libdir), "\n" if $ENV{DEBUG_INC}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # Should returns $dist_root | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 11 | return "$dir[0]/.."; | |||||||||||||||||||||||||||||||||||||||||