| 1 | package Makefile::AST; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.215'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | #use Smart::Comments '####'; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Makefile::AST::StemMatch; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Makefile::AST::Rule::Implicit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Makefile::AST::Rule; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Makefile::AST::Variable; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | __PACKAGE__->mk_ro_accessors(qw{ | |||||||||||||||||||||||||||||||||||||||||
| 19 | phony_targets targets prereqs makefile | ||||||||||||||||||||||||||||||||||||||||||
| 20 | pad_stack named_pads pad_triggers | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | __PACKAGE__->mk_accessors(qw{ | |||||||||||||||||||||||||||||||||||||||||
| 24 | default_goal | ||||||||||||||||||||||||||||||||||||||||||
| 25 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use List::Util 'first'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use List::MoreUtils qw( uniq pairwise ) ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use Cwd qw/ realpath /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use MDOM::Util 'trim_tokens'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use MDOM::Document::Gmake; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # XXX better name? | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | our $Runtime = undef; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub new ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | my $class = ref $_[0] ? ref shift : shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $makefile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | return bless { | |||||||||||||||||||||||||||||||||||||||||
| 41 | explicit_rules => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | implicit_rules => [], | ||||||||||||||||||||||||||||||||||||||||||
| 43 | pad_stack => [{}], # the last scope is | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # the default GLOBAL | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # scope | ||||||||||||||||||||||||||||||||||||||||||
| 46 | named_pads => {}, # hooks for target-specific | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # variables | ||||||||||||||||||||||||||||||||||||||||||
| 48 | pad_triggers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | targets => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | prereqs => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | phony_targets => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | makefile => $makefile, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | sub is_phony_target ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_phony_target: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->phony_targets->{$target}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | sub set_phony_target ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_phony_target: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->phony_targets->{$target} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | sub target_exists ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target_exists: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | # XXX provide hooks for mocking file systems | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # XXX access the mtime cache instead in the future | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 17 | my $target = shift; | |||||||||||||||||||||||||||||||||||||||||
| 71 | #### Test if target exists: $target | ||||||||||||||||||||||||||||||||||||||||||
| 72 | #### Result: -e $target | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 17 | return -e $target; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | sub target_ought_to_exist ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 25 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target_ought_to_exist: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | my $res = $self->targets->{$target} || | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 25 | ▶ | $self->prereqs->{$target}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->targets->{$target} || $self->prereqs->{$target}
MC/DC100%2/2
$self->targets->{$target} || $self->prereqs->{$target}
$self->targets->{$target}
$self->prereqs->{$target}
Truth table100%3/3
A || B
A= $self->targets->{$target}B= $self->prereqs->{$target}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | ### Test if $target ought to exist: $res | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 25 | $res; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sub apply_explicit_rules ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_explicit_rules: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | my $list = $self->{explicit_rules}->{$target} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'explicit_rules'}{$target} || []
MC/DC100%1/1
$self->{'explicit_rules'}{$target} || []
$self->{'explicit_rules'}{$target}
Truth table100%2/2
A
A= $self->{'explicit_rules'}{$target}
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | ▶ | wantarray ? @$list : $list->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | sub get_var ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_var: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my $pads = $self->pad_stack; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | for my $pad (@$pads) { | |||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | if (my $var = $pad->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | return $var; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | # XXX sub find_var | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # find_var(name => $name, flavor => $flavor) | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # enter the pad for a lexical scope | ||||||||||||||||||||||||||||||||||||||||||
| 105 | sub enter_pad ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter_pad: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | #### Entering pad named: $name | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $stack = $self->pad_stack; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $pad; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | $pad = | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $self->named_pads->{$name} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->named_pads->{$name} ||= {}
MC/DC0%0/1
$self->named_pads->{$name} ||= {}
$self->named_pads->{$name}
Truth table0%0/2
A
A= $self->named_pads->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $pad = {}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | unshift @$stack, $pad; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $list = $self->pad_triggers->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ($list) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | for my $trigger (@$list) { | |||||||||||||||||||||||||||||||||||||||||
| 121 | #### Firing pad trigger for: $name | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $trigger->($self); | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | sub leave_pad ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my ($self, $count) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_pad: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | #### Leaving pad... | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $stack = $self->pad_stack; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $count = 1 if !defined $count; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | for (1..$count) { | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | shift @$stack if @$stack > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | sub pad_stack_len ($) { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | scalar(@{ $_[0]->pad_stack }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad_stack_len: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | sub add_pad_trigger ($$$) { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my ($self, $name, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_pad_trigger: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $list = $self->pad_triggers->{$name} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->pad_triggers->{$name} ||= []
MC/DC0%0/1
$self->pad_triggers->{$name} ||= []
$self->pad_triggers->{$name}
Truth table0%0/2
A
A= $self->pad_triggers->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | push @$list, $sub; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | sub add_var ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | my ($self, $var) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_var: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | # XXX variable overridding check | ||||||||||||||||||||||||||||||||||||||||||
| 151 | ## variable name: $var->name() | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | if (!ref $var->value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | $var->value( | |||||||||||||||||||||||||||||||||||||||||
| 154 | [MDOM::Document::Gmake::_tokenize_command( | ||||||||||||||||||||||||||||||||||||||||||
| 155 | $var->value | ||||||||||||||||||||||||||||||||||||||||||
| 156 | )] | ||||||||||||||||||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | $self->pad_stack->[0]->{$var->name()} = $var; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | sub add_auto_var ($$$@) { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_auto_var: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | my %pairs = @_; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | while (my ($name, $value) = each %pairs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | my $var = Makefile::AST::Variable->new( | |||||||||||||||||||||||||||||||||||||||||
| 167 | { name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | flavor => 'simple', | ||||||||||||||||||||||||||||||||||||||||||
| 169 | origin => 'automatic', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $self->add_var($var); | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | sub explicit_rules ($) { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
explicit_rules: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my @items = values %{ $self->{explicit_rules} }; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my @rules = map { @$_ } @items; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | \@rules; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | sub implicit_rules ($) { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | ▶ | $_[0]->{implicit_rules}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
implicit_rules: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | sub add_explicit_rule ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | my ($self, $rule) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_explicit_rule: called CC=8 SCAR=24.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | if (!defined $self->default_goal) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $target = $rule->target; | |||||||||||||||||||||||||||||||||||||||||
| 193 | ### check if it's the default target: $target | ||||||||||||||||||||||||||||||||||||||||||
| 194 | # XXX skip the makefile itself | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | if ($target !~ m{^\./Makefile_\S+} and (substr($target, 0, 1) ne '.' or $target =~ m{/})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $target =~ m[^\./Makefile_\S+] and substr($target, 0, 1) ne "." || $target =~ m[/]
substr($target, 0, 1) ne "." or $target =~ m[/]
MC/DC0%0/3
not $target =~ m[^\./Makefile_\S+] and substr($target, 0, 1) ne "." || $target =~ m[/]
not $target =~ m[^\./Makefile_\S+]
substr($target, 0, 1) ne "."
$target =~ m[/]
Truth table0%0/4
not(A) and B or C
A= not $target =~ m[^\./Makefile_\S+]B= substr($target, 0, 1) ne "."C= $target =~ m[/]
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | $self->default_goal($target); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | if ($rule->colon eq ':') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | # XXX check single colon rules for conflicts | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # XXX merge prereqs if no cmd given | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | $self->{explicit_rules}->{$rule->target} = | |||||||||||||||||||||||||||||||||||||||||
| 203 | [$rule]; | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # XXX check double colon rules for conflicts | ||||||||||||||||||||||||||||||||||||||||||
| 206 | my $list = | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $self->{explicit_rules}->{$rule->target} ||= | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"explicit_rules"}{$rule->target} ||= []
MC/DC0%0/1
$self->{"explicit_rules"}{$rule->target} ||= []
$self->{"explicit_rules"}{$rule->target}
Truth table0%0/2
A
A= $self->{"explicit_rules"}{$rule->target}
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | []; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # XXX check if $list is an ARRAY ref | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | push @$list, $rule; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | for my $prereq (@{$rule->normal_prereqs}, @{$rule->order_prereqs}) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $self->prereqs->{$prereq} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->targets->{$rule->target} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | sub add_implicit_rule ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | my ($self, $rule) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_implicit_rule: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | # XXX cancel a built-in implicit rule by defining | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # a pattern rule with the same target and | ||||||||||||||||||||||||||||||||||||||||||
| 222 | # prerequisites, but no commands | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | for my $target (@{ $rule->targets }) { | |||||||||||||||||||||||||||||||||||||||||
| 224 | # XXX better pattern recognition | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | next if $target =~ /\%/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->targets->{$target} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | for my $prereq (@{$rule->normal_prereqs}, @{$rule->order_prereqs}) { | |||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | ▶ | next if $prereq =~ /\%/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | $self->prereqs->{$prereq} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | my $list = $self->{implicit_rules}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | unshift @$list, $rule; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # implementation for the implicit rule search | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # algorithm | ||||||||||||||||||||||||||||||||||||||||||
| 238 | sub apply_implicit_rules ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 7 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_implicit_rules: called CC=10 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # XXX handle archive(member) here | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | #### step 2... | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | my @rules = grep { $_->match_target($target) } | |||||||||||||||||||||||||||||||||||||||||
| 245 | 7 | @{ $self->implicit_rules }; | |||||||||||||||||||||||||||||||||||||||||
| 246 | #### rules: map { $_->as_str } @rules | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 7 | ▶ | return undef if !@rules; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | #### step 3... | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | ▶ | if (first { ! $_->match_anything } @rules) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | @rules = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | ▶ | !( $_->match_anything && !$_->is_terminal ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_->match_anything && !$_->is_terminal
MC/DC0%0/2
$_->match_anything && !$_->is_terminal
$_->match_anything
!$_->is_terminal
Truth table33%1/3
A && not(B)
A= $_->match_anythingB= !$_->is_terminal
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | } @rules; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | #### rules: map { $_->as_str } @rules | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | #### step 4... | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | @rules = grep { @{ $_->commands } > 0 } @rules; | |||||||||||||||||||||||||||||||||||||||||
| 259 | #### rules: map { $_->as_str } @rules | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | #### step 5... | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # XXX This is hacky...not sure if it's the right | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # XXX thing to do (it's unspec'd afaik) | ||||||||||||||||||||||||||||||||||||||||||
| 264 | @rules = sort { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 4 | -( scalar( @{ $a->normal_prereqs } ) <=> | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | scalar( @{ $b->normal_prereqs } ) ) | |||||||||||||||||||||||||||||||||||||||||
| 267 | } @rules; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | for my $rule (@rules) { | |||||||||||||||||||||||||||||||||||||||||
| 269 | #### target: $target | ||||||||||||||||||||||||||||||||||||||||||
| 270 | #### rule: $rule->as_str | ||||||||||||||||||||||||||||||||||||||||||
| 271 | #### file test: -e 'bar.hpp' | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | my $applied = $rule->apply($self, $target); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | ▶ | if ($applied) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | #### applied rule: $applied->as_str | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | return $applied; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | ### step 6... | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | for my $rule (@rules) { | |||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | ▶ | next if $rule->is_terminal; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | #### applying the implicit rule recursively | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | my $applied = $rule->apply( | |||||||||||||||||||||||||||||||||||||||||
| 284 | $self, $target, | ||||||||||||||||||||||||||||||||||||||||||
| 285 | { recursive => 1 }); | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | ▶ | if ($applied) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return $applied; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | #### Failed to apply the rule recursively | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | ### step 7... | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | my $applied = $self->apply_explicit_rules('.DEFAULT'); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | ▶ | if ($applied) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $applied->target($target); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $applied; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | sub _pat2re ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my ($pat, $capture) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pat2re: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $pat = quotemeta $pat; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($capture) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $pat =~ s/\\\%/(\\S*)/g; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $pat =~ s/\\\%/\\S*/g; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $pat; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub _split_args($$$$) { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | my ($self, $func, $s, $m, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_args: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $n ||= $m; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$n ||= $m
MC/DC0%0/2
$n ||= $m
$n
$m
Truth table0%0/3
A ||= B
A= $nB= $m
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my @tokens = ''; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 317 | ### $n | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | while (@args <= $n) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | ### split args: @args | ||||||||||||||||||||||||||||||||||||||||||
| 320 | ### split tokens: @tokens | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ($s =~ /\G\s+/gc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | push @tokens, $&, ''; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | elsif ($s =~ /\G[^\$,]+/gc) { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $tokens[-1] .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | elsif ($s =~ /\G,/gc) { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if (@args < $n - 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | push @args, [grep { $_ ne '' } @tokens]; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | @tokens = ''; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $tokens[-1] .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | elsif (my $res = MDOM::Document::Gmake::extract_interp($s)) { | ||||||||||||||||||||||||||||||||||||||||||
| 336 | #die $res; | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | push @tokens, MDOM::Token::Interpolation->new($res), ''; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | elsif ($s =~ /\G\$./gc) { | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | push @tokens, MDOM::Token::Interpolation->new($&), ''; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | elsif ($s =~ /\G./gc) { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $tokens[-1] .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if (@args <= $n - 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | push @args, [grep { $_ ne '' } @tokens]; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | last if @args >= $m and @args <= $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args >= $m and @args <= $n
MC/DC0%0/2
@args >= $m and @args <= $n
@args >= $m
@args <= $n
Truth table0%0/3
A and B
A= @args >= $mB= @args <= $n
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | warn $self->makefile, ":$.: ", | |||||||||||||||||||||||||||||||||||||||||
| 351 | "*** insufficient number of arguments (", | ||||||||||||||||||||||||||||||||||||||||||
| 352 | scalar(@args), ") to function `$func'. Stop.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | exit(2); | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return @args; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | sub eval_var_value ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eval_var_value: not called CC=3 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if (my $var = $self->get_var($name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | ### eval_var_value: $var | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ($var->flavor eq 'recursive') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | ## HERE! eval_var_value | ||||||||||||||||||||||||||||||||||||||||||
| 365 | ## eval recursive var: $var | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $val = $self->solve_refs_in_tokens( | |||||||||||||||||||||||||||||||||||||||||
| 367 | $var->value | ||||||||||||||||||||||||||||||||||||||||||
| 368 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $val =~ s/^\s+|\s+$//gs; | |||||||||||||||||||||||||||||||||||||||||
| 370 | #warn "value: $val\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | # don't complain about uninitialized value: | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $val = join '', @{$var->value}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $val =~ s/^\s+|\s+$//gs; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 380 | # process undefined var: | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | sub _text2words ($) { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | my ($text) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text2words: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $text =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | split /\s+/, $text; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | sub _check_numeric ($$$$) { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | my ($self, $func, $order, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_numeric: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if ($n !~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | warn $self->makefile, ":$.: ", | |||||||||||||||||||||||||||||||||||||||||
| 395 | "*** non-numeric $order argument to `$func' function: '$n'. Stop.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | exit(2); | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | sub _check_greater_than ($$$$$) { | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my ($self, $func, $order, $n, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_greater_than: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($n <= $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | warn $self->makefile, ":$.: *** $order argument to `$func' function must be greater than $value. Stop.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | exit(2); | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | sub _trim ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | for (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | sub _process_func_ref ($$$) { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my ($self, $name, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_func_ref: not called CC=53 SCAR=79.1
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | ### process func ref: $name | ||||||||||||||||||||||||||||||||||||||||||
| 417 | # XXX $name = $self->_process_refs($name); | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $nargs = scalar(@args); | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ($name eq 'subst') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my @args = $self->_split_args($name, $args, 3); | |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 423 | ### arguments: @args | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ($from, $to, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $from = quotemeta($from); | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $text =~ s/$from/$to/g; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ($name eq 'patsubst') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my @args = $self->_split_args($name, $args, 3); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my ($pattern, $replacement, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $re = _pat2re($pattern, 1); | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $replacement =~ s/\%/\${1}/g; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $replacement = qq("$replacement"); | |||||||||||||||||||||||||||||||||||||||||
| 436 | #### pattern: $re | ||||||||||||||||||||||||||||||||||||||||||
| 437 | #### replacement: $replacement | ||||||||||||||||||||||||||||||||||||||||||
| 438 | #### text: $text | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $code = "s/^$re\$/$replacement/e"; | |||||||||||||||||||||||||||||||||||||||||
| 440 | #### code: $code | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | map { eval $code; } @words; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return join ' ', grep { $_ ne '' } @words; | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if ($name eq 'strip') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my ($string) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $string =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $string =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if ($name eq 'findstring') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my ($find, $in) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if (index($in, $find) >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return $find; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my ($patterns, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my @regexes = map { _pat2re($_) } | |||||||||||||||||||||||||||||||||||||||||
| 464 | split /\s+/, $patterns; | ||||||||||||||||||||||||||||||||||||||||||
| 465 | ## regexes: @regexes | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $regex = join '|', map { "(?:$_)" } @regexes; | |||||||||||||||||||||||||||||||||||||||||
| 467 | ## regex: $regex | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return join ' ', grep /^$regex$/, @words; | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ($name eq 'filter') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my ($patterns, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my @regexes = map { _pat2re($_) } | |||||||||||||||||||||||||||||||||||||||||
| 477 | split /\s+/, $patterns; | ||||||||||||||||||||||||||||||||||||||||||
| 478 | ## regexes: @regexes | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $regex = join '|', map { "(?:$_)" } @regexes; | |||||||||||||||||||||||||||||||||||||||||
| 480 | ## regex: $regex | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | return join ' ', grep /^$regex$/, @words; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ($name eq 'filter-out') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my ($patterns, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my @regexes = map { _pat2re($_) } | |||||||||||||||||||||||||||||||||||||||||
| 489 | split /\s+/, $patterns; | ||||||||||||||||||||||||||||||||||||||||||
| 490 | ## regexes: @regexes | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $regex = join '|', map { "(?:$_)" } @regexes; | |||||||||||||||||||||||||||||||||||||||||
| 492 | ## regex: $regex | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return join ' ', grep !/^$regex$/, @words; | |||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if ($name eq 'sort') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my ($list) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | _trim($list); | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | return join ' ', uniq sort split /\s+/, $list; | |||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ($name eq 'words') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return scalar(@words); | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if ($name eq 'word') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my ($n, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | _trim($n); | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->_check_numeric('word', 'first', $n); | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $self->_check_greater_than('word', 'first', $n, 0); | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | return $n > @words ? '' : $words[$n - 1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if ($name eq 'wordlist') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my @args = $self->_split_args($name, $args, 3); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my ($s, $e, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | _trim($s, $e, $text); | |||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $self->_check_numeric('wordlist', 'first', $s); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $self->_check_numeric('wordlist', 'second', $e); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $self->_check_greater_than('wordlist', 'first', $s, 0); | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $self->_check_greater_than('wordlist', 'second', $s, -1); | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ($s > $e || $s > @words || $e == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$s > $e or $s > @words or $e == 0
$s > $e or $s > @words
MC/DC0%0/3
$s > $e or $s > @words or $e == 0
$s > $e
$s > @words
$e == 0
Truth table0%0/4
A or B or C
A= $s > $eB= $s > @wordsC= $e == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $e = @words if $e > @words; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | return join ' ', @words[$s-1..$e-1]; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ($name eq 'firstword') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | return @words > 0 ? $words[0] : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if ($name eq 'lastword') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my @words = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | return @words > 0 ? $words[-1] : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if ($name eq 'dir') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | return join ' ', map { /.*\// ? $& : './' } @names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if ($name eq 'notdir') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return join ' ', map { s/.*\///; $_ } @names; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if ($name eq 'suffix') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | my $s = join ' ', map { /.*(\..*)/ ? $1 : '' } @names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $s =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if ($name eq 'basename') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | my $s = join ' ', map { /(.*)\./ ? $1 : $_ } @names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | $s =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if ($name eq 'addsuffix') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my ($suffix, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 586 | #_trim($suffix); | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return join ' ', map { $_ . $suffix } @names; | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if ($name eq 'addprefix') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my ($suffix, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 594 | #_trim($suffix); | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | return join ' ', map { $suffix . $_ } @names; | |||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | if ($name eq 'join') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my @args = $self->_split_args($name, $args, 2); | |||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my ($list_1, $list_2) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my @list_1 = _text2words($list_1); | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my @list_2 = _text2words($list_2); | |||||||||||||||||||||||||||||||||||||||||
| 604 | return join ' ', pairwise { | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | $a . $b | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | } @list_1, @list_2; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if ($name eq 'wildcard') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my ($pattern) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return join ' ', grep { -e $_ } glob $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | if ($name eq 'realpath') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return join ' ', map { realpath($_) } @names; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if ($name eq 'abspath') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my ($text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my @names = _text2words($text); | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my @paths = map { File::Spec->rel2abs($_) } @names; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | for my $path (@paths) { | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my @f = split '/', $path; | |||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my @new_f; | |||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | for (@f) { | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if ($_ eq '..') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | pop @new_f; | |||||||||||||||||||||||||||||||||||||||||
| 635 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | push @new_f, $_; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $path = join '/', @new_f; | |||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | return join ' ', @paths; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if ($name eq 'shell') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my @args = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | map { $_ = $self->solve_refs_in_tokens($_) } @args; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my ($cmd) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $output = `$cmd`; | |||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $output =~ s/(?:\r?\n)+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $output =~ s/\r?\n/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if ($name eq 'if') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my @args = $self->_split_args($name, $args, 2, 3); | |||||||||||||||||||||||||||||||||||||||||
| 654 | #map { $_ = $self->solve_refs_in_tokens($_) } @args; | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my ($condition, $then_part, $else_part) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | trim_tokens($condition); | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $condition = $self->solve_refs_in_tokens($condition); | |||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | return $condition eq '' ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 659 | $self->solve_refs_in_tokens($else_part) | ||||||||||||||||||||||||||||||||||||||||||
| 660 | : | ||||||||||||||||||||||||||||||||||||||||||
| 661 | $self->solve_refs_in_tokens($then_part); | ||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if ($name eq 'or') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my @args = $self->_split_args($name, $args, 1, 1000_000_000); | |||||||||||||||||||||||||||||||||||||||||
| 665 | #map { $_ = $self->solve_refs_in_tokens($_) } @args; | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | trim_tokens($arg); | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $value = $self->solve_refs_in_tokens($arg); | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | return $value if $value ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if ($name eq 'and') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my @args = $self->_split_args($name, $args, 1, 1000_000_000); | |||||||||||||||||||||||||||||||||||||||||
| 675 | #map { $_ = $self->solve_refs_in_tokens($_) } @args; | ||||||||||||||||||||||||||||||||||||||||||
| 676 | ## arguments for 'and': @args | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | trim_tokens($arg); | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $value = $self->solve_refs_in_tokens($arg); | |||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | return '' if $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if ($name eq 'foreach') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my @args = $self->_split_args($name, $args, 3); | |||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my ($var, $list, $text) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $var = $self->solve_refs_in_tokens($var); | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $list = $self->solve_refs_in_tokens($list); | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my @words = _text2words($list); | |||||||||||||||||||||||||||||||||||||||||
| 691 | # save the original status of $var | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $rvars = $self->{_vars}; | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my $not_exist = !exists $rvars->{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $old_val = $rvars->{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | for my $word (@words) { | |||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $rvars->{$var} = $word; | |||||||||||||||||||||||||||||||||||||||||
| 699 | #warn "$word"; | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | push @results, $self->solve_refs_in_tokens($text); | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | # restore the original status of $var | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if ($not_exist) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | delete $rvars->{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 706 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $rvars->{$var} = $old_val; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | return join ' ', @results; | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | if ($name eq 'error') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my ($text) = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $text = $self->solve_refs_in_tokens($text); | |||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | warn $self->makefile, ":$.: *** $text. Stop.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | exit(2) if $Runtime; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | if ($name eq 'warning') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my ($text) = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $text = $self->solve_refs_in_tokens($text); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | warn $self->makefile, ":$.: $text\n"; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if ($name eq 'info') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my ($text) = $self->_split_args($name, $args, 1); | |||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $text = $self->solve_refs_in_tokens($text); | |||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | print "$text\n"; | |||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | sub solve_refs_in_tokens ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | my ($self, $tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
solve_refs_in_tokens: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | return '' if !$tokens; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my @new_tokens; | |||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | for my $token (@$tokens) { | |||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | if (!ref $token or !$token->isa('MDOM::Token::Interpolation')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $token and $token->isa("MDOM::Token::Interpolation")
MC/DC0%0/2
ref $token and $token->isa("MDOM::Token::Interpolation")
ref $token
$token->isa("MDOM::Token::Interpolation")
Truth table0%0/3
A and B
A= ref $tokenB= $token->isa("MDOM::Token::Interpolation")
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | ### solve_refs: non-var-ref token: $token | ||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | push @new_tokens, $token; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if ($token =~ /^\$[{(](.*)[)}]$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $s = $1; | |||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | if ($s =~ /^([-\w]+)\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $res = $self->_process_func_ref($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | if (defined $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | push @new_tokens, $res; | |||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | } elsif ($s =~ /^(\S+?):(\S+?)=(\S+)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my ($var, $from, $to) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | my $res = $self->_process_func_ref( | |||||||||||||||||||||||||||||||||||||||||
| 756 | 'patsubst', "\%$from,\%$to,\$($var)" | ||||||||||||||||||||||||||||||||||||||||||
| 757 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | if (defined $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | push @new_tokens, $res; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | ### found variable reference: $1 | ||||||||||||||||||||||||||||||||||||||||||
| 764 | ### evaluating variable : $s | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | push @new_tokens, $self->eval_var_value($s); | |||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 767 | } elsif ($token =~ /^\$\$$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | push @new_tokens, '$'; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 770 | } elsif ($token =~ /^\$(.)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | push @new_tokens, $self->eval_var_value($1); | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | push @new_tokens, $token; | |||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||
| 776 | ### solving results: join '', @new_tokens | ||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | return join '', @new_tokens; | |||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 781 | __END__ | ||||||||||||||||||||||||||||||||||||||||||