line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Makefile::AST::StemMatch; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
739
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
5
|
2
|
|
|
2
|
|
10
|
use base 'Class::Accessor::Fast'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1243
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw{ |
8
|
|
|
|
|
|
|
pattern target stem dir notdir |
9
|
|
|
|
|
|
|
}); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _split_path ($) { |
12
|
20
|
|
|
20
|
|
20
|
my ($path) = @_; |
13
|
20
|
|
|
|
|
86
|
my ($dir, $notdir); |
14
|
20
|
100
|
|
|
|
80
|
if ($path =~ m{.*/}) { |
15
|
1
|
|
|
|
|
3
|
$dir = $&; |
16
|
1
|
|
|
|
|
2
|
$notdir = $'; |
17
|
|
|
|
|
|
|
} else { |
18
|
19
|
|
|
|
|
22
|
$dir = ''; |
19
|
19
|
|
|
|
|
19
|
$notdir = $path; |
20
|
|
|
|
|
|
|
} |
21
|
20
|
|
|
|
|
110
|
return ($dir, $notdir); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _pat2re ($@) { |
25
|
20
|
|
|
20
|
|
25
|
my ($pat, $capture) = @_; |
26
|
20
|
|
|
|
|
27
|
$pat = quotemeta $pat; |
27
|
20
|
50
|
|
|
|
30
|
if ($capture) { |
28
|
20
|
|
|
|
|
51
|
$pat =~ s/\\\%/(\\S*)/; |
29
|
|
|
|
|
|
|
} else { |
30
|
0
|
|
|
|
|
0
|
$pat =~ s/\\\%/\\S*/; |
31
|
|
|
|
|
|
|
} |
32
|
20
|
|
|
|
|
36
|
$pat; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new ($$) { |
36
|
20
|
50
|
|
20
|
1
|
56
|
my $class = ref $_[0] ? ref shift : shift; |
37
|
20
|
|
|
|
|
24
|
my $opts = shift; |
38
|
20
|
|
|
|
|
27
|
my $pattern = $opts->{pattern}; |
39
|
20
|
|
|
|
|
98
|
my $target = $opts->{target}; |
40
|
20
|
|
|
|
|
42
|
my ($dir, $notdir) = _split_path($target); |
41
|
20
|
|
|
|
|
40
|
my $re = _pat2re($pattern, 1); |
42
|
20
|
|
|
|
|
22
|
my $stem; |
43
|
20
|
50
|
|
|
|
34
|
if ($pattern =~ m{/}) { |
44
|
0
|
0
|
|
|
|
0
|
if ($target =~ $re) { |
45
|
0
|
|
|
|
|
0
|
$stem = $1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} else { |
48
|
20
|
100
|
|
|
|
390
|
if ($notdir =~ $re) { |
49
|
13
|
|
|
|
|
28
|
$stem = $1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
20
|
100
|
|
|
|
42
|
if (defined $stem) { |
53
|
13
|
|
|
|
|
106
|
return $class->SUPER::new( |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
pattern => $pattern, |
56
|
|
|
|
|
|
|
target => $target, |
57
|
|
|
|
|
|
|
stem => $stem, |
58
|
|
|
|
|
|
|
dir => $dir, |
59
|
|
|
|
|
|
|
notdir => $notdir, |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} else { |
63
|
7
|
|
|
|
|
20
|
return undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub subs_stem ($$) { |
68
|
46
|
|
|
46
|
0
|
71
|
my ($self, $other_pat) = @_; |
69
|
46
|
|
|
|
|
83
|
my $stem = $self->stem; |
70
|
46
|
|
|
|
|
206
|
$other_pat =~ s/\%/$stem/; |
71
|
46
|
50
|
|
|
|
89
|
if ($self->pattern !~ m{/}) { |
72
|
46
|
|
|
|
|
245
|
$other_pat = $self->dir . $other_pat; |
73
|
|
|
|
|
|
|
} |
74
|
46
|
|
|
|
|
468
|
return $other_pat; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |