line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This is a copy of Text::Glob, modified to support "**/" |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
package Code::TidyAll::Util::Zglob; |
4
|
|
|
|
|
|
|
|
5
|
27
|
|
|
27
|
|
198
|
use strict; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
801
|
|
6
|
27
|
|
|
27
|
|
160
|
use warnings; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
1171
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.83'; |
9
|
|
|
|
|
|
|
|
10
|
27
|
|
|
27
|
|
194
|
use Exporter qw(import); |
|
27
|
|
|
|
|
71
|
|
|
27
|
|
|
|
|
2216
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( zglobs_to_regex zglob_to_regex ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $strict_leading_dot = 1; |
15
|
|
|
|
|
|
|
our $strict_wildcard_slash = 1; |
16
|
|
|
|
|
|
|
|
17
|
27
|
|
|
27
|
|
218
|
use constant debug => 0; |
|
27
|
|
|
|
|
72
|
|
|
27
|
|
|
|
|
18423
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub zglobs_to_regex { |
20
|
132
|
|
|
132
|
0
|
5838
|
my @globs = @_; |
21
|
|
|
|
|
|
|
return @globs |
22
|
132
|
100
|
|
|
|
1657
|
? do { |
23
|
61
|
|
|
|
|
132
|
my $re = join( '|', map { "(?:" . zglob_to_regex($_) . ")" } @globs ); |
|
61
|
|
|
|
|
184
|
|
24
|
61
|
|
|
|
|
2323
|
qr/$re/; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
: qr/(?!)/; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub zglob_to_regex { |
30
|
64
|
|
|
64
|
0
|
7891
|
my $glob = shift; |
31
|
64
|
|
|
|
|
171
|
my $regex = zglob_to_regex_string($glob); |
32
|
64
|
|
|
|
|
2140
|
return qr/^$regex$/; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub zglob_to_regex_string { |
36
|
64
|
|
|
64
|
0
|
121
|
my $glob = shift; |
37
|
64
|
|
|
|
|
129
|
my ( $regex, $in_curlies, $escaping ); |
38
|
64
|
|
|
|
|
103
|
local $_; |
39
|
64
|
|
|
|
|
110
|
my $first_byte = 1; |
40
|
64
|
|
|
|
|
227
|
$glob =~ s/\*\*\//\cZ/g; # convert **/ to single character |
41
|
64
|
|
|
|
|
496
|
for ( $glob =~ m/(.)/gs ) { |
42
|
400
|
100
|
|
|
|
738
|
if ($first_byte) { |
43
|
81
|
50
|
|
|
|
560
|
if ($strict_leading_dot) { |
44
|
81
|
50
|
|
|
|
275
|
$regex .= '(?=[^\.])' unless $_ eq '.'; |
45
|
|
|
|
|
|
|
} |
46
|
81
|
|
|
|
|
137
|
$first_byte = 0; |
47
|
|
|
|
|
|
|
} |
48
|
400
|
100
|
|
|
|
729
|
if ( $_ eq '/' ) { |
49
|
17
|
|
|
|
|
40
|
$first_byte = 1; |
50
|
|
|
|
|
|
|
} |
51
|
400
|
100
|
66
|
|
|
5044
|
if ( $_ eq '.' |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
52
|
|
|
|
|
|
|
|| $_ eq '(' |
53
|
|
|
|
|
|
|
|| $_ eq ')' |
54
|
|
|
|
|
|
|
|| $_ eq '|' |
55
|
|
|
|
|
|
|
|| $_ eq '+' |
56
|
|
|
|
|
|
|
|| $_ eq '^' |
57
|
|
|
|
|
|
|
|| $_ eq '$' |
58
|
|
|
|
|
|
|
|| $_ eq '@' |
59
|
|
|
|
|
|
|
|| $_ eq '%' ) { |
60
|
19
|
|
|
|
|
41
|
$regex .= "\\$_"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ( $_ eq "\cZ" ) { # handle **/ - if escaping, only escape first * |
63
|
23
|
0
|
|
|
|
61
|
$regex |
|
|
50
|
|
|
|
|
|
64
|
|
|
|
|
|
|
.= $escaping |
65
|
|
|
|
|
|
|
? ( "\\*" . ( $strict_wildcard_slash ? "[^/]*" : ".*" ) . "/" ) |
66
|
|
|
|
|
|
|
: ".*"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( $_ eq '*' ) { |
69
|
64
|
50
|
|
|
|
217
|
$regex |
|
|
50
|
|
|
|
|
|
70
|
|
|
|
|
|
|
.= $escaping ? "\\*" |
71
|
|
|
|
|
|
|
: $strict_wildcard_slash ? "[^/]*" |
72
|
|
|
|
|
|
|
: ".*"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ( $_ eq '?' ) { |
75
|
0
|
0
|
|
|
|
0
|
$regex |
|
|
0
|
|
|
|
|
|
76
|
|
|
|
|
|
|
.= $escaping ? "\\?" |
77
|
|
|
|
|
|
|
: $strict_wildcard_slash ? "[^/]" |
78
|
|
|
|
|
|
|
: "."; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( $_ eq '{' ) { |
81
|
0
|
0
|
|
|
|
0
|
$regex .= $escaping ? "\\{" : "("; |
82
|
0
|
0
|
|
|
|
0
|
++$in_curlies unless $escaping; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
elsif ( $_ eq '}' && $in_curlies ) { |
85
|
0
|
0
|
|
|
|
0
|
$regex .= $escaping ? "}" : ")"; |
86
|
0
|
0
|
|
|
|
0
|
--$in_curlies unless $escaping; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
elsif ( $_ eq ',' && $in_curlies ) { |
89
|
0
|
0
|
|
|
|
0
|
$regex .= $escaping ? "," : "|"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
elsif ( $_ eq "\\" ) { |
92
|
0
|
0
|
|
|
|
0
|
if ($escaping) { |
93
|
0
|
|
|
|
|
0
|
$regex .= "\\\\"; |
94
|
0
|
|
|
|
|
0
|
$escaping = 0; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
0
|
|
|
|
|
0
|
$escaping = 1; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
0
|
next; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
294
|
|
|
|
|
404
|
$regex .= $_; |
103
|
294
|
|
|
|
|
379
|
$escaping = 0; |
104
|
|
|
|
|
|
|
} |
105
|
400
|
|
|
|
|
600
|
$escaping = 0; |
106
|
|
|
|
|
|
|
} |
107
|
64
|
|
|
|
|
136
|
print "# $glob $regex\n" if debug; |
108
|
|
|
|
|
|
|
|
109
|
64
|
|
|
|
|
184
|
return $regex; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# ABSTRACT: Test::Glob hacked up to support "**/*" |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding UTF-8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Code::TidyAll::Util::Zglob - Test::Glob hacked up to support "**/*" |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
version 0.83 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SUPPORT |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SOURCE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHORS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Jonathan Swartz <swartz@pobox.com> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2011 - 2022 by Jonathan Swartz. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The full text of the license can be found in the |
160
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |