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