| 1 | package ExtUtils::Builder::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | $ExtUtils::Builder::Util::VERSION = '0.020'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Exporter 5.57 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | our @EXPORT_OK = qw/get_perl require_module unix_to_native_path native_to_unix_path command code function split_like_shell/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use ExtUtils::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 16 | ▶ | use ExtUtils::Helpers 0.027 'split_like_shell'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 16 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | ▶ | use File::Spec::Unix; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 16 | ▶ | use Scalar::Util 'tainted'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | sub get_perl { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_perl: called CC=5 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | my (%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | my $config = $opts{config} // ExtUtils::Config->new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"config"} // "ExtUtils::Config"->new
MC/DC0%0/2
$opts{"config"} // "ExtUtils::Config"->new
$opts{"config"}
"ExtUtils::Config"->new
Truth table33%1/3
A // B
A= $opts{"config"}B= "ExtUtils::Config"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | if (File::Spec->file_name_is_absolute($^X) and not tainted($^X)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
"File::Spec"->file_name_is_absolute($^X) and not &tainted($^X)
MC/DC0%0/2
"File::Spec"->file_name_is_absolute($^X) and not &tainted($^X)
"File::Spec"->file_name_is_absolute($^X)
not &tainted($^X)
Truth table33%1/3
A and not(B)
A= "File::Spec"->file_name_is_absolute($^X)B= not &tainted($^X)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | return $^X; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | elsif ($config->get('userelocatableinc')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | require Devel::FindPerl; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | return Devel::FindPerl::find_perl_interpreter($config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $config->get('perlpath'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | sub require_module { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_module: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | my $module = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | (my $filename = "$module.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | require $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | return $module; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my (@command) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | require ExtUtils::Builder::Action::Command; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | return ExtUtils::Builder::Action::Command->new(command => \@command); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 10 | ▶ | sub code { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | require ExtUtils::Builder::Action::Code; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 10 | return ExtUtils::Builder::Action::Code->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub function { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
function: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | require ExtUtils::Builder::Action::Function; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return ExtUtils::Builder::Action::Function->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 16 | my %cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub glob_to_regex { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
glob_to_regex: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $input = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | return $cache{$input} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$cache{$input} ||= do {
my $regex = _glob_to_regex_string($input);
qr/^$regex$/
}
MC/DC0%0/2
$cache{$input} ||= do {
my $regex = _glob_to_regex_string($input);
qr/^$regex$/
}
$cache{$input}
do {
my $regex = _glob_to_regex_string($input);
qr/^$regex$/
}
Truth table33%1/3
A ||= B
A= $cache{$input}B= do {
my $regex = _glob_to_regex_string($input);
qr/^$regex$/
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | my $regex = _glob_to_regex_string($input); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | qr/^$regex$/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub _glob_to_regex_string { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_glob_to_regex_string: called CC=17 SCAR=45.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my $glob = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | my $in_curlies; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | local $_ = $glob; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | my $regex = !/\A(?=\.)/ ? '(?=[^\.])' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | while (!/\G\z/mgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | if (/\G([^\/.()|+^\$@%\\*?{},\[\]]+)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | $regex .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif (m{\G/}gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $regex .= !/\G(?=\.)/gc ? '/(?=[^\.])' : '/' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif (/ \G ( [.()|+^\$@%] ) /xmgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $regex .= quotemeta $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | elsif (/ \G \\ ( [*?{}\\,] ) /xmgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $regex .= quotemeta $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | elsif (/\G\*/mgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $regex .= "[^/]*"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | elsif (/\G\?/mgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $regex .= "[^/]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | elsif (/\G\{/mgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $regex .= "("; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ++$in_curlies; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | elsif (/\G \[ ( [^\]]+ ) \] /xgc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $regex .= "[\Q$1\E]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | elsif ($in_curlies && /\G\}/mgc) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$in_curlies and /\G\}/cgm
MC/DC0%0/2
$in_curlies and /\G\}/cgm
$in_curlies
/\G\}/cgm
Truth table0%0/3
A and B
A= $in_curliesB= /\G\}/cgm
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $regex .= ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | --$in_curlies; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ▶ | elsif ($in_curlies && /\G,/mgc) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$in_curlies and /\G,/cgm
MC/DC0%0/2
$in_curlies and /\G,/cgm
$in_curlies
/\G,/cgm
Truth table0%0/3
A and B
A= $in_curliesB= /\G,/cgm
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $regex .= "|"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | elsif (/\G([},]+)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $regex .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | croak sprintf "Couldn't parse at %s|%s", substr($_, 0 , pos), substr $_, pos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | return $regex; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | sub unix_to_native_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unix_to_native_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | my ($input) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | my ($volume, $unix_dir, $file) = File::Spec::Unix->splitpath($input); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | my @splitdir = File::Spec::Unix->splitdir($unix_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | my $catdir = File::Spec->catdir(@splitdir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | return File::Spec->catpath($volume, $catdir, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub native_to_unix_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
native_to_unix_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ($input) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($volume, $unix_dir, $file) = File::Spec->splitpath($input); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my @splitdir = File::Spec->splitdir($unix_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $catdir = File::Spec::Unix->catdir(@splitdir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return File::Spec::Unix->catpath($volume, $catdir, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # ABSTRACT: Utility functions for ExtUtils::Builder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||