Elatin1.pm

filter: Statementstmt 43.6% 1312 / 3009 Branchbran 40.7% 1063 / 2608 Conditioncond 31.0% 115 / 370 MC/DCmcdc 15.9% 35 / 220 Subroutinesub 68.9% 111 / 161 Podpod 4.6% 3 / 64 totaltotal 41.0% 2639 / 6432 CC 1475 SCAR 97.8
CC
1475
Cov
42%
escape_token
55669.4
e_s1
3320.4
e_split
2070.1
CRAP 17630.0
↑ Summary Latin1.pm »
1 package Elatin1;
2 425 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 425 ▶BEGIN { $INC{'warnings.pm'} = '' if $] < 5.006 } use warnings;
Subroutine BEGIN: called CC=2 SCAR=7.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.006" 0 424 424
4 ######################################################################
5 #
6 # Elatin1 - Run-time routines for Latin1.pm
7 #
8 # http://search.cpan.org/dist/Char-Latin1/
9 #
10 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
11 ######################################################################
12  
13 425 ▶use 5.00503; # Galapagos Consensus 1998 for primetools
Subroutine BEGIN: called CC=1 SCAR=0.0
14 # use 5.008001; # Lancaster Consensus 2013 for toolchains
15  
16 # 12.3. Delaying use Until Runtime
17 # in Chapter 12. Packages, Libraries, and Modules
18 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
19 # (and so on)
20  
21 # Version numbers should be boring
22 # http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
23 # For the impatient, the disinterested or those who just want to follow
24 # a recipe, my advice for all modules is this:
25 # our $VERSION = "0.001"; # or "0.001_001" for a dev release
26 # $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1'
27  
28 425 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 424 $VERSION = '1.22';
30 424 $VERSION = $VERSION;
31  
32 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
33 425 ▶ if ($^X =~ / jperl /oxmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^X =~ / jperl /imosx) 0 424 424
34 1 die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n";
35 }
36 425 if (CORE::ord('A') == 193) {
37 die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n";
38 }
39 424 if (CORE::ord('A') != 0x41) {
40 die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n";
41 }
42 }
43  
44 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=9.5
45  
46 # instead of utf8.pm
47 424 ▶ CORE::eval q{
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
48 no warnings qw(redefine);
49 *utf8::upgrade = sub { CORE::length $_[0] };
50 *utf8::downgrade = sub { 1 };
51 *utf8::encode = sub { };
52 *utf8::decode = sub { 1 };
53 *utf8::is_utf8 = sub { };
54 *utf8::valid = sub { 1 };
55 };
56 424 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 424 424
57 0 ▶ *utf8::upgrade = sub { CORE::length $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 ▶ *utf8::downgrade = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 ▶ *utf8::encode = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ *utf8::decode = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ *utf8::is_utf8 = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 ▶ *utf8::valid = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 }
64 }
65  
66 # instead of Symbol.pm
67 BEGIN {
68 0 ▶ sub gensym () {
Subroutine gensym: not called CC=2 SCAR=17.9
Pod undocumented
69 0 ▶ if ($] < 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.006) { } 0 0 0
70 0 return \do { local *_ };
71 }
72 else {
73 0 return undef;
74 }
75 }
76  
77 20 ▶ sub qualify ($$) {
Subroutine qualify: called CC=8 SCAR=28.9
Pod undocumented
78 20 my($name) = @_;
79  
80 20 ▶ if (ref $name) {
Branch: 7 branches
BranchTrueFalseTotal
if (ref $name) { } 5 15 20
elsif (&Elatin1::index($name, '::') >= 0) { } 0 15 15
elsif (&Elatin1::index($name, q[']) >= 0) { } 0 15 15
elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) { } 0 15 15
elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) { } 0 15 15
elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) { } 0 15 15
elsif (defined $_[1]) { } 15 0 15
81 5 return $name;
82 }
83 elsif (Elatin1::index($name,'::') >= 0) {
84 0 return $name;
85 }
86 elsif (Elatin1::index($name,"'") >= 0) {
87 0 return $name;
88 }
89  
90 # special character, "^xyz"
91 elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) {
92  
93 # RGS 2001-11-05 : translate leading ^X to control-char
94 0 $name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee;
95 0 return 'main::' . $name;
96 }
97  
98 # Global names
99 elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) {
100 0 return 'main::' . $name;
101 }
102  
103 # or other
104 elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) {
105 0 return 'main::' . $name;
106 }
107  
108 elsif (defined $_[1]) {
109 15 return $_[1] . '::' . $name;
110 }
111 else {
112 0 return (caller)[0] . '::' . $name;
113 }
114 }
115  
116 20 ▶ sub qualify_to_ref ($;$) {
Subroutine qualify_to_ref: called CC=2 SCAR=7.2
Pod undocumented
117 20 ▶ if (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) { } 20 0 20
118 424 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
119 20 return \*{ qualify $_[0], $_[1] };
120 }
121 else {
122 424 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
123 0 return \*{ qualify $_[0], (caller)[0] };
124 }
125 }
126 }
127  
128 # P.714 29.2.39. flock
129 # in Chapter 29: Functions
130 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
131  
132 # P.863 flock
133 # in Chapter 27: Functions
134 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
135  
136 sub LOCK_SH() {1}
137 sub LOCK_EX() {2}
138 sub LOCK_UN() {8}
139 sub LOCK_NB() {4}
140  
141 # instead of Carp.pm
142 sub carp;
143 sub croak;
144 sub cluck;
145 sub confess;
146  
147 # 6.18. Matching Multiple-Byte Characters
148 # in Chapter 6. Pattern Matching
149 # of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
150 # (and so on)
151  
152 # regexp of character
153 424 my $your_char = q{[\x00-\xFF]};
154 424 ▶use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
155 424 ▶use vars qw($q_char); $q_char = qr/$your_char/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
156  
157 #
158 # Latin-1 character range per length
159 #
160 424 my %range_tr = ();
161  
162 #
163 # Latin-1 case conversion
164 #
165 424 my %lc = ();
166 424 @lc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} =
167 qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);
168 424 my %uc = ();
169 424 @uc{qw(a b c d e f g h i j k l m n o p q r s t u v w x y z)} =
170 qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
171 424 my %fc = ();
172 424 @fc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} =
173 qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);
174  
175 424 ▶if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { __PACKAGE__ =~ / \b Elatin1 \z/mosx }) { } 424 0 424
176 }
177  
178 elsif (__PACKAGE__ =~ / \b Elatin1 \z/oxms) {
179 424 %range_tr = (
180 1 => [ [0x00..0xFF],
181 ],
182 );
183  
184 424 %lc = (%lc,
185 "\xC0" => "\xE0", # LATIN LETTER A WITH GRAVE
186 "\xC1" => "\xE1", # LATIN LETTER A WITH ACUTE
187 "\xC2" => "\xE2", # LATIN LETTER A WITH CIRCUMFLEX
188 "\xC3" => "\xE3", # LATIN LETTER A WITH TILDE
189 "\xC4" => "\xE4", # LATIN LETTER A WITH DIAERESIS
190 "\xC5" => "\xE5", # LATIN LETTER A WITH RING ABOVE
191 "\xC6" => "\xE6", # LATIN LETTER AE
192 "\xC7" => "\xE7", # LATIN LETTER C WITH CEDILLA
193 "\xC8" => "\xE8", # LATIN LETTER E WITH GRAVE
194 "\xC9" => "\xE9", # LATIN LETTER E WITH ACUTE
195 "\xCA" => "\xEA", # LATIN LETTER E WITH CIRCUMFLEX
196 "\xCB" => "\xEB", # LATIN LETTER E WITH DIAERESIS
197 "\xCC" => "\xEC", # LATIN LETTER I WITH GRAVE
198 "\xCD" => "\xED", # LATIN LETTER I WITH ACUTE
199 "\xCE" => "\xEE", # LATIN LETTER I WITH CIRCUMFLEX
200 "\xCF" => "\xEF", # LATIN LETTER I WITH DIAERESIS
201 "\xD0" => "\xF0", # LATIN LETTER ETH (Icelandic)
202 "\xD1" => "\xF1", # LATIN LETTER N WITH TILDE
203 "\xD2" => "\xF2", # LATIN LETTER O WITH GRAVE
204 "\xD3" => "\xF3", # LATIN LETTER O WITH ACUTE
205 "\xD4" => "\xF4", # LATIN LETTER O WITH CIRCUMFLEX
206 "\xD5" => "\xF5", # LATIN LETTER O WITH TILDE
207 "\xD6" => "\xF6", # LATIN LETTER O WITH DIAERESIS
208 "\xD8" => "\xF8", # LATIN LETTER O WITH STROKE
209 "\xD9" => "\xF9", # LATIN LETTER U WITH GRAVE
210 "\xDA" => "\xFA", # LATIN LETTER U WITH ACUTE
211 "\xDB" => "\xFB", # LATIN LETTER U WITH CIRCUMFLEX
212 "\xDC" => "\xFC", # LATIN LETTER U WITH DIAERESIS
213 "\xDD" => "\xFD", # LATIN LETTER Y WITH ACUTE
214 "\xDE" => "\xFE", # LATIN LETTER THORN (Icelandic)
215 );
216  
217 424 %uc = (%uc,
218 "\xE0" => "\xC0", # LATIN LETTER A WITH GRAVE
219 "\xE1" => "\xC1", # LATIN LETTER A WITH ACUTE
220 "\xE2" => "\xC2", # LATIN LETTER A WITH CIRCUMFLEX
221 "\xE3" => "\xC3", # LATIN LETTER A WITH TILDE
222 "\xE4" => "\xC4", # LATIN LETTER A WITH DIAERESIS
223 "\xE5" => "\xC5", # LATIN LETTER A WITH RING ABOVE
224 "\xE6" => "\xC6", # LATIN LETTER AE
225 "\xE7" => "\xC7", # LATIN LETTER C WITH CEDILLA
226 "\xE8" => "\xC8", # LATIN LETTER E WITH GRAVE
227 "\xE9" => "\xC9", # LATIN LETTER E WITH ACUTE
228 "\xEA" => "\xCA", # LATIN LETTER E WITH CIRCUMFLEX
229 "\xEB" => "\xCB", # LATIN LETTER E WITH DIAERESIS
230 "\xEC" => "\xCC", # LATIN LETTER I WITH GRAVE
231 "\xED" => "\xCD", # LATIN LETTER I WITH ACUTE
232 "\xEE" => "\xCE", # LATIN LETTER I WITH CIRCUMFLEX
233 "\xEF" => "\xCF", # LATIN LETTER I WITH DIAERESIS
234 "\xF0" => "\xD0", # LATIN LETTER ETH (Icelandic)
235 "\xF1" => "\xD1", # LATIN LETTER N WITH TILDE
236 "\xF2" => "\xD2", # LATIN LETTER O WITH GRAVE
237 "\xF3" => "\xD3", # LATIN LETTER O WITH ACUTE
238 "\xF4" => "\xD4", # LATIN LETTER O WITH CIRCUMFLEX
239 "\xF5" => "\xD5", # LATIN LETTER O WITH TILDE
240 "\xF6" => "\xD6", # LATIN LETTER O WITH DIAERESIS
241 "\xF8" => "\xD8", # LATIN LETTER O WITH STROKE
242 "\xF9" => "\xD9", # LATIN LETTER U WITH GRAVE
243 "\xFA" => "\xDA", # LATIN LETTER U WITH ACUTE
244 "\xFB" => "\xDB", # LATIN LETTER U WITH CIRCUMFLEX
245 "\xFC" => "\xDC", # LATIN LETTER U WITH DIAERESIS
246 "\xFD" => "\xDD", # LATIN LETTER Y WITH ACUTE
247 "\xFE" => "\xDE", # LATIN LETTER THORN (Icelandic)
248 );
249  
250 424 %fc = (%fc,
251 "\xC0" => "\xE0", # LATIN CAPITAL LETTER A WITH GRAVE --> LATIN SMALL LETTER A WITH GRAVE
252 "\xC1" => "\xE1", # LATIN CAPITAL LETTER A WITH ACUTE --> LATIN SMALL LETTER A WITH ACUTE
253 "\xC2" => "\xE2", # LATIN CAPITAL LETTER A WITH CIRCUMFLEX --> LATIN SMALL LETTER A WITH CIRCUMFLEX
254 "\xC3" => "\xE3", # LATIN CAPITAL LETTER A WITH TILDE --> LATIN SMALL LETTER A WITH TILDE
255 "\xC4" => "\xE4", # LATIN CAPITAL LETTER A WITH DIAERESIS --> LATIN SMALL LETTER A WITH DIAERESIS
256 "\xC5" => "\xE5", # LATIN CAPITAL LETTER A WITH RING ABOVE --> LATIN SMALL LETTER A WITH RING ABOVE
257 "\xC6" => "\xE6", # LATIN CAPITAL LETTER AE --> LATIN SMALL LETTER AE
258 "\xC7" => "\xE7", # LATIN CAPITAL LETTER C WITH CEDILLA --> LATIN SMALL LETTER C WITH CEDILLA
259 "\xC8" => "\xE8", # LATIN CAPITAL LETTER E WITH GRAVE --> LATIN SMALL LETTER E WITH GRAVE
260 "\xC9" => "\xE9", # LATIN CAPITAL LETTER E WITH ACUTE --> LATIN SMALL LETTER E WITH ACUTE
261 "\xCA" => "\xEA", # LATIN CAPITAL LETTER E WITH CIRCUMFLEX --> LATIN SMALL LETTER E WITH CIRCUMFLEX
262 "\xCB" => "\xEB", # LATIN CAPITAL LETTER E WITH DIAERESIS --> LATIN SMALL LETTER E WITH DIAERESIS
263 "\xCC" => "\xEC", # LATIN CAPITAL LETTER I WITH GRAVE --> LATIN SMALL LETTER I WITH GRAVE
264 "\xCD" => "\xED", # LATIN CAPITAL LETTER I WITH ACUTE --> LATIN SMALL LETTER I WITH ACUTE
265 "\xCE" => "\xEE", # LATIN CAPITAL LETTER I WITH CIRCUMFLEX --> LATIN SMALL LETTER I WITH CIRCUMFLEX
266 "\xCF" => "\xEF", # LATIN CAPITAL LETTER I WITH DIAERESIS --> LATIN SMALL LETTER I WITH DIAERESIS
267 "\xD0" => "\xF0", # LATIN CAPITAL LETTER ETH --> LATIN SMALL LETTER ETH
268 "\xD1" => "\xF1", # LATIN CAPITAL LETTER N WITH TILDE --> LATIN SMALL LETTER N WITH TILDE
269 "\xD2" => "\xF2", # LATIN CAPITAL LETTER O WITH GRAVE --> LATIN SMALL LETTER O WITH GRAVE
270 "\xD3" => "\xF3", # LATIN CAPITAL LETTER O WITH ACUTE --> LATIN SMALL LETTER O WITH ACUTE
271 "\xD4" => "\xF4", # LATIN CAPITAL LETTER O WITH CIRCUMFLEX --> LATIN SMALL LETTER O WITH CIRCUMFLEX
272 "\xD5" => "\xF5", # LATIN CAPITAL LETTER O WITH TILDE --> LATIN SMALL LETTER O WITH TILDE
273 "\xD6" => "\xF6", # LATIN CAPITAL LETTER O WITH DIAERESIS --> LATIN SMALL LETTER O WITH DIAERESIS
274 "\xD8" => "\xF8", # LATIN CAPITAL LETTER O WITH STROKE --> LATIN SMALL LETTER O WITH STROKE
275 "\xD9" => "\xF9", # LATIN CAPITAL LETTER U WITH GRAVE --> LATIN SMALL LETTER U WITH GRAVE
276 "\xDA" => "\xFA", # LATIN CAPITAL LETTER U WITH ACUTE --> LATIN SMALL LETTER U WITH ACUTE
277 "\xDB" => "\xFB", # LATIN CAPITAL LETTER U WITH CIRCUMFLEX --> LATIN SMALL LETTER U WITH CIRCUMFLEX
278 "\xDC" => "\xFC", # LATIN CAPITAL LETTER U WITH DIAERESIS --> LATIN SMALL LETTER U WITH DIAERESIS
279 "\xDD" => "\xFD", # LATIN CAPITAL LETTER Y WITH ACUTE --> LATIN SMALL LETTER Y WITH ACUTE
280 "\xDE" => "\xFE", # LATIN CAPITAL LETTER THORN --> LATIN SMALL LETTER THORN
281 "\xDF" => "\x73\x73", # LATIN SMALL LETTER SHARP S --> LATIN SMALL LETTER S, LATIN SMALL LETTER S
282 );
283 }
284  
285 else {
286 0 croak "Don't know my package name '@{[__PACKAGE__]}'";
287 }
288  
289 #
290 # @ARGV wildcard globbing
291 #
292 212 ▶sub import {
Subroutine import: called CC=7 SCAR=28.3
293  
294 212 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) 0 212 212
295 0 my @argv = ();
296 0 for (@ARGV) {
297  
298 # has space
299 0 ▶ if (/\A (?:$q_char)*? [ ] /oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\A (?:$Elatin1::q_char)*? [ ] /mosx) { } 0 0 0
elsif (/\A (?:$Elatin1::q_char)*? [*?] /mosx) { } 0 0 0
300 0 ▶ if (my @glob = Elatin1::glob(qq{"$_"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Elatin1::glob(qq["$_"])) { } 0 0 0
301 0 push @argv, @glob;
302 }
303 else {
304 0 push @argv, $_;
305 }
306 }
307  
308 # has wildcard metachar
309 elsif (/\A (?:$q_char)*? [*?] /oxms) {
310 0 ▶ if (my @glob = Elatin1::glob($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Elatin1::glob($_)) { } 0 0 0
311 0 push @argv, @glob;
312 }
313 else {
314 0 push @argv, $_;
315 }
316 }
317  
318 # no wildcard globbing
319 else {
320 0 push @argv, $_;
321 }
322 }
323 0 @ARGV = @argv;
324 }
325  
326 212 *Char::ord = \&Latin1::ord;
327 212 *Char::ord_ = \&Latin1::ord_;
328 212 *Char::reverse = \&Latin1::reverse;
329 212 *Char::getc = \&Latin1::getc;
330 212 *Char::length = \&Latin1::length;
331 212 *Char::substr = \&Latin1::substr;
332 212 *Char::index = \&Latin1::index;
333 212 *Char::rindex = \&Latin1::rindex;
334 212 *Char::eval = \&Latin1::eval;
335 212 *Char::escape = \&Latin1::escape;
336 212 *Char::escape_token = \&Latin1::escape_token;
337 212 *Char::escape_script = \&Latin1::escape_script;
338 }
339  
340 # P.230 Care with Prototypes
341 # in Chapter 6: Subroutines
342 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
343 #
344 # If you aren't careful, you can get yourself into trouble with prototypes.
345 # But if you are careful, you can do a lot of neat things with them. This is
346 # all very powerful, of course, and should only be used in moderation to make
347 # the world a better place.
348  
349 # P.332 Care with Prototypes
350 # in Chapter 7: Subroutines
351 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
352 #
353 # If you aren't careful, you can get yourself into trouble with prototypes.
354 # But if you are careful, you can do a lot of neat things with them. This is
355 # all very powerful, of course, and should only be used in moderation to make
356 # the world a better place.
357  
358 #
359 # Prototypes of subroutines
360 #
361 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
362 sub Elatin1::split(;$$$);
363 sub Elatin1::tr($$$$;$);
364 sub Elatin1::chop(@);
365 sub Elatin1::index($$;$);
366 sub Elatin1::rindex($$;$);
367 sub Elatin1::lcfirst(@);
368 sub Elatin1::lcfirst_();
369 sub Elatin1::lc(@);
370 sub Elatin1::lc_();
371 sub Elatin1::ucfirst(@);
372 sub Elatin1::ucfirst_();
373 sub Elatin1::uc(@);
374 sub Elatin1::uc_();
375 sub Elatin1::fc(@);
376 sub Elatin1::fc_();
377 sub Elatin1::ignorecase;
378 sub Elatin1::classic_character_class;
379 sub Elatin1::capture;
380 sub Elatin1::chr(;$);
381 sub Elatin1::chr_();
382 sub Elatin1::glob($);
383 sub Elatin1::glob_();
384  
385 sub Latin1::ord(;$);
386 sub Latin1::ord_();
387 sub Latin1::reverse(@);
388 sub Latin1::getc(;*@);
389 sub Latin1::length(;$);
390 sub Latin1::substr($$;$$);
391 sub Latin1::index($$;$);
392 sub Latin1::rindex($$;$);
393 sub Latin1::escape(;$);
394  
395 #
396 # Regexp work
397 #
398 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
399 $re_a
400 $re_t
401 $re_n
402 $re_r
403 424 );
404  
405 #
406 # Character class
407 #
408 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
409 $dot
410 $dot_s
411 $eD
412 $eS
413 $eW
414 $eH
415 $eV
416 $eR
417 $eN
418 $not_alnum
419 $not_alpha
420 $not_ascii
421 $not_blank
422 $not_cntrl
423 $not_digit
424 $not_graph
425 $not_lower
426 $not_lower_i
427 $not_print
428 $not_punct
429 $not_space
430 $not_upper
431 $not_upper_i
432 $not_word
433 $not_xdigit
434 $eb
435 $eB
436 424 );
437  
438 424 ${Elatin1::dot} = qr{(?>[^\x0A])};
439 424 ${Elatin1::dot_s} = qr{(?>[\x00-\xFF])};
440 424 ${Elatin1::eD} = qr{(?>[^0-9])};
441  
442 # Vertical tabs are now whitespace
443 # \s in a regex now matches a vertical tab in all circumstances.
444 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
445 # ${Elatin1::eS} = qr{(?>[^\x09\x0A \x0C\x0D\x20])};
446 # ${Elatin1::eS} = qr{(?>[^\x09\x0A\x0B\x0C\x0D\x20])};
447 424 ${Elatin1::eS} = qr{(?>[^\s])};
448  
449 424 ${Elatin1::eW} = qr{(?>[^0-9A-Z_a-z])};
450 424 ${Elatin1::eH} = qr{(?>[^\x09\x20])};
451 424 ${Elatin1::eV} = qr{(?>[^\x0A\x0B\x0C\x0D])};
452 424 ${Elatin1::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])};
453 424 ${Elatin1::eN} = qr{(?>[^\x0A])};
454 424 ${Elatin1::not_alnum} = qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
455 424 ${Elatin1::not_alpha} = qr{(?>[^\x41-\x5A\x61-\x7A])};
456 424 ${Elatin1::not_ascii} = qr{(?>[^\x00-\x7F])};
457 424 ${Elatin1::not_blank} = qr{(?>[^\x09\x20])};
458 424 ${Elatin1::not_cntrl} = qr{(?>[^\x00-\x1F\x7F])};
459 424 ${Elatin1::not_digit} = qr{(?>[^\x30-\x39])};
460 424 ${Elatin1::not_graph} = qr{(?>[^\x21-\x7F])};
461 424 ${Elatin1::not_lower} = qr{(?>[^\x61-\x7A])};
462 424 ${Elatin1::not_lower_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
463 # ${Elatin1::not_lower_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
464 424 ${Elatin1::not_print} = qr{(?>[^\x20-\x7F])};
465 424 ${Elatin1::not_punct} = qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
466 424 ${Elatin1::not_space} = qr{(?>[^\s\x0B])};
467 424 ${Elatin1::not_upper} = qr{(?>[^\x41-\x5A])};
468 424 ${Elatin1::not_upper_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
469 # ${Elatin1::not_upper_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
470 424 ${Elatin1::not_word} = qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
471 424 ${Elatin1::not_xdigit} = qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
472 424 ${Elatin1::eb} = qr{(?:\A(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[0-9A-Z_a-z])|(?<=[0-9A-Z_a-z])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]|\z))};
473 424 ${Elatin1::eB} = qr{(?:(?<=[0-9A-Z_a-z])(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]))};
474  
475 # avoid: Name "Elatin1::foo" used only once: possible typo at here.
476 424 ${Elatin1::dot} = ${Elatin1::dot};
477 424 ${Elatin1::dot_s} = ${Elatin1::dot_s};
478 424 ${Elatin1::eD} = ${Elatin1::eD};
479 424 ${Elatin1::eS} = ${Elatin1::eS};
480 424 ${Elatin1::eW} = ${Elatin1::eW};
481 424 ${Elatin1::eH} = ${Elatin1::eH};
482 424 ${Elatin1::eV} = ${Elatin1::eV};
483 424 ${Elatin1::eR} = ${Elatin1::eR};
484 424 ${Elatin1::eN} = ${Elatin1::eN};
485 424 ${Elatin1::not_alnum} = ${Elatin1::not_alnum};
486 424 ${Elatin1::not_alpha} = ${Elatin1::not_alpha};
487 424 ${Elatin1::not_ascii} = ${Elatin1::not_ascii};
488 424 ${Elatin1::not_blank} = ${Elatin1::not_blank};
489 424 ${Elatin1::not_cntrl} = ${Elatin1::not_cntrl};
490 424 ${Elatin1::not_digit} = ${Elatin1::not_digit};
491 424 ${Elatin1::not_graph} = ${Elatin1::not_graph};
492 424 ${Elatin1::not_lower} = ${Elatin1::not_lower};
493 424 ${Elatin1::not_lower_i} = ${Elatin1::not_lower_i};
494 424 ${Elatin1::not_print} = ${Elatin1::not_print};
495 424 ${Elatin1::not_punct} = ${Elatin1::not_punct};
496 424 ${Elatin1::not_space} = ${Elatin1::not_space};
497 424 ${Elatin1::not_upper} = ${Elatin1::not_upper};
498 424 ${Elatin1::not_upper_i} = ${Elatin1::not_upper_i};
499 424 ${Elatin1::not_word} = ${Elatin1::not_word};
500 424 ${Elatin1::not_xdigit} = ${Elatin1::not_xdigit};
501 424 ${Elatin1::eb} = ${Elatin1::eb};
502 424 ${Elatin1::eB} = ${Elatin1::eB};
503  
504 #
505 # Latin-1 split
506 #
507 72 ▶sub Elatin1::split(;$$$) {
Subroutine split: called CC=34 SCAR=38.5
Pod undocumented
508  
509 # P.794 29.2.161. split
510 # in Chapter 29: Functions
511 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
512  
513 # P.951 split
514 # in Chapter 27: Functions
515 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
516  
517 72 my $pattern = $_[0];
518 72 my $string = $_[1];
519 72 my $limit = $_[2];
520  
521 # if $pattern is also omitted or is the literal space, " "
522 72 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 2 70 72
523 2 $pattern = ' ';
524 }
525  
526 # if $string is omitted, the function splits the $_ string
527 72 ▶ if (not defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 6 66 72
528 6 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 6 6
529 0 $string = $_;
530 }
531 else {
532 6 $string = '';
533 }
534 }
535  
536 72 my @split = ();
537  
538 # when string is empty
539 72 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 10 62 72
elsif ($pattern eq ' ') { } 2 60 62
540  
541 # resulting list value in list context
542 10 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 5 5 10
543 5 return @split;
544 }
545  
546 # count of substrings in scalar context
547 else {
548 5 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 5 5
549 5 @_ = @split;
550 5 return scalar @_;
551 }
552 }
553  
554 # split's first argument is more consistently interpreted
555 #
556 # After some changes earlier in v5.17, split's behavior has been simplified:
557 # if the PATTERN argument evaluates to a string containing one space, it is
558 # treated the way that a literal string containing one space once was.
559 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
560  
561 # if $pattern is also omitted or is the literal space, " ", the function splits
562 # on whitespace, /\s+/, after skipping any leading whitespace
563 # (and so on)
564  
565 elsif ($pattern eq ' ') {
566 2 ▶ if (not defined $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit) { } 2 0 2
567 2 return CORE::split(' ', $string);
568 }
569 else {
570 0 return CORE::split(' ', $string, $limit);
571 }
572 }
573  
574 # if $limit is negative, it is treated as if an arbitrarily large $limit has been specified
575 60 ▶ if ((not defined $limit) or ($limit <= 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $limit or $limit <= 0) { } 60 0 60
elsif ($limit > 0) { } 0 0 0
Condition33%1/3
not defined $limit or $limit <= 0
l!l&&r!l&&!r
6000
MC/DC0%0/2
not defined $limit or $limit <= 0
not defined $limit $limit <= 0
Truth table33%1/3
not(A) or B
A= not defined $limitB= $limit <= 0
ABresult
1X1
011
000
576  
577 # a pattern capable of matching either the null string or something longer than the
578 # null string will split the value of $string into separate characters wherever it
579 # matches the null string between characters
580 # (and so on)
581  
582 60 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 2 58 60
583 2 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
584 2 my $limit = scalar(() = $string =~ /($pattern)/oxmsg);
585  
586 # P.1024 Appendix W.10 Multibyte Processing
587 # of ISBN 1-56592-224-7 CJKV Information Processing
588 # (and so on)
589  
590 # the //m modifier is assumed when you split on the pattern /^/
591 # (and so on)
592  
593 2 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
594 # V
595 2 ▶ while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and $string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m) 9 2 11
Condition100%3/3
--$limit > 0 and $string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m
!ll&&!rl&&r
119
MC/DC100%2/2
--$limit > 0 and $string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m
--$limit > 0 $string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m
Truth table100%3/3
A and B
A= --$limit > 0B= $string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m
ABresult
0X0
100
111
596  
597 # if the $pattern contains parentheses, then the substring matched by each pair of parentheses
598 # is included in the resulting list, interspersed with the fields that are ordinarily returned
599 # (and so on)
600  
601 9 local $@;
602 9 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
603 9 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 9 9 18
604 9 push @split, CORE::eval('$' . $digit);
605 }
606 }
607 }
608  
609 else {
610 58 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
611  
612 58 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
613 # V
614 58 ▶ while ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin1::q_char)*?)$pattern//m) 163 58 221
615 163 local $@;
616 163 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
617 163 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 230 163 393
618 230 push @split, CORE::eval('$' . $digit);
619 }
620 }
621 }
622 }
623  
624 elsif ($limit > 0) {
625 0 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 0 0 0
626 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
627 0 ▶ while ((--$limit > 0) and (CORE::length($string) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and length $string > 0) 0 0 0
Condition0%0/3
--$limit > 0 and length $string > 0
!ll&&!rl&&r
000
MC/DC0%0/2
--$limit > 0 and length $string > 0
--$limit > 0 length $string > 0
Truth table0%0/3
A and B
A= --$limit > 0B= length $string > 0
ABresult
0X0
100
111
628  
629 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
630 # V
631 0 ▶ if ($string =~ s/\A((?:$q_char)+?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin1::q_char)+?)$pattern//m) 0 0 0
632 0 local $@;
633 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
634 0 push @split, CORE::eval('$' . $digit);
635 }
636 }
637 }
638 }
639 else {
640 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
641 0 ▶ while ((--$limit > 0) and (CORE::length($string) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and length $string > 0) 0 0 0
Condition0%0/3
--$limit > 0 and length $string > 0
!ll&&!rl&&r
000
MC/DC0%0/2
--$limit > 0 and length $string > 0
--$limit > 0 length $string > 0
Truth table0%0/3
A and B
A= --$limit > 0B= length $string > 0
ABresult
0X0
100
111
642  
643 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
644 # V
645 0 ▶ if ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin1::q_char)*?)$pattern//m) 0 0 0
646 0 local $@;
647 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
648 0 push @split, CORE::eval('$' . $digit);
649 }
650 }
651 }
652 }
653 }
654  
655 60 ▶ if (CORE::length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 58 2 60
656 58 push @split, $string;
657 }
658  
659 # if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result
660 60 ▶ if ((not defined $_[2]) or ($_[2] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_[2] or $_[2] == 0) 60 0 60
Condition33%1/3
not defined $_[2] or $_[2] == 0
l!l&&r!l&&!r
6000
MC/DC0%0/2
not defined $_[2] or $_[2] == 0
not defined $_[2] $_[2] == 0
Truth table33%1/3
not(A) or B
A= not defined $_[2]B= $_[2] == 0
ABresult
1X1
011
000
661 60 ▶ while ((scalar(@split) >= 1) and ($split[-1] eq '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @split >= 1 and $split[-1] eq "") 0 60 60
Condition33%1/3
scalar @split >= 1 and $split[-1] eq ""
!ll&&!rl&&r
0600
MC/DC0%0/2
scalar @split >= 1 and $split[-1] eq ""
scalar @split >= 1 $split[-1] eq ""
Truth table33%1/3
A and B
A= scalar @split >= 1B= $split[-1] eq ""
ABresult
0X0
100
111
662 0 pop @split;
663 }
664 }
665  
666 # resulting list value in list context
667 60 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 58 2 60
668 58 return @split;
669 }
670  
671 # count of substrings in scalar context
672 else {
673 2 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 2 2
674 2 @_ = @split;
675 2 return scalar @_;
676 }
677 }
678  
679 #
680 # get last subexpression offsets
681 #
682 60 ▶sub _last_subexpression_offsets {
Subroutine _last_subexpression_offsets: called CC=3 SCAR=11.0
683 60 my $pattern = $_[0];
684  
685 # remove comment
686 60 $pattern =~ s/\(\?\# .*? \)//oxmsg;
687  
688 60 my $modifier = '';
689 60 ▶ if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/mosx) 11 49 60
690 11 $modifier = $1;
691 11 $modifier =~ s/-[A-Za-z]*//;
692 }
693  
694 # with /x modifier
695 60 my @char = ();
696 60 ▶ if ($modifier =~ /x/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /x/mosx) { } 5 55 60
697 5 @char = $pattern =~ /\G((?>
698 [^\\\#\[\(] |
699 \\ $q_char |
700 \# (?>[^\n]*) $ |
701 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
702 \(\? |
703 $q_char
704 ))/oxmsg;
705 }
706  
707 # without /x modifier
708 else {
709 55 @char = $pattern =~ /\G((?>
710 [^\\\[\(] |
711 \\ $q_char |
712 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
713 \(\? |
714 $q_char
715 ))/oxmsg;
716 }
717  
718 60 return scalar grep { $_ eq '(' } @char;
719 }
720  
721 #
722 # Latin-1 transliteration (tr///)
723 #
724 6 ▶sub Elatin1::tr($$$$;$) {
Subroutine tr: called CC=26 SCAR=48.6
Pod undocumented
725  
726 6 my $bind_operator = $_[1];
727 6 my $searchlist = $_[2];
728 6 my $replacementlist = $_[3];
729 6 ▶ my $modifier = $_[4] || '';
Condition100%2/2
$_[4] || ''
l!l
51
MC/DC100%1/1
$_[4] || ''
$_[4]
Truth table100%2/2
A
A= $_[4]
Aresult
11
00
730  
731 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) 5 1 6
732 5 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 5 5
733 0 croak "Using !~ with tr///r doesn't make sense";
734 }
735 }
736  
737 6 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
738 6 my @searchlist = _charlist_tr($searchlist);
739 6 my @replacementlist = _charlist_tr($replacementlist);
740  
741 6 my %tr = ();
742 6 ▶ for (my $i=0; $i <= $#searchlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#searchlist) 19 6 25
743 19 ▶ if (not exists $tr{$searchlist[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$searchlist[$i]}) 19 0 19
744 19 ▶ if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $replacementlist[$i] and $replacementlist[$i] ne '') { } 19 0 19
elsif ($modifier =~ /d/mosx) { } 0 0 0
elsif (defined $replacementlist[-1] and $replacementlist[-1] ne '') { } 0 0 0
Condition33%1/3
defined $replacementlist[$i] and $replacementlist[$i] ne ""
!ll&&!rl&&r
0019
MC/DC0%0/2
defined $replacementlist[$i] and $replacementlist[$i] ne ""
defined $replacementlist[$i] $replacementlist[$i] ne ""
Truth table33%1/3
A and B
A= defined $replacementlist[$i]B= $replacementlist[$i] ne ""
ABresult
0X0
100
111
745 19 $tr{$searchlist[$i]} = $replacementlist[$i];
746 }
747 elsif ($modifier =~ /d/oxms) {
748 0 $tr{$searchlist[$i]} = '';
749 }
750 ▶ elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) {
Condition0%0/3
defined $replacementlist[-1] and $replacementlist[-1] ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $replacementlist[-1] and $replacementlist[-1] ne ""
defined $replacementlist[-1] $replacementlist[-1] ne ""
Truth table0%0/3
A and B
A= defined $replacementlist[-1]B= $replacementlist[-1] ne ""
ABresult
0X0
100
111
751 0 $tr{$searchlist[$i]} = $replacementlist[-1];
752 }
753 else {
754 0 $tr{$searchlist[$i]} = $searchlist[$i];
755 }
756 }
757 }
758  
759 6 my $tr = 0;
760 6 my $replaced = '';
761 6 ▶ if ($modifier =~ /c/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /c/mosx) { } 0 6 6
762 0 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 0 0 0
763 0 ▶ if (not exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $tr{$char}) { } 0 0 0
764 0 ▶ if (defined $replacementlist[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $replacementlist[-1]) 0 0 0
765 0 $replaced .= $replacementlist[-1];
766 }
767 0 $tr++;
768 0 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 0 0
769 0 ▶ while (@char and (not exists $tr{$char[0]})) {
Branch: 1 branch
BranchTrueFalseTotal
if (@char and not exists $tr{$char[0]}) 0 0 0
Condition0%0/3
@char and not exists $tr{$char[0]}
!ll&&!rl&&r
000
MC/DC0%0/2
@char and not exists $tr{$char[0]}
@char not exists $tr{$char[0]}
Truth table0%0/3
A and not(B)
A= @charB= not exists $tr{$char[0]}
ABresult
0X0
100
111
770 0 shift @char;
771 0 $tr++;
772 }
773 }
774 }
775 else {
776 0 $replaced .= $char;
777 }
778 }
779 }
780 else {
781 6 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 36 6 42
782 36 ▶ if (exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$char}) { } 19 17 36
783 19 $replaced .= $tr{$char};
784 19 $tr++;
785 19 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 19 19
786 0 ▶ while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) {
Branch: 1 branch
BranchTrueFalseTotal
if (@char and exists $tr{$char[0]} and $tr{$char[0]} eq $tr{$char}) 0 0 0
Condition0%0/6
@char and exists $tr{$char[0]} and $tr{$char[0]} eq $tr{$char}
!ll&&!rl&&r
000
@char and exists $tr{$char[0]}
!ll&&!rl&&r
000
MC/DC0%0/3
@char and exists $tr{$char[0]} and $tr{$char[0]} eq $tr{$char}
@char exists $tr{$char[0]} $tr{$char[0]} eq $tr{$char}
Truth table0%0/4
A and B and C
A= @charB= exists $tr{$char[0]}C= $tr{$char[0]} eq $tr{$char}
ABCresult
0XX0
10X0
1100
1111
787 0 shift @char;
788 0 $tr++;
789 }
790 }
791 }
792 else {
793 17 $replaced .= $char;
794 }
795 }
796 }
797  
798 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) { } 5 1 6
799 5 return $replaced;
800 }
801 else {
802 1 $_[0] = $replaced;
803 1 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) { } 0 1 1
804 0 return not $tr;
805 }
806 else {
807 1 return $tr;
808 }
809 }
810 }
811  
812 #
813 # Latin-1 chop
814 #
815 0 ▶sub Elatin1::chop(@) {
Subroutine chop: not called CC=3 SCAR=24.8
Pod undocumented
816  
817 0 my $chop;
818 0 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
819 0 my @char = /\G (?>$q_char) /oxmsg;
820 0 $chop = pop @char;
821 0 $_ = join '', @char;
822 }
823 else {
824 0 for (@_) {
825 0 my @char = /\G (?>$q_char) /oxmsg;
826 0 $chop = pop @char;
827 0 $_ = join '', @char;
828 }
829 }
830 0 return $chop;
831 }
832  
833 #
834 # Latin-1 index by octet
835 #
836 30 ▶sub Elatin1::index($$;$) {
Subroutine index: called CC=6 SCAR=20.8
Pod documented
837  
838 30 my($str,$substr,$position) = @_;
839 30 ▶ $position ||= 0;
Condition50%1/2
$position ||= 0
l!l
030
MC/DC0%0/1
$position ||= 0
$position
Truth table50%1/2
A
A= $position
Aresult
11
00
840 30 my $pos = 0;
841  
842 30 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str) 130 30 160
843 130 ▶ if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos, length $substr) eq $substr) 0 130 130
844 0 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 0 0 0
845 0 return $pos;
846 }
847 }
848 130 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Elatin1::q_char) /mosx) { } 130 0 130
849 130 $pos += CORE::length($1);
850 }
851 else {
852 0 $pos += 1;
853 }
854 }
855 30 return -1;
856 }
857  
858 #
859 # Latin-1 reverse index
860 #
861 0 ▶sub Elatin1::rindex($$;$) {
Subroutine rindex: not called CC=6 SCAR=37.4
Pod undocumented
862  
863 0 my($str,$substr,$position) = @_;
864 0 ▶ $position ||= CORE::length($str) - 1;
Condition0%0/3
$position ||= length($str) - 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$position ||= length($str) - 1
$position length($str) - 1
Truth table0%0/3
A ||= B
A= $positionB= length($str) - 1
ABresult
1X1
011
000
865 0 my $pos = 0;
866 0 my $rindex = -1;
867  
868 0 ▶ while (($pos < CORE::length($str)) and ($pos <= $position)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str and $pos <= $position) 0 0 0
Condition0%0/3
$pos < length $str and $pos <= $position
!ll&&!rl&&r
000
MC/DC0%0/2
$pos < length $str and $pos <= $position
$pos < length $str $pos <= $position
Truth table0%0/3
A and B
A= $pos < length $strB= $pos <= $position
ABresult
0X0
100
111
869 0 ▶ if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos, length $substr) eq $substr) 0 0 0
870 0 $rindex = $pos;
871 }
872 0 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Elatin1::q_char) /mosx) { } 0 0 0
873 0 $pos += CORE::length($1);
874 }
875 else {
876 0 $pos += 1;
877 }
878 }
879 0 return $rindex;
880 }
881  
882 #
883 # Latin-1 lower case first with parameter
884 #
885 0 ▶sub Elatin1::lcfirst(@) {
Subroutine lcfirst: not called CC=4 SCAR=30.0
Pod undocumented
886 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
887 0 my $s = shift @_;
888 0 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 0 0
Condition0%0/3
@_ and wantarray
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table0%0/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
889 0 return Elatin1::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
890 }
891 else {
892 0 return Elatin1::lc(CORE::substr($s,0,1)) . CORE::substr($s,1);
893 }
894 }
895 else {
896 0 return Elatin1::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
897 }
898 }
899  
900 #
901 # Latin-1 lower case first without parameter
902 #
903 0 ▶sub Elatin1::lcfirst_() {
Subroutine lcfirst_: not called CC=1 SCAR=6.9
Pod undocumented
904 0 return Elatin1::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
905 }
906  
907 #
908 # Latin-1 lower case with parameter
909 #
910 57 ▶sub Elatin1::lc(@) {
Subroutine lc: called CC=6 SCAR=24.2
Pod undocumented
911 57 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 57 0 57
912 57 my $s = shift @_;
913 57 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 57 57
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
5700
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
914 0 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
915 }
916 else {
917 57 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 59 0 59
918 }
919 }
920 else {
921 0 return Elatin1::lc_();
922 }
923 }
924  
925 #
926 # Latin-1 lower case without parameter
927 #
928 0 ▶sub Elatin1::lc_() {
Subroutine lc_: not called CC=2 SCAR=17.9
Pod undocumented
929 0 my $s = $_;
930 0 ▶ return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
931 }
932  
933 #
934 # Latin-1 upper case first with parameter
935 #
936 0 ▶sub Elatin1::ucfirst(@) {
Subroutine ucfirst: not called CC=4 SCAR=30.0
Pod undocumented
937 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
938 0 my $s = shift @_;
939 0 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 0 0
Condition0%0/3
@_ and wantarray
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table0%0/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
940 0 return Elatin1::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
941 }
942 else {
943 0 return Elatin1::uc(CORE::substr($s,0,1)) . CORE::substr($s,1);
944 }
945 }
946 else {
947 0 return Elatin1::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
948 }
949 }
950  
951 #
952 # Latin-1 upper case first without parameter
953 #
954 0 ▶sub Elatin1::ucfirst_() {
Subroutine ucfirst_: not called CC=1 SCAR=6.9
Pod undocumented
955 0 return Elatin1::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
956 }
957  
958 #
959 # Latin-1 upper case with parameter
960 #
961 2385 ▶sub Elatin1::uc(@) {
Subroutine uc: called CC=6 SCAR=22.9
Pod undocumented
962 2385 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2385 0 2385
963 2385 my $s = shift @_;
964 2385 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2385 2385
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
238500
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
965 0 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
966 }
967 else {
968 2385 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 853 1534 2387
969 }
970 }
971 else {
972 0 return Elatin1::uc_();
973 }
974 }
975  
976 #
977 # Latin-1 upper case without parameter
978 #
979 0 ▶sub Elatin1::uc_() {
Subroutine uc_: not called CC=2 SCAR=17.9
Pod undocumented
980 0 my $s = $_;
981 0 ▶ return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
982 }
983  
984 #
985 # Latin-1 fold case with parameter
986 #
987 2399 ▶sub Elatin1::fc(@) {
Subroutine fc: called CC=6 SCAR=22.9
Pod undocumented
988 2399 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2399 0 2399
989 2399 my $s = shift @_;
990 2399 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2399 2399
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
239900
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
991 0 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
992 }
993 else {
994 2399 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 1759 5439 7198
995 }
996 }
997 else {
998 0 return Elatin1::fc_();
999 }
1000 }
1001  
1002 #
1003 # Latin-1 fold case without parameter
1004 #
1005 0 ▶sub Elatin1::fc_() {
Subroutine fc_: not called CC=2 SCAR=17.9
Pod undocumented
1006 0 my $s = $_;
1007 0 ▶ return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1008 }
1009  
1010 #
1011 # Latin-1 regexp capture
1012 #
1013 {
1014 0 ▶ sub Elatin1::capture {
Subroutine capture: not called CC=1 SCAR=6.9
Pod documented
1015 0 return $_[0];
1016 }
1017 }
1018  
1019 #
1020 # Latin-1 regexp ignore case modifier
1021 #
1022 424 ▶sub Elatin1::ignorecase {
Subroutine ignorecase: called CC=25 SCAR=52.1
Pod undocumented
1023  
1024 11 my @string = @_;
1025 11 my $metachar = qr/[\@\\|[\]{]/oxms;
1026  
1027 # ignore case of $scalar or @array
1028 11 for my $string (@string) {
1029  
1030 # split regexp
1031 11 my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg;
1032  
1033 # unescape character
1034 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 924 11 935
1035 924 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 924 924
1036  
1037 # open character class [...]
1038 924 ▶ if ($char[$i] eq '[') {
Branch: 4 branches
BranchTrueFalseTotal
if ($char[$i] eq '[') { } 0 924 924
elsif ($char[$i] eq '[^') { } 0 924 924
elsif (my $char = classic_character_class($char[$i])) { } 0 924 924
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/mosx) { } 924 0 924
1039 0 my $left = $i;
1040  
1041 # [] make die "unmatched [] in regexp ...\n"
1042  
1043 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1044 0 $i++;
1045 }
1046  
1047 0 while (1) {
1048 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1049 0 croak "Unmatched [] in regexp";
1050 }
1051 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1052 0 my $right = $i;
1053 0 my @charlist = charlist_qr(@char[$left+1..$right-1], 'i');
1054  
1055 # escape character
1056 0 for my $char (@charlist) {
1057 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1058 }
1059  
1060 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1061 0 $char = '\\' . $char;
1062 }
1063 }
1064  
1065 # [...]
1066 0 splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')';
1067  
1068 0 $i = $left;
1069 0 last;
1070 }
1071 }
1072 }
1073  
1074 # open character class [^...]
1075 elsif ($char[$i] eq '[^') {
1076 0 my $left = $i;
1077  
1078 # [^] make die "unmatched [] in regexp ...\n"
1079  
1080 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1081 0 $i++;
1082 }
1083  
1084 0 while (1) {
1085 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1086 0 croak "Unmatched [] in regexp";
1087 }
1088 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1089 0 my $right = $i;
1090 0 my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i');
1091  
1092 # escape character
1093 0 for my $char (@charlist) {
1094 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1095 }
1096  
1097 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1098 0 $char = '\\' . $char;
1099 }
1100 }
1101  
1102 # [^...]
1103 0 splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)";
1104  
1105 0 $i = $left;
1106 0 last;
1107 }
1108 }
1109 }
1110  
1111 # rewrite classic character class or escape character
1112 elsif (my $char = classic_character_class($char[$i])) {
1113 0 $char[$i] = $char;
1114 }
1115  
1116 # with /i modifier
1117 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1118 924 my $uc = Elatin1::uc($char[$i]);
1119 924 my $fc = Elatin1::fc($char[$i]);
1120 924 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) 476 448 924
1121 476 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 473 3 476
1122 473 $char[$i] = '[' . $uc . $fc . ']';
1123 }
1124 else {
1125 3 $char[$i] = '(?:' . $uc . '|' . $fc . ')';
1126 }
1127 }
1128 }
1129 }
1130  
1131 # characterize
1132 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 924 11 935
1133 924 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 924 924
1134  
1135 924 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx }) 0 935 935
1136 }
1137  
1138 # quote character before ? + * {
1139 0 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition66%2/3
$i >= 1 && $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
119130
MC/DC0%0/2
$i >= 1 && $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table66%2/3
A && B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
1140 0 ▶ if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($char[$i - 1] =~ /\A [\x00-\xFF] \z/mosx) 0 0 0
1141 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
1142 }
1143 }
1144 }
1145  
1146 11 $string = join '', @char;
1147 }
1148  
1149 # make regexp string
1150 11 return @string;
1151 }
1152  
1153 #
1154 # classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B )
1155 #
1156 2792 ▶sub Elatin1::classic_character_class {
Subroutine classic_character_class: called CC=2 SCAR=6.9
Pod undocumented
1157 2792 my($char) = @_;
1158  
1159 return {
1160 '\D' => '${Elatin1::eD}',
1161 '\S' => '${Elatin1::eS}',
1162 '\W' => '${Elatin1::eW}',
1163 '\d' => '[0-9]',
1164  
1165 # Before Perl 5.6, \s only matched the five whitespace characters
1166 # tab, newline, form-feed, carriage return, and the space character
1167 # itself, which, taken together, is the character class [\t\n\f\r ].
1168  
1169 # Vertical tabs are now whitespace
1170 # \s in a regex now matches a vertical tab in all circumstances.
1171 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1172 # \t \n \v \f \r space
1173 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1174 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1175 '\s' => '\s',
1176  
1177 '\w' => '[0-9A-Z_a-z]',
1178 '\C' => '[\x00-\xFF]',
1179 '\X' => 'X',
1180  
1181 # \h \v \H \V
1182  
1183 # P.114 Character Class Shortcuts
1184 # in Chapter 7: In the World of Regular Expressions
1185 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
1186  
1187 # P.357 13.2.3 Whitespace
1188 # in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes
1189 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1190 #
1191 # 0x00009 CHARACTER TABULATION h s
1192 # 0x0000a LINE FEED (LF) vs
1193 # 0x0000b LINE TABULATION v
1194 # 0x0000c FORM FEED (FF) vs
1195 # 0x0000d CARRIAGE RETURN (CR) vs
1196 # 0x00020 SPACE h s
1197  
1198 # P.196 Table 5-9. Alphanumeric regex metasymbols
1199 # in Chapter 5. Pattern Matching
1200 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1201  
1202 # (and so on)
1203  
1204 '\H' => '${Elatin1::eH}',
1205 '\V' => '${Elatin1::eV}',
1206 '\h' => '[\x09\x20]',
1207 '\v' => '[\x0A\x0B\x0C\x0D]',
1208 '\R' => '${Elatin1::eR}',
1209  
1210 # \N
1211 #
1212 # http://perldoc.perl.org/perlre.html
1213 # Character Classes and other Special Escapes
1214 # Any character but \n (experimental). Not affected by /s modifier
1215  
1216 '\N' => '${Elatin1::eN}',
1217  
1218 # \b \B
1219  
1220 # P.180 Boundaries: The \b and \B Assertions
1221 # in Chapter 5: Pattern Matching
1222 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1223  
1224 # P.219 Boundaries: The \b and \B Assertions
1225 # in Chapter 5: Pattern Matching
1226 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1227  
1228 # \b really means (?:(?<=\w)(?!\w)|(?<!\w)(?=\w))
1229 # or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z))
1230 '\b' => '${Elatin1::eb}',
1231  
1232 # \B really means (?:(?<=\w)(?=\w)|(?<!\w)(?!\w))
1233 # or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W))
1234 '\B' => '${Elatin1::eB}',
1235  
1236 2792 ▶ }->{$char} || '';
Condition100%2/2
{'\\D', '${Elatin1::eD}', '\\S', '${Elatin1::eS}', '\\W', '${Elatin1::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin1::eH}', '\\V', '${Elatin1::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin1::eR}', '\\N', '${Elatin1::eN}', '\\b', '${Elatin1::eb}', '\\B', '${Elatin1::eB}'}->{$char} || ''
l!l
1012691
MC/DC100%1/1
{'\\D', '${Elatin1::eD}', '\\S', '${Elatin1::eS}', '\\W', '${Elatin1::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin1::eH}', '\\V', '${Elatin1::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin1::eR}', '\\N', '${Elatin1::eN}', '\\b', '${Elatin1::eb}', '\\B', '${Elatin1::eB}'}->{$char} || ''
{'\\D', '${Elatin1::eD}', '\\S', '${Elatin1::eS}', '\\W', '${Elatin1::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin1::eH}', '\\V', '${Elatin1::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin1::eR}', '\\N', '${Elatin1::eN}', '\\b', '${Elatin1::eb}', '\\B', '${Elatin1::eB}'}->{$char}
Truth table100%2/2
A
A= {'\\D', '${Elatin1::eD}', '\\S', '${Elatin1::eS}', '\\W', '${Elatin1::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin1::eH}', '\\V', '${Elatin1::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin1::eR}', '\\N', '${Elatin1::eN}', '\\b', '${Elatin1::eb}', '\\B', '${Elatin1::eB}'}->{$char}
Aresult
11
00
1237 }
1238  
1239 #
1240 # prepare Latin-1 characters per length
1241 #
1242  
1243 # 1 octet characters
1244 424 my @chars1 = ();
1245 0 ▶sub chars1 {
Subroutine chars1: not called CC=5 SCAR=34.0
Pod undocumented
1246 0 ▶ if (@chars1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars1) 0 0 0
1247 0 return @chars1;
1248 }
1249 0 ▶ if (exists $range_tr{1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{1}) 0 0 0
1250 0 my @ranges = @{ $range_tr{1} };
1251 0 ▶ while (my @range = splice(@ranges,0,1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 1)) 0 0 0
1252 0 for my $oct0 (@{$range[0]}) {
1253 0 push @chars1, pack 'C', $oct0;
1254 }
1255 }
1256 }
1257 0 return @chars1;
1258 }
1259  
1260 # 2 octets characters
1261 424 my @chars2 = ();
1262 0 ▶sub chars2 {
Subroutine chars2: not called CC=6 SCAR=37.4
Pod undocumented
1263 0 ▶ if (@chars2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars2) 0 0 0
1264 0 return @chars2;
1265 }
1266 0 ▶ if (exists $range_tr{2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{2}) 0 0 0
1267 0 my @ranges = @{ $range_tr{2} };
1268 0 ▶ while (my @range = splice(@ranges,0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 2)) 0 0 0
1269 0 for my $oct0 (@{$range[0]}) {
1270 0 for my $oct1 (@{$range[1]}) {
1271 0 push @chars2, pack 'CC', $oct0,$oct1;
1272 }
1273 }
1274 }
1275 }
1276 0 return @chars2;
1277 }
1278  
1279 # 3 octets characters
1280 424 my @chars3 = ();
1281 0 ▶sub chars3 {
Subroutine chars3: not called CC=7 SCAR=40.3
Pod undocumented
1282 0 ▶ if (@chars3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars3) 0 0 0
1283 0 return @chars3;
1284 }
1285 0 ▶ if (exists $range_tr{3}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{3}) 0 0 0
1286 0 my @ranges = @{ $range_tr{3} };
1287 0 ▶ while (my @range = splice(@ranges,0,3)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 3)) 0 0 0
1288 0 for my $oct0 (@{$range[0]}) {
1289 0 for my $oct1 (@{$range[1]}) {
1290 0 for my $oct2 (@{$range[2]}) {
1291 0 push @chars3, pack 'CCC', $oct0,$oct1,$oct2;
1292 }
1293 }
1294 }
1295 }
1296 }
1297 0 return @chars3;
1298 }
1299  
1300 # 4 octets characters
1301 424 my @chars4 = ();
1302 0 ▶sub chars4 {
Subroutine chars4: not called CC=8 SCAR=42.8
Pod undocumented
1303 0 ▶ if (@chars4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars4) 0 0 0
1304 0 return @chars4;
1305 }
1306 0 ▶ if (exists $range_tr{4}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{4}) 0 0 0
1307 0 my @ranges = @{ $range_tr{4} };
1308 0 ▶ while (my @range = splice(@ranges,0,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 4)) 0 0 0
1309 0 for my $oct0 (@{$range[0]}) {
1310 0 for my $oct1 (@{$range[1]}) {
1311 0 for my $oct2 (@{$range[2]}) {
1312 0 for my $oct3 (@{$range[3]}) {
1313 0 push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3;
1314 }
1315 }
1316 }
1317 }
1318 }
1319 }
1320 0 return @chars4;
1321 }
1322  
1323 #
1324 # Latin-1 open character list for tr
1325 #
1326 12 ▶sub _charlist_tr {
Subroutine _charlist_tr: called CC=35 SCAR=66.4
1327  
1328 12 local $_ = shift @_;
1329  
1330 # unescape character
1331 12 my @char = ();
1332 12 ▶ while (not /\G \z/oxmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgmosx) 38 12 50
1333 38 ▶ if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) {
Branch: 7 branches
BranchTrueFalseTotal
if (/\G (\\0?55|\\x2[Dd]|\\-) /cgmosx) { } 0 38 38
elsif (/\G \\ ([0-7]{2,3}) /cgmosx) { } 0 38 38
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /cgmosx) { } 0 38 38
elsif (/\G \\c ([\x40-\x5F]) /cgmosx) { } 0 38 38
elsif (/\G (\\ [0nrtfbae]) /cgmosx) { } 0 38 38
elsif (/\G \\ ($Elatin1::q_char) /cgmosx) { } 0 38 38
elsif (/\G ($Elatin1::q_char) /cgmosx) { } 38 0 38
1334 0 push @char, '\-';
1335 }
1336 elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) {
1337 0 push @char, CORE::chr(oct $1);
1338 }
1339 elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) {
1340 0 push @char, CORE::chr(hex $1);
1341 }
1342 elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) {
1343 0 push @char, CORE::chr(CORE::ord($1) & 0x1F);
1344 }
1345 elsif (/\G (\\ [0nrtfbae]) /oxmsgc) {
1346 push @char, {
1347 '\0' => "\0",
1348 '\n' => "\n",
1349 '\r' => "\r",
1350 '\t' => "\t",
1351 '\f' => "\f",
1352 '\b' => "\x08", # \b means backspace in character class
1353 '\a' => "\a",
1354 '\e' => "\e",
1355 0 }->{$1};
1356 }
1357 elsif (/\G \\ ($q_char) /oxmsgc) {
1358 0 push @char, $1;
1359 }
1360 elsif (/\G ($q_char) /oxmsgc) {
1361 38 push @char, $1;
1362 }
1363 }
1364  
1365 # join separated multiple-octet
1366 12 @char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg;
1367  
1368 # unescape '-'
1369 12 my @i = ();
1370 12 for my $i (0 .. $#char) {
1371 38 ▶ if ($char[$i] eq '\-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\-') { } 0 38 38
elsif ($char[$i] eq '-') { } 0 38 38
1372 0 $char[$i] = '-';
1373 }
1374 elsif ($char[$i] eq '-') {
1375 0 ▶ if ((0 < $i) and ($i < $#char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < $i and $i < $#char) 0 0 0
Condition0%0/3
0 < $i and $i < $#char
!ll&&!rl&&r
000
MC/DC0%0/2
0 < $i and $i < $#char
0 < $i $i < $#char
Truth table0%0/3
A and B
A= 0 < $iB= $i < $#char
ABresult
0X0
100
111
1376 0 push @i, $i;
1377 }
1378 }
1379 }
1380  
1381 # open character list (reverse for splice)
1382 12 for my $i (CORE::reverse @i) {
1383 0 my @range = ();
1384  
1385 # range error
1386 0 ▶ if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i - 1] > length $char[$i + 1] or $char[$i - 1] gt $char[$i + 1]) 0 0 0
Condition0%0/3
length $char[$i - 1] > length $char[$i + 1] or $char[$i - 1] gt $char[$i + 1]
l!l&&r!l&&!r
000
MC/DC0%0/2
length $char[$i - 1] > length $char[$i + 1] or $char[$i - 1] gt $char[$i + 1]
length $char[$i - 1] > length $char[$i + 1] $char[$i - 1] gt $char[$i + 1]
Truth table0%0/3
A or B
A= length $char[$i - 1] > length $char[$i + 1]B= $char[$i - 1] gt $char[$i + 1]
ABresult
1X1
011
000
1387 0 croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1388 }
1389  
1390 # range of multiple-octet code
1391 0 ▶ if (CORE::length($char[$i-1]) == 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (length $char[$i - 1] == 1) { } 0 0 0
elsif (length $char[$i - 1] == 2) { } 0 0 0
elsif (length $char[$i - 1] == 3) { } 0 0 0
elsif (length $char[$i - 1] == 4) { } 0 0 0
1392 0 ▶ if (CORE::length($char[$i+1]) == 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (length $char[$i + 1] == 1) { } 0 0 0
elsif (length $char[$i + 1] == 2) { } 0 0 0
elsif (length $char[$i + 1] == 3) { } 0 0 0
elsif (length $char[$i + 1] == 4) { } 0 0 0
1393 0 ▶ push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1();
Condition0%0/3
$char[$i - 1] le $_ && $_ le $char[$i + 1]
!ll&&!rl&&r
000
MC/DC0%0/2
$char[$i - 1] le $_ && $_ le $char[$i + 1]
$char[$i - 1] le $_ $_ le $char[$i + 1]
Truth table0%0/3
A && B
A= $char[$i - 1] le $_B= $_ le $char[$i + 1]
ABresult
0X0
100
111
1394 }
1395 elsif (CORE::length($char[$i+1]) == 2) {
1396 0 push @range, grep {$char[$i-1] le $_} chars1();
1397 0 push @range, grep {$_ le $char[$i+1]} chars2();
1398 }
1399 elsif (CORE::length($char[$i+1]) == 3) {
1400 0 push @range, grep {$char[$i-1] le $_} chars1();
1401 0 push @range, chars2();
1402 0 push @range, grep {$_ le $char[$i+1]} chars3();
1403 }
1404 elsif (CORE::length($char[$i+1]) == 4) {
1405 0 push @range, grep {$char[$i-1] le $_} chars1();
1406 0 push @range, chars2();
1407 0 push @range, chars3();
1408 0 push @range, grep {$_ le $char[$i+1]} chars4();
1409 }
1410 else {
1411 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1412 }
1413 }
1414 elsif (CORE::length($char[$i-1]) == 2) {
1415 0 ▶ if (CORE::length($char[$i+1]) == 2) {
Branch: 3 branches
BranchTrueFalseTotal
if (length $char[$i + 1] == 2) { } 0 0 0
elsif (length $char[$i + 1] == 3) { } 0 0 0
elsif (length $char[$i + 1] == 4) { } 0 0 0
1416 0 ▶ push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2();
Condition0%0/3
$char[$i - 1] le $_ && $_ le $char[$i + 1]
!ll&&!rl&&r
000
MC/DC0%0/2
$char[$i - 1] le $_ && $_ le $char[$i + 1]
$char[$i - 1] le $_ $_ le $char[$i + 1]
Truth table0%0/3
A && B
A= $char[$i - 1] le $_B= $_ le $char[$i + 1]
ABresult
0X0
100
111
1417 }
1418 elsif (CORE::length($char[$i+1]) == 3) {
1419 0 push @range, grep {$char[$i-1] le $_} chars2();
1420 0 push @range, grep {$_ le $char[$i+1]} chars3();
1421 }
1422 elsif (CORE::length($char[$i+1]) == 4) {
1423 0 push @range, grep {$char[$i-1] le $_} chars2();
1424 0 push @range, chars3();
1425 0 push @range, grep {$_ le $char[$i+1]} chars4();
1426 }
1427 else {
1428 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1429 }
1430 }
1431 elsif (CORE::length($char[$i-1]) == 3) {
1432 0 ▶ if (CORE::length($char[$i+1]) == 3) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $char[$i + 1] == 3) { } 0 0 0
elsif (length $char[$i + 1] == 4) { } 0 0 0
1433 0 ▶ push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars3();
Condition0%0/3
$char[$i - 1] le $_ && $_ le $char[$i + 1]
!ll&&!rl&&r
000
MC/DC0%0/2
$char[$i - 1] le $_ && $_ le $char[$i + 1]
$char[$i - 1] le $_ $_ le $char[$i + 1]
Truth table0%0/3
A && B
A= $char[$i - 1] le $_B= $_ le $char[$i + 1]
ABresult
0X0
100
111
1434 }
1435 elsif (CORE::length($char[$i+1]) == 4) {
1436 0 push @range, grep {$char[$i-1] le $_} chars3();
1437 0 push @range, grep {$_ le $char[$i+1]} chars4();
1438 }
1439 else {
1440 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1441 }
1442 }
1443 elsif (CORE::length($char[$i-1]) == 4) {
1444 0 ▶ if (CORE::length($char[$i+1]) == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i + 1] == 4) { } 0 0 0
1445 0 ▶ push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4();
Condition0%0/3
$char[$i - 1] le $_ && $_ le $char[$i + 1]
!ll&&!rl&&r
000
MC/DC0%0/2
$char[$i - 1] le $_ && $_ le $char[$i + 1]
$char[$i - 1] le $_ $_ le $char[$i + 1]
Truth table0%0/3
A && B
A= $char[$i - 1] le $_B= $_ le $char[$i + 1]
ABresult
0X0
100
111
1446 }
1447 else {
1448 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1449 }
1450 }
1451 else {
1452 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1453 }
1454  
1455 0 splice @char, $i-1, 3, @range;
1456 }
1457  
1458 12 return @char;
1459 }
1460  
1461 #
1462 # Latin-1 open character class
1463 #
1464 0 ▶sub _cc {
Subroutine _cc: not called CC=7 SCAR=40.3
1465 0 ▶ if (scalar(@_) == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @_ == 0) { } 0 0 0
elsif (scalar @_ == 1) { } 0 0 0
elsif (scalar @_ == 2) { } 0 0 0
1466 0 die __FILE__, ": subroutine cc got no parameter.\n";
1467 }
1468 elsif (scalar(@_) == 1) {
1469 0 return sprintf('\x%02X',$_[0]);
1470 }
1471 elsif (scalar(@_) == 2) {
1472 0 ▶ if ($_[0] > $_[1]) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_[0] > $_[1]) { } 0 0 0
elsif ($_[0] == $_[1]) { } 0 0 0
elsif ($_[0] + 1 == $_[1]) { } 0 0 0
1473 0 die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n";
1474 }
1475 elsif ($_[0] == $_[1]) {
1476 0 return sprintf('\x%02X',$_[0]);
1477 }
1478 elsif (($_[0]+1) == $_[1]) {
1479 0 return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]);
1480 }
1481 else {
1482 0 return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]);
1483 }
1484 }
1485 else {
1486 0 die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n";
1487 }
1488 }
1489  
1490 #
1491 # Latin-1 octet range
1492 #
1493 246 ▶sub _octets {
Subroutine _octets: called CC=5 SCAR=19.3
1494 246 my $length = shift @_;
1495  
1496 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1497 246 my($a1) = unpack 'C', $_[0];
1498 246 my($z1) = unpack 'C', $_[1];
1499  
1500 246 ▶ if ($a1 > $z1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1 > $z1) 0 246 246
1501 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1);
1502 }
1503  
1504 246 ▶ if ($a1 == $z1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($a1 == $z1) { } 0 246 246
elsif ($a1 + 1 == $z1) { } 0 246 246
1505 0 return sprintf('\x%02X',$a1);
1506 }
1507 elsif (($a1+1) == $z1) {
1508 0 return sprintf('\x%02X\x%02X',$a1,$z1);
1509 }
1510 else {
1511 246 return sprintf('\x%02X-\x%02X',$a1,$z1);
1512 }
1513 }
1514 else {
1515 0 die __FILE__, ": subroutine _octets got invalid length ($length).\n";
1516 }
1517 }
1518  
1519 #
1520 # Latin-1 range regexp
1521 #
1522 246 ▶sub _range_regexp {
Subroutine _range_regexp: called CC=18 SCAR=41.7
1523 246 my($length,$first,$last) = @_;
1524  
1525 246 my @range_regexp = ();
1526 246 ▶ if (not exists $range_tr{$length}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $range_tr{$length}) 0 246 246
1527 0 return @range_regexp;
1528 }
1529  
1530 246 my @ranges = @{ $range_tr{$length} };
1531 246 ▶ while (my @range = splice(@ranges,0,$length)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, $length)) 246 246 492
1532 246 my $min = '';
1533 246 my $max = '';
1534 246 ▶ for (my $i=0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 246 246 492
1535 246 $min .= pack 'C', $range[$i][0];
1536 246 $max .= pack 'C', $range[$i][-1];
1537 }
1538  
1539 # min___max
1540 # FIRST_____________LAST
1541 # (nothing)
1542  
1543 246 ▶ if ($max lt $first) {
Branch: 7 branches
BranchTrueFalseTotal
if ($max lt $first) { } 0 246 246
elsif ($min le $first and $first le $max and $max le $last) { } 0 246 246
elsif ($min eq $first and $max eq $last) { } 0 246 246
elsif ($first le $min and $max le $last) { } 0 246 246
elsif ($min le $first and $last le $max) { } 246 0 246
elsif ($first le $min and $min le $last and $last le $max) { } 0 0 0
elsif ($last lt $min) { } 0 0 0
1544 }
1545  
1546 # **********
1547 # min_________max
1548 # FIRST_____________LAST
1549 # **********
1550  
1551 ▶ elsif (($min le $first) and ($first le $max) and ($max le $last)) {
Condition33%2/6
$min le $first and $first le $max and $max le $last
!ll&&!rl&&r
02460
$min le $first and $first le $max
!ll&&!rl&&r
00246
MC/DC0%0/3
$min le $first and $first le $max and $max le $last
$min le $first $first le $max $max le $last
Truth table25%1/4
A and B and C
A= $min le $firstB= $first le $maxC= $max le $last
ABCresult
0XX0
10X0
1100
1111
1552 0 push @range_regexp, _octets($length,$first,$max,$min,$max);
1553 }
1554  
1555 # **********************
1556 # min________________max
1557 # FIRST_____________LAST
1558 # **********************
1559  
1560 ▶ elsif (($min eq $first) and ($max eq $last)) {
Condition33%1/3
$min eq $first and $max eq $last
!ll&&!rl&&r
24600
MC/DC0%0/2
$min eq $first and $max eq $last
$min eq $first $max eq $last
Truth table33%1/3
A and B
A= $min eq $firstB= $max eq $last
ABresult
0X0
100
111
1561 0 push @range_regexp, _octets($length,$first,$last,$min,$max);
1562 }
1563  
1564 # *********
1565 # min___max
1566 # FIRST_____________LAST
1567 # *********
1568  
1569 ▶ elsif (($first le $min) and ($max le $last)) {
Condition33%1/3
$first le $min and $max le $last
!ll&&!rl&&r
24600
MC/DC0%0/2
$first le $min and $max le $last
$first le $min $max le $last
Truth table33%1/3
A and B
A= $first le $minB= $max le $last
ABresult
0X0
100
111
1570 0 push @range_regexp, _octets($length,$min,$max,$min,$max);
1571 }
1572  
1573 # **********************
1574 # min__________________________max
1575 # FIRST_____________LAST
1576 # **********************
1577  
1578 ▶ elsif (($min le $first) and ($last le $max)) {
Condition33%1/3
$min le $first and $last le $max
!ll&&!rl&&r
00246
MC/DC0%0/2
$min le $first and $last le $max
$min le $first $last le $max
Truth table33%1/3
A and B
A= $min le $firstB= $last le $max
ABresult
0X0
100
111
1579 246 push @range_regexp, _octets($length,$first,$last,$min,$max);
1580 }
1581  
1582 # *********
1583 # min________max
1584 # FIRST_____________LAST
1585 # *********
1586  
1587 ▶ elsif (($first le $min) and ($min le $last) and ($last le $max)) {
Condition0%0/6
$first le $min and $min le $last and $last le $max
!ll&&!rl&&r
000
$first le $min and $min le $last
!ll&&!rl&&r
000
MC/DC0%0/3
$first le $min and $min le $last and $last le $max
$first le $min $min le $last $last le $max
Truth table0%0/4
A and B and C
A= $first le $minB= $min le $lastC= $last le $max
ABCresult
0XX0
10X0
1100
1111
1588 0 push @range_regexp, _octets($length,$min,$last,$min,$max);
1589 }
1590  
1591 # min___max
1592 # FIRST_____________LAST
1593 # (nothing)
1594  
1595 elsif ($last lt $min) {
1596 }
1597  
1598 else {
1599 0 die __FILE__, ": subroutine _range_regexp panic.\n";
1600 }
1601 }
1602  
1603 246 return @range_regexp;
1604 }
1605  
1606 #
1607 # Latin-1 open character list for qr and not qr
1608 #
1609 650 ▶sub _charlist {
Subroutine _charlist: called CC=46 SCAR=45.9
1610  
1611 650 my $modifier = pop @_;
1612 650 my @char = @_;
1613  
1614 650 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 298 352 650
1615  
1616 # unescape character
1617 650 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1773 650 2423
1618  
1619 # escape - to ...
1620 1773 ▶ if ($char[$i] eq '-') {
Branch: 12 branches
BranchTrueFalseTotal
if ($char[$i] eq '-') { } 270 1503 1773
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 0 1503 1503
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 0 1503 1503
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 1503 1503
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/mosx) { } 0 1503 1503
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/mosx) { } 0 1503 1503
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/mosx) { } 22 1481 1503
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/mosx) { } 0 1481 1481
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/mosx) { } 25 1456 1481
elsif ($ignorecase and $char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/mosx) { } 8 1448 1456
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/mosx) { } 70 1378 1448
elsif ($char[$i] =~ /\A \\ ($Elatin1::q_char) \z/mosx) { } 7 1371 1378
1621 270 ▶ if ((0 < $i) and ($i < $#char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < $i and $i < $#char) 246 24 270
Condition100%3/3
0 < $i and $i < $#char
!ll&&!rl&&r
195246
MC/DC100%2/2
0 < $i and $i < $#char
0 < $i $i < $#char
Truth table100%3/3
A and B
A= 0 < $iB= $i < $#char
ABresult
0X0
100
111
1622 246 $char[$i] = '...';
1623 }
1624 }
1625  
1626 # octal escape sequence
1627 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
1628 0 $char[$i] = octchr($1);
1629 }
1630  
1631 # hexadecimal escape sequence
1632 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
1633 0 $char[$i] = hexchr($1);
1634 }
1635  
1636 # \b{...} --> b\{...}
1637 # \B{...} --> B\{...}
1638 # \N{CHARNAME} --> N\{CHARNAME}
1639 # \p{PROPERTY} --> p\{PROPERTY}
1640 # \P{PROPERTY} --> P\{PROPERTY}
1641 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
1642 0 $char[$i] = $1 . '\\' . $2;
1643 }
1644  
1645 # \p, \P, \X --> p, P, X
1646 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
1647 0 $char[$i] = $1;
1648 }
1649  
1650 elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) {
1651 0 $char[$i] = CORE::chr oct $1;
1652 }
1653 elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) {
1654 22 $char[$i] = CORE::chr hex $1;
1655 }
1656 elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) {
1657 0 $char[$i] = CORE::chr(CORE::ord($1) & 0x1F);
1658 }
1659 elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) {
1660 $char[$i] = {
1661 '\0' => "\0",
1662 '\n' => "\n",
1663 '\r' => "\r",
1664 '\t' => "\t",
1665 '\f' => "\f",
1666 '\b' => "\x08", # \b means backspace in character class
1667 '\a' => "\a",
1668 '\e' => "\e",
1669 '\d' => '[0-9]',
1670  
1671 # Vertical tabs are now whitespace
1672 # \s in a regex now matches a vertical tab in all circumstances.
1673 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1674 # \t \n \v \f \r space
1675 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1676 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1677 '\s' => '\s',
1678  
1679 '\w' => '[0-9A-Z_a-z]',
1680 '\D' => '${Elatin1::eD}',
1681 '\S' => '${Elatin1::eS}',
1682 '\W' => '${Elatin1::eW}',
1683  
1684 '\H' => '${Elatin1::eH}',
1685 '\V' => '${Elatin1::eV}',
1686 '\h' => '[\x09\x20]',
1687 '\v' => '[\x0A\x0B\x0C\x0D]',
1688 '\R' => '${Elatin1::eR}',
1689  
1690 25 }->{$1};
1691 }
1692  
1693 # POSIX-style character classes
1694 ▶ elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) {
Condition100%3/3
$ignorecase and $char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/mosx
!ll&&!rl&&r
8785708
MC/DC100%2/2
$ignorecase and $char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/mosx
$ignorecase $char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/mosx
Truth table100%3/3
A and B
A= $ignorecaseB= $char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/mosx
ABresult
0X0
100
111
1695 $char[$i] = {
1696  
1697 '[:lower:]' => '[\x41-\x5A\x61-\x7A]',
1698 '[:upper:]' => '[\x41-\x5A\x61-\x7A]',
1699 '[:^lower:]' => '${Elatin1::not_lower_i}',
1700 '[:^upper:]' => '${Elatin1::not_upper_i}',
1701  
1702 8 }->{$1};
1703 }
1704 elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) {
1705 $char[$i] = {
1706  
1707 '[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]',
1708 '[:alpha:]' => '[\x41-\x5A\x61-\x7A]',
1709 '[:ascii:]' => '[\x00-\x7F]',
1710 '[:blank:]' => '[\x09\x20]',
1711 '[:cntrl:]' => '[\x00-\x1F\x7F]',
1712 '[:digit:]' => '[\x30-\x39]',
1713 '[:graph:]' => '[\x21-\x7F]',
1714 '[:lower:]' => '[\x61-\x7A]',
1715 '[:print:]' => '[\x20-\x7F]',
1716 '[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]',
1717  
1718 # P.174 POSIX-Style Character Classes
1719 # in Chapter 5: Pattern Matching
1720 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1721  
1722 # P.311 11.2.4 Character Classes and other Special Escapes
1723 # in Chapter 11: perlre: Perl regular expressions
1724 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1725  
1726 # P.210 POSIX-Style Character Classes
1727 # in Chapter 5: Pattern Matching
1728 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1729  
1730 '[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK")
1731  
1732 '[:upper:]' => '[\x41-\x5A]',
1733 '[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]',
1734 '[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]',
1735 '[:^alnum:]' => '${Elatin1::not_alnum}',
1736 '[:^alpha:]' => '${Elatin1::not_alpha}',
1737 '[:^ascii:]' => '${Elatin1::not_ascii}',
1738 '[:^blank:]' => '${Elatin1::not_blank}',
1739 '[:^cntrl:]' => '${Elatin1::not_cntrl}',
1740 '[:^digit:]' => '${Elatin1::not_digit}',
1741 '[:^graph:]' => '${Elatin1::not_graph}',
1742 '[:^lower:]' => '${Elatin1::not_lower}',
1743 '[:^print:]' => '${Elatin1::not_print}',
1744 '[:^punct:]' => '${Elatin1::not_punct}',
1745 '[:^space:]' => '${Elatin1::not_space}',
1746 '[:^upper:]' => '${Elatin1::not_upper}',
1747 '[:^word:]' => '${Elatin1::not_word}',
1748 '[:^xdigit:]' => '${Elatin1::not_xdigit}',
1749  
1750 70 }->{$1};
1751 }
1752 elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) {
1753 7 $char[$i] = $1;
1754 }
1755 }
1756  
1757 # open character list
1758 650 my @singleoctet = ();
1759 650 my @multipleoctet = ();
1760 650 ▶ for (my $i=0; $i <= $#char; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1527 650 2177
1761  
1762 # escaped -
1763 1527 ▶ if (defined($char[$i+1]) and ($char[$i+1] eq '...')) {
Branch: 6 branches
BranchTrueFalseTotal
if (defined $char[$i + 1] and $char[$i + 1] eq '...') { } 246 1281 1527
elsif ($char[$i] eq '...') { } 246 1035 1281
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/mosx) { } 949 86 1035
elsif ($char[$i] =~ /\A (?: \\h ) \z/mosx) { } 0 86 86
elsif ($char[$i] =~ /\A (?: \\v ) \z/mosx) { } 0 86 86
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/mosx) { } 2 84 86
Condition100%3/3
defined $char[$i + 1] and $char[$i + 1] eq "..."
!ll&&!rl&&r
406875246
MC/DC100%2/2
defined $char[$i + 1] and $char[$i + 1] eq "..."
defined $char[$i + 1] $char[$i + 1] eq "..."
Truth table100%3/3
A and B
A= defined $char[$i + 1]B= $char[$i + 1] eq "..."
ABresult
0X0
100
111
1764 246 $i += 1;
1765 246 next;
1766 }
1767  
1768 # make range regexp
1769 elsif ($char[$i] eq '...') {
1770  
1771 # range error
1772 246 ▶ if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $char[$i - 1] > length $char[$i + 1]) { } 0 246 246
elsif (length $char[$i - 1] == length $char[$i + 1]) { } 246 0 246
1773 0 croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1774 }
1775 elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) {
1776 246 ▶ if ($char[$i-1] gt $char[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] gt $char[$i + 1]) 0 246 246
1777 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1778 }
1779 }
1780  
1781 # make range regexp per length
1782 246 for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) {
1783 246 my @regexp = ();
1784  
1785 # is first and last
1786 246 ▶ if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) {
Branch: 4 branches
BranchTrueFalseTotal
if ($length == length $char[$i - 1] and $length == length $char[$i + 1]) { } 246 0 246
elsif ($length == length $char[$i - 1]) { } 0 0 0
elsif (length $char[$i - 1] < $length and $length < length $char[$i + 1]) { } 0 0 0
elsif ($length == length $char[$i + 1]) { } 0 0 0
Condition33%1/3
$length == length $char[$i - 1] and $length == length $char[$i + 1]
!ll&&!rl&&r
00246
MC/DC0%0/2
$length == length $char[$i - 1] and $length == length $char[$i + 1]
$length == length $char[$i - 1] $length == length $char[$i + 1]
Truth table33%1/3
A and B
A= $length == length $char[$i - 1]B= $length == length $char[$i + 1]
ABresult
0X0
100
111
1787 246 push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]);
1788 }
1789  
1790 # is first
1791 elsif ($length == CORE::length($char[$i-1])) {
1792 0 push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length);
1793 }
1794  
1795 # is inside in first and last
1796 ▶ elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) {
Condition0%0/3
length $char[$i - 1] < $length and $length < length $char[$i + 1]
!ll&&!rl&&r
000
MC/DC0%0/2
length $char[$i - 1] < $length and $length < length $char[$i + 1]
length $char[$i - 1] < $length $length < length $char[$i + 1]
Truth table0%0/3
A and B
A= length $char[$i - 1] < $lengthB= $length < length $char[$i + 1]
ABresult
0X0
100
111
1797 0 push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length);
1798 }
1799  
1800 # is last
1801 elsif ($length == CORE::length($char[$i+1])) {
1802 0 push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]);
1803 }
1804  
1805 else {
1806 0 die __FILE__, ": subroutine make_regexp panic.\n";
1807 }
1808  
1809 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1810 246 push @singleoctet, @regexp;
1811 }
1812 else {
1813 0 push @multipleoctet, @regexp;
1814 }
1815 }
1816  
1817 246 $i += 2;
1818 }
1819  
1820 # with /i modifier
1821 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1822 949 ▶ if ($modifier =~ /i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) { } 480 469 949
1823 480 my $uc = Elatin1::uc($char[$i]);
1824 480 my $fc = Elatin1::fc($char[$i]);
1825 480 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) { } 240 240 480
1826 240 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 240 0 240
1827 240 push @singleoctet, $uc, $fc;
1828 }
1829 else {
1830 0 push @singleoctet, $uc;
1831 0 push @multipleoctet, $fc;
1832 }
1833 }
1834 else {
1835 240 push @singleoctet, $char[$i];
1836 }
1837 }
1838 else {
1839 469 push @singleoctet, $char[$i];
1840 }
1841 949 $i += 1;
1842 }
1843  
1844 # single character of single octet code
1845 elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) {
1846 0 push @singleoctet, "\t", "\x20";
1847 0 $i += 1;
1848 }
1849 elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) {
1850 0 push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D";
1851 0 $i += 1;
1852 }
1853 elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) {
1854 2 push @singleoctet, $char[$i];
1855 2 $i += 1;
1856 }
1857  
1858 # single character of multiple-octet code
1859 else {
1860 84 push @multipleoctet, $char[$i];
1861 84 $i += 1;
1862 }
1863 }
1864  
1865 # quote metachar
1866 650 for (@singleoctet) {
1867 1437 ▶ if ($_ eq '...') {
Branch: 5 branches
BranchTrueFalseTotal
if ($_ eq '...') { } 0 1437 1437
elsif (/\A \n \z/mosx) { } 8 1429 1437
elsif (/\A \r \z/mosx) { } 8 1421 1429
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/mosx) { } 744 677 1421
elsif (/\A [\x00-\xFF] \z/mosx) { } 429 248 677
1868 0 $_ = '-';
1869 }
1870 elsif (/\A \n \z/oxms) {
1871 8 $_ = '\n';
1872 }
1873 elsif (/\A \r \z/oxms) {
1874 8 $_ = '\r';
1875 }
1876 elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) {
1877 744 $_ = sprintf('\x%02X', CORE::ord $1);
1878 }
1879 elsif (/\A [\x00-\xFF] \z/oxms) {
1880 429 $_ = quotemeta $_;
1881 }
1882 }
1883  
1884 # return character list
1885 650 return \@singleoctet, \@multipleoctet;
1886 }
1887  
1888 #
1889 # Latin-1 octal escape sequence
1890 #
1891 5 ▶sub octchr {
Subroutine octchr: called CC=2 SCAR=6.9
Pod undocumented
1892 5 my($octdigit) = @_;
1893  
1894 5 my @binary = ();
1895 5 for my $octal (split(//,$octdigit)) {
1896 push @binary, {
1897 '0' => '000',
1898 '1' => '001',
1899 '2' => '010',
1900 '3' => '011',
1901 '4' => '100',
1902 '5' => '101',
1903 '6' => '110',
1904 '7' => '111',
1905 50 }->{$octal};
1906 }
1907 5 my $binary = join '', @binary;
1908  
1909 my $octchr = {
1910 # 1234567
1911 1 => pack('B*', "0000000$binary"),
1912 2 => pack('B*', "000000$binary"),
1913 3 => pack('B*', "00000$binary"),
1914 4 => pack('B*', "0000$binary"),
1915 5 => pack('B*', "000$binary"),
1916 6 => pack('B*', "00$binary"),
1917 7 => pack('B*', "0$binary"),
1918 0 => pack('B*', "$binary"),
1919  
1920 5 }->{CORE::length($binary) % 8};
1921  
1922 5 return $octchr;
1923 }
1924  
1925 #
1926 # Latin-1 hexadecimal escape sequence
1927 #
1928 5 ▶sub hexchr {
Subroutine hexchr: called CC=1 SCAR=0.0
Pod undocumented
1929 5 my($hexdigit) = @_;
1930  
1931 my $hexchr = {
1932 1 => pack('H*', "0$hexdigit"),
1933 0 => pack('H*', "$hexdigit"),
1934  
1935 5 }->{CORE::length($_[0]) % 2};
1936  
1937 5 return $hexchr;
1938 }
1939  
1940 #
1941 # Latin-1 open character list for qr
1942 #
1943 576 ▶sub charlist_qr {
Subroutine charlist_qr: called CC=17 SCAR=28.7
Pod undocumented
1944  
1945 576 my $modifier = pop @_;
1946 576 my @char = @_;
1947  
1948 576 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
1949 576 my @singleoctet = @$singleoctet;
1950 576 my @multipleoctet = @$multipleoctet;
1951  
1952 # return character list
1953 576 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) 498 78 576
1954  
1955 # with /i modifier
1956 498 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 265 233 498
1957 265 my %singleoctet_ignorecase = ();
1958 265 for (@singleoctet) {
1959 745 ▶ while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx) 745 745 1490
Condition100%3/3
s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx
l!l&&r!l&&!r
25720745
MC/DC100%2/2
s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx
s/ \A \\x(..) - \\x(..) //mosx s/ \A \\x((..)) //mosx
Truth table100%3/3
A or B
A= s/ \A \\x(..) - \\x(..) //mosxB= s/ \A \\x((..)) //mosx
ABresult
1X1
011
000
1960 745 for my $ord (hex($1) .. hex($2)) {
1961 795 my $char = CORE::chr($ord);
1962 795 my $uc = Elatin1::uc($char);
1963 795 my $fc = Elatin1::fc($char);
1964 795 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 240 555 795
1965 240 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
1966 }
1967 else {
1968 555 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 555 0 555
1969 555 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1970 555 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
1971 }
1972 else {
1973 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1974 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
1975 }
1976 }
1977 }
1978 }
1979 745 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 745 745
1980 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
1981 }
1982 }
1983 265 my $i = 0;
1984 265 my @singleoctet_ignorecase = ();
1985 265 for my $ord (0 .. 255) {
1986 67840 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 870 66970 67840
1987 870 push @{$singleoctet_ignorecase[$i]}, $ord;
1988 }
1989 else {
1990 66970 $i++;
1991 }
1992 }
1993 265 @singleoctet = ();
1994 265 for my $range (@singleoctet_ignorecase) {
1995 56160 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 770 55390 56160
1996 770 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 720 50 770
elsif (scalar @{$range;} == 2) { } 0 50 50
1997 720 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
1998 }
1999 50 elsif (scalar(@{$range}) == 2) {
2000 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2001 }
2002 else {
2003 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2004 }
2005 }
2006 }
2007 }
2008  
2009 498 my $not_anchor = '';
2010  
2011 498 push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' );
2012 }
2013 576 ▶ if (scalar(@multipleoctet) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 2) { } 6 570 576
2014 6 return '(?:' . join('|', @multipleoctet) . ')';
2015 }
2016 else {
2017 570 return $multipleoctet[0];
2018 }
2019 }
2020  
2021 #
2022 # Latin-1 open character list for not qr
2023 #
2024 74 ▶sub charlist_not_qr {
Subroutine charlist_not_qr: called CC=18 SCAR=33.1
Pod undocumented
2025  
2026 74 my $modifier = pop @_;
2027 74 my @char = @_;
2028  
2029 74 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
2030 74 my @singleoctet = @$singleoctet;
2031 74 my @multipleoctet = @$multipleoctet;
2032  
2033 # with /i modifier
2034 74 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 25 49 74
2035 25 my %singleoctet_ignorecase = ();
2036 25 for (@singleoctet) {
2037 25 ▶ while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx) 25 25 50
Condition66%2/3
s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx
l!l&&r!l&&!r
25025
MC/DC50%1/2
s/ \A \\x(..) - \\x(..) //mosx or s/ \A \\x((..)) //mosx
s/ \A \\x(..) - \\x(..) //mosx s/ \A \\x((..)) //mosx
Truth table66%2/3
A or B
A= s/ \A \\x(..) - \\x(..) //mosxB= s/ \A \\x((..)) //mosx
ABresult
1X1
011
000
2038 25 for my $ord (hex($1) .. hex($2)) {
2039 75 my $char = CORE::chr($ord);
2040 75 my $uc = Elatin1::uc($char);
2041 75 my $fc = Elatin1::fc($char);
2042 75 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 0 75 75
2043 0 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
2044 }
2045 else {
2046 75 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 75 0 75
2047 75 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2048 75 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
2049 }
2050 else {
2051 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2052 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
2053 }
2054 }
2055 }
2056 }
2057 25 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 25 25
2058 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
2059 }
2060 }
2061 25 my $i = 0;
2062 25 my @singleoctet_ignorecase = ();
2063 25 for my $ord (0 .. 255) {
2064 6400 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 150 6250 6400
2065 150 push @{$singleoctet_ignorecase[$i]}, $ord;
2066 }
2067 else {
2068 6250 $i++;
2069 }
2070 }
2071 25 @singleoctet = ();
2072 25 for my $range (@singleoctet_ignorecase) {
2073 2400 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 50 2350 2400
2074 50 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 0 50 50
elsif (scalar @{$range;} == 2) { } 0 50 50
2075 0 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2076 }
2077 50 elsif (scalar(@{$range}) == 2) {
2078 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2079 }
2080 else {
2081 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2082 }
2083 }
2084 }
2085 }
2086  
2087 # return character list
2088 74 ▶ if (scalar(@multipleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 1) { } 0 74 74
2089 0 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 0 0 0
2090  
2091 # any character other than multiple-octet and single octet character class
2092 0 return '(?!' . join('|', @multipleoctet) . ')(?:[^' . join('', @singleoctet) . '])';
2093 }
2094 else {
2095  
2096 # any character other than multiple-octet character class
2097 0 return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)";
2098 }
2099 }
2100 else {
2101 74 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 74 0 74
2102  
2103 # any character other than single octet character class
2104 74 return '(?:[^' . join('', @singleoctet) . '])';
2105 }
2106 else {
2107  
2108 # any character
2109 0 return "(?:$your_char)";
2110 }
2111 }
2112 }
2113  
2114 #
2115 # open file in read mode
2116 #
2117 424 ▶sub _open_r {
Subroutine _open_r: called CC=1 SCAR=0.0
2118 424 my(undef,$file) = @_;
2119 424 ▶ use Fcntl qw(O_RDONLY);
Subroutine BEGIN: called CC=1 SCAR=0.0
2120 424 return CORE::sysopen($_[0], $file, &O_RDONLY);
2121 }
2122  
2123 #
2124 # open file in append mode
2125 #
2126 212 ▶sub _open_a {
Subroutine _open_a: called CC=1 SCAR=0.0
2127 212 my(undef,$file) = @_;
2128 424 ▶ use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
2129 212 return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT);
2130 }
2131  
2132 #
2133 # safe system
2134 #
2135 212 ▶sub _systemx {
Subroutine _systemx: called CC=1 SCAR=0.0
2136  
2137 # P.707 29.2.33. exec
2138 # in Chapter 29: Functions
2139 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2140 #
2141 # Be aware that in older releases of Perl, exec (and system) did not flush
2142 # your output buffer, so you needed to enable command buffering by setting $|
2143 # on one or more filehandles to avoid lost output in the case of exec, or
2144 # misordererd output in the case of system. This situation was largely remedied
2145 # in the 5.6 release of Perl. (So, 5.005 release not yet.)
2146  
2147 # P.855 exec
2148 # in Chapter 27: Functions
2149 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2150 #
2151 # In very old release of Perl (before v5.6), exec (and system) did not flush
2152 # your output buffer, so you needed to enable command buffering by setting $|
2153 # on one or more filehandles to avoid lost output with exec or misordered
2154 # output with system.
2155  
2156 212 $| = 1;
2157  
2158 # P.565 23.1.2. Cleaning Up Your Environment
2159 # in Chapter 23: Security
2160 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2161  
2162 # P.656 Cleaning Up Your Environment
2163 # in Chapter 20: Security
2164 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2165  
2166 # local $ENV{'PATH'} = '.';
2167 212 local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
2168  
2169 # P.707 29.2.33. exec
2170 # in Chapter 29: Functions
2171 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2172 #
2173 # As we mentioned earlier, exec treats a discrete list of arguments as an
2174 # indication that it should bypass shell processing. However, there is one
2175 # place where you might still get tripped up. The exec call (and system, too)
2176 # will not distinguish between a single scalar argument and an array containing
2177 # only one element.
2178 #
2179 # @args = ("echo surprise"); # just one element in list
2180 # exec @args # still subject to shell escapes
2181 # or die "exec: $!"; # because @args == 1
2182 #
2183 # To avoid this, you can use the PATHNAME syntax, explicitly duplicating the
2184 # first argument as the pathname, which forces the rest of the arguments to be
2185 # interpreted as a list, even if there is only one of them:
2186 #
2187 # exec { $args[0] } @args # safe even with one-argument list
2188 # or die "can't exec @args: $!";
2189  
2190 # P.855 exec
2191 # in Chapter 27: Functions
2192 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2193 #
2194 # As we mentioned earlier, exec treats a discrete list of arguments as a
2195 # directive to bypass shell processing. However, there is one place where
2196 # you might still get tripped up. The exec call (and system, too) cannot
2197 # distinguish between a single scalar argument and an array containing
2198 # only one element.
2199 #
2200 # @args = ("echo surprise"); # just one element in list
2201 # exec @args # still subject to shell escapes
2202 # || die "exec: $!"; # because @args == 1
2203 #
2204 # To avoid this, use the PATHNAME syntax, explicitly duplicating the first
2205 # argument as the pathname, which forces the rest of the arguments to be
2206 # interpreted as a list, even if there is only one of them:
2207 #
2208 # exec { $args[0] } @args # safe even with one-argument list
2209 # || die "can't exec @args: $!";
2210  
2211 212 return CORE::system { $_[0] } @_; # safe even with one-argument list
2212 }
2213  
2214 #
2215 # Latin-1 order to character (with parameter)
2216 #
2217 3469 ▶sub Elatin1::chr(;$) {
Subroutine chr: called CC=4 SCAR=13.9
Pod undocumented
2218  
2219 3469 ▶ my $c = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3469 0 3469
2220  
2221 3469 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 24 3445 3469
2222 24 return "\x00";
2223 }
2224 else {
2225 3445 my @chr = ();
2226 3445 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 3445 3445 6890
2227 3445 unshift @chr, ($c % 0x100);
2228 3445 $c = int($c / 0x100);
2229 }
2230 3445 return pack 'C*', @chr;
2231 }
2232 }
2233  
2234 #
2235 # Latin-1 order to character (without parameter)
2236 #
2237 0 ▶sub Elatin1::chr_() {
Subroutine chr_: not called CC=3 SCAR=24.8
Pod undocumented
2238  
2239 0 my $c = $_;
2240  
2241 0 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 0 0 0
2242 0 return "\x00";
2243 }
2244 else {
2245 0 my @chr = ();
2246 0 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 0 0 0
2247 0 unshift @chr, ($c % 0x100);
2248 0 $c = int($c / 0x100);
2249 }
2250 0 return pack 'C*', @chr;
2251 }
2252 }
2253  
2254 #
2255 # Latin-1 path globbing (with parameter)
2256 #
2257 0 ▶sub Elatin1::glob($) {
Subroutine glob: not called CC=3 SCAR=24.8
Pod undocumented
2258  
2259 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2260 0 my @glob = _DOS_like_glob(@_);
2261 0 for my $glob (@glob) {
2262 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2263 }
2264 0 return @glob;
2265 }
2266 else {
2267 0 my $glob = _DOS_like_glob(@_);
2268 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2269 0 return $glob;
2270 }
2271 }
2272  
2273 #
2274 # Latin-1 path globbing (without parameter)
2275 #
2276 0 ▶sub Elatin1::glob_() {
Subroutine glob_: not called CC=3 SCAR=24.8
Pod undocumented
2277  
2278 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2279 0 my @glob = _DOS_like_glob();
2280 0 for my $glob (@glob) {
2281 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2282 }
2283 0 return @glob;
2284 }
2285 else {
2286 0 my $glob = _DOS_like_glob();
2287 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2288 0 return $glob;
2289 }
2290 }
2291  
2292 #
2293 # Latin-1 path globbing via File::DosGlob 1.10
2294 #
2295 # Often I confuse "_dosglob" and "_doglob".
2296 # So, I renamed "_dosglob" to "_DOS_like_glob".
2297 #
2298 424 my %iter;
2299 my %entries;
2300 0 ▶sub _DOS_like_glob {
Subroutine _DOS_like_glob: not called CC=10 SCAR=47.0
2301  
2302 # context (keyed by second cxix argument provided by core)
2303 0 my($expr,$cxix) = @_;
2304  
2305 # glob without args defaults to $_
2306 0 ▶ $expr = $_ if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2307  
2308 # represents the current user's home directory
2309 #
2310 # 7.3. Expanding Tildes in Filenames
2311 # in Chapter 7. File Access
2312 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2313 #
2314 # and File::HomeDir, File::HomeDir::Windows module
2315  
2316 # DOS-like system
2317 0 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) { } 0 0 0
2318 0 $expr =~ s{ \A ~ (?= [^/\\] ) }
2319 0 { my_home_MSWin32() }oxmse;
2320 }
2321  
2322 # UNIX-like system
2323 else {
2324 0 $expr =~ s{ \A ~ ( (?:[^/])* ) }
2325 0 ▶ { $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse;
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
Condition0%0/3
eval "(getpwnam(\$1))[7]" or my_home()
l!l&&r!l&&!r
000
MC/DC0%0/2
eval "(getpwnam(\$1))[7]" or my_home()
eval "(getpwnam(\$1))[7]" my_home()
Truth table0%0/3
A or B
A= eval "(getpwnam(\$1))[7]"B= my_home()
ABresult
1X1
011
000
2326 }
2327  
2328 # assume global context if not provided one
2329 0 ▶ $cxix = '_G_' if not defined $cxix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cxix 0 0 0
2330 0 ▶ $iter{$cxix} = 0 if not exists $iter{$cxix};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $iter{$cxix} 0 0 0
2331  
2332 # if we're just beginning, do it all first
2333 0 ▶ if ($iter{$cxix} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} == 0) 0 0 0
2334 0 $entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ];
2335 }
2336  
2337 # chuck it all out, quick or slow
2338 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2339 0 delete $iter{$cxix};
2340 0 return @{delete $entries{$cxix}};
2341 }
2342 else {
2343 0 ▶ if ($iter{$cxix} = scalar @{$entries{$cxix}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} = scalar @{$entries{$cxix};}) { } 0 0 0
2344 0 return shift @{$entries{$cxix}};
2345 }
2346 else {
2347 # return undef for EOL
2348 0 delete $iter{$cxix};
2349 0 delete $entries{$cxix};
2350 0 return undef;
2351 }
2352 }
2353 }
2354  
2355 #
2356 # Latin-1 path globbing subroutine
2357 #
2358 0 ▶sub _do_glob {
Subroutine _do_glob: not called CC=44 SCAR=75.9
2359  
2360 0 my($cond,@expr) = @_;
2361 0 my @glob = ();
2362 0 my $fix_drive_relative_paths = 0;
2363  
2364 OUTER:
2365 0 for my $expr (@expr) {
2366 0 ▶ next OUTER if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2367 0 ▶ next OUTER if $expr eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $expr eq "" 0 0 0
2368  
2369 0 my @matched = ();
2370 0 my @globdir = ();
2371 0 my $head = '.';
2372 0 my $pathsep = '/';
2373 0 my $tail;
2374  
2375 # if argument is within quotes strip em and do no globbing
2376 0 ▶ if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ /\A " ((?:$Elatin1::q_char)*?) " \z/mosx) 0 0 0
2377 0 $expr = $1;
2378 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2379 0 ▶ if (-d $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $expr) 0 0 0
2380 0 push @glob, $expr;
2381 }
2382 }
2383 else {
2384 0 ▶ if (-e $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $expr) 0 0 0
2385 0 push @glob, $expr;
2386 }
2387 }
2388 0 next OUTER;
2389 }
2390  
2391 # wildcards with a drive prefix such as h:*.pm must be changed
2392 # to h:./*.pm to expand correctly
2393 0 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) 0 0 0
2394 0 ▶ if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^/\\]) #$1./$2#oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ s( \A ((?:[A-Za-z]:)?) ([^/\\]) )[$1./$2]mosx) 0 0 0
2395 0 $fix_drive_relative_paths = 1;
2396 }
2397 }
2398  
2399 0 ▶ if (($head, $tail) = _parse_path($expr,$pathsep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($head, $tail) = _parse_path($expr, $pathsep)) 0 0 0
2400 0 ▶ if ($tail eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail eq "") 0 0 0
2401 0 push @glob, $expr;
2402 0 next OUTER;
2403 }
2404 0 ▶ if ($head =~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ / \A (?:$Elatin1::q_char)*? [*?] /mosx) 0 0 0
2405 0 ▶ if (@globdir = _do_glob('d', $head)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@globdir = _do_glob("d", $head)) 0 0 0
2406 0 push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir);
2407 0 next OUTER;
2408 }
2409 }
2410 0 ▶ if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq "" or $head =~ /\A [A-Za-z]: \z/mosx) 0 0 0
Condition0%0/3
$head eq "" or $head =~ /\A [A-Za-z]: \z/mosx
l!l&&r!l&&!r
000
MC/DC0%0/2
$head eq "" or $head =~ /\A [A-Za-z]: \z/mosx
$head eq "" $head =~ /\A [A-Za-z]: \z/mosx
Truth table0%0/3
A or B
A= $head eq ""B= $head =~ /\A [A-Za-z]: \z/mosx
ABresult
1X1
011
000
2411 0 $head .= $pathsep;
2412 }
2413 0 $expr = $tail;
2414 }
2415  
2416 # If file component has no wildcards, we can avoid opendir
2417 0 ▶ if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expr =~ / \A (?:$Elatin1::q_char)*? [*?] /mosx) 0 0 0
2418 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2419 0 $head = '';
2420 }
2421 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2422 0 $head .= $pathsep;
2423 }
2424 0 $head .= $expr;
2425 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2426 0 ▶ if (-d $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $head) 0 0 0
2427 0 push @glob, $head;
2428 }
2429 }
2430 else {
2431 0 ▶ if (-e $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $head) 0 0 0
2432 0 push @glob, $head;
2433 }
2434 }
2435 0 next OUTER;
2436 }
2437 0 ▶ opendir(*DIR, $head) or next OUTER;
Branch: 1 branch
BranchTrueFalseTotal
opendir *DIR, $head or next OUTER 0 0 0
2438 0 my @leaf = readdir DIR;
2439 0 closedir DIR;
2440  
2441 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2442 0 $head = '';
2443 }
2444 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Elatin1::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2445 0 $head .= $pathsep;
2446 }
2447  
2448 0 my $pattern = '';
2449 0 ▶ while ($expr =~ / \G ($q_char) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ / \G ($Elatin1::q_char) /cgox) 0 0 0
2450 0 my $char = $1;
2451  
2452 # 6.9. Matching Shell Globs as Regular Expressions
2453 # in Chapter 6. Pattern Matching
2454 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2455 # (and so on)
2456  
2457 0 ▶ if ($char eq '*') {
Branch: 3 branches
BranchTrueFalseTotal
if ($char eq '*') { } 0 0 0
elsif ($char eq '?') { } 0 0 0
elsif ((my $fc = &fc($char)) ne $char) { } 0 0 0
2458 0 $pattern .= "(?:$your_char)*",
2459 }
2460 elsif ($char eq '?') {
2461 0 $pattern .= "(?:$your_char)?", # DOS style
2462 # $pattern .= "(?:$your_char)", # UNIX style
2463 }
2464 elsif ((my $fc = Elatin1::fc($char)) ne $char) {
2465 0 $pattern .= $fc;
2466 }
2467 else {
2468 0 $pattern .= quotemeta $char;
2469 }
2470 }
2471 0 ▶ my $matchsub = sub { Elatin1::fc($_[0]) =~ /\A $pattern \z/xms };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2472  
2473 # if ($@) {
2474 # print STDERR "$0: $@\n";
2475 # next OUTER;
2476 # }
2477  
2478 INNER:
2479 0 for my $leaf (@leaf) {
2480 0 ▶ if ($leaf eq '.' or $leaf eq '..') {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf eq "." or $leaf eq "..") 0 0 0
Condition0%0/3
$leaf eq "." or $leaf eq ".."
l!l&&r!l&&!r
000
MC/DC0%0/2
$leaf eq "." or $leaf eq ".."
$leaf eq "." $leaf eq ".."
Truth table0%0/3
A or B
A= $leaf eq "."B= $leaf eq ".."
ABresult
1X1
011
000
2481 0 next INNER;
2482 }
2483 0 ▶ if ($cond eq 'd' and not -d "$head$leaf") {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq "d" and not -d "$head$leaf") 0 0 0
Condition0%0/3
$cond eq "d" and not -d "$head$leaf"
!ll&&!rl&&r
000
MC/DC0%0/2
$cond eq "d" and not -d "$head$leaf"
$cond eq "d" not -d "$head$leaf"
Truth table0%0/3
A and not(B)
A= $cond eq "d"B= not -d "$head$leaf"
ABresult
0X0
100
111
2484 0 next INNER;
2485 }
2486  
2487 0 ▶ if (&$matchsub($leaf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub($leaf)) 0 0 0
2488 0 push @matched, "$head$leaf";
2489 0 next INNER;
2490 }
2491  
2492 # [DOS compatibility special case]
2493 # Failed, add a trailing dot and try again, but only...
2494  
2495 0 ▶ if (Elatin1::index($leaf,'.') == -1 and # if name does not have a dot in it *and*
Branch: 1 branch
BranchTrueFalseTotal
if (&Elatin1::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin1::index($pattern, "\\.") != -1) 0 0 0
Condition0%0/6
&Elatin1::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin1::index($pattern, "\\.") != -1
!ll&&!rl&&r
000
&Elatin1::index($leaf, ".") == -1 and length $leaf <= 8
!ll&&!rl&&r
000
MC/DC0%0/3
&Elatin1::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin1::index($pattern, "\\.") != -1
&Elatin1::index($leaf, ".") == -1 length $leaf <= 8 &Elatin1::index($pattern, "\\.") != -1
Truth table0%0/4
A and B and C
A= &Elatin1::index($leaf, ".") == -1B= length $leaf <= 8C= &Elatin1::index($pattern, "\\.") != -1
ABCresult
0XX0
10X0
1100
1111
2496 CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and*
2497 Elatin1::index($pattern,'\\.') != -1 # pattern has a dot.
2498 ) {
2499 0 ▶ if (&$matchsub("$leaf.")) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub("$leaf.")) 0 0 0
2500 0 push @matched, "$head$leaf";
2501 0 next INNER;
2502 }
2503 }
2504 }
2505 0 ▶ if (@matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matched) 0 0 0
2506 0 push @glob, @matched;
2507 }
2508 }
2509 0 ▶ if ($fix_drive_relative_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fix_drive_relative_paths) 0 0 0
2510 0 for my $glob (@glob) {
2511 0 $glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms;
2512 }
2513 }
2514 0 return @glob;
2515 }
2516  
2517 #
2518 # Latin-1 parse line
2519 #
2520 0 ▶sub _parse_line {
Subroutine _parse_line: not called CC=3 SCAR=24.8
2521  
2522 0 my($line) = @_;
2523  
2524 0 $line .= ' ';
2525 0 my @piece = ();
2526 0 ▶ while ($line =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / " ( (?>(?: [^"] )* ) ) " (?>\s+) | ( (?>(?: [^"\s] )* ) ) (?>\s+) /gmosx) 0 0 0
2527 " ( (?>(?: [^"] )* ) ) " (?>\s+) |
2528 ( (?>(?: [^"\s] )* ) ) (?>\s+)
2529 /oxmsg
2530 ) {
2531 0 ▶ push @piece, defined($1) ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
2532 }
2533 0 return @piece;
2534 }
2535  
2536 #
2537 # Latin-1 parse path
2538 #
2539 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=2 SCAR=17.9
2540  
2541 0 my($path,$pathsep) = @_;
2542  
2543 0 $path .= '/';
2544 0 my @subpath = ();
2545 0 ▶ while ($path =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m( ((?: [^/\\] )+?) [/\\] )gmosx) 0 0 0
2546 ((?: [^\/\\] )+?) [\/\\]
2547 /oxmsg
2548 ) {
2549 0 push @subpath, $1;
2550 }
2551  
2552 0 my $tail = pop @subpath;
2553 0 my $head = join $pathsep, @subpath;
2554 0 return $head, $tail;
2555 }
2556  
2557 #
2558 # via File::HomeDir::Windows 1.00
2559 #
2560 0 ▶sub my_home_MSWin32 {
Subroutine my_home_MSWin32: not called CC=9 SCAR=45.0
Pod undocumented
2561  
2562 # A lot of unix people and unix-derived tools rely on
2563 # the ability to overload HOME. We will support it too
2564 # so that they can replace raw HOME calls with File::HomeDir.
2565 0 ▶ if (exists $ENV{'HOME'} and $ENV{'HOME'}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { } 0 0 0
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { } 0 0 0
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { } 0 0 0
Condition0%0/3
exists $ENV{"HOME"} and $ENV{"HOME"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"HOME"} and $ENV{"HOME"}
exists $ENV{"HOME"} $ENV{"HOME"}
Truth table0%0/3
A and B
A= exists $ENV{"HOME"}B= $ENV{"HOME"}
ABresult
0X0
100
111
2566 0 return $ENV{'HOME'};
2567 }
2568  
2569 # Do we have a user profile?
2570 ▶ elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) {
Condition0%0/3
exists $ENV{"USERPROFILE"} and $ENV{"USERPROFILE"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"USERPROFILE"} and $ENV{"USERPROFILE"}
exists $ENV{"USERPROFILE"} $ENV{"USERPROFILE"}
Truth table0%0/3
A and B
A= exists $ENV{"USERPROFILE"}B= $ENV{"USERPROFILE"}
ABresult
0X0
100
111
2571 0 return $ENV{'USERPROFILE'};
2572 }
2573  
2574 # Some Windows use something like $ENV{'HOME'}
2575 ▶ elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) {
Condition0%0/9
exists $ENV{"HOMEDRIVE"} and exists $ENV{"HOMEPATH"} and $ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
!ll&&!rl&&r
000
exists $ENV{"HOMEDRIVE"} and exists $ENV{"HOMEPATH"} and $ENV{"HOMEDRIVE"}
!ll&&!rl&&r
000
exists $ENV{"HOMEDRIVE"} and exists $ENV{"HOMEPATH"}
!ll&&!rl&&r
000
MC/DC0%0/4
exists $ENV{"HOMEDRIVE"} and exists $ENV{"HOMEPATH"} and $ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
exists $ENV{"HOMEDRIVE"} exists $ENV{"HOMEPATH"} $ENV{"HOMEDRIVE"} $ENV{"HOMEPATH"}
Truth table0%0/5
A and B and C and D
A= exists $ENV{"HOMEDRIVE"}B= exists $ENV{"HOMEPATH"}C= $ENV{"HOMEDRIVE"}D= $ENV{"HOMEPATH"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2576 0 return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
2577 }
2578  
2579 0 return undef;
2580 }
2581  
2582 #
2583 # via File::HomeDir::Unix 1.00
2584 #
2585 0 ▶sub my_home {
Subroutine my_home: not called CC=7 SCAR=40.3
Pod undocumented
2586 0 my $home;
2587  
2588 0 ▶ if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { } 0 0 0
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { } 0 0 0
Condition0%0/3
exists $ENV{"HOME"} and defined $ENV{"HOME"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"HOME"} and defined $ENV{"HOME"}
exists $ENV{"HOME"} defined $ENV{"HOME"}
Truth table0%0/3
A and B
A= exists $ENV{"HOME"}B= defined $ENV{"HOME"}
ABresult
0X0
100
111
2589 0 $home = $ENV{'HOME'};
2590 }
2591  
2592 # This is from the original code, but I'm guessing
2593 # it means "login directory" and exists on some Unixes.
2594 ▶ elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) {
Condition0%0/3
exists $ENV{"LOGDIR"} and $ENV{"LOGDIR"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"LOGDIR"} and $ENV{"LOGDIR"}
exists $ENV{"LOGDIR"} $ENV{"LOGDIR"}
Truth table0%0/3
A and B
A= exists $ENV{"LOGDIR"}B= $ENV{"LOGDIR"}
ABresult
0X0
100
111
2595 0 $home = $ENV{'LOGDIR'};
2596 }
2597  
2598 ### More-desperate methods
2599  
2600 # Light desperation on any (Unixish) platform
2601 else {
2602 0 $home = CORE::eval q{ (getpwuid($<))[7] };
2603 }
2604  
2605 # On Unix in general, a non-existant home means "no home"
2606 # For example, "nobody"-like users might use /nonexistant
2607 0 ▶ if (defined $home and ! -d($home)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $home and not -d $home) 0 0 0
Condition0%0/3
defined $home and not -d $home
!ll&&!rl&&r
000
MC/DC0%0/2
defined $home and not -d $home
defined $home not -d $home
Truth table0%0/3
A and not(B)
A= defined $homeB= not -d $home
ABresult
0X0
100
111
2608 0 $home = undef;
2609 }
2610 0 return $home;
2611 }
2612  
2613 #
2614 # ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched
2615 #
2616 56 ▶sub Elatin1::PREMATCH {
Subroutine PREMATCH: called CC=1 SCAR=0.0
Pod undocumented
2617 56 return $`;
2618 }
2619  
2620 #
2621 # ${^MATCH}, $MATCH, $& the string that matched
2622 #
2623 81 ▶sub Elatin1::MATCH {
Subroutine MATCH: called CC=1 SCAR=0.0
Pod undocumented
2624 81 return $&;
2625 }
2626  
2627 #
2628 # ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched
2629 #
2630 42 ▶sub Elatin1::POSTMATCH {
Subroutine POSTMATCH: called CC=1 SCAR=0.0
Pod undocumented
2631 42 return $';
2632 }
2633  
2634 #
2635 # Latin-1 character to order (with parameter)
2636 #
2637 0 ▶sub Latin1::ord(;$) {
Subroutine ord: not called CC=4 SCAR=30.0
2638  
2639 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2640  
2641 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Elatin1::q_char) /mosx) { } 0 0 0
2642 0 my @ord = unpack 'C*', $1;
2643 0 my $ord = 0;
2644 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2645 0 $ord = $ord * 0x100 + $o;
2646 }
2647 0 return $ord;
2648 }
2649 else {
2650 0 return CORE::ord $_;
2651 }
2652 }
2653  
2654 #
2655 # Latin-1 character to order (without parameter)
2656 #
2657 0 ▶sub Latin1::ord_() {
Subroutine ord_: not called CC=3 SCAR=24.8
2658  
2659 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Elatin1::q_char) /mosx) { } 0 0 0
2660 0 my @ord = unpack 'C*', $1;
2661 0 my $ord = 0;
2662 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2663 0 $ord = $ord * 0x100 + $o;
2664 }
2665 0 return $ord;
2666 }
2667 else {
2668 0 return CORE::ord $_;
2669 }
2670 }
2671  
2672 #
2673 # Latin-1 reverse
2674 #
2675 0 ▶sub Latin1::reverse(@) {
Subroutine reverse: not called CC=2 SCAR=17.9
2676  
2677 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2678 0 return CORE::reverse @_;
2679 }
2680 else {
2681  
2682 # One of us once cornered Larry in an elevator and asked him what
2683 # problem he was solving with this, but he looked as far off into
2684 # the distance as he could in an elevator and said, "It seemed like
2685 # a good idea at the time."
2686  
2687 0 return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg);
2688 }
2689 }
2690  
2691 #
2692 # Latin-1 getc (with parameter, without parameter)
2693 #
2694 20 ▶sub Latin1::getc(;*@) {
Subroutine getc: called CC=9 SCAR=26.7
2695  
2696 20 my($package) = caller;
2697 20 ▶ my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 20 0 20
2698 20 ▶ croak 'Too many arguments for Latin1::getc' if @_ and not wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if @_ and not wantarray 0 20 20
Condition33%1/3
@_ and not wantarray
!ll&&!rl&&r
2000
MC/DC0%0/2
@_ and not wantarray
@_ not wantarray
Truth table33%1/3
A and not(B)
A= @_B= not wantarray
ABresult
0X0
100
111
2699  
2700 0 my @length = sort { $a <=> $b } keys %range_tr;
2701 20 my $getc = '';
2702 20 for my $length ($length[0] .. $length[-1]) {
2703 20 $getc .= CORE::getc($fh);
2704 20 ▶ if (exists $range_tr{CORE::length($getc)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{length $getc}) 20 0 20
2705 20 ▶ if ($getc =~ /\A ${Elatin1::dot_s} \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A $Elatin1::dot_s \z/mosx) 20 0 20
2706 20 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 20 20
2707 }
2708 }
2709 }
2710 0 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2711 }
2712  
2713 #
2714 # Latin-1 length by character
2715 #
2716 0 ▶sub Latin1::length(;$) {
Subroutine length: not called CC=2 SCAR=17.9
2717  
2718 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2719  
2720 0 local @_ = /\G ($q_char) /oxmsg;
2721 0 return scalar @_;
2722 }
2723  
2724 #
2725 # Latin-1 substr by character
2726 #
2727 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
2728  
2729 # P.232 The lvalue Attribute
2730 # in Chapter 6: Subroutines
2731 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2732  
2733 # P.336 The lvalue Attribute
2734 # in Chapter 7: Subroutines
2735 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2736  
2737 # P.144 8.4 Lvalue subroutines
2738 # in Chapter 8: perlsub: Perl subroutines
2739 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
2740  
2741 0 ▶ CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : '');
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine substr: called CC=11 SCAR=24.3
Branch: 10 branches
BranchTrueFalseTotal
$] >= 5.014 ? : 424 0 424
if ($offset > scalar @char or $offset < -1 * scalar(@char)) 2 25 27
if (@_ == 4) { } 1 24 25
elsif (@_ == 3) { } 21 3 24
if ($offset == 0) { } 0 21 21
elsif ($offset > 0) { } 20 1 21
if ($length == 0) { } 0 21 21
elsif ($length > 0) { } 20 1 21
if ($offset == 0) { } 0 3 3
elsif ($offset > 0) { } 2 1 3
Condition66%2/3
$offset > scalar @char or $offset < -1 * scalar(@char)
l!l&&r!l&&!r
2025
MC/DC50%1/2
$offset > scalar @char or $offset < -1 * scalar(@char)
$offset > scalar @char $offset < -1 * scalar(@char)
Truth table66%2/3
A or B
A= $offset > scalar @charB= $offset < -1 * scalar(@char)
ABresult
1X1
011
000
2742 # vv----------------------*******
2743 sub Latin1::substr($$;$$) %s {
2744  
2745 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
2746  
2747 # If the substring is beyond either end of the string, substr() returns the undefined
2748 # value and produces a warning. When used as an lvalue, specifying a substring that
2749 # is entirely outside the string raises an exception.
2750 # http://perldoc.perl.org/functions/substr.html
2751  
2752 # A return with no argument returns the scalar value undef in scalar context,
2753 # an empty list () in list context, and (naturally) nothing at all in void
2754 # context.
2755  
2756 my $offset = $_[1];
2757 if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) {
2758 return;
2759 }
2760  
2761 # substr($string,$offset,$length,$replacement)
2762 if (@_ == 4) {
2763 my(undef,undef,$length,$replacement) = @_;
2764 my $substr = join '', splice(@char, $offset, $length, $replacement);
2765 $_[0] = join '', @char;
2766  
2767 # return $substr; this doesn't work, don't say "return"
2768 $substr;
2769 }
2770  
2771 # substr($string,$offset,$length)
2772 elsif (@_ == 3) {
2773 my(undef,undef,$length) = @_;
2774 my $octet_offset = 0;
2775 my $octet_length = 0;
2776 if ($offset == 0) {
2777 $octet_offset = 0;
2778 }
2779 elsif ($offset > 0) {
2780 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2781 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2782 }
2783 else {
2784 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2785 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2786 }
2787 if ($length == 0) {
2788 $octet_length = 0;
2789 }
2790 elsif ($length > 0) {
2791 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2792 $octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]);
2793 }
2794 else {
2795 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2796 $octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]);
2797 }
2798 CORE::substr($_[0], $octet_offset, $octet_length);
2799 }
2800  
2801 # substr($string,$offset)
2802 else {
2803 my $octet_offset = 0;
2804 if ($offset == 0) {
2805 $octet_offset = 0;
2806 }
2807 elsif ($offset > 0) {
2808 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2809 }
2810 else {
2811 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2812 }
2813 CORE::substr($_[0], $octet_offset);
2814 }
2815 }
2816 END
2817 }
2818  
2819 #
2820 # Latin-1 index by character
2821 #
2822 0 ▶sub Latin1::index($$;$) {
Subroutine index: not called CC=3 SCAR=24.8
2823  
2824 0 my $index;
2825 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2826 0 $index = Elatin1::index($_[0], $_[1], CORE::length(Latin1::substr($_[0], 0, $_[2])));
2827 }
2828 else {
2829 0 $index = Elatin1::index($_[0], $_[1]);
2830 }
2831  
2832 0 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 0 0 0
2833 0 return -1;
2834 }
2835 else {
2836 0 return Latin1::length(CORE::substr $_[0], 0, $index);
2837 }
2838 }
2839  
2840 #
2841 # Latin-1 rindex by character
2842 #
2843 0 ▶sub Latin1::rindex($$;$) {
Subroutine rindex: not called CC=3 SCAR=24.8
2844  
2845 0 my $rindex;
2846 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2847 0 $rindex = Elatin1::rindex($_[0], $_[1], CORE::length(Latin1::substr($_[0], 0, $_[2])));
2848 }
2849 else {
2850 0 $rindex = Elatin1::rindex($_[0], $_[1]);
2851 }
2852  
2853 0 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 0 0 0
2854 0 return -1;
2855 }
2856 else {
2857 0 return Latin1::length(CORE::substr $_[0], 0, $rindex);
2858 }
2859 }
2860  
2861 # when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??'
2862 # when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else)
2863 424 ▶use vars qw($slash); $slash = 'm//';
Subroutine BEGIN: called CC=1 SCAR=0.0
2864  
2865 # ord() to ord() or Latin1::ord()
2866 424 my $function_ord = 'ord';
2867  
2868 # ord to ord or Latin1::ord_
2869 424 my $function_ord_ = 'ord';
2870  
2871 # reverse to reverse or Latin1::reverse
2872 424 my $function_reverse = 'reverse';
2873  
2874 # getc to getc or Latin1::getc
2875 424 my $function_getc = 'getc';
2876  
2877 # P.1023 Appendix W.9 Multibyte Anchoring
2878 # of ISBN 1-56592-224-7 CJKV Information Processing
2879  
2880 424 my $anchor = '';
2881  
2882 424 ▶use vars qw($nest);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2883  
2884 # regexp of nested parens in qqXX
2885  
2886 # P.340 Matching Nested Constructs with Embedded Code
2887 # in Chapter 7: Perl
2888 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2889  
2890 my $qq_paren = qr{(?{local $nest=0}) (?>(?:
2891 [^\\()] |
2892 \( (?{$nest++}) |
2893 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2894 \\ [^c] |
2895 \\c[\x40-\x5F] |
2896 [\x00-\xFF]
2897 424 }xms;
2898  
2899 my $qq_brace = qr{(?{local $nest=0}) (?>(?:
2900 [^\\{}] |
2901 \{ (?{$nest++}) |
2902 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2903 \\ [^c] |
2904 \\c[\x40-\x5F] |
2905 [\x00-\xFF]
2906 424 }xms;
2907  
2908 my $qq_bracket = qr{(?{local $nest=0}) (?>(?:
2909 [^\\\[\]] |
2910 \[ (?{$nest++}) |
2911 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2912 \\ [^c] |
2913 \\c[\x40-\x5F] |
2914 [\x00-\xFF]
2915 424 }xms;
2916  
2917 my $qq_angle = qr{(?{local $nest=0}) (?>(?:
2918 [^\\<>] |
2919 \< (?{$nest++}) |
2920 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2921 \\ [^c] |
2922 \\c[\x40-\x5F] |
2923 [\x00-\xFF]
2924 424 }xms;
2925  
2926 424 my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} |
2927 (?: ::)? (?:
2928 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2929 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2930 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2931 ))
2932 }xms;
2933  
2934 424 my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} |
2935 (?: ::)? (?:
2936 (?>[0-9]+) |
2937 [^a-zA-Z_0-9\[\]] |
2938 ^[A-Z] |
2939 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2940 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2941 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2942 ))
2943 }xms;
2944  
2945 424 my $qq_substr = qr{(?> Char::substr | Latin1::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \)
2946 }xms;
2947  
2948 # regexp of nested parens in qXX
2949 my $q_paren = qr{(?{local $nest=0}) (?>(?:
2950 [^()] |
2951 \( (?{$nest++}) |
2952 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2953 [\x00-\xFF]
2954 424 }xms;
2955  
2956 my $q_brace = qr{(?{local $nest=0}) (?>(?:
2957 [^\{\}] |
2958 \{ (?{$nest++}) |
2959 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2960 [\x00-\xFF]
2961 424 }xms;
2962  
2963 my $q_bracket = qr{(?{local $nest=0}) (?>(?:
2964 [^\[\]] |
2965 \[ (?{$nest++}) |
2966 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2967 [\x00-\xFF]
2968 424 }xms;
2969  
2970 my $q_angle = qr{(?{local $nest=0}) (?>(?:
2971 [^<>] |
2972 \< (?{$nest++}) |
2973 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2974 [\x00-\xFF]
2975 424 }xms;
2976  
2977 424 my $matched = '';
2978 424 my $s_matched = '';
2979  
2980 424 my $tr_variable = ''; # variable of tr///
2981 424 my $sub_variable = ''; # variable of s///
2982 424 my $bind_operator = ''; # =~ or !~
2983  
2984 424 my @heredoc = (); # here document
2985 424 my @heredoc_delimiter = ();
2986 424 my $here_script = ''; # here script
2987  
2988 #
2989 # escape Latin-1 script
2990 #
2991 548 ▶sub Latin1::escape(;$) {
Subroutine escape: called CC=3 SCAR=11.0
2992 548 ▶ local($_) = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 292 256 548
2993  
2994 # P.359 The Study Function
2995 # in Chapter 7: Perl
2996 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2997  
2998 548 study $_; # Yes, I studied study yesterday.
2999  
3000 # while all script
3001  
3002 # 6.14. Matching from Where the Last Pattern Left Off
3003 # in Chapter 6. Pattern Matching
3004 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
3005 # (and so on)
3006  
3007 # one member of Tag-team
3008 #
3009 # P.128 Start of match (or end of previous match): \G
3010 # P.130 Advanced Use of \G with Perl
3011 # in Chapter 3: Overview of Regular Expression Features and Flavors
3012 # P.255 Use leading anchors
3013 # P.256 Expose ^ and \G at the front expressions
3014 # in Chapter 6: Crafting an Efficient Expression
3015 # P.315 "Tag-team" matching with /gc
3016 # in Chapter 7: Perl
3017 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3018  
3019 548 my $e_script = '';
3020 548 ▶ while (not /\G \z/oxgc) { # member
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 86314 548 86862
3021 86314 $e_script .= Latin1::escape_token();
3022 }
3023  
3024 548 return $e_script;
3025 }
3026  
3027 #
3028 # escape Latin-1 token of script
3029 #
3030 86314 ▶sub Latin1::escape_token {
Subroutine escape_token: called CC=504 SCAR=109.3
3031  
3032 # \n output here document
3033  
3034 86314 my $ignore_modules = join('|', qw(
3035 utf8
3036 bytes
3037 charnames
3038 I18N::Japanese
3039 I18N::Collate
3040 I18N::JExt
3041 File::DosGlob
3042 Wild
3043 Wildcard
3044 Japanese
3045 ));
3046  
3047 # another member of Tag-team
3048 #
3049 # P.315 "Tag-team" matching with /gc
3050 # in Chapter 7: Perl
3051 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3052  
3053 86314 ▶ if (/\G ( \n ) /oxgc) { # another member (and so on)
Branch: 139 branches
BranchTrueFalseTotal
if (/\G ( \n ) /cgox) { } 12799 73515 86314
elsif (/\G ((?>\s+)|\#.*) /cgox) { } 21237 52278 73515
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /cgox) { } 1644 50634 52278
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /cgox) { } 90 50544 50634
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx) { } 4 50540 50544
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 28 50512 50540
elsif (/\G ( \$' | \$\{'\} ) /cgmosx) { } 1 50511 50512
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 3 50508 50511
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /cgox) { } 1754 48754 50508
elsif (/\G ( [,;] ) /cgox) { } 5056 43698 48754
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 43698 43698
elsif (/\G ( \$ 0 ) /cgmosx) { } 2 43696 43698
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 43696 43696
elsif (/\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 1 43695 43696
elsif (/\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 4 43691 43695
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 43691 43691
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 43691 43691
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 43691 43691
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 43691 43691
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /cgmosx) { } 0 43691 43691
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 0 43691 43691
elsif (/\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /cgmosx) { } 42 43649 43691
elsif (m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 63 43586 43649
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /cgox) { } 0 43586 43586
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /cgox) { } 0 43586 43586
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /cgox) { } 0 43586 43586
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /cgox) { } 0 43586 43586
elsif (/\G \b ( if | unless | while | until | for | when ) \b /cgox) { } 251 43335 43586
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 19 43316 43335
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 43316 43316
elsif (/\G \b Latin1::eval (?= (?>\s*) \{ ) /cgox) { } 22 43294 43316
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /cgox) { } 0 43294 43294
elsif (/\G \b Latin1::eval \b (?! (?>\s*) => ) /cgox) { } 168 43126 43294
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /cgox) { } 2 43124 43126
elsif (/\G \b chop \b (?! (?>\s*) => ) /cgox) { } 0 43124 43124
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /cgox) { } 2 43122 43124
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /cgox) { } 0 43122 43122
elsif (/\G \b Latin1::index \b (?! (?>\s*) => ) /cgox) { } 0 43122 43122
elsif (/\G \b index \b (?! (?>\s*) => ) /cgox) { } 0 43122 43122
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /cgox) { } 2 43120 43122
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /cgox) { } 0 43120 43120
elsif (/\G \b Latin1::rindex \b (?! (?>\s*) => ) /cgox) { } 0 43120 43120
elsif (/\G \b rindex \b (?! (?>\s*) => ) /cgox) { } 0 43120 43120
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 43119 43120
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43119 43119
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 43118 43119
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43118 43118
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 6 43112 43118
elsif (/\G -s (?>\s*) (\") ((?:$Elatin1::qq_char)+?) (\") /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Elatin1::qq_char)+?) (\#) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Elatin1::qq_char)+?) (\1) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Elatin1::q_char)+?) (\') /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Elatin1::q_char)+?) (\#) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Elatin1::q_char)+?) (\1) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 43112 43112
elsif (/\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 43112 43112
elsif (/\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 43112 43112
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43110 43112
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43108 43110
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 36 43072 43108
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43070 43072
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 8 43062 43070
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43062 43062
elsif (/\G \b lc \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b uc \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b fc \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G -s \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b chr \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b ord \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b glob \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b reverse \b (?! (?>\s*) => ) /cgox) { } 0 43062 43062
elsif (/\G \b getc \b (?! (?>\s*) => ) /cgox) { } 8 43054 43062
elsif (/\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 87 42967 43054
elsif (/\G \b ( tr | y ) \b /cgox) { } 4 42963 42967
elsif (/\G \b (qq) \b /cgox) { } 2252 40711 42963
elsif (/\G \b (qr) \b /cgox) { } 0 40711 40711
elsif (/\G \b (qw) \b /cgox) { } 16 40695 40711
elsif (/\G \b (qx) \b /cgox) { } 0 40695 40695
elsif (/\G \b (q) \b /cgox) { } 473 40222 40695
elsif (/\G \b (m) \b /cgox) { } 209 40013 40222
elsif (/\G \b (s) \b /cgox) { } 101 39912 40013
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39912 39912
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39912 39912
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39912 39912
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /cgmosx) { } 37 39875 39912
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39875 39875
elsif (/\G \b use ((?>\s+) strict) \b /cgmosx) { } 0 39875 39875
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 2 39873 39875
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 0 39873 39873
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 2 39871 39873
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39871 39871
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39871 39871
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39871 39871
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39871 39871
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39871 39871
elsif (/\G \b use \b /cgmosx) { } 0 39871 39871
elsif (/\G \b no \b /cgmosx) { } 2 39869 39871
elsif (/\G (?<![\w\$\@\%\&\*]) (\') /cgox) { } 1142 38727 39869
elsif (/\G (\") /cgox) { } 1859 36868 38727
elsif (/\G (\`) /cgox) { } 1 36867 36868
elsif ($Elatin1::slash eq 'm//' and m[\G (/) ]cgox) { } 681 36186 36867
elsif ($Elatin1::slash eq 'm//' and /\G (\?) /cgox) { } 0 36186 36186
elsif (/\G ( <<>> ) /cgox) { } 0 36186 36186
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 36186 36186
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 6 36180 36186
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 3 36177 36180
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 6 36171 36177
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 3 36168 36171
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 6 36162 36168
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 72 36090 36162
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 36090 36090
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 36 36054 36090
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 42 36012 36054
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 36012 36012
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 12 36000 36012
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 36000 36000
elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /cgox) { } 0 36000 36000
elsif (/\G ^ ( __DATA__ \n .*) \z /cgmosx) { } 0 36000 36000
elsif (/\G ^ ( __END__ \n .*) \z /cgmosx) { } 210 35790 36000
elsif (/\G ( \cD .*) \z /cgmosx) { } 0 35790 35790
elsif (/\G ( \cZ .*) \z /cgmosx) { } 0 35790 35790
elsif (/\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 5839 29951 35790
elsif (/\G ( \.\.\. ) /cgox) { } 7 29944 29951
elsif (m"\G ((?> !~~ | !~ | != | ! | %= | % | &&= | && | &= | &\.= | &\. | & | -= | -> | - | :(?>\s*)= | : | <<>> | <<= | <=> | <= | < | == | => | =~ | = | >>= | >> | >= | > | \*\*= | \*\* | \*= | \* | \+= | \+ | \.\. | \.= | \. | //= | // | /= | / | \? | \\ | \^= | \^\.= | \^\. | \^ | \b x= | \|\|= | \|\| | \|= | \|\.= | \|\. | \| | ~~ | ~\. | ~ | \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | \b(?: print )\b | [,;\(\{\[] )) "cgox) { } 9766 20178 29944
elsif (/\G ($Elatin1::q_char) /cgox) { } 20178 0 20178
3054 12799 my $heredoc = '';
3055 12799 ▶ if (scalar(@heredoc_delimiter) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @heredoc_delimiter >= 1) 174 12625 12799
3056 174 $slash = 'm//';
3057  
3058 174 $heredoc = join '', @heredoc;
3059 174 @heredoc = ();
3060  
3061 # skip here document
3062 174 for my $heredoc_delimiter (@heredoc_delimiter) {
3063 174 /\G .*? \n $heredoc_delimiter \n/xmsgc;
3064 }
3065 174 @heredoc_delimiter = ();
3066  
3067 174 $here_script = '';
3068 }
3069 12799 return "\n" . $heredoc;
3070 }
3071  
3072 # ignore space, comment
3073 21237 elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; }
3074  
3075 # if (, elsif (, unless (, while (, until (, given (, and when (
3076  
3077 # given, when
3078  
3079 # P.225 The given Statement
3080 # in Chapter 15: Smart Matching and given-when
3081 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3082  
3083 # P.133 The given Statement
3084 # in Chapter 4: Statements and Declarations
3085 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3086  
3087 elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) {
3088 1644 $slash = 'm//';
3089 1644 return $1;
3090 }
3091  
3092 # scalar variable ($scalar = ...) =~ tr///;
3093 # scalar variable ($scalar = ...) =~ s///;
3094  
3095 # state
3096  
3097 # P.68 Persistent, Private Variables
3098 # in Chapter 4: Subroutines
3099 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3100  
3101 # P.160 Persistent Lexically Scoped Variables: state
3102 # in Chapter 4: Statements and Declarations
3103 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3104  
3105 # (and so on)
3106  
3107 elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) {
3108 90 my $e_string = e_string($1);
3109  
3110 90 ▶ if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /cgox) { } 0 90 90
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /cgox) { } 0 90 90
3111 0 $tr_variable = $e_string . e_string($1);
3112 0 $bind_operator = $2;
3113 0 $slash = 'm//';
3114 0 return '';
3115 }
3116 elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3117 0 $sub_variable = $e_string . e_string($1);
3118 0 $bind_operator = $2;
3119 0 $slash = 'm//';
3120 0 return '';
3121 }
3122 else {
3123 90 $slash = 'div';
3124 90 return $e_string;
3125 }
3126 }
3127  
3128 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
3129 elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
3130 4 $slash = 'div';
3131 4 return q{Elatin1::PREMATCH()};
3132 }
3133  
3134 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
3135 elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
3136 28 $slash = 'div';
3137 28 return q{Elatin1::MATCH()};
3138 }
3139  
3140 # $', ${'} --> $', ${'}
3141 elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) {
3142 1 $slash = 'div';
3143 1 return $1;
3144 }
3145  
3146 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
3147 elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
3148 3 $slash = 'div';
3149 3 return q{Elatin1::POSTMATCH()};
3150 }
3151  
3152 # scalar variable $scalar =~ tr///;
3153 # scalar variable $scalar =~ s///;
3154 # substr() =~ tr///;
3155 # substr() =~ s///;
3156 elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) {
3157 1754 my $scalar = e_string($1);
3158  
3159 1754 ▶ if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /cgox) { } 2 1752 1754
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /cgox) { } 65 1687 1752
3160 2 $tr_variable = $scalar;
3161 2 $bind_operator = $1;
3162 2 $slash = 'm//';
3163 2 return '';
3164 }
3165 elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3166 65 $sub_variable = $scalar;
3167 65 $bind_operator = $1;
3168 65 $slash = 'm//';
3169 65 return '';
3170 }
3171 else {
3172 1687 $slash = 'div';
3173 1687 return $scalar;
3174 }
3175 }
3176  
3177 # end of statement
3178 elsif (/\G ( [,;] ) /oxgc) {
3179 5056 $slash = 'm//';
3180  
3181 # clear tr/// variable
3182 5056 $tr_variable = '';
3183  
3184 # clear s/// variable
3185 5056 $sub_variable = '';
3186  
3187 5056 $bind_operator = '';
3188  
3189 5056 return $1;
3190 }
3191  
3192 # bareword
3193 elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
3194 0 return $1;
3195 }
3196  
3197 # $0 --> $0
3198 elsif (/\G ( \$ 0 ) /oxmsgc) {
3199 2 $slash = 'div';
3200 2 return $1;
3201 }
3202 elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
3203 0 $slash = 'div';
3204 0 return $1;
3205 }
3206  
3207 # $$ --> $$
3208 elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
3209 1 $slash = 'div';
3210 1 return $1;
3211 }
3212  
3213 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
3214 # $1, $2, $3 --> $1, $2, $3 otherwise
3215 elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
3216 4 $slash = 'div';
3217 4 return e_capture($1);
3218 }
3219 elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
3220 0 $slash = 'div';
3221 0 return e_capture($1);
3222 }
3223  
3224 # $$foo[ ... ] --> $ $foo->[ ... ]
3225 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
3226 0 $slash = 'div';
3227 0 return e_capture($1.'->'.$2);
3228 }
3229  
3230 # $$foo{ ... } --> $ $foo->{ ... }
3231 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
3232 0 $slash = 'div';
3233 0 return e_capture($1.'->'.$2);
3234 }
3235  
3236 # $$foo
3237 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
3238 0 $slash = 'div';
3239 0 return e_capture($1);
3240 }
3241  
3242 # ${ foo }
3243 elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) {
3244 0 $slash = 'div';
3245 0 return '${' . $1 . '}';
3246 }
3247  
3248 # ${ ... }
3249 elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
3250 0 $slash = 'div';
3251 0 return e_capture($1);
3252 }
3253  
3254 # variable or function
3255 # $ @ % & * $ #
3256 elsif (/\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) {
3257 42 $slash = 'div';
3258 42 return $1;
3259 }
3260 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
3261 # $ @ # \ ' " / ? ( ) [ ] < >
3262 elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
3263 63 $slash = 'div';
3264 63 return $1;
3265 }
3266  
3267 # while (<FILEHANDLE>)
3268 elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) {
3269 0 return $1;
3270 }
3271  
3272 # while (<WILDCARD>) --- glob
3273  
3274 # avoid "Error: Runtime exception" of perl version 5.005_03
3275  
3276 elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /oxgc) {
3277 0 return 'while ($_ = Elatin1::glob("' . $1 . '"))';
3278 }
3279  
3280 # while (glob)
3281 elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) {
3282 0 return 'while ($_ = Elatin1::glob_)';
3283 }
3284  
3285 # while (glob(WILDCARD))
3286 elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) {
3287 0 return 'while ($_ = Elatin1::glob';
3288 }
3289  
3290 # doit if, doit unless, doit while, doit until, doit for, doit when
3291 251 elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; }
3292  
3293 # subroutines of package Elatin1
3294 19 elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; }
3295 0 elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3296 22 elsif (/\G \b Latin1::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3297 0 elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; }
3298 168 elsif (/\G \b Latin1::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Latin1::escape'; }
3299 2 elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; }
3300 0 elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::chop'; }
3301 2 elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; }
3302 0 elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; }
3303 0 elsif (/\G \b Latin1::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Latin1::index'; }
3304 0 elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::index'; }
3305 2 elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; }
3306 0 elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; }
3307 0 elsif (/\G \b Latin1::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Latin1::rindex'; }
3308 0 elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::rindex'; }
3309 1 elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::lc'; }
3310 0 elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::lcfirst'; }
3311 1 elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::uc'; }
3312 0 elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::ucfirst'; }
3313 6 elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::fc'; }
3314  
3315 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
3316 0 elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); }
3317 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3318 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3319 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3320 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3321 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3322 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3323  
3324 0 elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); }
3325 0 elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3326 0 elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3327 0 elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3328 0 elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3329 0 elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3330 0 elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3331  
3332 elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc)
3333 0 { $slash = 'm//'; return "-s $1"; }
3334 0 elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; }
3335 0 elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; }
3336 0 elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; }
3337  
3338 2 elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; }
3339 2 elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; }
3340 36 elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::chr'; }
3341 2 elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; }
3342 8 elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; }
3343 0 elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin1::glob'; }
3344 0 elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::lc_'; }
3345 0 elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::lcfirst_'; }
3346 0 elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::uc_'; }
3347 0 elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::ucfirst_'; }
3348 0 elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::fc_'; }
3349 0 elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; }
3350  
3351 0 elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; }
3352 0 elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; }
3353 0 elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::chr_'; }
3354 0 elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; }
3355 0 elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; }
3356 0 elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin1::glob_'; }
3357 0 elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; }
3358 8 elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; }
3359 # split
3360 elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
3361 87 $slash = 'm//';
3362  
3363 87 my $e = '';
3364 87 ▶ while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( (?>\s+) | \( | \#.* ) /cgox) 85 87 172
3365 85 $e .= $1;
3366 }
3367  
3368 # end of split
3369 87 ▶ if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Elatin1::split' . $e; }
Branch: 23 branches
BranchTrueFalseTotal
if (/\G (?= [,;\)\}\]] ) /cgox) { } 2 85 87
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /cgox) { } 1 84 85
elsif (/\G \b qq (\#) [ ] (\#) /cgox) { } 0 84 84
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /cgox) { } 0 84 84
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /cgox) { } 0 84 84
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /cgox) { } 0 84 84
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /cgox) { } 0 84 84
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /cgox) { } 0 84 84
elsif (/\G \b q (\#) [ ] (\#) /cgox) { } 0 84 84
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /cgox) { } 0 84 84
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /cgox) { } 0 84 84
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /cgox) { } 0 84 84
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /cgox) { } 0 84 84
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /cgox) { } 0 84 84
elsif (/\G ' [ ] ' /cgox) { } 10 74 84
elsif (/\G " [ ] " /cgox) { } 0 74 74
elsif (/\G \b (qq) \b /cgox) { } 0 74 74
elsif (/\G \b (qr) \b /cgox) { } 12 62 74
elsif (/\G \b (q) \b /cgox) { } 0 62 62
elsif (/\G \b (m) \b /cgox) { } 18 44 62
elsif (/\G (\') /cgox) { } 0 44 44
elsif (/\G (\") /cgox) { } 0 44 44
elsif (m[\G (/) ]cgox) { } 44 0 44
3370  
3371 # split scalar value
3372 1 elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Elatin1::split' . $e . e_string($1); }
3373  
3374 # split literal space
3375 0 elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Elatin1::split' . $e . qq {qq$1 $2}; }
3376 0 elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Elatin1::split' . $e . qq{$1qq$2 $3}; }
3377 0 elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Elatin1::split' . $e . qq{$1qq$2 $3}; }
3378 0 elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Elatin1::split' . $e . qq{$1qq$2 $3}; }
3379 0 elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Elatin1::split' . $e . qq{$1qq$2 $3}; }
3380 0 elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Elatin1::split' . $e . qq{$1qq$2 $3}; }
3381 0 elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Elatin1::split' . $e . qq {q$1 $2}; }
3382 0 elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Elatin1::split' . $e . qq {$1q$2 $3}; }
3383 0 elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Elatin1::split' . $e . qq {$1q$2 $3}; }
3384 0 elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Elatin1::split' . $e . qq {$1q$2 $3}; }
3385 0 elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Elatin1::split' . $e . qq {$1q$2 $3}; }
3386 0 elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Elatin1::split' . $e . qq {$1q$2 $3}; }
3387 10 elsif (/\G ' [ ] ' /oxgc) { return 'Elatin1::split' . $e . qq {' '}; }
3388 0 elsif (/\G " [ ] " /oxgc) { return 'Elatin1::split' . $e . qq {" "}; }
3389  
3390 # split qq//
3391 elsif (/\G \b (qq) \b /oxgc) {
3392 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) /cgox) { } 0 0 0
3393 else {
3394 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3395 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) /cgox) { } 0 0 0
3396 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( )
3397 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { }
3398 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ]
3399 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < >
3400 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { }
3401 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * *
3402 }
3403 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3404 }
3405 }
3406  
3407 # split qr//
3408 elsif (/\G \b (qr) \b /oxgc) {
3409 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 12 12
3410 else {
3411 12 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 12 0 12
3412 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 8 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 12 12
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 12 0 12
3413 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( )
3414 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { }
3415 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ]
3416 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < >
3417 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' '
3418 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { }
3419 12 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * *
3420 }
3421 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3422 }
3423 }
3424  
3425 # split q//
3426 elsif (/\G \b (q) \b /oxgc) {
3427 0 ▶ if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:\\\#|\\\\|$Elatin1::q_char)*?) (\#) /cgox) { } 0 0 0
3428 else {
3429 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3430 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::q_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:\\\\|\\\1| $Elatin1::q_char)*?) (\1) /cgox) { } 0 0 0
3431 0 elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( )
3432 0 elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { }
3433 0 elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ]
3434 0 elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < >
3435 0 elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { }
3436 0 elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * *
3437 }
3438 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3439 }
3440 }
3441  
3442 # split m//
3443 elsif (/\G \b (m) \b /oxgc) {
3444 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
3445 else {
3446 18 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 18 0 18
3447 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 8 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 18 18
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 18 0 18
3448 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( )
3449 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { }
3450 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ]
3451 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < >
3452 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' '
3453 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { }
3454 18 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * *
3455 }
3456 0 die __FILE__, ": Search pattern not terminated\n";
3457 }
3458 }
3459  
3460 # split ''
3461 elsif (/\G (\') /oxgc) {
3462 0 my $q_string = '';
3463 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3464 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\') /cgox) { } 0 0 0
elsif (/\G \' /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
3465 0 elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
3466 0 elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' '
3467 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3468 }
3469 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3470 }
3471  
3472 # split ""
3473 elsif (/\G (\") /oxgc) {
3474 0 my $qq_string = '';
3475 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3476 0 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\") /cgox) { } 0 0 0
elsif (/\G \" /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
3477 0 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
3478 0 elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " "
3479 0 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
3480 }
3481 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3482 }
3483  
3484 # split //
3485 elsif (/\G (\/) /oxgc) {
3486 44 my $regexp = '';
3487 44 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 381 0 381
3488 0 ▶ if (/\G (\\\\) /oxgc) { $regexp .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 381 381
elsif (m[\G (\\/) ]cgox) { } 0 381 381
elsif (m[\G / ([cgimosxpadlunbB]*) ]cgox) { } 44 337 381
elsif (/\G ($Elatin1::q_char) /cgox) { } 337 0 337
3489 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
3490 44 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / /
3491 337 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
3492 }
3493 0 die __FILE__, ": Search pattern not terminated\n";
3494 }
3495 }
3496  
3497 # tr/// or y///
3498  
3499 # about [cdsrbB]* (/B modifier)
3500 #
3501 # P.559 appendix C
3502 # of ISBN 4-89052-384-7 Programming perl
3503 # (Japanese title is: Perl puroguramingu)
3504  
3505 elsif (/\G \b ( tr | y ) \b /oxgc) {
3506 4 my $ope = $1;
3507  
3508 # $1 $2 $3 $4 $5 $6
3509 4 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ((?:$Elatin1::qq_char)*?) (\#) ([cdsrbB]*) /cgox) { } 0 4 4
3510 0 my @tr = ($tr_variable,$2);
3511 0 return e_tr(@tr,'',$4,$6);
3512 }
3513 else {
3514 4 my $e = '';
3515 4 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 4 0 4
3516 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 4 4
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 4 4
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 4 4
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 4 4
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 4 4
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ((?:$Elatin1::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 4 0 4
3517 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3518 0 my @tr = ($tr_variable,$2);
3519 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3520 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3521 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( )
3522 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { }
3523 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ]
3524 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < >
3525 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * *
3526 }
3527 0 die __FILE__, ": Transliteration replacement not terminated\n";
3528 }
3529 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3530 0 my @tr = ($tr_variable,$2);
3531 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3532 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3533 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( )
3534 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { }
3535 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ]
3536 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < >
3537 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * *
3538 }
3539 0 die __FILE__, ": Transliteration replacement not terminated\n";
3540 }
3541 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3542 0 my @tr = ($tr_variable,$2);
3543 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3544 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3545 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( )
3546 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { }
3547 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ]
3548 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < >
3549 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * *
3550 }
3551 0 die __FILE__, ": Transliteration replacement not terminated\n";
3552 }
3553 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3554 0 my @tr = ($tr_variable,$2);
3555 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3556 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3557 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( )
3558 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { }
3559 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ]
3560 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < >
3561 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * *
3562 }
3563 0 die __FILE__, ": Transliteration replacement not terminated\n";
3564 }
3565 # $1 $2 $3 $4 $5 $6
3566 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * *
3567 4 my @tr = ($tr_variable,$2);
3568 4 return e_tr(@tr,'',$4,$6);
3569 }
3570 }
3571 0 die __FILE__, ": Transliteration pattern not terminated\n";
3572 }
3573 }
3574  
3575 # qq//
3576 elsif (/\G \b (qq) \b /oxgc) {
3577 2252 my $ope = $1;
3578  
3579 # if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# #
3580 2252 ▶ if (/\G (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 2252 2252
3581 0 my $qq_string = '';
3582 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3583 0 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\#) /cgox) { } 0 0 0
elsif (/\G (\#) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::qq_char) /cgox) { } 0 0 0
3584 0 elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; }
3585 0 elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); }
3586 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3587 }
3588 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3589 }
3590  
3591 else {
3592 2252 my $e = '';
3593 2252 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 2252 0 2252
3594 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 2252 2252
elsif (/\G (\() /cgox) { } 0 2252 2252
elsif (/\G (\{) /cgox) { } 2222 30 2252
elsif (/\G (\[) /cgox) { } 0 30 30
elsif (/\G (\<) /cgox) { } 30 0 30
elsif (/\G (\S) /cgox) { } 0 0 0
3595  
3596 # elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( )
3597 elsif (/\G (\() /oxgc) { # qq ( )
3598 0 my $qq_string = '';
3599 0 local $nest = 1;
3600 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3601 0 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\)) /cgox) { } 0 0 0
elsif (/\G (\() /cgox) { } 0 0 0
elsif (/\G (\)) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::qq_char) /cgox) { } 0 0 0
3602 0 elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; }
3603 0 elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; }
3604 elsif (/\G (\)) /oxgc) {
3605 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 0 0 0
3606 0 else { $qq_string .= $1; }
3607 }
3608 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3609 }
3610 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3611 }
3612  
3613 # elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { }
3614 elsif (/\G (\{) /oxgc) { # qq { }
3615 2222 my $qq_string = '';
3616 2222 local $nest = 1;
3617 2222 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 85104 0 85104
3618 85104 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 722 84382 85104
elsif (/\G (\\\}) /cgox) { } 0 84382 84382
elsif (/\G (\{) /cgox) { } 1189 83193 84382
elsif (/\G (\}) /cgox) { } 3411 79782 83193
elsif (/\G ($Elatin1::qq_char) /cgox) { } 79782 0 79782
3619 0 elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; }
3620 1189 elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; }
3621 elsif (/\G (\}) /oxgc) {
3622 3411 ▶ if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 2222 1189 3411
3623 1189 else { $qq_string .= $1; }
3624 }
3625 79782 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3626 }
3627 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3628 }
3629  
3630 # elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ]
3631 elsif (/\G (\[) /oxgc) { # qq [ ]
3632 0 my $qq_string = '';
3633 0 local $nest = 1;
3634 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3635 0 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\]) /cgox) { } 0 0 0
elsif (/\G (\[) /cgox) { } 0 0 0
elsif (/\G (\]) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::qq_char) /cgox) { } 0 0 0
3636 0 elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; }
3637 0 elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; }
3638 elsif (/\G (\]) /oxgc) {
3639 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 0 0 0
3640 0 else { $qq_string .= $1; }
3641 }
3642 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3643 }
3644 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3645 }
3646  
3647 # elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < >
3648 elsif (/\G (\<) /oxgc) { # qq < >
3649 30 my $qq_string = '';
3650 30 local $nest = 1;
3651 30 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 1166 0 1166
3652 1166 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 22 1144 1166
elsif (/\G (\\\>) /cgox) { } 0 1144 1144
elsif (/\G (\<) /cgox) { } 0 1144 1144
elsif (/\G (\>) /cgox) { } 30 1114 1144
elsif (/\G ($Elatin1::qq_char) /cgox) { } 1114 0 1114
3653 0 elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; }
3654 0 elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; }
3655 elsif (/\G (\>) /oxgc) {
3656 30 ▶ if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 30 0 30
3657 0 else { $qq_string .= $1; }
3658 }
3659 1114 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3660 }
3661 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3662 }
3663  
3664 # elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * *
3665 elsif (/\G (\S) /oxgc) { # qq * *
3666 0 my $delimiter = $1;
3667 0 my $qq_string = '';
3668 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3669 0 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\Q$delimiter\E) /cgox) { } 0 0 0
elsif (/\G (\Q$delimiter\E) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::qq_char) /cgox) { } 0 0 0
3670 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; }
3671 0 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); }
3672 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3673 }
3674 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3675 }
3676 }
3677 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3678 }
3679 }
3680  
3681 # qr//
3682 elsif (/\G \b (qr) \b /oxgc) {
3683 0 my $ope = $1;
3684 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3685 0 return e_qr($ope,$1,$3,$2,$4);
3686 }
3687 else {
3688 0 my $e = '';
3689 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3690 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 8 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3691 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( )
3692 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { }
3693 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ]
3694 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < >
3695 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' '
3696 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { }
3697 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * *
3698 }
3699 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3700 }
3701 }
3702  
3703 # qw//
3704 elsif (/\G \b (qw) \b /oxgc) {
3705 16 my $ope = $1;
3706 16 ▶ if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) (.*?) (\#) /cgmosx) { } 0 16 16
3707 0 return e_qw($ope,$1,$3,$2);
3708 }
3709 else {
3710 16 my $e = '';
3711 16 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 16 0 16
3712 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 11 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 16 16
elsif (/\G (\() ([^(]*?) (\)) /cgmosx) { } 16 0 16
elsif (/\G (\() ((?:$q_paren)*?) (\)) /cgmosx) { } 0 0 0
elsif (/\G (\{) ([^{]*?) (\}) /cgmosx) { } 0 0 0
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /cgmosx) { } 0 0 0
elsif (/\G (\[) ([^[]*?) (\]) /cgmosx) { } 0 0 0
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /cgmosx) { } 0 0 0
elsif (/\G (\<) ([^<]*?) (\>) /cgmosx) { } 0 0 0
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /cgmosx) { } 0 0 0
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /cgmosx) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::q_char)*?) (\1) /cgmosx) { } 0 0 0
3713  
3714 16 elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3715 0 elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3716  
3717 0 elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3718 0 elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3719  
3720 0 elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3721 0 elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3722  
3723 0 elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3724 0 elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3725  
3726 0 elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3727 0 elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3728 }
3729 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3730 }
3731 }
3732  
3733 # qx//
3734 elsif (/\G \b (qx) \b /oxgc) {
3735 0 my $ope = $1;
3736 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) /cgox) { } 0 0 0
3737 0 return e_qq($ope,$1,$3,$2);
3738 }
3739 else {
3740 0 my $e = '';
3741 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3742 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) /cgox) { } 0 0 0
3743 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( )
3744 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { }
3745 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ]
3746 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < >
3747 0 elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' '
3748 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * *
3749 }
3750 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3751 }
3752 }
3753  
3754 # q//
3755 elsif (/\G \b (q) \b /oxgc) {
3756 473 my $ope = $1;
3757  
3758 # if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# #
3759  
3760 # avoid "Error: Runtime exception" of perl version 5.005_03
3761 # (and so on)
3762  
3763 473 ▶ if (/\G (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 473 473
3764 0 my $q_string = '';
3765 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3766 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\#) /cgox) { } 0 0 0
elsif (/\G (\#) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
3767 0 elsif (/\G (\\\#) /oxgc) { $q_string .= $1; }
3768 0 elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); }
3769 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3770 }
3771 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3772 }
3773  
3774 else {
3775 473 my $e = '';
3776 473 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 473 0 473
3777 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 473 473
elsif (/\G (\() /cgox) { } 0 473 473
elsif (/\G (\{) /cgox) { } 467 6 473
elsif (/\G (\[) /cgox) { } 0 6 6
elsif (/\G (\<) /cgox) { } 5 1 6
elsif (/\G (\S) /cgox) { } 1 0 1
3778  
3779 # elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( )
3780 elsif (/\G (\() /oxgc) { # q ( )
3781 0 my $q_string = '';
3782 0 local $nest = 1;
3783 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3784 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\)) /cgox) { } 0 0 0
elsif (/\G (\\\() /cgox) { } 0 0 0
elsif (/\G (\() /cgox) { } 0 0 0
elsif (/\G (\)) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
3785 0 elsif (/\G (\\\)) /oxgc) { $q_string .= $1; }
3786 0 elsif (/\G (\\\() /oxgc) { $q_string .= $1; }
3787 0 elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; }
3788 elsif (/\G (\)) /oxgc) {
3789 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 0 0 0
3790 0 else { $q_string .= $1; }
3791 }
3792 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3793 }
3794 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3795 }
3796  
3797 # elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { }
3798 elsif (/\G (\{) /oxgc) { # q { }
3799 467 my $q_string = '';
3800 467 local $nest = 1;
3801 467 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 8249 0 8249
3802 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 8249 8249
elsif (/\G (\\\}) /cgox) { } 0 8249 8249
elsif (/\G (\\\{) /cgox) { } 0 8249 8249
elsif (/\G (\{) /cgox) { } 159 8090 8249
elsif (/\G (\}) /cgox) { } 626 7464 8090
elsif (/\G ($Elatin1::q_char) /cgox) { } 7464 0 7464
3803 0 elsif (/\G (\\\}) /oxgc) { $q_string .= $1; }
3804 0 elsif (/\G (\\\{) /oxgc) { $q_string .= $1; }
3805 159 elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; }
3806 elsif (/\G (\}) /oxgc) {
3807 626 ▶ if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 467 159 626
3808 159 else { $q_string .= $1; }
3809 }
3810 7464 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3811 }
3812 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3813 }
3814  
3815 # elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ]
3816 elsif (/\G (\[) /oxgc) { # q [ ]
3817 0 my $q_string = '';
3818 0 local $nest = 1;
3819 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3820 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\]) /cgox) { } 0 0 0
elsif (/\G (\\\[) /cgox) { } 0 0 0
elsif (/\G (\[) /cgox) { } 0 0 0
elsif (/\G (\]) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
3821 0 elsif (/\G (\\\]) /oxgc) { $q_string .= $1; }
3822 0 elsif (/\G (\\\[) /oxgc) { $q_string .= $1; }
3823 0 elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; }
3824 elsif (/\G (\]) /oxgc) {
3825 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 0 0 0
3826 0 else { $q_string .= $1; }
3827 }
3828 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3829 }
3830 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3831 }
3832  
3833 # elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < >
3834 elsif (/\G (\<) /oxgc) { # q < >
3835 5 my $q_string = '';
3836 5 local $nest = 1;
3837 5 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 88 0 88
3838 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 88 88
elsif (/\G (\\\>) /cgox) { } 0 88 88
elsif (/\G (\\\<) /cgox) { } 0 88 88
elsif (/\G (\<) /cgox) { } 0 88 88
elsif (/\G (\>) /cgox) { } 5 83 88
elsif (/\G ($Elatin1::q_char) /cgox) { } 83 0 83
3839 0 elsif (/\G (\\\>) /oxgc) { $q_string .= $1; }
3840 0 elsif (/\G (\\\<) /oxgc) { $q_string .= $1; }
3841 0 elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; }
3842 elsif (/\G (\>) /oxgc) {
3843 5 ▶ if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin1::nest == 0) { } 5 0 5
3844 0 else { $q_string .= $1; }
3845 }
3846 83 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3847 }
3848 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3849 }
3850  
3851 # elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * *
3852 elsif (/\G (\S) /oxgc) { # q * *
3853 1 my $delimiter = $1;
3854 1 my $q_string = '';
3855 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 14 0 14
3856 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 14 14
elsif (/\G (\\\Q$delimiter\E) /cgox) { } 0 14 14
elsif (/\G (\Q$delimiter\E) /cgox) { } 1 13 14
elsif (/\G ($Elatin1::q_char) /cgox) { } 13 0 13
3857 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; }
3858 1 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); }
3859 13 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3860 }
3861 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3862 }
3863 }
3864 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3865 }
3866 }
3867  
3868 # m//
3869 elsif (/\G \b (m) \b /oxgc) {
3870 209 my $ope = $1;
3871 209 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
3872 0 return e_qr($ope,$1,$3,$2,$4);
3873 }
3874 else {
3875 209 my $e = '';
3876 209 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 209 0 209
3877 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 9 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 209 209
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\?) ((?:$Elatin1::qq_char)*?) (\?) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 10 199 209
elsif (/\G ([*\-:\\^|]) ((?:$Elatin1::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 199 199
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 199 0 199
3878 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( )
3879 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { }
3880 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ]
3881 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < >
3882 0 elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ?
3883 10 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' '
3884 0 elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { }
3885 199 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * *
3886 }
3887 0 die __FILE__, ": Search pattern not terminated\n";
3888 }
3889 }
3890  
3891 # s///
3892  
3893 # about [cegimosxpradlunbB]* (/cg modifier)
3894 #
3895 # P.67 Pattern-Matching Operators
3896 # of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition.
3897  
3898 elsif (/\G \b (s) \b /oxgc) {
3899 101 my $ope = $1;
3900  
3901 # $1 $2 $3 $4 $5 $6
3902 101 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin1::qq_char)*?) (\#) ((?:$Elatin1::qq_char)*?) (\#) ([cegimosxpradlunbB]*) /cgox) { } 1 100 101
3903 1 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3904 }
3905 else {
3906 100 my $e = '';
3907 100 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 100 0 100
3908 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 9 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 100 100
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 100 100
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 100 100
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 100 100
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 100 100
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ((?:$Elatin1::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 21 79 100
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin1::qq_char)*?) (\1) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\$) ((?:$Elatin1::qq_char)*?) (\1) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 79 0 79
3909 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3910 0 my @s = ($1,$2,$3);
3911 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3912 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 10 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin1::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin1::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin1::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3913 # $1 $2 $3 $4
3914 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3915 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3916 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3917 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3918 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3919 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3920 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3921 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3922 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3923 }
3924 0 die __FILE__, ": Substitution replacement not terminated\n";
3925 }
3926 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3927 0 my @s = ($1,$2,$3);
3928 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3929 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 10 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin1::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin1::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin1::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3930 # $1 $2 $3 $4
3931 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3932 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3933 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3934 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3935 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3936 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3937 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3938 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3939 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3940 }
3941 0 die __FILE__, ": Substitution replacement not terminated\n";
3942 }
3943 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3944 0 my @s = ($1,$2,$3);
3945 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3946 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 8 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin1::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3947 # $1 $2 $3 $4
3948 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3949 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3950 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3951 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3952 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3953 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3954 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3955 }
3956 0 die __FILE__, ": Substitution replacement not terminated\n";
3957 }
3958 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3959 0 my @s = ($1,$2,$3);
3960 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3961 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 10 branches
BranchTrueFalseTotal
if (/\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\') ((?:$Elatin1::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin1::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin1::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin1::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin1::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3962 # $1 $2 $3 $4
3963 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3964 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3965 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3966 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3967 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3968 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3969 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3970 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3971 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3972 }
3973 0 die __FILE__, ": Substitution replacement not terminated\n";
3974 }
3975 # $1 $2 $3 $4 $5 $6
3976 elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) {
3977 21 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3978 }
3979 # $1 $2 $3 $4 $5 $6
3980 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3981 0 return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { }
3982 }
3983 # $1 $2 $3 $4 $5 $6
3984 elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3985 0 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3986 }
3987 # $1 $2 $3 $4 $5 $6
3988 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3989 79 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3990 }
3991 }
3992 0 die __FILE__, ": Substitution pattern not terminated\n";
3993 }
3994 }
3995  
3996 # require ignore module
3997 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; }
3998 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# require$1\n$2"; }
3999 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; }
4000  
4001 # use strict; --> use strict; no strict qw(refs);
4002 37 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; }
4003 0 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; }
4004 0 elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; }
4005  
4006 # use 5.12.0; --> use 5.12.0; no strict qw(refs);
4007 elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4008 2 ▶ if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 >= 6 or $2 == 5 and $3 ge '012') { } 0 2 2
Condition33%2/6
$2 >= 6 or $2 == 5 and $3 ge "012"
l!l&&r!l&&!r
002
$2 == 5 and $3 ge "012"
!ll&&!rl&&r
020
MC/DC0%0/3
$2 >= 6 or $2 == 5 and $3 ge "012"
$2 >= 6 $2 == 5 $3 ge "012"
Truth table25%1/4
A or B and C
A= $2 >= 6B= $2 == 5C= $3 ge "012"
ABCresult
1XX1
0111
00X0
0100
4009 0 return "use $1; no strict qw(refs);";
4010 }
4011 else {
4012 2 return "use $1;";
4013 }
4014 }
4015 elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4016 0 ▶ if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 >= 6 or $2 == 5 and $3 >= 12) { } 0 0 0
Condition0%0/6
$2 >= 6 or $2 == 5 and $3 >= 12
l!l&&r!l&&!r
000
$2 == 5 and $3 >= 12
!ll&&!rl&&r
000
MC/DC0%0/3
$2 >= 6 or $2 == 5 and $3 >= 12
$2 >= 6 $2 == 5 $3 >= 12
Truth table0%0/4
A or B and C
A= $2 >= 6B= $2 == 5C= $3 >= 12
ABCresult
1XX1
0111
00X0
0100
4017 0 return "use $1; no strict qw(refs);";
4018 }
4019 else {
4020 0 return "use $1;";
4021 }
4022 }
4023  
4024 # ignore use module
4025 2 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; }
4026 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# use$1\n$2"; }
4027 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; }
4028  
4029 # ignore no module
4030 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; }
4031 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# no$1\n$2"; }
4032 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; }
4033  
4034 # use else
4035 0 elsif (/\G \b use \b /oxmsgc) { return "use"; }
4036  
4037 # use else
4038 2 elsif (/\G \b no \b /oxmsgc) { return "no"; }
4039  
4040 # ''
4041 elsif (/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
4042 1142 my $q_string = '';
4043 1142 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 10175 0 10175
4044 10175 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 4 10171 10175
elsif (/\G (\\\') /cgox) { } 48 10123 10171
elsif (/\G \' /cgox) { } 1142 8981 10123
elsif (/\G ($Elatin1::q_char) /cgox) { } 8981 0 8981
4045 48 elsif (/\G (\\\') /oxgc) { $q_string .= $1; }
4046 1142 elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); }
4047 8981 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
4048 }
4049 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4050 }
4051  
4052 # ""
4053 elsif (/\G (\") /oxgc) {
4054 1859 my $qq_string = '';
4055 1859 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 36974 0 36974
4056 36974 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 67 36907 36974
elsif (/\G (\\\") /cgox) { } 12 36895 36907
elsif (/\G \" /cgox) { } 1859 35036 36895
elsif (/\G ($Elatin1::q_char) /cgox) { } 35036 0 35036
4057 12 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; }
4058 1859 elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); }
4059 35036 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
4060 }
4061 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4062 }
4063  
4064 # ``
4065 elsif (/\G (\`) /oxgc) {
4066 1 my $qx_string = '';
4067 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 19 0 19
4068 0 ▶ if (/\G (\\\\) /oxgc) { $qx_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 19 19
elsif (/\G (\\\`) /cgox) { } 0 19 19
elsif (/\G \` /cgox) { } 1 18 19
elsif (/\G ($Elatin1::q_char) /cgox) { } 18 0 18
4069 0 elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; }
4070 1 elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); }
4071 18 elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; }
4072 }
4073 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4074 }
4075  
4076 # // --- not divide operator (num / num), not defined-or
4077 ▶ elsif (($slash eq 'm//') and /\G (\/) /oxgc) {
Condition100%3/3
$Elatin1::slash eq "m//" and m[\G (/) ]cgox
!ll&&!rl&&r
273388848681
MC/DC100%2/2
$Elatin1::slash eq "m//" and m[\G (/) ]cgox
$Elatin1::slash eq "m//" m[\G (/) ]cgox
Truth table100%3/3
A and B
A= $Elatin1::slash eq "m//"B= m[\G (/) ]cgox
ABresult
0X0
100
111
4078 681 my $regexp = '';
4079 681 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 5636 0 5636
4080 0 ▶ if (/\G (\\\\) /oxgc) { $regexp .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 5636 5636
elsif (m[\G (\\/) ]cgox) { } 0 5636 5636
elsif (m[\G / ([cgimosxpadlunbB]*) ]cgox) { } 681 4955 5636
elsif (/\G ($Elatin1::q_char) /cgox) { } 4955 0 4955
4081 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; }
4082 681 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); }
4083 4955 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4084 }
4085 0 die __FILE__, ": Search pattern not terminated\n";
4086 }
4087  
4088 # ?? --- not conditional operator (condition ? then : else)
4089 ▶ elsif (($slash eq 'm//') and /\G (\?) /oxgc) {
Condition66%2/3
$Elatin1::slash eq "m//" and /\G (\?) /cgox
!ll&&!rl&&r
2733888480
MC/DC0%0/2
$Elatin1::slash eq "m//" and /\G (\?) /cgox
$Elatin1::slash eq "m//" /\G (\?) /cgox
Truth table66%2/3
A and B
A= $Elatin1::slash eq "m//"B= /\G (\?) /cgox
ABresult
0X0
100
111
4090 0 my $regexp = '';
4091 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
4092 0 ▶ if (/\G (\\\\) /oxgc) { $regexp .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 0 0
elsif (/\G (\\\?) /cgox) { } 0 0 0
elsif (/\G \? ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G ($Elatin1::q_char) /cgox) { } 0 0 0
4093 0 elsif (/\G (\\\?) /oxgc) { $regexp .= $1; }
4094 0 elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); }
4095 0 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4096 }
4097 0 die __FILE__, ": Search pattern not terminated\n";
4098 }
4099  
4100 # <<>> (a safer ARGV)
4101 0 elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; }
4102  
4103 # << (bit shift) --- not here document
4104 0 elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; }
4105  
4106 # <<~'HEREDOC'
4107 elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4108 6 $slash = 'm//';
4109 6 my $here_quote = $1;
4110 6 my $delimiter = $2;
4111  
4112 # get here document
4113 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4114 6 $here_script = CORE::substr $_, pos $_;
4115 6 $here_script =~ s/.*?\n//oxm;
4116 }
4117 6 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 6 0 6
4118 6 my $heredoc = $1;
4119 6 my $indent = $2;
4120 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4121 6 push @heredoc, $heredoc . qq{\n$delimiter\n};
4122 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4123 }
4124 else {
4125 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4126 }
4127 6 return qq{<<'$delimiter'};
4128 }
4129  
4130 # <<~\HEREDOC
4131  
4132 # P.66 2.6.6. "Here" Documents
4133 # in Chapter 2: Bits and Pieces
4134 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4135  
4136 # P.73 "Here" Documents
4137 # in Chapter 2: Bits and Pieces
4138 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4139  
4140 elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4141 3 $slash = 'm//';
4142 3 my $here_quote = $1;
4143 3 my $delimiter = $2;
4144  
4145 # get here document
4146 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4147 3 $here_script = CORE::substr $_, pos $_;
4148 3 $here_script =~ s/.*?\n//oxm;
4149 }
4150 3 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 3 0 3
4151 3 my $heredoc = $1;
4152 3 my $indent = $2;
4153 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4154 3 push @heredoc, $heredoc . qq{\n$delimiter\n};
4155 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4156 }
4157 else {
4158 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4159 }
4160 3 return qq{<<\\$delimiter};
4161 }
4162  
4163 # <<~"HEREDOC"
4164 elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4165 6 $slash = 'm//';
4166 6 my $here_quote = $1;
4167 6 my $delimiter = $2;
4168  
4169 # get here document
4170 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4171 6 $here_script = CORE::substr $_, pos $_;
4172 6 $here_script =~ s/.*?\n//oxm;
4173 }
4174 6 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 6 0 6
4175 6 my $heredoc = $1;
4176 6 my $indent = $2;
4177 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4178 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4179 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4180 }
4181 else {
4182 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4183 }
4184 6 return qq{<<"$delimiter"};
4185 }
4186  
4187 # <<~HEREDOC
4188 elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4189 3 $slash = 'm//';
4190 3 my $here_quote = $1;
4191 3 my $delimiter = $2;
4192  
4193 # get here document
4194 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4195 3 $here_script = CORE::substr $_, pos $_;
4196 3 $here_script =~ s/.*?\n//oxm;
4197 }
4198 3 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 3 0 3
4199 3 my $heredoc = $1;
4200 3 my $indent = $2;
4201 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4202 3 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4203 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4204 }
4205 else {
4206 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4207 }
4208 3 return qq{<<$delimiter};
4209 }
4210  
4211 # <<~`HEREDOC`
4212 elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4213 6 $slash = 'm//';
4214 6 my $here_quote = $1;
4215 6 my $delimiter = $2;
4216  
4217 # get here document
4218 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4219 6 $here_script = CORE::substr $_, pos $_;
4220 6 $here_script =~ s/.*?\n//oxm;
4221 }
4222 6 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 6 0 6
4223 6 my $heredoc = $1;
4224 6 my $indent = $2;
4225 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4226 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4227 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4228 }
4229 else {
4230 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4231 }
4232 6 return qq{<<`$delimiter`};
4233 }
4234  
4235 # <<'HEREDOC'
4236 elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
4237 72 $slash = 'm//';
4238 72 my $here_quote = $1;
4239 72 my $delimiter = $2;
4240  
4241 # get here document
4242 72 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 72 0 72
4243 72 $here_script = CORE::substr $_, pos $_;
4244 72 $here_script =~ s/.*?\n//oxm;
4245 }
4246 72 ▶ if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n $delimiter \n //msx) { } 72 0 72
4247 72 push @heredoc, $1 . qq{\n$delimiter\n};
4248 72 push @heredoc_delimiter, $delimiter;
4249 }
4250 else {
4251 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4252 }
4253 72 return $here_quote;
4254 }
4255  
4256 # <<\HEREDOC
4257  
4258 # P.66 2.6.6. "Here" Documents
4259 # in Chapter 2: Bits and Pieces
4260 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4261  
4262 # P.73 "Here" Documents
4263 # in Chapter 2: Bits and Pieces
4264 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4265  
4266 elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
4267 0 $slash = 'm//';
4268 0 my $here_quote = $1;
4269 0 my $delimiter = $2;
4270  
4271 # get here document
4272 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4273 0 $here_script = CORE::substr $_, pos $_;
4274 0 $here_script =~ s/.*?\n//oxm;
4275 }
4276 0 ▶ if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n $delimiter \n //msx) { } 0 0 0
4277 0 push @heredoc, $1 . qq{\n$delimiter\n};
4278 0 push @heredoc_delimiter, $delimiter;
4279 }
4280 else {
4281 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4282 }
4283 0 return $here_quote;
4284 }
4285  
4286 # <<"HEREDOC"
4287 elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
4288 36 $slash = 'm//';
4289 36 my $here_quote = $1;
4290 36 my $delimiter = $2;
4291  
4292 # get here document
4293 36 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 36 0 36
4294 36 $here_script = CORE::substr $_, pos $_;
4295 36 $here_script =~ s/.*?\n//oxm;
4296 }
4297 36 ▶ if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n $delimiter \n //msx) { } 36 0 36
4298 36 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4299 36 push @heredoc_delimiter, $delimiter;
4300 }
4301 else {
4302 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4303 }
4304 36 return $here_quote;
4305 }
4306  
4307 # <<HEREDOC
4308 elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
4309 42 $slash = 'm//';
4310 42 my $here_quote = $1;
4311 42 my $delimiter = $2;
4312  
4313 # get here document
4314 42 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 42 0 42
4315 42 $here_script = CORE::substr $_, pos $_;
4316 42 $here_script =~ s/.*?\n//oxm;
4317 }
4318 42 ▶ if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n $delimiter \n //msx) { } 42 0 42
4319 42 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4320 42 push @heredoc_delimiter, $delimiter;
4321 }
4322 else {
4323 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4324 }
4325 42 return $here_quote;
4326 }
4327  
4328 # <<`HEREDOC`
4329 elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
4330 0 $slash = 'm//';
4331 0 my $here_quote = $1;
4332 0 my $delimiter = $2;
4333  
4334 # get here document
4335 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4336 0 $here_script = CORE::substr $_, pos $_;
4337 0 $here_script =~ s/.*?\n//oxm;
4338 }
4339 0 ▶ if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n $delimiter \n //msx) { } 0 0 0
4340 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4341 0 push @heredoc_delimiter, $delimiter;
4342 }
4343 else {
4344 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4345 }
4346 0 return $here_quote;
4347 }
4348  
4349 # <<= <=> <= < operator
4350 elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
4351 12 return $1;
4352 }
4353  
4354 # <FILEHANDLE>
4355 elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
4356 0 return $1;
4357 }
4358  
4359 # <WILDCARD> --- glob
4360  
4361 # avoid "Error: Runtime exception" of perl version 5.005_03
4362  
4363 elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /oxgc) {
4364 0 return 'Elatin1::glob("' . $1 . '")';
4365 }
4366  
4367 # __DATA__
4368 0 elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; }
4369  
4370 # __END__
4371 210 elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; }
4372  
4373 # \cD Control-D
4374  
4375 # P.68 2.6.8. Other Literal Tokens
4376 # in Chapter 2: Bits and Pieces
4377 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4378  
4379 # P.76 Other Literal Tokens
4380 # in Chapter 2: Bits and Pieces
4381 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4382  
4383 0 elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; }
4384  
4385 # \cZ Control-Z
4386 0 elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; }
4387  
4388 # any operator before div
4389 elsif (/\G (
4390 -- | \+\+ |
4391 [\)\}\]]
4392  
4393 5839 ) /oxgc) { $slash = 'div'; return $1; }
4394  
4395 # yada-yada or triple-dot operator
4396 elsif (/\G (
4397 \.\.\.
4398  
4399 7 ) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; }
4400  
4401 # any operator before m//
4402  
4403 # //, //= (defined-or)
4404  
4405 # P.164 Logical Operators
4406 # in Chapter 10: More Control Structures
4407 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4408  
4409 # P.119 C-Style Logical (Short-Circuit) Operators
4410 # in Chapter 3: Unary and Binary Operators
4411 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4412  
4413 # (and so on)
4414  
4415 # ~~
4416  
4417 # P.221 The Smart Match Operator
4418 # in Chapter 15: Smart Matching and given-when
4419 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4420  
4421 # P.112 Smartmatch Operator
4422 # in Chapter 3: Unary and Binary Operators
4423 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4424  
4425 # (and so on)
4426  
4427 elsif (/\G ((?>
4428  
4429 !~~ | !~ | != | ! |
4430 %= | % |
4431 &&= | && | &= | &\.= | &\. | & |
4432 -= | -> | - |
4433 :(?>\s*)= |
4434 : |
4435 <<>> |
4436 <<= | <=> | <= | < |
4437 == | => | =~ | = |
4438 >>= | >> | >= | > |
4439 \*\*= | \*\* | \*= | \* |
4440 \+= | \+ |
4441 \.\. | \.= | \. |
4442 \/\/= | \/\/ |
4443 \/= | \/ |
4444 \? |
4445 \\ |
4446 \^= | \^\.= | \^\. | \^ |
4447 \b x= |
4448 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
4449 ~~ | ~\. | ~ |
4450 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
4451 \b(?: print )\b |
4452  
4453 [,;\(\{\[]
4454  
4455 9766 )) /oxgc) { $slash = 'm//'; return $1; }
4456  
4457 # other any character
4458 20178 elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; }
4459  
4460 # system error
4461 else {
4462 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4463 }
4464 }
4465  
4466 # escape Latin-1 string
4467 1873 ▶sub e_string {
Subroutine e_string: called CC=54 SCAR=72.5
Pod documented
4468 1873 my($string) = @_;
4469 1873 my $e_string = '';
4470  
4471 1873 local $slash = 'm//';
4472  
4473 # P.1024 Appendix W.10 Multibyte Processing
4474 # of ISBN 1-56592-224-7 CJKV Information Processing
4475 # (and so on)
4476  
4477 1873 my @char = $string =~ / \G (?>[^\\]|\\$q_char|$q_char) /oxmsg;
4478  
4479 # without { ... }
4480 1873 ▶ if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char) 1854 19 1873
Condition66%2/3
grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char
!ll&&!rl&&r
1854019
MC/DC50%1/2
grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char
grep /\A \{ \z/msx, @char grep /\A \} \z/msx, @char
Truth table66%2/3
A and B
A= grep /\A \{ \z/msx, @charB= grep /\A \} \z/msx, @char
ABresult
0X0
100
111
4481 1854 ▶ if ($string !~ /<</oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /<</mosx) 1854 0 1854
4482 1854 return $string;
4483 }
4484 }
4485  
4486 E_STRING_LOOP:
4487 19 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 223 19 242
4488 223 ▶ if (0) {
Branch: 24 branches
BranchTrueFalseTotal
if (do { $string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx }) { } 0 223 223
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$' | \$\{'\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ 0 ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 3 220 223
elsif ($string =~ /\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /cgmosx) { } 7 213 220
elsif ($string =~ m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 0 213 213
elsif ($string =~ /\G \b (qq) \b /cgox) { } 0 213 213
elsif ($string =~ /\G \b (qx) \b /cgox) { } 0 213 213
elsif ($string =~ /\G \b (q) \b /cgox) { } 0 213 213
elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$Elatin1::q_char)*?) (\') /cgox) { } 0 213 213
elsif ($string =~ /\G (\") ((?:$Elatin1::qq_char)*?) (\") /cgox) { } 0 213 213
elsif ($string =~ /\G (\`) ((?:$Elatin1::qq_char)*?) (\`) /cgox) { } 0 213 213
elsif ($string =~ /\G ($Elatin1::q_char) /cgox) { } 213 0 213
4489 }
4490  
4491 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Elatin1::PREMATCH()]}
4492 elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
4493 0 $e_string .= q{Elatin1::PREMATCH()};
4494 0 $slash = 'div';
4495 }
4496  
4497 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Elatin1::MATCH()]}
4498 elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
4499 0 $e_string .= q{Elatin1::MATCH()};
4500 0 $slash = 'div';
4501 }
4502  
4503 # $', ${'} --> $', ${'}
4504 elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) {
4505 0 $e_string .= $1;
4506 0 $slash = 'div';
4507 }
4508  
4509 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Elatin1::POSTMATCH()]}
4510 elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
4511 0 $e_string .= q{Elatin1::POSTMATCH()};
4512 0 $slash = 'div';
4513 }
4514  
4515 # bareword
4516 elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
4517 0 $e_string .= $1;
4518 0 $slash = 'div';
4519 }
4520  
4521 # $0 --> $0
4522 elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) {
4523 0 $e_string .= $1;
4524 0 $slash = 'div';
4525 }
4526 elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
4527 0 $e_string .= $1;
4528 0 $slash = 'div';
4529 }
4530  
4531 # $$ --> $$
4532 elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
4533 0 $e_string .= $1;
4534 0 $slash = 'div';
4535 }
4536  
4537 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4538 # $1, $2, $3 --> $1, $2, $3 otherwise
4539 elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
4540 0 $e_string .= e_capture($1);
4541 0 $slash = 'div';
4542 }
4543 elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
4544 0 $e_string .= e_capture($1);
4545 0 $slash = 'div';
4546 }
4547  
4548 # $$foo[ ... ] --> $ $foo->[ ... ]
4549 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
4550 0 $e_string .= e_capture($1.'->'.$2);
4551 0 $slash = 'div';
4552 }
4553  
4554 # $$foo{ ... } --> $ $foo->{ ... }
4555 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
4556 0 $e_string .= e_capture($1.'->'.$2);
4557 0 $slash = 'div';
4558 }
4559  
4560 # $$foo
4561 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
4562 0 $e_string .= e_capture($1);
4563 0 $slash = 'div';
4564 }
4565  
4566 # ${ foo }
4567 elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) {
4568 0 $e_string .= '${' . $1 . '}';
4569 0 $slash = 'div';
4570 }
4571  
4572 # ${ ... }
4573 elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
4574 3 $e_string .= e_capture($1);
4575 3 $slash = 'div';
4576 }
4577  
4578 # variable or function
4579 # $ @ % & * $ #
4580 elsif ($string =~ /\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) {
4581 7 $e_string .= $1;
4582 7 $slash = 'div';
4583 }
4584 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
4585 # $ @ # \ ' " / ? ( ) [ ] < >
4586 elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
4587 0 $e_string .= $1;
4588 0 $slash = 'div';
4589 }
4590  
4591 # qq//
4592 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4593 0 my $ope = $1;
4594 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Elatin1::qq_char)*?) (\#) /cgox) { } 0 0 0
4595 0 $e_string .= e_qq($ope,$1,$3,$2);
4596 }
4597 else {
4598 0 my $e = '';
4599 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4600 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if ($string =~ /\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 0 0
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 0 0
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 0 0
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Elatin1::qq_char)*?) (\1) /cgox) { } 0 0 0
4601 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( )
4602 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { }
4603 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ]
4604 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < >
4605 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * *
4606 }
4607 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4608 }
4609 }
4610  
4611 # qx//
4612 elsif ($string =~ /\G \b (qx) \b /oxgc) {
4613 0 my $ope = $1;
4614 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Elatin1::qq_char)*?) (\#) /cgox) { } 0 0 0
4615 0 $e_string .= e_qq($ope,$1,$3,$2);
4616 }
4617 else {
4618 0 my $e = '';
4619 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4620 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 7 branches
BranchTrueFalseTotal
if ($string =~ /\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /cgox) { } 0 0 0
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /cgox) { } 0 0 0
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /cgox) { } 0 0 0
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /cgox) { } 0 0 0
elsif ($string =~ /\G (\') ((?:$Elatin1::qq_char)*?) (\') /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Elatin1::qq_char)*?) (\1) /cgox) { } 0 0 0
4621 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( )
4622 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { }
4623 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ]
4624 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < >
4625 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' '
4626 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * *
4627 }
4628 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4629 }
4630 }
4631  
4632 # q//
4633 elsif ($string =~ /\G \b (q) \b /oxgc) {
4634 0 my $ope = $1;
4635 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Elatin1::q_char)*?) (\#) /cgox) { } 0 0 0
4636 0 $e_string .= e_q($ope,$1,$3,$2);
4637 }
4638 else {
4639 0 my $e = '';
4640 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4641 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if ($string =~ /\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /cgox) { } 0 0 0
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /cgox) { } 0 0 0
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /cgox) { } 0 0 0
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $Elatin1::q_char)*?) (\1) /cgox) { } 0 0 0
4642 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( )
4643 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { }
4644 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ]
4645 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < >
4646 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * *
4647 }
4648 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4649 }
4650 }
4651  
4652 # ''
4653 0 elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('',$1,$3,$2); }
4654  
4655 # ""
4656 0 elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4657  
4658 # ``
4659 0 elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4660  
4661 # other any character
4662 213 elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; }
4663  
4664 # system error
4665 else {
4666 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4667 }
4668 }
4669  
4670 19 return $e_string;
4671 }
4672  
4673 #
4674 # character class
4675 #
4676 1920 ▶sub character_class {
Subroutine character_class: called CC=3 SCAR=11.0
Pod undocumented
4677 1920 my($char,$modifier) = @_;
4678  
4679 1920 ▶ if ($char eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '.') { } 52 1868 1920
4680 52 ▶ if ($modifier =~ /s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/) { } 17 35 52
4681 17 return '${Elatin1::dot_s}';
4682 }
4683 else {
4684 35 return '${Elatin1::dot}';
4685 }
4686 }
4687 else {
4688 1868 return Elatin1::classic_character_class($char);
4689 }
4690 }
4691  
4692 #
4693 # escape capture ($1, $2, $3, ...)
4694 #
4695 212 ▶sub e_capture {
Subroutine e_capture: called CC=1 SCAR=0.0
Pod undocumented
4696  
4697 212 return join '', '${', $_[0], '}';
4698 }
4699  
4700 #
4701 # escape transliteration (tr/// or y///)
4702 #
4703 4 ▶sub e_tr {
Subroutine e_tr: called CC=5 SCAR=16.8
Pod undocumented
4704 4 my($variable,$charclass,$e,$charclass2,$modifier) = @_;
4705 4 my $e_tr = '';
4706 4 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
31
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
4707  
4708 4 $slash = 'div';
4709  
4710 # quote character class 1
4711 4 $charclass = q_tr($charclass);
4712  
4713 # quote character class 2
4714 4 $charclass2 = q_tr($charclass2);
4715  
4716 # /b /B modifier
4717 4 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) { } 0 4 4
4718 0 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 0 0 0
4719 0 $e_tr = qq{tr$charclass$e$charclass2$modifier};
4720 }
4721 else {
4722 0 $e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier};
4723 }
4724 }
4725 else {
4726 4 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 2 2 4
4727 2 $e_tr = qq{Elatin1::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')};
4728 }
4729 else {
4730 2 $e_tr = qq{Elatin1::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')};
4731 }
4732 }
4733  
4734 # clear tr/// variable
4735 4 $tr_variable = '';
4736 4 $bind_operator = '';
4737  
4738 4 return $e_tr;
4739 }
4740  
4741 #
4742 # quote for escape transliteration (tr/// or y///)
4743 #
4744 8 ▶sub q_tr {
Subroutine q_tr: called CC=9 SCAR=40.6
Pod undocumented
4745 8 my($charclass) = @_;
4746  
4747 # quote character class
4748 8 ▶ if ($charclass !~ /'/oxms) {
Branch: 6 branches
BranchTrueFalseTotal
if (not $charclass =~ /'/mosx) { } 8 0 8
elsif (not $charclass =~ m[/]mosx) { } 0 0 0
elsif (not $charclass =~ /\#/mosx) { } 0 0 0
elsif (not $charclass =~ /[\<\>]/mosx) { } 0 0 0
elsif (not $charclass =~ /[\(\)]/mosx) { } 0 0 0
elsif (not $charclass =~ /[\{\}]/mosx) { } 0 0 0
4749 8 return e_q('', "'", "'", $charclass); # --> q' '
4750 }
4751 elsif ($charclass !~ /\//oxms) {
4752 0 return e_q('q', '/', '/', $charclass); # --> q/ /
4753 }
4754 elsif ($charclass !~ /\#/oxms) {
4755 0 return e_q('q', '#', '#', $charclass); # --> q# #
4756 }
4757 elsif ($charclass !~ /[\<\>]/oxms) {
4758 0 return e_q('q', '<', '>', $charclass); # --> q< >
4759 }
4760 elsif ($charclass !~ /[\(\)]/oxms) {
4761 0 return e_q('q', '(', ')', $charclass); # --> q( )
4762 }
4763 elsif ($charclass !~ /[\{\}]/oxms) {
4764 0 return e_q('q', '{', '}', $charclass); # --> q{ }
4765 }
4766 else {
4767 0 for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
4768 0 ▶ if ($charclass !~ /\Q$char\E/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($charclass =~ /\Q$char\E/msx) 0 0 0
4769 0 return e_q('q', $char, $char, $charclass);
4770 }
4771 }
4772 }
4773  
4774 0 return e_q('q', '{', '}', $charclass);
4775 }
4776  
4777 #
4778 # escape q string (q//, '')
4779 #
4780 1623 ▶sub e_q {
Subroutine e_q: called CC=1 SCAR=0.0
Pod undocumented
4781 1623 my($ope,$delimiter,$end_delimiter,$string) = @_;
4782  
4783 1623 $slash = 'div';
4784  
4785 1623 return join '', $ope, $delimiter, $string, $end_delimiter;
4786 }
4787  
4788 #
4789 # escape qq string (qq//, "", qx//, ``)
4790 #
4791 4197 ▶sub e_qq {
Subroutine e_qq: called CC=37 SCAR=50.9
Pod undocumented
4792 4197 my($ope,$delimiter,$end_delimiter,$string) = @_;
4793  
4794 4197 $slash = 'div';
4795  
4796 4197 my $left_e = 0;
4797 4197 my $right_e = 0;
4798  
4799 # split regexp
4800 4197 my @char = $string =~ /\G((?>
4801 [^\\\$] |
4802 \\x\{ (?>[0-9A-Fa-f]+) \} |
4803 \\o\{ (?>[0-7]+) \} |
4804 \\N\{ (?>[^0-9\}][^\}]*) \} |
4805 \\ $q_char |
4806 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
4807 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
4808 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
4809 \$ (?>\s* [0-9]+) |
4810 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
4811 \$ \$ (?![\w\{]) |
4812 \$ (?>\s*) \$ (?>\s*) $qq_variable |
4813 $q_char
4814 ))/oxmsg;
4815  
4816 4197 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 116605 4197 120802
4817  
4818 # "\L\u" --> "\u\L"
4819 116605 ▶ if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) {
Branch: 5 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\L' and $char[$i + 1] eq '\\u') { } 0 116605 116605
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 116605 116605
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 116604 116605
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 116603 116604
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 116603 116603
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
11660500
MC/DC0%0/2
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
$char[$i] eq "\\L" $char[$i + 1] eq "\\u"
Truth table33%1/3
A and B
A= $char[$i] eq "\\L"B= $char[$i + 1] eq "\\u"
ABresult
0X0
100
111
4820 0 @char[$i,$i+1] = @char[$i+1,$i];
4821 }
4822  
4823 # "\U\l" --> "\l\U"
4824 ▶ elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) {
Condition33%1/3
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
!ll&&!rl&&r
11660500
MC/DC0%0/2
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
$char[$i] eq "\\U" $char[$i + 1] eq "\\l"
Truth table33%1/3
A and B
A= $char[$i] eq "\\U"B= $char[$i + 1] eq "\\l"
ABresult
0X0
100
111
4825 0 @char[$i,$i+1] = @char[$i+1,$i];
4826 }
4827  
4828 # octal escape sequence
4829 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
4830 1 $char[$i] = Elatin1::octchr($1);
4831 }
4832  
4833 # hexadecimal escape sequence
4834 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
4835 1 $char[$i] = Elatin1::hexchr($1);
4836 }
4837  
4838 # \N{CHARNAME} --> N{CHARNAME}
4839 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
4840 0 $char[$i] = $1;
4841 }
4842  
4843 116605 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 484 116121 116605
elsif ($char[$i] eq '\\u') { } 0 116121 116121
elsif ($char[$i] eq '\\l') { } 0 116121 116121
elsif ($char[$i] eq '\\U') { } 0 116121 116121
elsif ($char[$i] eq '\\L') { } 0 116121 116121
elsif ($char[$i] eq '\\F') { } 24 116097 116121
elsif ($char[$i] eq '\\Q') { } 0 116097 116097
elsif ($char[$i] eq '\\E') { } 24 116073 116097
elsif ($char[$i] eq '\\Q') { } 0 116073 116073
elsif ($char[$i] eq '\\E') { } 0 116073 116073
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 4 116069 116073
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 116069 116069
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 116069 116069
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 205 115864 116069
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 115864 115864
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 115864 115864
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 115864 115864
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 115864 115864
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 44 115820 115864
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 45 115775 115820
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 33 115742 115775
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 115742 115742
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 115742 115742
4844 }
4845  
4846 # \F
4847 #
4848 # P.69 Table 2-6. Translation escapes
4849 # in Chapter 2: Bits and Pieces
4850 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4851 # (and so on)
4852  
4853 # \u \l \U \L \F \Q \E
4854 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
4855 484 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 484 484
4856 0 $char[$i] = '\\' . $char[$i];
4857 }
4858 }
4859 elsif ($char[$i] eq '\u') {
4860  
4861 # "STRING @{[ LIST EXPR ]} MORE STRING"
4862  
4863 # P.257 Other Tricks You Can Do with Hard References
4864 # in Chapter 8: References
4865 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4866  
4867 # P.353 Other Tricks You Can Do with Hard References
4868 # in Chapter 8: References
4869 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4870  
4871 # (and so on)
4872  
4873 0 $char[$i] = '@{[Elatin1::ucfirst qq<';
4874 0 $left_e++;
4875 }
4876 elsif ($char[$i] eq '\l') {
4877 0 $char[$i] = '@{[Elatin1::lcfirst qq<';
4878 0 $left_e++;
4879 }
4880 elsif ($char[$i] eq '\U') {
4881 0 $char[$i] = '@{[Elatin1::uc qq<';
4882 0 $left_e++;
4883 }
4884 elsif ($char[$i] eq '\L') {
4885 0 $char[$i] = '@{[Elatin1::lc qq<';
4886 0 $left_e++;
4887 }
4888 elsif ($char[$i] eq '\F') {
4889 24 $char[$i] = '@{[Elatin1::fc qq<';
4890 24 $left_e++;
4891 }
4892 elsif ($char[$i] eq '\Q') {
4893 0 $char[$i] = '@{[CORE::quotemeta qq<';
4894 0 $left_e++;
4895 }
4896 elsif ($char[$i] eq '\E') {
4897 24 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 24 0 24
4898 24 $char[$i] = '>]}';
4899 24 $right_e++;
4900 }
4901 else {
4902 0 $char[$i] = '';
4903 }
4904 }
4905 elsif ($char[$i] eq '\Q') {
4906 0 while (1) {
4907 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
4908 0 last;
4909 }
4910 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
4911 0 last;
4912 }
4913 }
4914 }
4915 elsif ($char[$i] eq '\E') {
4916 }
4917  
4918 # $0 --> $0
4919 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
4920 }
4921 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
4922 }
4923  
4924 # $$ --> $$
4925 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
4926 }
4927  
4928 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4929 # $1, $2, $3 --> $1, $2, $3 otherwise
4930 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
4931 205 $char[$i] = e_capture($1);
4932 }
4933 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
4934 0 $char[$i] = e_capture($1);
4935 }
4936  
4937 # $$foo[ ... ] --> $ $foo->[ ... ]
4938 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
4939 0 $char[$i] = e_capture($1.'->'.$2);
4940 }
4941  
4942 # $$foo{ ... } --> $ $foo->{ ... }
4943 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
4944 0 $char[$i] = e_capture($1.'->'.$2);
4945 }
4946  
4947 # $$foo
4948 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
4949 0 $char[$i] = e_capture($1);
4950 }
4951  
4952 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
4953 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
4954 44 $char[$i] = '@{[Elatin1::PREMATCH()]}';
4955 }
4956  
4957 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
4958 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
4959 45 $char[$i] = '@{[Elatin1::MATCH()]}';
4960 }
4961  
4962 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
4963 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
4964 33 $char[$i] = '@{[Elatin1::POSTMATCH()]}';
4965 }
4966  
4967 # ${ foo } --> ${ foo }
4968 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
4969 }
4970  
4971 # ${ ... }
4972 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
4973 0 $char[$i] = e_capture($1);
4974 }
4975 }
4976  
4977 # return string
4978 4197 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 4197 4197
4979 0 return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter;
4980 }
4981 4197 return join '', $ope, $delimiter, @char, $end_delimiter;
4982 }
4983  
4984 #
4985 # escape qw string (qw//)
4986 #
4987 16 ▶sub e_qw {
Subroutine e_qw: called CC=11 SCAR=43.1
Pod undocumented
4988 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
4989  
4990 16 $slash = 'div';
4991  
4992 # choice again delimiter
4993 16 my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg);
4994 16 ▶ if (not $octet{$end_delimiter}) {
Branch: 5 branches
BranchTrueFalseTotal
if (not $octet{$end_delimiter}) { } 16 0 16
elsif (not $octet{')'}) { } 0 0 0
elsif (not $octet{'}'}) { } 0 0 0
elsif (not $octet{']'}) { } 0 0 0
elsif (not $octet{'>'}) { } 0 0 0
4995 16 return join '', $ope, $delimiter, $string, $end_delimiter;
4996 }
4997 elsif (not $octet{')'}) {
4998 0 return join '', $ope, '(', $string, ')';
4999 }
5000 elsif (not $octet{'}'}) {
5001 0 return join '', $ope, '{', $string, '}';
5002 }
5003 elsif (not $octet{']'}) {
5004 0 return join '', $ope, '[', $string, ']';
5005 }
5006 elsif (not $octet{'>'}) {
5007 0 return join '', $ope, '<', $string, '>';
5008 }
5009 else {
5010 0 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5011 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5012 0 return join '', $ope, $char, $string, $char;
5013 }
5014 }
5015 }
5016  
5017 # qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC')
5018 0 my @string = CORE::split(/\s+/, $string);
5019 0 for my $string (@string) {
5020 0 my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5021 0 for my $octet (@octet) {
5022 0 ▶ if ($octet =~ /\A (['\\]) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet =~ /\A (['\\]) \z/mosx) 0 0 0
5023 0 $octet = '\\' . $1;
5024 }
5025 }
5026 0 $string = join '', @octet;
5027 }
5028 0 return join '', '(', (join ', ', map { "'$_'" } @string), ')';
5029 }
5030  
5031 #
5032 # escape here document (<<"HEREDOC", <<HEREDOC, <<`HEREDOC`, <<~"HEREDOC", <<~HEREDOC, <<~`HEREDOC`)
5033 #
5034 93 ▶sub e_heredoc {
Subroutine e_heredoc: called CC=37 SCAR=56.3
Pod undocumented
5035 93 my($string) = @_;
5036  
5037 93 $slash = 'm//';
5038  
5039 93 my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC`
5040  
5041 93 my $left_e = 0;
5042 93 my $right_e = 0;
5043  
5044 # split regexp
5045 93 my @char = $string =~ /\G((?>
5046 [^\\\$] |
5047 \\x\{ (?>[0-9A-Fa-f]+) \} |
5048 \\o\{ (?>[0-7]+) \} |
5049 \\N\{ (?>[^0-9\}][^\}]*) \} |
5050 \\ $q_char |
5051 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5052 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5053 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5054 \$ (?>\s* [0-9]+) |
5055 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5056 \$ \$ (?![\w\{]) |
5057 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5058 $q_char
5059 ))/oxmsg;
5060  
5061 93 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 3177 93 3270
5062  
5063 # "\L\u" --> "\u\L"
5064 3177 ▶ if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) {
Branch: 5 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\L' and $char[$i + 1] eq '\\u') { } 0 3177 3177
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 3177 3177
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 3176 3177
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 3175 3176
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 3175 3175
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
317700
MC/DC0%0/2
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
$char[$i] eq "\\L" $char[$i + 1] eq "\\u"
Truth table33%1/3
A and B
A= $char[$i] eq "\\L"B= $char[$i + 1] eq "\\u"
ABresult
0X0
100
111
5065 0 @char[$i,$i+1] = @char[$i+1,$i];
5066 }
5067  
5068 # "\U\l" --> "\l\U"
5069 ▶ elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) {
Condition33%1/3
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
!ll&&!rl&&r
317700
MC/DC0%0/2
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
$char[$i] eq "\\U" $char[$i + 1] eq "\\l"
Truth table33%1/3
A and B
A= $char[$i] eq "\\U"B= $char[$i + 1] eq "\\l"
ABresult
0X0
100
111
5070 0 @char[$i,$i+1] = @char[$i+1,$i];
5071 }
5072  
5073 # octal escape sequence
5074 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5075 1 $char[$i] = Elatin1::octchr($1);
5076 }
5077  
5078 # hexadecimal escape sequence
5079 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5080 1 $char[$i] = Elatin1::hexchr($1);
5081 }
5082  
5083 # \N{CHARNAME} --> N{CHARNAME}
5084 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5085 0 $char[$i] = $1;
5086 }
5087  
5088 3177 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 0 3177 3177
elsif ($char[$i] eq '\\u') { } 0 3177 3177
elsif ($char[$i] eq '\\l') { } 0 3177 3177
elsif ($char[$i] eq '\\U') { } 0 3177 3177
elsif ($char[$i] eq '\\L') { } 0 3177 3177
elsif ($char[$i] eq '\\F') { } 0 3177 3177
elsif ($char[$i] eq '\\Q') { } 0 3177 3177
elsif ($char[$i] eq '\\E') { } 0 3177 3177
elsif ($char[$i] eq '\\Q') { } 0 3177 3177
elsif ($char[$i] eq '\\E') { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 3177 3177
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 8 3169 3177
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 8 3161 3169
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 6 3155 3161
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 3155 3155
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 3155 3155
5089 }
5090  
5091 # \u \l \U \L \F \Q \E
5092 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5093 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
5094 0 $char[$i] = '\\' . $char[$i];
5095 }
5096 }
5097 elsif ($char[$i] eq '\u') {
5098 0 $char[$i] = '@{[Elatin1::ucfirst qq<';
5099 0 $left_e++;
5100 }
5101 elsif ($char[$i] eq '\l') {
5102 0 $char[$i] = '@{[Elatin1::lcfirst qq<';
5103 0 $left_e++;
5104 }
5105 elsif ($char[$i] eq '\U') {
5106 0 $char[$i] = '@{[Elatin1::uc qq<';
5107 0 $left_e++;
5108 }
5109 elsif ($char[$i] eq '\L') {
5110 0 $char[$i] = '@{[Elatin1::lc qq<';
5111 0 $left_e++;
5112 }
5113 elsif ($char[$i] eq '\F') {
5114 0 $char[$i] = '@{[Elatin1::fc qq<';
5115 0 $left_e++;
5116 }
5117 elsif ($char[$i] eq '\Q') {
5118 0 $char[$i] = '@{[CORE::quotemeta qq<';
5119 0 $left_e++;
5120 }
5121 elsif ($char[$i] eq '\E') {
5122 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
5123 0 $char[$i] = '>]}';
5124 0 $right_e++;
5125 }
5126 else {
5127 0 $char[$i] = '';
5128 }
5129 }
5130 elsif ($char[$i] eq '\Q') {
5131 0 while (1) {
5132 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5133 0 last;
5134 }
5135 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5136 0 last;
5137 }
5138 }
5139 }
5140 elsif ($char[$i] eq '\E') {
5141 }
5142  
5143 # $0 --> $0
5144 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5145 }
5146 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5147 }
5148  
5149 # $$ --> $$
5150 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5151 }
5152  
5153 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5154 # $1, $2, $3 --> $1, $2, $3 otherwise
5155 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5156 0 $char[$i] = e_capture($1);
5157 }
5158 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5159 0 $char[$i] = e_capture($1);
5160 }
5161  
5162 # $$foo[ ... ] --> $ $foo->[ ... ]
5163 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5164 0 $char[$i] = e_capture($1.'->'.$2);
5165 }
5166  
5167 # $$foo{ ... } --> $ $foo->{ ... }
5168 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5169 0 $char[$i] = e_capture($1.'->'.$2);
5170 }
5171  
5172 # $$foo
5173 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5174 0 $char[$i] = e_capture($1);
5175 }
5176  
5177 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
5178 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5179 8 $char[$i] = '@{[Elatin1::PREMATCH()]}';
5180 }
5181  
5182 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
5183 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5184 8 $char[$i] = '@{[Elatin1::MATCH()]}';
5185 }
5186  
5187 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
5188 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5189 6 $char[$i] = '@{[Elatin1::POSTMATCH()]}';
5190 }
5191  
5192 # ${ foo } --> ${ foo }
5193 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5194 }
5195  
5196 # ${ ... }
5197 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5198 0 $char[$i] = e_capture($1);
5199 }
5200 }
5201  
5202 # return string
5203 93 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 93 93
5204 0 return join '', @char, '>]}' x ($left_e - $right_e);
5205 }
5206 93 return join '', @char;
5207 }
5208  
5209 #
5210 # escape regexp (m//, qr//)
5211 #
5212 880 ▶sub e_qr {
Subroutine e_qr: called CC=110 SCAR=73.6
Pod undocumented
5213 880 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5214 880 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
366514
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
5215  
5216 880 $modifier =~ tr/p//d;
5217 880 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 880 880
5218 0 my $line = 0;
5219 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5220 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5221 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5222 0 last;
5223 }
5224 }
5225 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5226 }
5227  
5228 880 $slash = 'div';
5229  
5230 # literal null string pattern
5231 880 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 872 880
elsif ($modifier =~ tr/Bb//d) { } 2 870 872
5232 8 $modifier =~ tr/bB//d;
5233 8 $modifier =~ tr/i//d;
5234 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5235 }
5236  
5237 # /b /B modifier
5238 elsif ($modifier =~ tr/bB//d) {
5239  
5240 # choice again delimiter
5241 2 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 2 2
5242 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5243 0 my %octet = map {$_ => 1} @char;
5244 0 ▶ if (not $octet{')'}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $octet{')'}) { } 0 0 0
elsif (not $octet{'}'}) { } 0 0 0
elsif (not $octet{']'}) { } 0 0 0
elsif (not $octet{'>'}) { } 0 0 0
5245 0 $delimiter = '(';
5246 0 $end_delimiter = ')';
5247 }
5248 elsif (not $octet{'}'}) {
5249 0 $delimiter = '{';
5250 0 $end_delimiter = '}';
5251 }
5252 elsif (not $octet{']'}) {
5253 0 $delimiter = '[';
5254 0 $end_delimiter = ']';
5255 }
5256 elsif (not $octet{'>'}) {
5257 0 $delimiter = '<';
5258 0 $end_delimiter = '>';
5259 }
5260 else {
5261 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5262 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5263 0 $delimiter = $char;
5264 0 $end_delimiter = $char;
5265 0 last;
5266 }
5267 }
5268 }
5269 }
5270  
5271 2 ▶ if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ope =~ /\A m? \z/mosx and $delimiter eq '?') { } 0 2 2
Condition33%1/3
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
!ll&&!rl&&r
020
MC/DC0%0/2
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
$ope =~ /\A m? \z/mosx $delimiter eq "?"
Truth table33%1/3
A and B
A= $ope =~ /\A m? \z/mosxB= $delimiter eq "?"
ABresult
0X0
100
111
5272 0 return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier;
5273 }
5274 else {
5275 2 return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5276 }
5277 }
5278  
5279 870 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 312 558 870
5280 870 my $metachar = qr/[\@\\|[\]{^]/oxms;
5281  
5282 # split regexp
5283 870 my @char = $string =~ /\G((?>
5284 [^\\\$\@\[\(] |
5285 \\x (?>[0-9A-Fa-f]{1,2}) |
5286 \\ (?>[0-7]{2,3}) |
5287 \\c [\x40-\x5F] |
5288 \\x\{ (?>[0-9A-Fa-f]+) \} |
5289 \\o\{ (?>[0-7]+) \} |
5290 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5291 \\ $q_char |
5292 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5293 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5294 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5295 [\$\@] $qq_variable |
5296 \$ (?>\s* [0-9]+) |
5297 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5298 \$ \$ (?![\w\{]) |
5299 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5300 \[\^ |
5301 \[\: (?>[a-z]+) :\] |
5302 \[\:\^ (?>[a-z]+) :\] |
5303 \(\? |
5304 $q_char
5305 ))/oxmsg;
5306  
5307 # choice again delimiter
5308 870 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 870 870
5309 0 my %octet = map {$_ => 1} @char;
5310 0 ▶ if (not $octet{')'}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $octet{')'}) { } 0 0 0
elsif (not $octet{'}'}) { } 0 0 0
elsif (not $octet{']'}) { } 0 0 0
elsif (not $octet{'>'}) { } 0 0 0
5311 0 $delimiter = '(';
5312 0 $end_delimiter = ')';
5313 }
5314 elsif (not $octet{'}'}) {
5315 0 $delimiter = '{';
5316 0 $end_delimiter = '}';
5317 }
5318 elsif (not $octet{']'}) {
5319 0 $delimiter = '[';
5320 0 $end_delimiter = ']';
5321 }
5322 elsif (not $octet{'>'}) {
5323 0 $delimiter = '<';
5324 0 $end_delimiter = '>';
5325 }
5326 else {
5327 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5328 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5329 0 $delimiter = $char;
5330 0 $end_delimiter = $char;
5331 0 last;
5332 }
5333 }
5334 }
5335 }
5336  
5337 870 my $left_e = 0;
5338 870 my $right_e = 0;
5339 870 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2100 870 2970
5340  
5341 # "\L\u" --> "\u\L"
5342 2100 ▶ if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) {
Branch: 6 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\L' and $char[$i + 1] eq '\\u') { } 0 2100 2100
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 2100 2100
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 2099 2100
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 2098 2099
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 6 2092 2098
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/mosx) { } 4 2088 2092
Condition66%2/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
209910
MC/DC0%0/2
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
$char[$i] eq "\\L" $char[$i + 1] eq "\\u"
Truth table66%2/3
A and B
A= $char[$i] eq "\\L"B= $char[$i + 1] eq "\\u"
ABresult
0X0
100
111
5343 0 @char[$i,$i+1] = @char[$i+1,$i];
5344 }
5345  
5346 # "\U\l" --> "\l\U"
5347 ▶ elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) {
Condition66%2/3
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
!ll&&!rl&&r
209910
MC/DC0%0/2
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
$char[$i] eq "\\U" $char[$i + 1] eq "\\l"
Truth table66%2/3
A and B
A= $char[$i] eq "\\U"B= $char[$i + 1] eq "\\l"
ABresult
0X0
100
111
5348 0 @char[$i,$i+1] = @char[$i+1,$i];
5349 }
5350  
5351 # octal escape sequence
5352 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5353 1 $char[$i] = Elatin1::octchr($1);
5354 }
5355  
5356 # hexadecimal escape sequence
5357 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5358 1 $char[$i] = Elatin1::hexchr($1);
5359 }
5360  
5361 # \b{...} --> b\{...}
5362 # \B{...} --> B\{...}
5363 # \N{CHARNAME} --> N\{CHARNAME}
5364 # \p{PROPERTY} --> p\{PROPERTY}
5365 # \P{PROPERTY} --> P\{PROPERTY}
5366 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5367 6 $char[$i] = $1 . '\\' . $2;
5368 }
5369  
5370 # \p, \P, \X --> p, P, X
5371 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
5372 4 $char[$i] = $1;
5373 }
5374  
5375 2100 ▶ if (0) {
Branch: 30 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx }) { } 6 2094 2100
elsif ($char[$i] eq '[') { } 556 1538 2094
elsif ($char[$i] eq '[^') { } 74 1464 1538
elsif (my $char = character_class($char[$i], $modifier)) { } 139 1325 1464
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 20 1305 1325
elsif ($char[$i] =~ /\A [<>] \z/mosx) { } 1 1304 1305
elsif ($char[$i] eq '\\u') { } 0 1304 1304
elsif ($char[$i] eq '\\l') { } 0 1304 1304
elsif ($char[$i] eq '\\U') { } 1 1303 1304
elsif ($char[$i] eq '\\L') { } 1 1302 1303
elsif ($char[$i] eq '\\F') { } 18 1284 1302
elsif ($char[$i] eq '\\Q') { } 1 1283 1284
elsif ($char[$i] eq '\\E') { } 21 1262 1283
elsif ($char[$i] eq '\\Q') { } 0 1262 1262
elsif ($char[$i] eq '\\E') { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 1262 1262
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 8 1254 1262
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 8 1246 1254
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 6 1240 1246
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/mosx) { } 0 1240 1240
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 1240 1240
elsif ($char[$i] =~ /\A [\$\@].+ /mosx) { } 21 1219 1240
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 138 1377 1515
5376 }
5377  
5378 # join separated multiple-octet
5379 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
5380 6 ▶ if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf '"%s%s%s%s"', @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 6 6
elsif ($i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf '"%s%s%s"', @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 6 6
elsif ($i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf '"%s%s"', @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 12 12
Condition33%2/6
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
600
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3
!ll&&!rl&&r
600
MC/DC0%0/3
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
$i + 3 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
Truth table25%1/4
A and B and C
A= $i + 3 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3C= eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5381 0 $char[$i] .= join '', splice @char, $i+1, 3;
5382 }
5383 ▶ elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) {
Condition33%2/6
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
600
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2
!ll&&!rl&&r
600
MC/DC0%0/3
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
$i + 2 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
Truth table25%1/4
A and B and C
A= $i + 2 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2C= eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5384 0 $char[$i] .= join '', splice @char, $i+1, 2;
5385 }
5386 ▶ elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) {
Condition50%3/6
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
600
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1
!ll&&!rl&&r
420
MC/DC0%0/3
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
$i + 1 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
Truth table50%2/4
A and B and C
A= $i + 1 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1C= eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5387 0 $char[$i] .= join '', splice @char, $i+1, 1;
5388 }
5389 }
5390  
5391 # open character class [...]
5392 elsif ($char[$i] eq '[') {
5393 556 my $left = $i;
5394  
5395 # [] make die "Unmatched [] in regexp ...\n"
5396 # (and so on)
5397  
5398 556 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 3 553 556
5399 3 $i++;
5400 }
5401  
5402 556 while (1) {
5403 2063 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 2063 2063
5404 0 die __FILE__, ": Unmatched [] in regexp\n";
5405 }
5406 2063 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 556 1507 2063
5407 556 my $right = $i;
5408  
5409 # [...]
5410 556 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 30 526 556
5411 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5412 }
5413 else {
5414 526 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
5415 }
5416  
5417 556 $i = $left;
5418 556 last;
5419 }
5420 }
5421 }
5422  
5423 # open character class [^...]
5424 elsif ($char[$i] eq '[^') {
5425 74 my $left = $i;
5426  
5427 # [^] make die "Unmatched [] in regexp ...\n"
5428 # (and so on)
5429  
5430 74 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 4 70 74
5431 4 $i++;
5432 }
5433  
5434 74 while (1) {
5435 272 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 272 272
5436 0 die __FILE__, ": Unmatched [] in regexp\n";
5437 }
5438 272 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 74 198 272
5439 74 my $right = $i;
5440  
5441 # [^...]
5442 74 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 30 44 74
5443 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5444 }
5445 else {
5446 44 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5447 }
5448  
5449 74 $i = $left;
5450 74 last;
5451 }
5452 }
5453 }
5454  
5455 # rewrite character class or escape character
5456 elsif (my $char = character_class($char[$i],$modifier)) {
5457 139 $char[$i] = $char;
5458 }
5459  
5460 # /i modifier
5461 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition100%6/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
1297820
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
12663128
MC/DC100%3/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table100%4/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5462 20 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 20 0 20
5463 20 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
5464 }
5465 else {
5466 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
5467 }
5468 }
5469  
5470 # \u \l \U \L \F \Q \E
5471 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
5472 1 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 1 1
5473 0 $char[$i] = '\\' . $char[$i];
5474 }
5475 }
5476 elsif ($char[$i] eq '\u') {
5477 0 $char[$i] = '@{[Elatin1::ucfirst qq<';
5478 0 $left_e++;
5479 }
5480 elsif ($char[$i] eq '\l') {
5481 0 $char[$i] = '@{[Elatin1::lcfirst qq<';
5482 0 $left_e++;
5483 }
5484 elsif ($char[$i] eq '\U') {
5485 1 $char[$i] = '@{[Elatin1::uc qq<';
5486 1 $left_e++;
5487 }
5488 elsif ($char[$i] eq '\L') {
5489 1 $char[$i] = '@{[Elatin1::lc qq<';
5490 1 $left_e++;
5491 }
5492 elsif ($char[$i] eq '\F') {
5493 18 $char[$i] = '@{[Elatin1::fc qq<';
5494 18 $left_e++;
5495 }
5496 elsif ($char[$i] eq '\Q') {
5497 1 $char[$i] = '@{[CORE::quotemeta qq<';
5498 1 $left_e++;
5499 }
5500 elsif ($char[$i] eq '\E') {
5501 21 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 21 0 21
5502 21 $char[$i] = '>]}';
5503 21 $right_e++;
5504 }
5505 else {
5506 0 $char[$i] = '';
5507 }
5508 }
5509 elsif ($char[$i] eq '\Q') {
5510 0 while (1) {
5511 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5512 0 last;
5513 }
5514 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5515 0 last;
5516 }
5517 }
5518 }
5519 elsif ($char[$i] eq '\E') {
5520 }
5521  
5522 # $0 --> $0
5523 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5524 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5525 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5526 }
5527 }
5528 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5529 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5530 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5531 }
5532 }
5533  
5534 # $$ --> $$
5535 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5536 }
5537  
5538 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5539 # $1, $2, $3 --> $1, $2, $3 otherwise
5540 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5541 0 $char[$i] = e_capture($1);
5542 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5543 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5544 }
5545 }
5546 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5547 0 $char[$i] = e_capture($1);
5548 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5549 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5550 }
5551 }
5552  
5553 # $$foo[ ... ] --> $ $foo->[ ... ]
5554 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5555 0 $char[$i] = e_capture($1.'->'.$2);
5556 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5557 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5558 }
5559 }
5560  
5561 # $$foo{ ... } --> $ $foo->{ ... }
5562 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5563 0 $char[$i] = e_capture($1.'->'.$2);
5564 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5565 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5566 }
5567 }
5568  
5569 # $$foo
5570 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5571 0 $char[$i] = e_capture($1);
5572 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5573 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5574 }
5575 }
5576  
5577 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
5578 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5579 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5580 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::PREMATCH())]}';
5581 }
5582 else {
5583 8 $char[$i] = '@{[Elatin1::PREMATCH()]}';
5584 }
5585 }
5586  
5587 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
5588 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5589 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5590 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::MATCH())]}';
5591 }
5592 else {
5593 8 $char[$i] = '@{[Elatin1::MATCH()]}';
5594 }
5595 }
5596  
5597 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
5598 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5599 6 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 6 6
5600 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::POSTMATCH())]}';
5601 }
5602 else {
5603 6 $char[$i] = '@{[Elatin1::POSTMATCH()]}';
5604 }
5605 }
5606  
5607 # ${ foo }
5608 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
5609 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5610 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5611 }
5612 }
5613  
5614 # ${ ... }
5615 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5616 0 $char[$i] = e_capture($1);
5617 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5618 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5619 }
5620 }
5621  
5622 # $scalar or @array
5623 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
5624 21 $char[$i] = e_string($char[$i]);
5625 21 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 11 10 21
5626 11 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
5627 }
5628 }
5629  
5630 # quote character before ? + * {
5631 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition100%3/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
296785138
MC/DC100%2/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table100%3/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
5632 138 ▶ if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/mosx) { } 11 127 138
elsif ($ope =~ /\A m? \z/mosx and $delimiter eq '?') { } 0 127 127
5633 }
5634 ▶ elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) {
Condition33%1/3
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
!ll&&!rl&&r
01270
MC/DC0%0/2
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
$ope =~ /\A m? \z/mosx $delimiter eq "?"
Truth table33%1/3
A and B
A= $ope =~ /\A m? \z/mosxB= $delimiter eq "?"
ABresult
0X0
100
111
5635 0 my $char = $char[$i-1];
5636 0 ▶ if ($char[$i] eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq '{') { } 0 0 0
5637 0 die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n};
5638 }
5639 else {
5640 0 die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n};
5641 }
5642 }
5643 else {
5644 127 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5645 }
5646 }
5647 }
5648  
5649 # make regexp string
5650 870 $modifier =~ tr/i//d;
5651 870 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 870 870
5652 0 ▶ if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ope =~ /\A m? \z/mosx and $delimiter eq '?') { } 0 0 0
Condition0%0/3
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
!ll&&!rl&&r
000
MC/DC0%0/2
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
$ope =~ /\A m? \z/mosx $delimiter eq "?"
Truth table0%0/3
A and B
A= $ope =~ /\A m? \z/mosxB= $delimiter eq "?"
ABresult
0X0
100
111
5653 0 return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier;
5654 }
5655 else {
5656 0 return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
5657 }
5658 }
5659 870 ▶ if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ope =~ /\A m? \z/mosx and $delimiter eq '?') { } 0 870 870
Condition33%1/3
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
!ll&&!rl&&r
08700
MC/DC0%0/2
$ope =~ /\A m? \z/mosx and $delimiter eq "?"
$ope =~ /\A m? \z/mosx $delimiter eq "?"
Truth table33%1/3
A and B
A= $ope =~ /\A m? \z/mosxB= $delimiter eq "?"
ABresult
0X0
100
111
5660 0 return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier;
5661 }
5662 else {
5663 870 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5664 }
5665 }
5666  
5667 #
5668 # double quote stuff
5669 #
5670 180 ▶sub qq_stuff {
Subroutine qq_stuff: called CC=6 SCAR=18.5
Pod undocumented
5671 180 my($delimiter,$end_delimiter,$stuff) = @_;
5672  
5673 # scalar variable or array variable
5674 180 ▶ if ($stuff =~ /\A [\$\@] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff =~ /\A [\$\@] /mosx) 100 80 180
5675 100 return $stuff;
5676 }
5677  
5678 # quote by delimiter
5679 80 my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg);
5680 80 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5681 80 ▶ next if $char eq $delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $delimiter 0 80 80
5682 80 ▶ next if $char eq $end_delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $end_delimiter 0 80 80
5683 80 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 80 0 80
5684 80 return join '', 'qq', $char, $stuff, $char;
5685 }
5686 }
5687 0 return join '', 'qq', '<', $stuff, '>';
5688 }
5689  
5690 #
5691 # escape regexp (m'', qr'', and m''b, qr''b)
5692 #
5693 10 ▶sub e_qr_q {
Subroutine e_qr_q: called CC=7 SCAR=25.3
Pod undocumented
5694 10 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5695 10 ▶ $modifier ||= '';
Condition50%1/2
$modifier ||= ""
l!l
010
MC/DC0%0/1
$modifier ||= ""
$modifier
Truth table50%1/2
A
A= $modifier
Aresult
11
00
5696  
5697 10 $modifier =~ tr/p//d;
5698 10 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 10 10
5699 0 my $line = 0;
5700 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5701 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5702 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5703 0 last;
5704 }
5705 }
5706 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5707 }
5708  
5709 10 $slash = 'div';
5710  
5711 # literal null string pattern
5712 10 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 2 10
elsif ($modifier =~ tr/Bb//d) { } 0 2 2
5713 8 $modifier =~ tr/bB//d;
5714 8 $modifier =~ tr/i//d;
5715 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5716 }
5717  
5718 # with /b /B modifier
5719 elsif ($modifier =~ tr/bB//d) {
5720 0 return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
5721 }
5722  
5723 # without /b /B modifier
5724 else {
5725 2 return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
5726 }
5727 }
5728  
5729 #
5730 # escape regexp (m'', qr'')
5731 #
5732 2 ▶sub e_qr_qt {
Subroutine e_qr_qt: called CC=20 SCAR=51.8
Pod undocumented
5733 2 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5734  
5735 2 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 2 2
5736  
5737 # split regexp
5738 2 my @char = $string =~ /\G((?>
5739 [^\\\[\$\@\/] |
5740 [\x00-\xFF] |
5741 \[\^ |
5742 \[\: (?>[a-z]+) \:\] |
5743 \[\:\^ (?>[a-z]+) \:\] |
5744 [\$\@\/] |
5745 \\ (?:$q_char) |
5746 (?:$q_char)
5747 ))/oxmsg;
5748  
5749 # unescape character
5750 2 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2 2 4
5751 2 ▶ if (0) {
Branch: 6 branches
BranchTrueFalseTotal
if (do { $char[$i] eq '[' }) { } 0 2 2
elsif ($char[$i] eq '[^') { } 0 2 2
elsif ($char[$i] =~ m(\A [\$\@/\\] \z)mosx) { } 0 2 2
elsif (my $char = character_class($char[$i], $modifier)) { } 0 2 2
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 0 2 2
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 4 4
5752 }
5753  
5754 # open character class [...]
5755 elsif ($char[$i] eq '[') {
5756 0 my $left = $i;
5757 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5758 0 $i++;
5759 }
5760 0 while (1) {
5761 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5762 0 die __FILE__, ": Unmatched [] in regexp\n";
5763 }
5764 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5765 0 my $right = $i;
5766  
5767 # [...]
5768 0 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
5769  
5770 0 $i = $left;
5771 0 last;
5772 }
5773 }
5774 }
5775  
5776 # open character class [^...]
5777 elsif ($char[$i] eq '[^') {
5778 0 my $left = $i;
5779 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5780 0 $i++;
5781 }
5782 0 while (1) {
5783 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5784 0 die __FILE__, ": Unmatched [] in regexp\n";
5785 }
5786 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5787 0 my $right = $i;
5788  
5789 # [^...]
5790 0 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5791  
5792 0 $i = $left;
5793 0 last;
5794 }
5795 }
5796 }
5797  
5798 # escape $ @ / and \
5799 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5800 0 $char[$i] = '\\' . $char[$i];
5801 }
5802  
5803 # rewrite character class or escape character
5804 elsif (my $char = character_class($char[$i],$modifier)) {
5805 0 $char[$i] = $char;
5806 }
5807  
5808 # /i modifier
5809 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
200
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
200
MC/DC0%0/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table25%1/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5810 0 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
5811 0 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
5812 }
5813 else {
5814 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
5815 }
5816 }
5817  
5818 # quote character before ? + * {
5819 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition33%1/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
200
MC/DC0%0/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table33%1/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
5820 0 ▶ if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A [\x00-\xFF] \z/mosx) { } 0 0 0
5821 }
5822 else {
5823 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5824 }
5825 }
5826 }
5827  
5828 2 $delimiter = '/';
5829 2 $end_delimiter = '/';
5830  
5831 2 $modifier =~ tr/i//d;
5832 2 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5833 }
5834  
5835 #
5836 # escape regexp (m''b, qr''b)
5837 #
5838 0 ▶sub e_qr_qb {
Subroutine e_qr_qb: not called CC=4 SCAR=30.0
Pod undocumented
5839 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5840  
5841 # split regexp
5842 0 my @char = $string =~ /\G ((?>[^\\]|\\\\)) /oxmsg;
5843  
5844 # unescape character
5845 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
5846 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $char[$i] eq '\\\\' }) { } 0 0 0
elsif ($char[$i] =~ m(\A [\$\@/\\] \z)mosx) { } 0 0 0
5847 }
5848  
5849 # remain \\
5850 elsif ($char[$i] eq '\\\\') {
5851 }
5852  
5853 # escape $ @ / and \
5854 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5855 0 $char[$i] = '\\' . $char[$i];
5856 }
5857 }
5858  
5859 0 $delimiter = '/';
5860 0 $end_delimiter = '/';
5861 0 return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5862 }
5863  
5864 #
5865 # escape regexp (s/here//)
5866 #
5867 80 ▶sub e_s1 {
Subroutine e_s1: called CC=106 SCAR=81.1
Pod undocumented
5868 80 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5869 80 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
3050
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
5870  
5871 80 $modifier =~ tr/p//d;
5872 80 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 80 80
5873 0 my $line = 0;
5874 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5875 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5876 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5877 0 last;
5878 }
5879 }
5880 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5881 }
5882  
5883 80 $slash = 'div';
5884  
5885 # literal null string pattern
5886 80 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 72 80
elsif ($modifier =~ tr/Bb//d) { } 0 72 72
5887 8 $modifier =~ tr/bB//d;
5888 8 $modifier =~ tr/i//d;
5889 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5890 }
5891  
5892 # /b /B modifier
5893 elsif ($modifier =~ tr/bB//d) {
5894  
5895 # choice again delimiter
5896 0 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 0 0
5897 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5898 0 my %octet = map {$_ => 1} @char;
5899 0 ▶ if (not $octet{')'}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $octet{')'}) { } 0 0 0
elsif (not $octet{'}'}) { } 0 0 0
elsif (not $octet{']'}) { } 0 0 0
elsif (not $octet{'>'}) { } 0 0 0
5900 0 $delimiter = '(';
5901 0 $end_delimiter = ')';
5902 }
5903 elsif (not $octet{'}'}) {
5904 0 $delimiter = '{';
5905 0 $end_delimiter = '}';
5906 }
5907 elsif (not $octet{']'}) {
5908 0 $delimiter = '[';
5909 0 $end_delimiter = ']';
5910 }
5911 elsif (not $octet{'>'}) {
5912 0 $delimiter = '<';
5913 0 $end_delimiter = '>';
5914 }
5915 else {
5916 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5917 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5918 0 $delimiter = $char;
5919 0 $end_delimiter = $char;
5920 0 last;
5921 }
5922 }
5923 }
5924 }
5925  
5926 0 my $prematch = '';
5927 0 return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5928 }
5929  
5930 72 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 1 71 72
5931 72 my $metachar = qr/[\@\\|[\]{^]/oxms;
5932  
5933 # split regexp
5934 72 my @char = $string =~ /\G((?>
5935 [^\\\$\@\[\(] |
5936 \\ (?>[1-9][0-9]*) |
5937 \\g (?>\s*) (?>[1-9][0-9]*) |
5938 \\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5939 \\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5940 \\x (?>[0-9A-Fa-f]{1,2}) |
5941 \\ (?>[0-7]{2,3}) |
5942 \\c [\x40-\x5F] |
5943 \\x\{ (?>[0-9A-Fa-f]+) \} |
5944 \\o\{ (?>[0-7]+) \} |
5945 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5946 \\ $q_char |
5947 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5948 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5949 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5950 [\$\@] $qq_variable |
5951 \$ (?>\s* [0-9]+) |
5952 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5953 \$ \$ (?![\w\{]) |
5954 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5955 \[\^ |
5956 \[\: (?>[a-z]+) :\] |
5957 \[\:\^ (?>[a-z]+) :\] |
5958 \(\? |
5959 $q_char
5960 ))/oxmsg;
5961  
5962 # choice again delimiter
5963 72 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 72 72
5964 0 my %octet = map {$_ => 1} @char;
5965 0 ▶ if (not $octet{')'}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $octet{')'}) { } 0 0 0
elsif (not $octet{'}'}) { } 0 0 0
elsif (not $octet{']'}) { } 0 0 0
elsif (not $octet{'>'}) { } 0 0 0
5966 0 $delimiter = '(';
5967 0 $end_delimiter = ')';
5968 }
5969 elsif (not $octet{'}'}) {
5970 0 $delimiter = '{';
5971 0 $end_delimiter = '}';
5972 }
5973 elsif (not $octet{']'}) {
5974 0 $delimiter = '[';
5975 0 $end_delimiter = ']';
5976 }
5977 elsif (not $octet{'>'}) {
5978 0 $delimiter = '<';
5979 0 $end_delimiter = '>';
5980 }
5981 else {
5982 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5983 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5984 0 $delimiter = $char;
5985 0 $end_delimiter = $char;
5986 0 last;
5987 }
5988 }
5989 }
5990 }
5991  
5992 # count '('
5993 72 my $parens = grep { $_ eq '(' } @char;
5994  
5995 72 my $left_e = 0;
5996 72 my $right_e = 0;
5997 72 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 200 72 272
5998  
5999 # "\L\u" --> "\u\L"
6000 200 ▶ if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) {
Branch: 6 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\L' and $char[$i + 1] eq '\\u') { } 0 200 200
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 200 200
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 199 200
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 198 199
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 198 198
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/mosx) { } 0 198 198
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
20000
MC/DC0%0/2
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
$char[$i] eq "\\L" $char[$i + 1] eq "\\u"
Truth table33%1/3
A and B
A= $char[$i] eq "\\L"B= $char[$i + 1] eq "\\u"
ABresult
0X0
100
111
6001 0 @char[$i,$i+1] = @char[$i+1,$i];
6002 }
6003  
6004 # "\U\l" --> "\l\U"
6005 ▶ elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) {
Condition33%1/3
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
!ll&&!rl&&r
20000
MC/DC0%0/2
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
$char[$i] eq "\\U" $char[$i + 1] eq "\\l"
Truth table33%1/3
A and B
A= $char[$i] eq "\\U"B= $char[$i + 1] eq "\\l"
ABresult
0X0
100
111
6006 0 @char[$i,$i+1] = @char[$i+1,$i];
6007 }
6008  
6009 # octal escape sequence
6010 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6011 1 $char[$i] = Elatin1::octchr($1);
6012 }
6013  
6014 # hexadecimal escape sequence
6015 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6016 1 $char[$i] = Elatin1::hexchr($1);
6017 }
6018  
6019 # \b{...} --> b\{...}
6020 # \B{...} --> B\{...}
6021 # \N{CHARNAME} --> N\{CHARNAME}
6022 # \p{PROPERTY} --> p\{PROPERTY}
6023 # \P{PROPERTY} --> P\{PROPERTY}
6024 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6025 0 $char[$i] = $1 . '\\' . $2;
6026 }
6027  
6028 # \p, \P, \X --> p, P, X
6029 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6030 0 $char[$i] = $1;
6031 }
6032  
6033 200 ▶ if (0) {
Branch: 35 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx }) { } 0 200 200
elsif ($char[$i] eq '[') { } 17 183 200
elsif ($char[$i] eq '[^') { } 0 183 183
elsif (my $char = character_class($char[$i], $modifier)) { } 7 176 183
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 3 173 176
elsif ($char[$i] =~ /\A [<>] \z/mosx) { } 0 173 173
elsif ($char[$i] eq '\\u') { } 0 173 173
elsif ($char[$i] eq '\\l') { } 0 173 173
elsif ($char[$i] eq '\\U') { } 0 173 173
elsif ($char[$i] eq '\\L') { } 0 173 173
elsif ($char[$i] eq '\\F') { } 0 173 173
elsif ($char[$i] eq '\\Q') { } 0 173 173
elsif ($char[$i] eq '\\E') { } 0 173 173
elsif ($char[$i] eq '\\Q') { } 0 173 173
elsif ($char[$i] eq '\\E') { } 0 173 173
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 173 173
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 4 169 173
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 4 165 169
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 3 162 165
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/mosx) { } 0 162 162
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 162 162
elsif ($char[$i] =~ /\A [\$\@].+ /mosx) { } 4 158 162
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 14 204 218
6034 }
6035  
6036 # join separated multiple-octet
6037 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6038 0 ▶ if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf '"%s%s%s%s"', @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
elsif ($i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf '"%s%s%s"', @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
elsif ($i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf '"%s%s"', @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
Condition0%0/6
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
$i + 3 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 3 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3C= eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6039 0 $char[$i] .= join '', splice @char, $i+1, 3;
6040 }
6041 ▶ elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) {
Condition0%0/6
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
$i + 2 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 2 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2C= eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6042 0 $char[$i] .= join '', splice @char, $i+1, 2;
6043 }
6044 ▶ elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) {
Condition0%0/6
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
$i + 1 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 1 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1C= eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6045 0 $char[$i] .= join '', splice @char, $i+1, 1;
6046 }
6047 }
6048  
6049 # open character class [...]
6050 elsif ($char[$i] eq '[') {
6051 17 my $left = $i;
6052 17 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 17 17
6053 0 $i++;
6054 }
6055 17 while (1) {
6056 74 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 74 74
6057 0 die __FILE__, ": Unmatched [] in regexp\n";
6058 }
6059 74 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 17 57 74
6060 17 my $right = $i;
6061  
6062 # [...]
6063 17 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 0 17 17
6064 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6065 }
6066 else {
6067 17 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
6068 }
6069  
6070 17 $i = $left;
6071 17 last;
6072 }
6073 }
6074 }
6075  
6076 # open character class [^...]
6077 elsif ($char[$i] eq '[^') {
6078 0 my $left = $i;
6079 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6080 0 $i++;
6081 }
6082 0 while (1) {
6083 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6084 0 die __FILE__, ": Unmatched [] in regexp\n";
6085 }
6086 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6087 0 my $right = $i;
6088  
6089 # [^...]
6090 0 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 0 0 0
6091 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6092 }
6093 else {
6094 0 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6095 }
6096  
6097 0 $i = $left;
6098 0 last;
6099 }
6100 }
6101 }
6102  
6103 # rewrite character class or escape character
6104 elsif (my $char = character_class($char[$i],$modifier)) {
6105 7 $char[$i] = $char;
6106 }
6107  
6108 # /i modifier
6109 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition66%4/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
17303
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
17303
MC/DC33%1/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table50%2/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6110 3 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 3 0 3
6111 3 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
6112 }
6113 else {
6114 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
6115 }
6116 }
6117  
6118 # \u \l \U \L \F \Q \E
6119 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
6120 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6121 0 $char[$i] = '\\' . $char[$i];
6122 }
6123 }
6124 elsif ($char[$i] eq '\u') {
6125 0 $char[$i] = '@{[Elatin1::ucfirst qq<';
6126 0 $left_e++;
6127 }
6128 elsif ($char[$i] eq '\l') {
6129 0 $char[$i] = '@{[Elatin1::lcfirst qq<';
6130 0 $left_e++;
6131 }
6132 elsif ($char[$i] eq '\U') {
6133 0 $char[$i] = '@{[Elatin1::uc qq<';
6134 0 $left_e++;
6135 }
6136 elsif ($char[$i] eq '\L') {
6137 0 $char[$i] = '@{[Elatin1::lc qq<';
6138 0 $left_e++;
6139 }
6140 elsif ($char[$i] eq '\F') {
6141 0 $char[$i] = '@{[Elatin1::fc qq<';
6142 0 $left_e++;
6143 }
6144 elsif ($char[$i] eq '\Q') {
6145 0 $char[$i] = '@{[CORE::quotemeta qq<';
6146 0 $left_e++;
6147 }
6148 elsif ($char[$i] eq '\E') {
6149 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6150 0 $char[$i] = '>]}';
6151 0 $right_e++;
6152 }
6153 else {
6154 0 $char[$i] = '';
6155 }
6156 }
6157 elsif ($char[$i] eq '\Q') {
6158 0 while (1) {
6159 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6160 0 last;
6161 }
6162 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6163 0 last;
6164 }
6165 }
6166 }
6167 elsif ($char[$i] eq '\E') {
6168 }
6169  
6170 # \0 --> \0
6171 elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) {
6172 }
6173  
6174 # \g{N}, \g{-N}
6175  
6176 # P.108 Using Simple Patterns
6177 # in Chapter 7: In the World of Regular Expressions
6178 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
6179  
6180 # P.221 Capturing
6181 # in Chapter 5: Pattern Matching
6182 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6183  
6184 # \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3}
6185 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6186 }
6187  
6188 # \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable)
6189 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6190 }
6191  
6192 # \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable)
6193 elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6194 }
6195  
6196 # \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable)
6197 elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6198 }
6199  
6200 # $0 --> $0
6201 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6202 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6203 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6204 }
6205 }
6206 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6207 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6208 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6209 }
6210 }
6211  
6212 # $$ --> $$
6213 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6214 }
6215  
6216 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6217 # $1, $2, $3 --> $1, $2, $3 otherwise
6218 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6219 0 $char[$i] = e_capture($1);
6220 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6221 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6222 }
6223 }
6224 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6225 0 $char[$i] = e_capture($1);
6226 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6227 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6228 }
6229 }
6230  
6231 # $$foo[ ... ] --> $ $foo->[ ... ]
6232 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6233 0 $char[$i] = e_capture($1.'->'.$2);
6234 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6235 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6236 }
6237 }
6238  
6239 # $$foo{ ... } --> $ $foo->{ ... }
6240 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6241 0 $char[$i] = e_capture($1.'->'.$2);
6242 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6243 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6244 }
6245 }
6246  
6247 # $$foo
6248 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6249 0 $char[$i] = e_capture($1);
6250 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6251 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6252 }
6253 }
6254  
6255 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
6256 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6257 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6258 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::PREMATCH())]}';
6259 }
6260 else {
6261 4 $char[$i] = '@{[Elatin1::PREMATCH()]}';
6262 }
6263 }
6264  
6265 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
6266 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6267 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6268 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::MATCH())]}';
6269 }
6270 else {
6271 4 $char[$i] = '@{[Elatin1::MATCH()]}';
6272 }
6273 }
6274  
6275 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
6276 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6277 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 3 3
6278 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::POSTMATCH())]}';
6279 }
6280 else {
6281 3 $char[$i] = '@{[Elatin1::POSTMATCH()]}';
6282 }
6283 }
6284  
6285 # ${ foo }
6286 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6287 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6288 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6289 }
6290 }
6291  
6292 # ${ ... }
6293 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6294 0 $char[$i] = e_capture($1);
6295 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6296 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6297 }
6298 }
6299  
6300 # $scalar or @array
6301 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6302 4 $char[$i] = e_string($char[$i]);
6303 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 4 4
6304 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6305 }
6306 }
6307  
6308 # quote character before ? + * {
6309 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition100%3/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
608414
MC/DC100%2/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table100%3/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
6310 14 ▶ if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/mosx) { } 0 14 14
6311 }
6312 else {
6313 14 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6314 }
6315 }
6316 }
6317  
6318 # make regexp string
6319 72 my $prematch = '';
6320 72 $modifier =~ tr/i//d;
6321 72 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 72 72
6322 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6323 }
6324 72 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6325 }
6326  
6327 #
6328 # escape regexp (s'here'' or s'here''b)
6329 #
6330 21 ▶sub e_s1_q {
Subroutine e_s1_q: called CC=7 SCAR=24.3
Pod undocumented
6331 21 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6332 21 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
318
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
6333  
6334 21 $modifier =~ tr/p//d;
6335 21 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 21 21
6336 0 my $line = 0;
6337 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6338 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6339 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6340 0 last;
6341 }
6342 }
6343 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6344 }
6345  
6346 21 $slash = 'div';
6347  
6348 # literal null string pattern
6349 21 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 13 21
elsif ($modifier =~ tr/Bb//d) { } 0 13 13
6350 8 $modifier =~ tr/bB//d;
6351 8 $modifier =~ tr/i//d;
6352 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6353 }
6354  
6355 # with /b /B modifier
6356 elsif ($modifier =~ tr/bB//d) {
6357 0 return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6358 }
6359  
6360 # without /b /B modifier
6361 else {
6362 13 return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6363 }
6364 }
6365  
6366 #
6367 # escape regexp (s'here'')
6368 #
6369 13 ▶sub e_s1_qt {
Subroutine e_s1_qt: called CC=20 SCAR=50.1
Pod undocumented
6370 13 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6371  
6372 13 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 13 13
6373  
6374 # split regexp
6375 13 my @char = $string =~ /\G((?>
6376 [^\\\[\$\@\/] |
6377 [\x00-\xFF] |
6378 \[\^ |
6379 \[\: (?>[a-z]+) \:\] |
6380 \[\:\^ (?>[a-z]+) \:\] |
6381 [\$\@\/] |
6382 \\ (?:$q_char) |
6383 (?:$q_char)
6384 ))/oxmsg;
6385  
6386 # unescape character
6387 13 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 25 13 38
6388 25 ▶ if (0) {
Branch: 6 branches
BranchTrueFalseTotal
if (do { $char[$i] eq '[' }) { } 0 25 25
elsif ($char[$i] eq '[^') { } 0 25 25
elsif ($char[$i] =~ m(\A [\$\@/\\] \z)mosx) { } 0 25 25
elsif (my $char = character_class($char[$i], $modifier)) { } 6 19 25
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 0 19 19
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 32 32
6389 }
6390  
6391 # open character class [...]
6392 elsif ($char[$i] eq '[') {
6393 0 my $left = $i;
6394 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6395 0 $i++;
6396 }
6397 0 while (1) {
6398 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6399 0 die __FILE__, ": Unmatched [] in regexp\n";
6400 }
6401 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6402 0 my $right = $i;
6403  
6404 # [...]
6405 0 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
6406  
6407 0 $i = $left;
6408 0 last;
6409 }
6410 }
6411 }
6412  
6413 # open character class [^...]
6414 elsif ($char[$i] eq '[^') {
6415 0 my $left = $i;
6416 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6417 0 $i++;
6418 }
6419 0 while (1) {
6420 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6421 0 die __FILE__, ": Unmatched [] in regexp\n";
6422 }
6423 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6424 0 my $right = $i;
6425  
6426 # [^...]
6427 0 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6428  
6429 0 $i = $left;
6430 0 last;
6431 }
6432 }
6433 }
6434  
6435 # escape $ @ / and \
6436 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6437 0 $char[$i] = '\\' . $char[$i];
6438 }
6439  
6440 # rewrite character class or escape character
6441 elsif (my $char = character_class($char[$i],$modifier)) {
6442 6 $char[$i] = $char;
6443 }
6444  
6445 # /i modifier
6446 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
1900
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
1900
MC/DC0%0/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table25%1/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6447 0 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6448 0 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
6449 }
6450 else {
6451 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
6452 }
6453 }
6454  
6455 # quote character before ? + * {
6456 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition66%2/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
1360
MC/DC0%0/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table66%2/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
6457 0 ▶ if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A [\x00-\xFF] \z/mosx) { } 0 0 0
6458 }
6459 else {
6460 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6461 }
6462 }
6463 }
6464  
6465 13 $modifier =~ tr/i//d;
6466 13 $delimiter = '/';
6467 13 $end_delimiter = '/';
6468 13 my $prematch = '';
6469 13 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6470 }
6471  
6472 #
6473 # escape regexp (s'here''b)
6474 #
6475 0 ▶sub e_s1_qb {
Subroutine e_s1_qb: not called CC=4 SCAR=30.0
Pod undocumented
6476 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6477  
6478 # split regexp
6479 0 my @char = $string =~ /\G (?>[^\\]|\\\\) /oxmsg;
6480  
6481 # unescape character
6482 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6483 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $char[$i] eq '\\\\' }) { } 0 0 0
elsif ($char[$i] =~ m(\A [\$\@/\\] \z)mosx) { } 0 0 0
6484 }
6485  
6486 # remain \\
6487 elsif ($char[$i] eq '\\\\') {
6488 }
6489  
6490 # escape $ @ / and \
6491 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6492 0 $char[$i] = '\\' . $char[$i];
6493 }
6494 }
6495  
6496 0 $delimiter = '/';
6497 0 $end_delimiter = '/';
6498 0 my $prematch = '';
6499 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6500 }
6501  
6502 #
6503 # escape regexp (s''here')
6504 #
6505 16 ▶sub e_s2_q {
Subroutine e_s2_q: called CC=4 SCAR=13.9
Pod undocumented
6506 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
6507  
6508 16 $slash = 'div';
6509  
6510 16 my @char = $string =~ / \G (?>[^\\]|\\\\|$q_char) /oxmsg;
6511 16 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 9 16 25
6512 9 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A \\\\ \z/mosx }) { } 1 8 9
elsif ($char[$i] =~ m(\A [\$\@/\\] \z)mosx) { } 5 3 8
6513 }
6514  
6515 # not escape \\
6516 elsif ($char[$i] =~ /\A \\\\ \z/oxms) {
6517 }
6518  
6519 # escape $ @ / and \
6520 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6521 5 $char[$i] = '\\' . $char[$i];
6522 }
6523 }
6524  
6525 16 return join '', $ope, $delimiter, @char, $end_delimiter;
6526 }
6527  
6528 #
6529 # escape regexp (s/here/and here/modifier)
6530 #
6531 101 ▶sub e_sub {
Subroutine e_sub: called CC=20 SCAR=32.6
Pod undocumented
6532 101 my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_;
6533 101 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
4556
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
6534  
6535 101 $modifier =~ tr/p//d;
6536 101 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 101 101
6537 0 my $line = 0;
6538 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6539 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6540 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6541 0 last;
6542 }
6543 }
6544 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6545 }
6546  
6547 101 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq "") 36 65 101
6548 36 $variable = '$_';
6549 36 $bind_operator = ' =~ ';
6550 }
6551  
6552 101 $slash = 'div';
6553  
6554 # P.128 Start of match (or end of previous match): \G
6555 # P.130 Advanced Use of \G with Perl
6556 # in Chapter 3: Overview of Regular Expression Features and Flavors
6557 # P.312 Iterative Matching: Scalar Context, with /g
6558 # in Chapter 7: Perl
6559 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
6560  
6561 # P.181 Where You Left Off: The \G Assertion
6562 # in Chapter 5: Pattern Matching
6563 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6564  
6565 # P.220 Where You Left Off: The \G Assertion
6566 # in Chapter 5: Pattern Matching
6567 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6568  
6569 101 my $e_modifier = $modifier =~ tr/e//d;
6570 101 my $r_modifier = $modifier =~ tr/r//d;
6571  
6572 101 my $my = '';
6573 101 ▶ if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/mosx) 0 101 101
6574 0 $my = $variable;
6575 0 $variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms;
6576 0 $variable =~ s/ = .+ \z//oxms;
6577 }
6578  
6579 101 (my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms;
6580 101 $variable_basename =~ s/ \s+ \z//oxms;
6581  
6582 # quote replacement string
6583 101 my $e_replacement = '';
6584 101 ▶ if ($e_modifier >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e_modifier >= 1) { } 17 84 101
6585 17 $e_replacement = e_qq('', '', '', $replacement);
6586 17 $e_modifier--;
6587 }
6588 else {
6589 84 ▶ if ($delimiter2 eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter2 eq q[']) { } 16 68 84
6590 16 $e_replacement = e_s2_q('qq', '/', '/', $replacement);
6591 }
6592 else {
6593 68 $e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement);
6594 }
6595 }
6596  
6597 101 my $sub = '';
6598  
6599 # with /r
6600 101 ▶ if ($r_modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r_modifier) { } 10 91 101
6601 10 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 5 5 10
6602 }
6603  
6604 # s///gr without multibyte anchoring
6605 elsif ($modifier =~ /g/oxms) {
6606 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6607 # 1 2 3 4 5
6608 q<CORE::eval{local $Elatin1::re_t=%s; while($Elatin1::re_t =~ %s){%s local $^W=0; local $Elatin1::re_r=%s; %s$Elatin1::re_t="$`$Elatin1::re_r$'"; pos($Elatin1::re_t)=length "$`$Elatin1::re_r"; } return $Elatin1::re_t}>,
6609  
6610 $variable, # 1
6611 ($delimiter1 eq "'") ? # 2
6612 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6613 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6614 $s_matched, # 3
6615 $e_replacement, # 4
6616 '$Elatin1::re_r=CORE::eval $Elatin1::re_r; ' x $e_modifier, # 5
6617 );
6618 }
6619  
6620 # s///r
6621 else {
6622  
6623 5 my $prematch = q{$`};
6624  
6625 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6626 # 1 2 3 4 5 6 7
6627 q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Elatin1::re_r=%s; %s"%s$Elatin1::re_r$'" } : %s>,
6628  
6629 $variable, # 1
6630 ($delimiter1 eq "'") ? # 2
6631 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6632 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6633 $s_matched, # 3
6634 $e_replacement, # 4
6635 '$Elatin1::re_r=CORE::eval $Elatin1::re_r; ' x $e_modifier, # 5
6636 $prematch, # 6
6637 $variable, # 7
6638 );
6639 }
6640  
6641 # $var !~ s///r doesn't make sense
6642 10 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 10 10
6643 0 $sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub;
6644 }
6645 }
6646  
6647 # without /r
6648 else {
6649 91 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 23 68 91
6650 }
6651  
6652 # s///g without multibyte anchoring
6653 elsif ($modifier =~ /g/oxms) {
6654 23 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 3 20 23
$bind_operator =~ / !~ /mosx ? : 3 20 23
6655 # 1 2 3 4 5 6 7 8
6656 q<CORE::eval{local $Elatin1::re_n=0; while(%s =~ %s){%s local $^W=0; local $Elatin1::re_r=%s; %s%s="$`$Elatin1::re_r$'"; pos(%s)=length "$`$Elatin1::re_r"; $Elatin1::re_n++} return %s$Elatin1::re_n}>,
6657  
6658 $variable, # 1
6659 ($delimiter1 eq "'") ? # 2
6660 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6661 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6662 $s_matched, # 3
6663 $e_replacement, # 4
6664 '$Elatin1::re_r=CORE::eval $Elatin1::re_r; ' x $e_modifier, # 5
6665 $variable, # 6
6666 $variable, # 7
6667 ($bind_operator =~ / !~ /oxms) ? '!' : '', # 8
6668 );
6669 }
6670  
6671 # s///
6672 else {
6673  
6674 68 my $prematch = q{$`};
6675  
6676 68 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$bind_operator =~ / =~ /mosx ? : 65 3 68
$delimiter1 eq q['] ? : 18 50 68
6677  
6678 ($bind_operator =~ / =~ /oxms) ?
6679  
6680 # 1 2 3 4 5 6 7 8
6681 q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Elatin1::re_r=%s; %s%s="%s$Elatin1::re_r$'"; 1 } : undef> :
6682  
6683 # 1 2 3 4 5 6 7 8
6684 q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Elatin1::re_r=%s; %s%s="%s$Elatin1::re_r$'"; undef }>,
6685  
6686 $variable, # 1
6687 $bind_operator, # 2
6688 ($delimiter1 eq "'") ? # 3
6689 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6690 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6691 $s_matched, # 4
6692 $e_replacement, # 5
6693 '$Elatin1::re_r=CORE::eval $Elatin1::re_r; ' x $e_modifier, # 6
6694 $variable, # 7
6695 $prematch, # 8
6696 );
6697 }
6698 }
6699  
6700 # (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1]
6701 101 ▶ if ($my ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($my ne "") 0 101 101
6702 0 $sub = "($my, $sub)[1]";
6703 }
6704  
6705 # clear s/// variable
6706 101 $sub_variable = '';
6707 101 $bind_operator = '';
6708  
6709 101 return $sub;
6710 }
6711  
6712 #
6713 # escape regexp of split qr//
6714 #
6715 74 ▶sub e_split {
Subroutine e_split: called CC=88 SCAR=76.4
Pod undocumented
6716 74 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6717 74 ▶ $modifier ||= '';
Condition100%2/2
$modifier ||= ""
l!l
767
MC/DC100%1/1
$modifier ||= ""
$modifier
Truth table100%2/2
A
A= $modifier
Aresult
11
00
6718  
6719 74 $modifier =~ tr/p//d;
6720 74 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 74 74
6721 0 my $line = 0;
6722 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6723 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6724 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6725 0 last;
6726 }
6727 }
6728 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6729 }
6730  
6731 74 $slash = 'div';
6732  
6733 # /b /B modifier
6734 74 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 74 74
6735 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
6736 }
6737  
6738 74 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 74 74
6739 74 my $metachar = qr/[\@\\|[\]{^]/oxms;
6740  
6741 # split regexp
6742 74 my @char = $string =~ /\G((?>
6743 [^\\\$\@\[\(] |
6744 \\x (?>[0-9A-Fa-f]{1,2}) |
6745 \\ (?>[0-7]{2,3}) |
6746 \\c [\x40-\x5F] |
6747 \\x\{ (?>[0-9A-Fa-f]+) \} |
6748 \\o\{ (?>[0-7]+) \} |
6749 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
6750 \\ $q_char |
6751 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
6752 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
6753 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
6754 [\$\@] $qq_variable |
6755 \$ (?>\s* [0-9]+) |
6756 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
6757 \$ \$ (?![\w\{]) |
6758 \$ (?>\s*) \$ (?>\s*) $qq_variable |
6759 \[\^ |
6760 \[\: (?>[a-z]+) :\] |
6761 \[\:\^ (?>[a-z]+) :\] |
6762 \(\? |
6763 $q_char
6764 ))/oxmsg;
6765  
6766 74 my $left_e = 0;
6767 74 my $right_e = 0;
6768 74 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 249 74 323
6769  
6770 # "\L\u" --> "\u\L"
6771 249 ▶ if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) {
Branch: 6 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\L' and $char[$i + 1] eq '\\u') { } 0 249 249
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 249 249
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 248 249
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 247 248
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 247 247
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/mosx) { } 0 247 247
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
24900
MC/DC0%0/2
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
$char[$i] eq "\\L" $char[$i + 1] eq "\\u"
Truth table33%1/3
A and B
A= $char[$i] eq "\\L"B= $char[$i + 1] eq "\\u"
ABresult
0X0
100
111
6772 0 @char[$i,$i+1] = @char[$i+1,$i];
6773 }
6774  
6775 # "\U\l" --> "\l\U"
6776 ▶ elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) {
Condition33%1/3
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
!ll&&!rl&&r
24900
MC/DC0%0/2
$char[$i] eq "\\U" and $char[$i + 1] eq "\\l"
$char[$i] eq "\\U" $char[$i + 1] eq "\\l"
Truth table33%1/3
A and B
A= $char[$i] eq "\\U"B= $char[$i + 1] eq "\\l"
ABresult
0X0
100
111
6777 0 @char[$i,$i+1] = @char[$i+1,$i];
6778 }
6779  
6780 # octal escape sequence
6781 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6782 1 $char[$i] = Elatin1::octchr($1);
6783 }
6784  
6785 # hexadecimal escape sequence
6786 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6787 1 $char[$i] = Elatin1::hexchr($1);
6788 }
6789  
6790 # \b{...} --> b\{...}
6791 # \B{...} --> B\{...}
6792 # \N{CHARNAME} --> N\{CHARNAME}
6793 # \p{PROPERTY} --> p\{PROPERTY}
6794 # \P{PROPERTY} --> P\{PROPERTY}
6795 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6796 0 $char[$i] = $1 . '\\' . $2;
6797 }
6798  
6799 # \p, \P, \X --> p, P, X
6800 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6801 0 $char[$i] = $1;
6802 }
6803  
6804 249 ▶ if (0) {
Branch: 31 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx }) { } 0 249 249
elsif ($char[$i] eq '[') { } 3 246 249
elsif ($char[$i] eq '[^') { } 0 246 246
elsif (my $char = character_class($char[$i], $modifier)) { } 1 245 246
elsif ($char[$i] eq '^' and not $modifier =~ /m/mosx) { } 7 238 245
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 0 238 238
elsif ($char[$i] =~ /\A ([<>]) \z/mosx) { } 0 238 238
elsif ($char[$i] eq '\\u') { } 0 238 238
elsif ($char[$i] eq '\\l') { } 0 238 238
elsif ($char[$i] eq '\\U') { } 0 238 238
elsif ($char[$i] eq '\\L') { } 0 238 238
elsif ($char[$i] eq '\\F') { } 0 238 238
elsif ($char[$i] eq '\\Q') { } 0 238 238
elsif ($char[$i] eq '\\E') { } 0 238 238
elsif ($char[$i] eq '\\Q') { } 0 238 238
elsif ($char[$i] eq '\\E') { } 0 238 238
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 238 238
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 12 226 238
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 12 214 226
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 9 205 214
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/mosx) { } 0 205 205
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 205 205
elsif ($char[$i] =~ /\A [\$\@].+ /mosx) { } 3 202 205
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 1 234 235
6805 }
6806  
6807 # join separated multiple-octet
6808 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6809 0 ▶ if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf '"%s%s%s%s"', @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
elsif ($i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf '"%s%s%s"', @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
elsif ($i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf '"%s%s"', @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx) { } 0 0 0
Condition0%0/6
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 3 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 and eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
$i + 3 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3 eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 3 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 3]) == 3C= eval(sprintf "\"%s%s%s%s\"", @char[$i .. $i + 3]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6810 0 $char[$i] .= join '', splice @char, $i+1, 3;
6811 }
6812 ▶ elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) {
Condition0%0/6
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 2 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 and eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
$i + 2 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2 eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 2 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, @char[$i + 1 .. $i + 2]) == 2C= eval(sprintf "\"%s%s%s\"", @char[$i .. $i + 2]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6813 0 $char[$i] .= join '', splice @char, $i+1, 2;
6814 }
6815 ▶ elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) {
Condition0%0/6
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
!ll&&!rl&&r
000
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 1 <= $#char and grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 and eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
$i + 1 <= $#char grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1 eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
Truth table0%0/4
A and B and C
A= $i + 1 <= $#charB= grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/mosx, $char[$i + 1]) == 1C= eval(sprintf "\"%s%s\"", @char[$i .. $i + 1]) =~ /\A $Elatin1::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6816 0 $char[$i] .= join '', splice @char, $i+1, 1;
6817 }
6818 }
6819  
6820 # open character class [...]
6821 elsif ($char[$i] eq '[') {
6822 3 my $left = $i;
6823 3 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 3 3
6824 0 $i++;
6825 }
6826 3 while (1) {
6827 7 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 7 7
6828 0 die __FILE__, ": Unmatched [] in regexp\n";
6829 }
6830 7 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 3 4 7
6831 3 my $right = $i;
6832  
6833 # [...]
6834 3 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 0 3 3
6835 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6836 }
6837 else {
6838 3 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
6839 }
6840  
6841 3 $i = $left;
6842 3 last;
6843 }
6844 }
6845 }
6846  
6847 # open character class [^...]
6848 elsif ($char[$i] eq '[^') {
6849 0 my $left = $i;
6850 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6851 0 $i++;
6852 }
6853 0 while (1) {
6854 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6855 0 die __FILE__, ": Unmatched [] in regexp\n";
6856 }
6857 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6858 0 my $right = $i;
6859  
6860 # [^...]
6861 0 ▶ if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(/\A [\$\@]/mosx, @char[$left + 1 .. $right - 1]) >= 1) { } 0 0 0
6862 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin1::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6863 }
6864 else {
6865 0 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6866 }
6867  
6868 0 $i = $left;
6869 0 last;
6870 }
6871 }
6872 }
6873  
6874 # rewrite character class or escape character
6875 elsif (my $char = character_class($char[$i],$modifier)) {
6876 1 $char[$i] = $char;
6877 }
6878  
6879 # P.794 29.2.161. split
6880 # in Chapter 29: Functions
6881 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6882  
6883 # P.951 split
6884 # in Chapter 27: Functions
6885 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6886  
6887 # said "The //m modifier is assumed when you split on the pattern /^/",
6888 # but perl5.008 is not so. Therefore, this software adds //m.
6889 # (and so on)
6890  
6891 # split(m/^/) --> split(m/^/m)
6892 ▶ elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) {
Condition100%3/3
$char[$i] eq "^" and not $modifier =~ /m/mosx
!ll&&!rl&&r
23627
MC/DC100%2/2
$char[$i] eq "^" and not $modifier =~ /m/mosx
$char[$i] eq "^" not $modifier =~ /m/mosx
Truth table100%3/3
A and not(B)
A= $char[$i] eq "^"B= not $modifier =~ /m/mosx
ABresult
0X0
100
111
6893 7 $modifier .= 'm';
6894 }
6895  
6896 # /i modifier
6897 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
23800
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
23800
MC/DC0%0/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table25%1/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6898 0 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6899 0 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
6900 }
6901 else {
6902 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
6903 }
6904 }
6905  
6906 # \u \l \U \L \F \Q \E
6907 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
6908 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6909 0 $char[$i] = '\\' . $char[$i];
6910 }
6911 }
6912 elsif ($char[$i] eq '\u') {
6913 0 $char[$i] = '@{[Elatin1::ucfirst qq<';
6914 0 $left_e++;
6915 }
6916 elsif ($char[$i] eq '\l') {
6917 0 $char[$i] = '@{[Elatin1::lcfirst qq<';
6918 0 $left_e++;
6919 }
6920 elsif ($char[$i] eq '\U') {
6921 0 $char[$i] = '@{[Elatin1::uc qq<';
6922 0 $left_e++;
6923 }
6924 elsif ($char[$i] eq '\L') {
6925 0 $char[$i] = '@{[Elatin1::lc qq<';
6926 0 $left_e++;
6927 }
6928 elsif ($char[$i] eq '\F') {
6929 0 $char[$i] = '@{[Elatin1::fc qq<';
6930 0 $left_e++;
6931 }
6932 elsif ($char[$i] eq '\Q') {
6933 0 $char[$i] = '@{[CORE::quotemeta qq<';
6934 0 $left_e++;
6935 }
6936 elsif ($char[$i] eq '\E') {
6937 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6938 0 $char[$i] = '>]}';
6939 0 $right_e++;
6940 }
6941 else {
6942 0 $char[$i] = '';
6943 }
6944 }
6945 elsif ($char[$i] eq '\Q') {
6946 0 while (1) {
6947 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6948 0 last;
6949 }
6950 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6951 0 last;
6952 }
6953 }
6954 }
6955 elsif ($char[$i] eq '\E') {
6956 }
6957  
6958 # $0 --> $0
6959 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6960 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6961 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6962 }
6963 }
6964 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6965 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6966 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6967 }
6968 }
6969  
6970 # $$ --> $$
6971 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6972 }
6973  
6974 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6975 # $1, $2, $3 --> $1, $2, $3 otherwise
6976 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6977 0 $char[$i] = e_capture($1);
6978 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6979 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6980 }
6981 }
6982 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6983 0 $char[$i] = e_capture($1);
6984 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6985 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6986 }
6987 }
6988  
6989 # $$foo[ ... ] --> $ $foo->[ ... ]
6990 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6991 0 $char[$i] = e_capture($1.'->'.$2);
6992 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6993 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
6994 }
6995 }
6996  
6997 # $$foo{ ... } --> $ $foo->{ ... }
6998 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6999 0 $char[$i] = e_capture($1.'->'.$2);
7000 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7001 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
7002 }
7003 }
7004  
7005 # $$foo
7006 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
7007 0 $char[$i] = e_capture($1);
7008 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7009 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
7010 }
7011 }
7012  
7013 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin1::PREMATCH()
7014 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
7015 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7016 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::PREMATCH())]}';
7017 }
7018 else {
7019 12 $char[$i] = '@{[Elatin1::PREMATCH()]}';
7020 }
7021 }
7022  
7023 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin1::MATCH()
7024 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
7025 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7026 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::MATCH())]}';
7027 }
7028 else {
7029 12 $char[$i] = '@{[Elatin1::MATCH()]}';
7030 }
7031 }
7032  
7033 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin1::POSTMATCH()
7034 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
7035 9 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 9 9
7036 0 $char[$i] = '@{[Elatin1::ignorecase(Elatin1::POSTMATCH())]}';
7037 }
7038 else {
7039 9 $char[$i] = '@{[Elatin1::POSTMATCH()]}';
7040 }
7041 }
7042  
7043 # ${ foo }
7044 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
7045 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7046 0 $char[$i] = '@{[Elatin1::ignorecase(' . $1 . ')]}';
7047 }
7048 }
7049  
7050 # ${ ... }
7051 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
7052 0 $char[$i] = e_capture($1);
7053 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7054 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
7055 }
7056 }
7057  
7058 # $scalar or @array
7059 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
7060 3 $char[$i] = e_string($char[$i]);
7061 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 3 3
7062 0 $char[$i] = '@{[Elatin1::ignorecase(' . $char[$i] . ')]}';
7063 }
7064 }
7065  
7066 # quote character before ? + * {
7067 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition100%3/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
331681
MC/DC100%2/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table100%3/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
7068 1 ▶ if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/mosx) { } 1 0 1
7069 }
7070 else {
7071 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7072 }
7073 }
7074 }
7075  
7076 # make regexp string
7077 74 $modifier =~ tr/i//d;
7078 74 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 74 74
7079 0 return join '', 'Elatin1::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier;
7080 }
7081 74 return join '', 'Elatin1::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7082 }
7083  
7084 #
7085 # escape regexp of split qr''
7086 #
7087 0 ▶sub e_split_q {
Subroutine e_split_q: not called CC=26 SCAR=65.5
Pod undocumented
7088 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7089 0 ▶ $modifier ||= '';
Condition0%0/2
$modifier ||= ""
l!l
00
MC/DC0%0/1
$modifier ||= ""
$modifier
Truth table0%0/2
A
A= $modifier
Aresult
11
00
7090  
7091 0 $modifier =~ tr/p//d;
7092 0 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 0 0
7093 0 my $line = 0;
7094 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7095 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7096 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7097 0 last;
7098 }
7099 }
7100 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7101 }
7102  
7103 0 $slash = 'div';
7104  
7105 # /b /B modifier
7106 0 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 0 0
7107 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7108 }
7109  
7110 0 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 0 0
7111  
7112 # split regexp
7113 0 my @char = $string =~ /\G((?>
7114 [^\\\[] |
7115 [\x00-\xFF] |
7116 \[\^ |
7117 \[\: (?>[a-z]+) \:\] |
7118 \[\:\^ (?>[a-z]+) \:\] |
7119 \\ (?:$q_char) |
7120 (?:$q_char)
7121 ))/oxmsg;
7122  
7123 # unescape character
7124 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
7125 0 ▶ if (0) {
Branch: 6 branches
BranchTrueFalseTotal
if (do { $char[$i] eq '[' }) { } 0 0 0
elsif ($char[$i] eq '[^') { } 0 0 0
elsif (my $char = character_class($char[$i], $modifier)) { } 0 0 0
elsif ($char[$i] eq '^' and not $modifier =~ /m/mosx) { } 0 0 0
elsif ($ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])) { } 0 0 0
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 0 0
7126 }
7127  
7128 # open character class [...]
7129 elsif ($char[$i] eq '[') {
7130 0 my $left = $i;
7131 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7132 0 $i++;
7133 }
7134 0 while (1) {
7135 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7136 0 die __FILE__, ": Unmatched [] in regexp\n";
7137 }
7138 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7139 0 my $right = $i;
7140  
7141 # [...]
7142 0 splice @char, $left, $right-$left+1, Elatin1::charlist_qr(@char[$left+1..$right-1], $modifier);
7143  
7144 0 $i = $left;
7145 0 last;
7146 }
7147 }
7148 }
7149  
7150 # open character class [^...]
7151 elsif ($char[$i] eq '[^') {
7152 0 my $left = $i;
7153 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7154 0 $i++;
7155 }
7156 0 while (1) {
7157 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7158 0 die __FILE__, ": Unmatched [] in regexp\n";
7159 }
7160 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7161 0 my $right = $i;
7162  
7163 # [^...]
7164 0 splice @char, $left, $right-$left+1, Elatin1::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7165  
7166 0 $i = $left;
7167 0 last;
7168 }
7169 }
7170 }
7171  
7172 # rewrite character class or escape character
7173 elsif (my $char = character_class($char[$i],$modifier)) {
7174 0 $char[$i] = $char;
7175 }
7176  
7177 # split(m/^/) --> split(m/^/m)
7178 ▶ elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) {
Condition0%0/3
$char[$i] eq "^" and not $modifier =~ /m/mosx
!ll&&!rl&&r
000
MC/DC0%0/2
$char[$i] eq "^" and not $modifier =~ /m/mosx
$char[$i] eq "^" not $modifier =~ /m/mosx
Truth table0%0/3
A and not(B)
A= $char[$i] eq "^"B= not $modifier =~ /m/mosx
ABresult
0X0
100
111
7179 0 $modifier .= 'm';
7180 }
7181  
7182 # /i modifier
7183 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin1::uc($char[$i]) ne Elatin1::fc($char[$i]))) {
Condition0%0/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
!ll&&!rl&&r
000
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx
!ll&&!rl&&r
000
MC/DC0%0/3
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin1::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin1::uc($char[$i]) ne &fc($char[$i])
Truth table0%0/4
A and B and C
A= $ignorecaseB= $char[$i] =~ /\A [\x00-\xFF] \z/mosxC= &Elatin1::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7184 0 ▶ if (CORE::length(Elatin1::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7185 0 $char[$i] = '[' . Elatin1::uc($char[$i]) . Elatin1::fc($char[$i]) . ']';
7186 }
7187 else {
7188 0 $char[$i] = '(?:' . Elatin1::uc($char[$i]) . '|' . Elatin1::fc($char[$i]) . ')';
7189 }
7190 }
7191  
7192 # quote character before ? + * {
7193 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition0%0/3
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
000
MC/DC0%0/2
$i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx
$i >= 1 $char[$i] =~ /\A [\?\+\*\{] \z/mosx
Truth table0%0/3
A and B
A= $i >= 1B= $char[$i] =~ /\A [\?\+\*\{] \z/mosx
ABresult
0X0
100
111
7194 0 ▶ if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] =~ /\A [\x00-\xFF] \z/mosx) { } 0 0 0
7195 }
7196 else {
7197 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7198 }
7199 }
7200 }
7201  
7202 0 $modifier =~ tr/i//d;
7203 0 return join '', 'Elatin1::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7204 }
7205  
7206 #
7207 # instead of Carp::carp
7208 #
7209 0 ▶sub carp {
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
7210 0 my($package,$filename,$line) = caller(1);
7211 0 print STDERR "@_ at $filename line $line.\n";
7212 }
7213  
7214 #
7215 # instead of Carp::croak
7216 #
7217 0 ▶sub croak {
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
7218 0 my($package,$filename,$line) = caller(1);
7219 0 print STDERR "@_ at $filename line $line.\n";
7220 0 die "\n";
7221 }
7222  
7223 #
7224 # instead of Carp::cluck
7225 #
7226 0 ▶sub cluck {
Subroutine cluck: not called CC=2 SCAR=17.9
Pod undocumented
7227 0 my $i = 0;
7228 0 my @cluck = ();
7229 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7230 0 push @cluck, "[$i] $filename($line) $package::$subroutine\n";
7231 0 $i++;
7232 }
7233 0 print STDERR CORE::reverse @cluck;
7234 0 print STDERR "\n";
7235 0 print STDERR @_;
7236 }
7237  
7238 #
7239 # instead of Carp::confess
7240 #
7241 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
7242 0 my $i = 0;
7243 0 my @confess = ();
7244 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7245 0 push @confess, "[$i] $filename($line) $package::$subroutine\n";
7246 0 $i++;
7247 }
7248 0 print STDERR CORE::reverse @confess;
7249 0 print STDERR "\n";
7250 0 print STDERR @_;
7251 0 die "\n";
7252 }
7253  
7254 424 1;
7255  
7256 __END__
↑ Summary Latin1.pm »