lib/Code/TidyAll/Zglob.pm

filter: Statementstmt 64.2% 99 / 154 Branchbran 47.3% 53 / 112 Conditioncond 53.3% 40 / 75 MC/DCmcdc 20.0% 8 / 40 Subroutinesub 93.3% 14 / 15 Podpod 0.0% 0 / 7 totaltotal 53.1% 214 / 403 CC 83 SCAR 43.2
CC
83
Cov
56%
glob_to_regex_string
165.1
glob_fs_fold
44.6
dbg
34.6
CRAP 75.4
« lib/Code/TidyAll/Util/Zglob.pm ↑ Summary blib/lib/Code/TidyAll/SVN/Precommit.pm »
1 package Code::TidyAll::Zglob;
2 58 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 58 ▶use warnings 'all', FATAL => 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 58 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 58 our $VERSION = '0.85';
6 58 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 58 our @EXPORT = qw(zglob);
9  
10 58 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 58 our $SEPCHAR = '/';
13 58 ▶our $NOCASE = $^O =~ /^(?:MSWin32|VMS|os2|dos|riscos|MacOS|darwin)$/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /^(?:MSWin32|VMS|os2|dos|riscos|MacOS|darwin)$/ ? : 0 58 58
14 58 our $DIRFLAG = \"DIR?";
15 58 our $DEEPFLAG = \"**";
16 58 our $PARENTFLAG = \"..";
17 58 our $DEBUG = 0;
18 58 our $STRICT_LEADING_DOT = 1;
19 58 our $STRICT_WILDCARD_SLASH = 1;
20  
21 43 ▶sub zglob {
Subroutine zglob: called CC=2 SCAR=7.8
Pod undocumented
22 43 my ($pattern) = @_;
23 #dbg("FOLDING: $pattern");
24 # support ~tokuhirom/
25 43 ▶ if ($^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 43 43
26 0 require Win32;
27 0 ▶ $pattern =~ s!^(\~[^$SEPCHAR]*)!Win32::GetLongPathName([glob($1)]->[0])!e;
Subroutine BEGIN: called CC=1 SCAR=0.6
28 } else {
29 0 $pattern =~ s!^(\~[^$SEPCHAR]*)![glob($1)]->[0]!e;
30 }
31 43 my ($node, $matcher) = glob_prepare_pattern($pattern);
32 # $node : \0 if absolute path, \1 if relative.
33  
34 #dbg("pattern: ", $node, $matcher);
35 43 return _rec($node, $matcher, []);
36 }
37  
38 392 ▶sub dbg(@) {
Subroutine dbg: called CC=6 SCAR=35.4
Pod undocumented
39 392 ▶ return unless $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless $Code::TidyAll::Zglob::DEBUG 392 0 392
40 0 my ($pkg, $filename, $line, $sub) = caller(1);
41 0 my $i = 0;
42 0 ▶ while (caller($i++)) { 1 }
Branch: 1 branch
BranchTrueFalseTotal
if (caller $i++) 0 0 0
43 0 my $msg;
44 0 $msg .= ('-' x ($i-5));
45 0 $msg .= " [$sub] ";
46 0 for (@_) {
47 0 $msg .= ' ';
48 0 ▶ if (not defined $_) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (ref $_) { } 0 0 0
49 0 $msg .= '<<undef>>';
50 } elsif (ref $_) {
51 0 require Data::Dumper;
52 0 local $Data::Dumper::Terse = 1;
53 0 local $Data::Dumper::Indent = 0;
54 0 $msg .= Data::Dumper::Dumper($_);
55 } else {
56 0 $msg .= $_;
57 }
58 }
59 0 $msg .= " at $filename line $line\n";
60 0 print($msg);
61 }
62  
63 48 ▶sub _recstar {
Subroutine _recstar: called CC=1 SCAR=0.0
64 48 my ($node, $matcher) = @_;
65 #dbg("recstar: ", $node, $matcher, $seed);
66 return (
67 _rec( $node, $matcher ),
68 (
69 48 map { _recstar( $_, $matcher ) }
70 glob_fs_fold( $node, qr{^[^.].*$}, 1 )
71 )
72 );
73 }
74  
75 181 ▶sub _rec {
Subroutine _rec: called CC=11 SCAR=34.6
76 181 my ($node, $matcher) = @_;
77 # $matcher: ArrayRef[Any]
78  
79 181 my ($current, @rest) = @{$matcher};
80 181 ▶ if (!defined $current) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $current) { } 0 181 181
elsif (ref $current eq 'SCALAR' and $current == $Code::TidyAll::Zglob::DEEPFLAG) { } 33 148 181
elsif (ref $current eq 'SCALAR' and $current == $Code::TidyAll::Zglob::PARENTFLAG) { } 0 148 148
elsif (@rest == 0) { } 52 96 148
81 #dbg("FINISHED");
82 0 return ();
83 ▶ } elsif (ref($current) eq 'SCALAR' && $current == $DEEPFLAG) {
Condition66%2/3
ref $current eq "SCALAR" and $current == $Code::TidyAll::Zglob::DEEPFLAG
!ll&&!rl&&r
148033
MC/DC50%1/2
ref $current eq "SCALAR" and $current == $Code::TidyAll::Zglob::DEEPFLAG
ref $current eq "SCALAR" $current == $Code::TidyAll::Zglob::DEEPFLAG
Truth table66%2/3
A and B
A= ref $current eq "SCALAR"B= $current == $Code::TidyAll::Zglob::DEEPFLAG
ABresult
0X0
100
111
84 #dbg("** mode");
85 33 return _recstar($node, \@rest);
86 ▶ } elsif (ref($current) eq 'SCALAR' && $current == $PARENTFLAG) {
Condition33%1/3
ref $current eq "SCALAR" and $current == $Code::TidyAll::Zglob::PARENTFLAG
!ll&&!rl&&r
14800
MC/DC0%0/2
ref $current eq "SCALAR" and $current == $Code::TidyAll::Zglob::PARENTFLAG
ref $current eq "SCALAR" $current == $Code::TidyAll::Zglob::PARENTFLAG
Truth table33%1/3
A and B
A= ref $current eq "SCALAR"B= $current == $Code::TidyAll::Zglob::PARENTFLAG
ABresult
0X0
100
111
87 0 ▶ if (ref($node) eq 'SCALAR' && $$node eq 1) { #t
Branch: 2 branches
BranchTrueFalseTotal
if (ref $node eq 'SCALAR' and $$node eq 1) { } 0 0 0
elsif (ref $node eq 'SCALAR' and $$node eq 0) { } 0 0 0
Condition0%0/3
ref $node eq "SCALAR" and $$node eq 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $node eq "SCALAR" and $$node eq 1
ref $node eq "SCALAR" $$node eq 1
Truth table0%0/3
A and B
A= ref $node eq "SCALAR"B= $$node eq 1
ABresult
0X0
100
111
88 0 die "You cannot get a parent directory of root dir.";
89 ▶ } elsif (ref($node) eq 'SCALAR' && $$node eq 0) { #f
Condition0%0/3
ref $node eq "SCALAR" and $$node eq 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $node eq "SCALAR" and $$node eq 0
ref $node eq "SCALAR" $$node eq 0
Truth table0%0/3
A and B
A= ref $node eq "SCALAR"B= $$node eq 0
ABresult
0X0
100
111
90 0 return _rec("..", \@rest);
91 } else {
92 0 return _rec("$node$SEPCHAR..", \@rest);
93 }
94 } elsif (@rest == 0) {
95 #dbg("file name");
96 # (folder proc seed node (car matcher) #f)
97 52 return glob_fs_fold($node, $current, 0);
98 } else {
99 96 return glob_fs_fold($node, $current, 1, \@rest);
100 }
101 }
102  
103  
104 # /^home$/ のような固定の文字列の場合に高速化をはかるための最適化予定地なので、とりあえず undef をかえしておいても問題がない
105 0 ▶sub fixed_regexp_p {
Subroutine fixed_regexp_p: not called CC=1 SCAR=6.9
Pod undocumented
106 0 return undef;
107 0 die "TBI"
108 }
109  
110 # returns arrayref of seeds.
111 196 ▶sub glob_fs_fold {
Subroutine glob_fs_fold: called CC=24 SCAR=38.0
Pod undocumented
112 196 my ($node, $regexp, $non_leaf_p, $rest) = @_;
113  
114 196 my $prefix = do {
115 196 ▶ if (ref $node eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $node eq 'SCALAR') { } 43 153 196
elsif (not $node =~ m[/$]) { } 153 0 153
116 43 ▶ if ($$node eq 1) { #t
Branch: 2 branches
BranchTrueFalseTotal
if ($$node eq 1) { } 43 0 43
elsif ($$node eq '0') { } 0 0 0
117 43 $SEPCHAR
118 } elsif ($$node eq '0') { #f
119 0 '';
120 } else {
121 0 die "FATAL";
122 }
123 } elsif ($node !~ m{/$}) {
124 153 $node . '/';
125 } else {
126 0 $node;
127 }
128 };
129 196 dbg("prefix: $prefix");
130 196 dbg("regxp: ", $regexp);
131 196 ▶ if ($^O eq 'MSWin32' && ref $regexp eq 'SCALAR' && $$regexp =~ /^[a-zA-Z]\:$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and ref $regexp eq "SCALAR" and $$regexp =~ /^[a-zA-Z]\:$/) 0 196 196
Condition33%2/6
$^O eq "MSWin32" and ref $regexp eq "SCALAR" and $$regexp =~ /^[a-zA-Z]\:$/
!ll&&!rl&&r
19600
$^O eq "MSWin32" and ref $regexp eq "SCALAR"
!ll&&!rl&&r
19600
MC/DC0%0/3
$^O eq "MSWin32" and ref $regexp eq "SCALAR" and $$regexp =~ /^[a-zA-Z]\:$/
$^O eq "MSWin32" ref $regexp eq "SCALAR" $$regexp =~ /^[a-zA-Z]\:$/
Truth table25%1/4
A and B and C
A= $^O eq "MSWin32"B= ref $regexp eq "SCALAR"C= $$regexp =~ /^[a-zA-Z]\:$/
ABCresult
0XX0
10X0
1100
1111
132 0 return _rec($$regexp . '/', $rest);
133 }
134 196 ▶ if (ref $regexp eq 'SCALAR' && $regexp == $DIRFLAG) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $regexp eq 'SCALAR' and $regexp == $Code::TidyAll::Zglob::DIRFLAG) { } 0 196 196
Condition33%1/3
ref $regexp eq "SCALAR" and $regexp == $Code::TidyAll::Zglob::DIRFLAG
!ll&&!rl&&r
19600
MC/DC0%0/2
ref $regexp eq "SCALAR" and $regexp == $Code::TidyAll::Zglob::DIRFLAG
ref $regexp eq "SCALAR" $regexp == $Code::TidyAll::Zglob::DIRFLAG
Truth table33%1/3
A and B
A= ref $regexp eq "SCALAR"B= $regexp == $Code::TidyAll::Zglob::DIRFLAG
ABresult
0X0
100
111
135 0 ▶ if ($rest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest) { } 0 0 0
136 0 return _rec($prefix, $rest);
137 } else {
138 0 return ($prefix);
139 }
140 # } elsif (my $string_portion = fixed_regexp_p($regexp)) { # /^path$/
141 # die "TBI";
142 # my $full = $prefix . $string_portion;
143 # if (-e $full && (!$non_leaf_p || -d $full)) {
144 # $proc->($full, $seed);
145 # } else {
146 # $proc;
147 # }
148 } else { # normal regexp
149 #dbg("normal regexp");
150 196 my $dir = do {
151 196 ▶ if (ref($node) eq 'SCALAR' && $$node eq 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $node eq 'SCALAR' and $$node eq 1) { } 43 153 196
elsif (ref $node eq 'SCALAR' and $$node eq 0) { } 0 153 153
Condition66%2/3
ref $node eq "SCALAR" and $$node eq 1
!ll&&!rl&&r
153043
MC/DC50%1/2
ref $node eq "SCALAR" and $$node eq 1
ref $node eq "SCALAR" $$node eq 1
Truth table66%2/3
A and B
A= ref $node eq "SCALAR"B= $$node eq 1
ABresult
0X0
100
111
152 43 $SEPCHAR
153 ▶ } elsif (ref($node) eq 'SCALAR' && $$node eq 0) {
Condition33%1/3
ref $node eq "SCALAR" and $$node eq 0
!ll&&!rl&&r
15300
MC/DC0%0/2
ref $node eq "SCALAR" and $$node eq 0
ref $node eq "SCALAR" $$node eq 0
Truth table33%1/3
A and B
A= ref $node eq "SCALAR"B= $$node eq 0
ABresult
0X0
100
111
154 0 '.';
155 } else {
156 153 $node;
157 }
158 };
159 #dbg("dir: $dir");
160 196 ▶ opendir my $dirh, $dir or do {
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dirh, $dir or do { return () } 196 0 196
161 #dbg("cannot open dir: $dir: $!");
162 0 return ();
163 };
164 196 my @ret;
165 196 ▶ while (defined(my $child = readdir($dirh))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $child = readdir $dirh)) 1774 196 1970
166 1774 ▶ next if $child eq '.' or $child eq '..';
Branch: 1 branch
BranchTrueFalseTotal
if $child eq "." or $child eq ".." 392 1382 1774
Condition100%3/3
$child eq "." or $child eq ".."
l!l&&r!l&&!r
1961961382
MC/DC100%2/2
$child eq "." or $child eq ".."
$child eq "." $child eq ".."
Truth table100%3/3
A or B
A= $child eq "."B= $child eq ".."
ABresult
1X1
011
000
167 1382 my $full;
168 #dbg("non-leaf: ", $non_leaf_p);
169 1382 ▶ if (($child =~ $regexp) && ($full = $prefix . $child) && (!$non_leaf_p || -d $full)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child =~ /$regexp/ and $full = $prefix . $child and !$non_leaf_p || -d $full) 180 1202 1382
Condition88%8/9
$child =~ /$regexp/ and $full = $prefix . $child and !$non_leaf_p || -d $full
!ll&&!rl&&r
111191180
$child =~ /$regexp/ and $full = $prefix . $child
!ll&&!rl&&r
11110271
not $non_leaf_p or -d $full
l!l&&r!l&&!r
7510591
MC/DC75%3/4
$child =~ /$regexp/ and $full = $prefix . $child and !$non_leaf_p || -d $full
$child =~ /$regexp/ $full = $prefix . $child not $non_leaf_p -d $full
Truth table80%4/5
A and B and not(C) or D
A= $child =~ /$regexp/B= $full = $prefix . $childC= not $non_leaf_pD= -d $full
ABCDresult
0XXX0
10XX0
11000
111X1
11011
170 #dbg("matched: ", $regexp, $child, $full);
171 180 ▶ if ($rest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest) { } 90 90 180
172 90 push @ret, _rec($full, $rest);
173 } else {
174 90 push @ret, $full;
175 }
176 # } else {
177 #dbg("Don't match: $child");
178 }
179 }
180 196 return @ret;
181 }
182 }
183  
184 43 ▶sub glob_prepare_pattern {
Subroutine glob_prepare_pattern: called CC=11 SCAR=30.0
Pod undocumented
185 43 my ($pattern) = @_;
186 43 my @path = split $SEPCHAR, $pattern;
187  
188 43 ▶ my $is_absolute = $path[0] eq '' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$path[0] eq '' ? : 43 0 43
189 43 ▶ if ($is_absolute) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_absolute) 43 0 43
190 43 shift @path;
191 }
192 43 ▶ if ($^O eq 'MSWin32' && $path[0] =~ /^[a-zA-Z]\:$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and $path[0] =~ /^[a-zA-Z]\:$/) 0 43 43
Condition33%1/3
$^O eq "MSWin32" and $path[0] =~ /^[a-zA-Z]\:$/
!ll&&!rl&&r
4300
MC/DC0%0/2
$^O eq "MSWin32" and $path[0] =~ /^[a-zA-Z]\:$/
$^O eq "MSWin32" $path[0] =~ /^[a-zA-Z]\:$/
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $path[0] =~ /^[a-zA-Z]\:$/
ABresult
0X0
100
111
193 0 $is_absolute = 1;
194 }
195  
196 @path = map {
197 43 ▶ if ($_ eq '**') {
Branch: 5 branches
BranchTrueFalseTotal
if ($_ eq '**') { } 33 139 172
elsif ($_ eq '') { } 0 139 139
elsif ($_ eq '.') { } 0 139 139
elsif ($_ eq '..') { } 0 139 139
elsif ($^O eq 'MSWin32' and $_ =~ /^[a-zA-Z]\:$/) { } 0 139 139
198 33 $DEEPFLAG
199 } elsif ($_ eq '') {
200 0 $DIRFLAG
201 } elsif ($_ eq '.') {
202 ()
203 0 } elsif ($_ eq '..') {
204 0 $PARENTFLAG
205 ▶ } elsif ($^O eq 'MSWin32' && $_ =~ '^[a-zA-Z]\:$') {
Condition33%1/3
$^O eq "MSWin32" and $_ =~ /^[a-zA-Z]\:$/
!ll&&!rl&&r
13900
MC/DC0%0/2
$^O eq "MSWin32" and $_ =~ /^[a-zA-Z]\:$/
$^O eq "MSWin32" $_ =~ /^[a-zA-Z]\:$/
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $_ =~ /^[a-zA-Z]\:$/
ABresult
0X0
100
111
206 0 \$_
207 } else {
208 139 glob_to_regex($_) # TODO: replace with original implementation?
209 }
210 } @path;
211  
212 43 return ( \$is_absolute, \@path );
213 }
214  
215 # this is not a private function. '**' was handled at glob_prepare_pattern() function.
216 139 ▶sub glob_to_regex {
Subroutine glob_to_regex: called CC=2 SCAR=7.1
Pod undocumented
217 139 my $glob = shift;
218 139 my $regex = glob_to_regex_string($glob);
219 139 ▶ return $NOCASE ? qr/^$regex$/i : qr/^$regex$/;
Branch: 1 branch
BranchTrueFalseTotal
$Code::TidyAll::Zglob::NOCASE ? : 0 139 139
220 }
221  
222 139 ▶sub glob_to_regex_string {
Subroutine glob_to_regex_string: called CC=33 SCAR=51.1
Pod undocumented
223 139 my $glob = shift;
224 139 my ($regex, $in_curlies, $escaping);
225 139 local $_;
226 139 my $first_byte = 1;
227 139 for ($glob =~ m/(.)/gs) {
228 1126 ▶ if ($first_byte) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_byte) 139 987 1126
229 139 ▶ if ($STRICT_LEADING_DOT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Code::TidyAll::Zglob::STRICT_LEADING_DOT) 139 0 139
230 139 ▶ $regex .= '(?=[^\.])' unless $_ eq '.';
Branch: 1 branch
BranchTrueFalseTotal
unless $_ eq "." 139 0 139
231 }
232 139 $first_byte = 0;
233 }
234 1126 ▶ if ($_ eq '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "/") 0 1126 1126
235 0 $first_byte = 1;
236 }
237 1126 ▶ if ($_ eq '.' || $_ eq '(' || $_ eq ')' || $_ eq '|' ||
Branch: 7 branches
BranchTrueFalseTotal
if ($_ eq '.' or $_ eq '(' or $_ eq ')' or $_ eq '|' or $_ eq '+' or $_ eq '^' or $_ eq '$' or $_ eq '@' or $_ eq '%') { } 32 1094 1126
elsif ($_ eq '*') { } 39 1055 1094
elsif ($_ eq '?') { } 0 1055 1055
elsif ($_ eq '{') { } 0 1055 1055
elsif ($_ eq '}' and $in_curlies) { } 0 1055 1055
elsif ($_ eq ',' and $in_curlies) { } 0 1055 1055
elsif ($_ eq '\\') { } 0 1055 1055
Condition66%16/24
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+" or $_ eq "^" or $_ eq "\$" or $_ eq "\@" or $_ eq "%"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+" or $_ eq "^" or $_ eq "\$" or $_ eq "\@"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+" or $_ eq "^" or $_ eq "\$"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+" or $_ eq "^"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "(" or $_ eq ")"
l!l&&r!l&&!r
3201094
$_ eq "." or $_ eq "("
l!l&&r!l&&!r
3201094
MC/DC11%1/9
$_ eq "." or $_ eq "(" or $_ eq ")" or $_ eq "|" or $_ eq "+" or $_ eq "^" or $_ eq "\$" or $_ eq "\@" or $_ eq "%"
$_ eq "." $_ eq "(" $_ eq ")" $_ eq "|" $_ eq "+" $_ eq "^" $_ eq "\$" $_ eq "\@" $_ eq "%"
Truth table20%2/10
A or B or C or D or E or F or G or H or I
A= $_ eq "."B= $_ eq "("C= $_ eq ")"D= $_ eq "|"E= $_ eq "+"F= $_ eq "^"G= $_ eq "\$"H= $_ eq "\@"I= $_ eq "%"
ABCDEFGHIresult
1XXXXXXXX1
01XXXXXXX1
001XXXXXX1
0001XXXXX1
00001XXXX1
000001XXX1
0000001XX1
00000001X1
0000000011
0000000000
238 $_ eq '+' || $_ eq '^' || $_ eq '$' || $_ eq '@' || $_ eq '%' ) {
239 32 $regex .= "\\$_";
240 }
241 elsif ($_ eq '*') {
242 39 ▶ $regex .= $escaping ? "\\*" :
Branch: 2 branches
BranchTrueFalseTotal
$escaping ? : 0 39 39
$Code::TidyAll::Zglob::STRICT_WILDCARD_SLASH ? : 39 0 39
243 $STRICT_WILDCARD_SLASH ? "[^/]*" : ".*";
244 }
245 elsif ($_ eq '?') {
246 0 ▶ $regex .= $escaping ? "\\?" :
Branch: 2 branches
BranchTrueFalseTotal
$escaping ? : 0 0 0
$Code::TidyAll::Zglob::STRICT_WILDCARD_SLASH ? : 0 0 0
247 $STRICT_WILDCARD_SLASH ? "[^/]" : ".";
248 }
249 elsif ($_ eq '{') {
250 0 ▶ $regex .= $escaping ? "\\{" : "(";
Branch: 1 branch
BranchTrueFalseTotal
$escaping ? : 0 0 0
251 0 ▶ ++$in_curlies unless $escaping;
Branch: 1 branch
BranchTrueFalseTotal
unless $escaping 0 0 0
252 }
253 ▶ elsif ($_ eq '}' && $in_curlies) {
Condition33%1/3
$_ eq "}" and $in_curlies
!ll&&!rl&&r
105500
MC/DC0%0/2
$_ eq "}" and $in_curlies
$_ eq "}" $in_curlies
Truth table33%1/3
A and B
A= $_ eq "}"B= $in_curlies
ABresult
0X0
100
111
254 0 ▶ $regex .= $escaping ? "}" : ")";
Branch: 1 branch
BranchTrueFalseTotal
$escaping ? : 0 0 0
255 0 ▶ --$in_curlies unless $escaping;
Branch: 1 branch
BranchTrueFalseTotal
unless $escaping 0 0 0
256 }
257 ▶ elsif ($_ eq ',' && $in_curlies) {
Condition33%1/3
$_ eq "," and $in_curlies
!ll&&!rl&&r
105500
MC/DC0%0/2
$_ eq "," and $in_curlies
$_ eq "," $in_curlies
Truth table33%1/3
A and B
A= $_ eq ","B= $in_curlies
ABresult
0X0
100
111
258 0 ▶ $regex .= $escaping ? "," : "|";
Branch: 1 branch
BranchTrueFalseTotal
$escaping ? : 0 0 0
259 }
260 elsif ($_ eq "\\") {
261 0 ▶ if ($escaping) {
Branch: 1 branch
BranchTrueFalseTotal
if ($escaping) { } 0 0 0
262 0 $regex .= "\\\\";
263 0 $escaping = 0;
264 }
265 else {
266 0 $escaping = 1;
267 }
268 0 next;
269 }
270 else {
271 1055 $regex .= $_;
272 1055 $escaping = 0;
273 }
274 1126 $escaping = 0;
275 }
276  
277 139 return $regex;
278 }
279  
280 58 1;
281  
282 # ABSTRACT: A borged copy of File::Zglob
283  
284 __END__
« lib/Code/TidyAll/Util/Zglob.pm ↑ Summary blib/lib/Code/TidyAll/SVN/Precommit.pm »