blib/lib/Code/TidyAll/Zglob.pm

filter: Statementstmt 63.5% 96 / 151 Branchbran 47.3% 53 / 112 Conditioncond 53.3% 40 / 75 MC/DCmcdc 17.5% 7 / 40 Subroutinesub 92.8% 13 / 14 Podpod 0.0% 0 / 7 totaltotal 52.3% 209 / 399 CC 83 SCAR 43.3
CC
83
Cov
56%
glob_to_regex_string
165.1
glob_fs_fold
44.6
dbg
34.6
CRAP 76.2
« blib/lib/Code/TidyAll/Util/Zglob.pm ↑ Summary blib/lib/Code/TidyAll/SVN/Precommit.pm »
1 package Code::TidyAll::Zglob;
2 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use warnings 'all', FATAL => 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 our $VERSION = '0.83';
6 35 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 35 our @EXPORT = qw(zglob);
9  
10 35 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 35 our $SEPCHAR = '/';
13 35 ▶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 35 35
14 35 our $DIRFLAG = \"DIR?";
15 35 our $DEEPFLAG = \"**";
16 35 our $PARENTFLAG = \"..";
17 35 our $DEBUG = 0;
18 35 our $STRICT_LEADING_DOT = 1;
19 35 our $STRICT_WILDCARD_SLASH = 1;
20  
21 sub zglob {
22 43 ▶ my ($pattern) = @_;
Subroutine zglob: called CC=2 SCAR=8.7
Pod undocumented
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;
28 } else {
29 43 $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 sub dbg(@) {
39 392 ▶ return unless $DEBUG;
Subroutine dbg: called CC=6 SCAR=35.4
Pod undocumented
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 sub _recstar {
64 48 ▶ my ($node, $matcher) = @_;
Subroutine _recstar: called CC=1 SCAR=0.0
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 sub _rec {
76 181 ▶ my ($node, $matcher) = @_;
Subroutine _rec: called CC=11 SCAR=34.6
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 sub fixed_regexp_p {
106 0 ▶ return undef;
Subroutine fixed_regexp_p: not called CC=1 SCAR=6.9
Pod undocumented
107 0 die "TBI"
108 }
109  
110 # returns arrayref of seeds.
111 sub glob_fs_fold {
112 196 ▶ my ($node, $regexp, $non_leaf_p, $rest) = @_;
Subroutine glob_fs_fold: called CC=24 SCAR=38.0
Pod undocumented
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 () } 0 196 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
1111157114
$child =~ /$regexp/ and $full = $prefix . $child
!ll&&!rl&&r
11110271
not $non_leaf_p or -d $full
l!l&&r!l&&!r
7510591
MC/DC50%2/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 table60%3/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 sub glob_prepare_pattern {
185 43 ▶ my ($pattern) = @_;
Subroutine glob_prepare_pattern: called CC=11 SCAR=30.0
Pod undocumented
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 sub glob_to_regex {
217 139 ▶ my $glob = shift;
Subroutine glob_to_regex: called CC=2 SCAR=7.1
Pod undocumented
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 sub glob_to_regex_string {
223 139 ▶ my $glob = shift;
Subroutine glob_to_regex_string: called CC=33 SCAR=51.1
Pod undocumented
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 35 1;
281  
282 # ABSTRACT: A borged copy of File::Zglob
283  
284 __END__
285  
286 =pod
287  
288 =encoding UTF-8
289  
290 =head1 NAME
291  
292 Code::TidyAll::Zglob - A borged copy of File::Zglob
293  
294 =head1 VERSION
295  
296 version 0.83
297  
298 =head1 DESCRIPTION
299  
300 File::Zglob has not been installable under Perl 5.26 and this has been an open
301 issue for 8+ months
302 (https://rt.cpan.org/Public/Bug/Display.html?id=120445). This module will go
303 away once File::Zglob is installable.
304  
305 =head1 LICENSE
306  
307 Copyright (C) Tokuhiro Matsuno
308  
309 This library is free software; you can redistribute it and/or modify
310 it under the same terms as Perl itself.
311  
312 =head1 SUPPORT
313  
314 Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
315  
316 =head1 SOURCE
317  
318 The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
319  
320 =head1 AUTHORS
321  
322 =over 4
323  
324 =item *
325  
326 Jonathan Swartz <swartz@pobox.com>
327  
328 =item *
329  
330 Dave Rolsky <autarch@urth.org>
331  
332 =back
333  
334 =head1 COPYRIGHT AND LICENSE
335  
336 This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
337  
338 This is free software; you can redistribute it and/or modify it under
339 the same terms as the Perl 5 programming language system itself.
340  
341 The full text of the license can be found in the
342 F<LICENSE> file included with this distribution.
343  
344 =cut
« blib/lib/Code/TidyAll/Util/Zglob.pm ↑ Summary blib/lib/Code/TidyAll/SVN/Precommit.pm »