Elatin9.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 Latin9.pm »
1 package Elatin9;
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 # Elatin9 - Run-time routines for Latin9.pm
7 #
8 # http://search.cpan.org/dist/Char-Latin9/
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 (&Elatin9::index($name, '::') >= 0) { } 0 15 15
elsif (&Elatin9::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 (Elatin9::index($name,'::') >= 0) {
84 0 return $name;
85 }
86 elsif (Elatin9::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-9 character range per length
159 #
160 424 my %range_tr = ();
161  
162 #
163 # Latin-9 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 Elatin9 \z/mosx }) { } 424 0 424
176 }
177  
178 elsif (__PACKAGE__ =~ / \b Elatin9 \z/oxms) {
179 424 %range_tr = (
180 1 => [ [0x00..0xFF],
181 ],
182 );
183  
184 424 %lc = (%lc,
185 "\xA6" => "\xA8", # LATIN LETTER S WITH CARON
186 "\xB4" => "\xB8", # LATIN LETTER Z WITH CARON
187 "\xBC" => "\xBD", # LATIN LIGATURE OE
188 "\xBE" => "\xFF", # LATIN LETTER Y WITH DIAERESIS
189 "\xC0" => "\xE0", # LATIN LETTER A WITH GRAVE
190 "\xC1" => "\xE1", # LATIN LETTER A WITH ACUTE
191 "\xC2" => "\xE2", # LATIN LETTER A WITH CIRCUMFLEX
192 "\xC3" => "\xE3", # LATIN LETTER A WITH TILDE
193 "\xC4" => "\xE4", # LATIN LETTER A WITH DIAERESIS
194 "\xC5" => "\xE5", # LATIN LETTER A WITH RING ABOVE
195 "\xC6" => "\xE6", # LATIN LETTER AE
196 "\xC7" => "\xE7", # LATIN LETTER C WITH CEDILLA
197 "\xC8" => "\xE8", # LATIN LETTER E WITH GRAVE
198 "\xC9" => "\xE9", # LATIN LETTER E WITH ACUTE
199 "\xCA" => "\xEA", # LATIN LETTER E WITH CIRCUMFLEX
200 "\xCB" => "\xEB", # LATIN LETTER E WITH DIAERESIS
201 "\xCC" => "\xEC", # LATIN LETTER I WITH GRAVE
202 "\xCD" => "\xED", # LATIN LETTER I WITH ACUTE
203 "\xCE" => "\xEE", # LATIN LETTER I WITH CIRCUMFLEX
204 "\xCF" => "\xEF", # LATIN LETTER I WITH DIAERESIS
205 "\xD0" => "\xF0", # LATIN LETTER ETH
206 "\xD1" => "\xF1", # LATIN LETTER N WITH TILDE
207 "\xD2" => "\xF2", # LATIN LETTER O WITH GRAVE
208 "\xD3" => "\xF3", # LATIN LETTER O WITH ACUTE
209 "\xD4" => "\xF4", # LATIN LETTER O WITH CIRCUMFLEX
210 "\xD5" => "\xF5", # LATIN LETTER O WITH TILDE
211 "\xD6" => "\xF6", # LATIN LETTER O WITH DIAERESIS
212 "\xD8" => "\xF8", # LATIN LETTER O WITH STROKE
213 "\xD9" => "\xF9", # LATIN LETTER U WITH GRAVE
214 "\xDA" => "\xFA", # LATIN LETTER U WITH ACUTE
215 "\xDB" => "\xFB", # LATIN LETTER U WITH CIRCUMFLEX
216 "\xDC" => "\xFC", # LATIN LETTER U WITH DIAERESIS
217 "\xDD" => "\xFD", # LATIN LETTER Y WITH ACUTE
218 "\xDE" => "\xFE", # LATIN LETTER THORN
219 );
220  
221 424 %uc = (%uc,
222 "\xA8" => "\xA6", # LATIN LETTER S WITH CARON
223 "\xB8" => "\xB4", # LATIN LETTER Z WITH CARON
224 "\xBD" => "\xBC", # LATIN LIGATURE OE
225 "\xE0" => "\xC0", # LATIN LETTER A WITH GRAVE
226 "\xE1" => "\xC1", # LATIN LETTER A WITH ACUTE
227 "\xE2" => "\xC2", # LATIN LETTER A WITH CIRCUMFLEX
228 "\xE3" => "\xC3", # LATIN LETTER A WITH TILDE
229 "\xE4" => "\xC4", # LATIN LETTER A WITH DIAERESIS
230 "\xE5" => "\xC5", # LATIN LETTER A WITH RING ABOVE
231 "\xE6" => "\xC6", # LATIN LETTER AE
232 "\xE7" => "\xC7", # LATIN LETTER C WITH CEDILLA
233 "\xE8" => "\xC8", # LATIN LETTER E WITH GRAVE
234 "\xE9" => "\xC9", # LATIN LETTER E WITH ACUTE
235 "\xEA" => "\xCA", # LATIN LETTER E WITH CIRCUMFLEX
236 "\xEB" => "\xCB", # LATIN LETTER E WITH DIAERESIS
237 "\xEC" => "\xCC", # LATIN LETTER I WITH GRAVE
238 "\xED" => "\xCD", # LATIN LETTER I WITH ACUTE
239 "\xEE" => "\xCE", # LATIN LETTER I WITH CIRCUMFLEX
240 "\xEF" => "\xCF", # LATIN LETTER I WITH DIAERESIS
241 "\xF0" => "\xD0", # LATIN LETTER ETH
242 "\xF1" => "\xD1", # LATIN LETTER N WITH TILDE
243 "\xF2" => "\xD2", # LATIN LETTER O WITH GRAVE
244 "\xF3" => "\xD3", # LATIN LETTER O WITH ACUTE
245 "\xF4" => "\xD4", # LATIN LETTER O WITH CIRCUMFLEX
246 "\xF5" => "\xD5", # LATIN LETTER O WITH TILDE
247 "\xF6" => "\xD6", # LATIN LETTER O WITH DIAERESIS
248 "\xF8" => "\xD8", # LATIN LETTER O WITH STROKE
249 "\xF9" => "\xD9", # LATIN LETTER U WITH GRAVE
250 "\xFA" => "\xDA", # LATIN LETTER U WITH ACUTE
251 "\xFB" => "\xDB", # LATIN LETTER U WITH CIRCUMFLEX
252 "\xFC" => "\xDC", # LATIN LETTER U WITH DIAERESIS
253 "\xFD" => "\xDD", # LATIN LETTER Y WITH ACUTE
254 "\xFE" => "\xDE", # LATIN LETTER THORN
255 "\xFF" => "\xBE", # LATIN LETTER Y WITH DIAERESIS
256 );
257  
258 424 %fc = (%fc,
259 "\xA6" => "\xA8", # LATIN CAPITAL LETTER S WITH CARON --> LATIN SMALL LETTER S WITH CARON
260 "\xB4" => "\xB8", # LATIN CAPITAL LETTER Z WITH CARON --> LATIN SMALL LETTER Z WITH CARON
261 "\xBC" => "\xBD", # LATIN CAPITAL LIGATURE OE --> LATIN SMALL LIGATURE OE
262 "\xBE" => "\xFF", # LATIN CAPITAL LETTER Y WITH DIAERESIS --> LATIN SMALL LETTER Y WITH DIAERESIS
263 "\xC0" => "\xE0", # LATIN CAPITAL LETTER A WITH GRAVE --> LATIN SMALL LETTER A WITH GRAVE
264 "\xC1" => "\xE1", # LATIN CAPITAL LETTER A WITH ACUTE --> LATIN SMALL LETTER A WITH ACUTE
265 "\xC2" => "\xE2", # LATIN CAPITAL LETTER A WITH CIRCUMFLEX --> LATIN SMALL LETTER A WITH CIRCUMFLEX
266 "\xC3" => "\xE3", # LATIN CAPITAL LETTER A WITH TILDE --> LATIN SMALL LETTER A WITH TILDE
267 "\xC4" => "\xE4", # LATIN CAPITAL LETTER A WITH DIAERESIS --> LATIN SMALL LETTER A WITH DIAERESIS
268 "\xC5" => "\xE5", # LATIN CAPITAL LETTER A WITH RING ABOVE --> LATIN SMALL LETTER A WITH RING ABOVE
269 "\xC6" => "\xE6", # LATIN CAPITAL LETTER AE --> LATIN SMALL LETTER AE
270 "\xC7" => "\xE7", # LATIN CAPITAL LETTER C WITH CEDILLA --> LATIN SMALL LETTER C WITH CEDILLA
271 "\xC8" => "\xE8", # LATIN CAPITAL LETTER E WITH GRAVE --> LATIN SMALL LETTER E WITH GRAVE
272 "\xC9" => "\xE9", # LATIN CAPITAL LETTER E WITH ACUTE --> LATIN SMALL LETTER E WITH ACUTE
273 "\xCA" => "\xEA", # LATIN CAPITAL LETTER E WITH CIRCUMFLEX --> LATIN SMALL LETTER E WITH CIRCUMFLEX
274 "\xCB" => "\xEB", # LATIN CAPITAL LETTER E WITH DIAERESIS --> LATIN SMALL LETTER E WITH DIAERESIS
275 "\xCC" => "\xEC", # LATIN CAPITAL LETTER I WITH GRAVE --> LATIN SMALL LETTER I WITH GRAVE
276 "\xCD" => "\xED", # LATIN CAPITAL LETTER I WITH ACUTE --> LATIN SMALL LETTER I WITH ACUTE
277 "\xCE" => "\xEE", # LATIN CAPITAL LETTER I WITH CIRCUMFLEX --> LATIN SMALL LETTER I WITH CIRCUMFLEX
278 "\xCF" => "\xEF", # LATIN CAPITAL LETTER I WITH DIAERESIS --> LATIN SMALL LETTER I WITH DIAERESIS
279 "\xD0" => "\xF0", # LATIN CAPITAL LETTER ETH --> LATIN SMALL LETTER ETH
280 "\xD1" => "\xF1", # LATIN CAPITAL LETTER N WITH TILDE --> LATIN SMALL LETTER N WITH TILDE
281 "\xD2" => "\xF2", # LATIN CAPITAL LETTER O WITH GRAVE --> LATIN SMALL LETTER O WITH GRAVE
282 "\xD3" => "\xF3", # LATIN CAPITAL LETTER O WITH ACUTE --> LATIN SMALL LETTER O WITH ACUTE
283 "\xD4" => "\xF4", # LATIN CAPITAL LETTER O WITH CIRCUMFLEX --> LATIN SMALL LETTER O WITH CIRCUMFLEX
284 "\xD5" => "\xF5", # LATIN CAPITAL LETTER O WITH TILDE --> LATIN SMALL LETTER O WITH TILDE
285 "\xD6" => "\xF6", # LATIN CAPITAL LETTER O WITH DIAERESIS --> LATIN SMALL LETTER O WITH DIAERESIS
286 "\xD8" => "\xF8", # LATIN CAPITAL LETTER O WITH STROKE --> LATIN SMALL LETTER O WITH STROKE
287 "\xD9" => "\xF9", # LATIN CAPITAL LETTER U WITH GRAVE --> LATIN SMALL LETTER U WITH GRAVE
288 "\xDA" => "\xFA", # LATIN CAPITAL LETTER U WITH ACUTE --> LATIN SMALL LETTER U WITH ACUTE
289 "\xDB" => "\xFB", # LATIN CAPITAL LETTER U WITH CIRCUMFLEX --> LATIN SMALL LETTER U WITH CIRCUMFLEX
290 "\xDC" => "\xFC", # LATIN CAPITAL LETTER U WITH DIAERESIS --> LATIN SMALL LETTER U WITH DIAERESIS
291 "\xDD" => "\xFD", # LATIN CAPITAL LETTER Y WITH ACUTE --> LATIN SMALL LETTER Y WITH ACUTE
292 "\xDE" => "\xFE", # LATIN CAPITAL LETTER THORN --> LATIN SMALL LETTER THORN
293 "\xDF" => "\x73\x73", # LATIN SMALL LETTER SHARP S --> LATIN SMALL LETTER S, LATIN SMALL LETTER S
294 );
295 }
296  
297 else {
298 0 croak "Don't know my package name '@{[__PACKAGE__]}'";
299 }
300  
301 #
302 # @ARGV wildcard globbing
303 #
304 212 ▶sub import {
Subroutine import: called CC=7 SCAR=28.3
305  
306 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
307 0 my @argv = ();
308 0 for (@ARGV) {
309  
310 # has space
311 0 ▶ if (/\A (?:$q_char)*? [ ] /oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\A (?:$Elatin9::q_char)*? [ ] /mosx) { } 0 0 0
elsif (/\A (?:$Elatin9::q_char)*? [*?] /mosx) { } 0 0 0
312 0 ▶ if (my @glob = Elatin9::glob(qq{"$_"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Elatin9::glob(qq["$_"])) { } 0 0 0
313 0 push @argv, @glob;
314 }
315 else {
316 0 push @argv, $_;
317 }
318 }
319  
320 # has wildcard metachar
321 elsif (/\A (?:$q_char)*? [*?] /oxms) {
322 0 ▶ if (my @glob = Elatin9::glob($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Elatin9::glob($_)) { } 0 0 0
323 0 push @argv, @glob;
324 }
325 else {
326 0 push @argv, $_;
327 }
328 }
329  
330 # no wildcard globbing
331 else {
332 0 push @argv, $_;
333 }
334 }
335 0 @ARGV = @argv;
336 }
337  
338 212 *Char::ord = \&Latin9::ord;
339 212 *Char::ord_ = \&Latin9::ord_;
340 212 *Char::reverse = \&Latin9::reverse;
341 212 *Char::getc = \&Latin9::getc;
342 212 *Char::length = \&Latin9::length;
343 212 *Char::substr = \&Latin9::substr;
344 212 *Char::index = \&Latin9::index;
345 212 *Char::rindex = \&Latin9::rindex;
346 212 *Char::eval = \&Latin9::eval;
347 212 *Char::escape = \&Latin9::escape;
348 212 *Char::escape_token = \&Latin9::escape_token;
349 212 *Char::escape_script = \&Latin9::escape_script;
350 }
351  
352 # P.230 Care with Prototypes
353 # in Chapter 6: Subroutines
354 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
355 #
356 # If you aren't careful, you can get yourself into trouble with prototypes.
357 # But if you are careful, you can do a lot of neat things with them. This is
358 # all very powerful, of course, and should only be used in moderation to make
359 # the world a better place.
360  
361 # P.332 Care with Prototypes
362 # in Chapter 7: Subroutines
363 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
364 #
365 # If you aren't careful, you can get yourself into trouble with prototypes.
366 # But if you are careful, you can do a lot of neat things with them. This is
367 # all very powerful, of course, and should only be used in moderation to make
368 # the world a better place.
369  
370 #
371 # Prototypes of subroutines
372 #
373 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
374 sub Elatin9::split(;$$$);
375 sub Elatin9::tr($$$$;$);
376 sub Elatin9::chop(@);
377 sub Elatin9::index($$;$);
378 sub Elatin9::rindex($$;$);
379 sub Elatin9::lcfirst(@);
380 sub Elatin9::lcfirst_();
381 sub Elatin9::lc(@);
382 sub Elatin9::lc_();
383 sub Elatin9::ucfirst(@);
384 sub Elatin9::ucfirst_();
385 sub Elatin9::uc(@);
386 sub Elatin9::uc_();
387 sub Elatin9::fc(@);
388 sub Elatin9::fc_();
389 sub Elatin9::ignorecase;
390 sub Elatin9::classic_character_class;
391 sub Elatin9::capture;
392 sub Elatin9::chr(;$);
393 sub Elatin9::chr_();
394 sub Elatin9::glob($);
395 sub Elatin9::glob_();
396  
397 sub Latin9::ord(;$);
398 sub Latin9::ord_();
399 sub Latin9::reverse(@);
400 sub Latin9::getc(;*@);
401 sub Latin9::length(;$);
402 sub Latin9::substr($$;$$);
403 sub Latin9::index($$;$);
404 sub Latin9::rindex($$;$);
405 sub Latin9::escape(;$);
406  
407 #
408 # Regexp work
409 #
410 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
411 $re_a
412 $re_t
413 $re_n
414 $re_r
415 424 );
416  
417 #
418 # Character class
419 #
420 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
421 $dot
422 $dot_s
423 $eD
424 $eS
425 $eW
426 $eH
427 $eV
428 $eR
429 $eN
430 $not_alnum
431 $not_alpha
432 $not_ascii
433 $not_blank
434 $not_cntrl
435 $not_digit
436 $not_graph
437 $not_lower
438 $not_lower_i
439 $not_print
440 $not_punct
441 $not_space
442 $not_upper
443 $not_upper_i
444 $not_word
445 $not_xdigit
446 $eb
447 $eB
448 424 );
449  
450 424 ${Elatin9::dot} = qr{(?>[^\x0A])};
451 424 ${Elatin9::dot_s} = qr{(?>[\x00-\xFF])};
452 424 ${Elatin9::eD} = qr{(?>[^0-9])};
453  
454 # Vertical tabs are now whitespace
455 # \s in a regex now matches a vertical tab in all circumstances.
456 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
457 # ${Elatin9::eS} = qr{(?>[^\x09\x0A \x0C\x0D\x20])};
458 # ${Elatin9::eS} = qr{(?>[^\x09\x0A\x0B\x0C\x0D\x20])};
459 424 ${Elatin9::eS} = qr{(?>[^\s])};
460  
461 424 ${Elatin9::eW} = qr{(?>[^0-9A-Z_a-z])};
462 424 ${Elatin9::eH} = qr{(?>[^\x09\x20])};
463 424 ${Elatin9::eV} = qr{(?>[^\x0A\x0B\x0C\x0D])};
464 424 ${Elatin9::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])};
465 424 ${Elatin9::eN} = qr{(?>[^\x0A])};
466 424 ${Elatin9::not_alnum} = qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
467 424 ${Elatin9::not_alpha} = qr{(?>[^\x41-\x5A\x61-\x7A])};
468 424 ${Elatin9::not_ascii} = qr{(?>[^\x00-\x7F])};
469 424 ${Elatin9::not_blank} = qr{(?>[^\x09\x20])};
470 424 ${Elatin9::not_cntrl} = qr{(?>[^\x00-\x1F\x7F])};
471 424 ${Elatin9::not_digit} = qr{(?>[^\x30-\x39])};
472 424 ${Elatin9::not_graph} = qr{(?>[^\x21-\x7F])};
473 424 ${Elatin9::not_lower} = qr{(?>[^\x61-\x7A])};
474 424 ${Elatin9::not_lower_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
475 # ${Elatin9::not_lower_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
476 424 ${Elatin9::not_print} = qr{(?>[^\x20-\x7F])};
477 424 ${Elatin9::not_punct} = qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
478 424 ${Elatin9::not_space} = qr{(?>[^\s\x0B])};
479 424 ${Elatin9::not_upper} = qr{(?>[^\x41-\x5A])};
480 424 ${Elatin9::not_upper_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
481 # ${Elatin9::not_upper_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
482 424 ${Elatin9::not_word} = qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
483 424 ${Elatin9::not_xdigit} = qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
484 424 ${Elatin9::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))};
485 424 ${Elatin9::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]))};
486  
487 # avoid: Name "Elatin9::foo" used only once: possible typo at here.
488 424 ${Elatin9::dot} = ${Elatin9::dot};
489 424 ${Elatin9::dot_s} = ${Elatin9::dot_s};
490 424 ${Elatin9::eD} = ${Elatin9::eD};
491 424 ${Elatin9::eS} = ${Elatin9::eS};
492 424 ${Elatin9::eW} = ${Elatin9::eW};
493 424 ${Elatin9::eH} = ${Elatin9::eH};
494 424 ${Elatin9::eV} = ${Elatin9::eV};
495 424 ${Elatin9::eR} = ${Elatin9::eR};
496 424 ${Elatin9::eN} = ${Elatin9::eN};
497 424 ${Elatin9::not_alnum} = ${Elatin9::not_alnum};
498 424 ${Elatin9::not_alpha} = ${Elatin9::not_alpha};
499 424 ${Elatin9::not_ascii} = ${Elatin9::not_ascii};
500 424 ${Elatin9::not_blank} = ${Elatin9::not_blank};
501 424 ${Elatin9::not_cntrl} = ${Elatin9::not_cntrl};
502 424 ${Elatin9::not_digit} = ${Elatin9::not_digit};
503 424 ${Elatin9::not_graph} = ${Elatin9::not_graph};
504 424 ${Elatin9::not_lower} = ${Elatin9::not_lower};
505 424 ${Elatin9::not_lower_i} = ${Elatin9::not_lower_i};
506 424 ${Elatin9::not_print} = ${Elatin9::not_print};
507 424 ${Elatin9::not_punct} = ${Elatin9::not_punct};
508 424 ${Elatin9::not_space} = ${Elatin9::not_space};
509 424 ${Elatin9::not_upper} = ${Elatin9::not_upper};
510 424 ${Elatin9::not_upper_i} = ${Elatin9::not_upper_i};
511 424 ${Elatin9::not_word} = ${Elatin9::not_word};
512 424 ${Elatin9::not_xdigit} = ${Elatin9::not_xdigit};
513 424 ${Elatin9::eb} = ${Elatin9::eb};
514 424 ${Elatin9::eB} = ${Elatin9::eB};
515  
516 #
517 # Latin-9 split
518 #
519 72 ▶sub Elatin9::split(;$$$) {
Subroutine split: called CC=34 SCAR=38.5
Pod undocumented
520  
521 # P.794 29.2.161. split
522 # in Chapter 29: Functions
523 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
524  
525 # P.951 split
526 # in Chapter 27: Functions
527 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
528  
529 72 my $pattern = $_[0];
530 72 my $string = $_[1];
531 72 my $limit = $_[2];
532  
533 # if $pattern is also omitted or is the literal space, " "
534 72 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 2 70 72
535 2 $pattern = ' ';
536 }
537  
538 # if $string is omitted, the function splits the $_ string
539 72 ▶ if (not defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 6 66 72
540 6 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 6 6
541 0 $string = $_;
542 }
543 else {
544 6 $string = '';
545 }
546 }
547  
548 72 my @split = ();
549  
550 # when string is empty
551 72 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 10 62 72
elsif ($pattern eq ' ') { } 2 60 62
552  
553 # resulting list value in list context
554 10 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 5 5 10
555 5 return @split;
556 }
557  
558 # count of substrings in scalar context
559 else {
560 5 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 5 5
561 5 @_ = @split;
562 5 return scalar @_;
563 }
564 }
565  
566 # split's first argument is more consistently interpreted
567 #
568 # After some changes earlier in v5.17, split's behavior has been simplified:
569 # if the PATTERN argument evaluates to a string containing one space, it is
570 # treated the way that a literal string containing one space once was.
571 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
572  
573 # if $pattern is also omitted or is the literal space, " ", the function splits
574 # on whitespace, /\s+/, after skipping any leading whitespace
575 # (and so on)
576  
577 elsif ($pattern eq ' ') {
578 2 ▶ if (not defined $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit) { } 2 0 2
579 2 return CORE::split(' ', $string);
580 }
581 else {
582 0 return CORE::split(' ', $string, $limit);
583 }
584 }
585  
586 # if $limit is negative, it is treated as if an arbitrarily large $limit has been specified
587 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
588  
589 # a pattern capable of matching either the null string or something longer than the
590 # null string will split the value of $string into separate characters wherever it
591 # matches the null string between characters
592 # (and so on)
593  
594 60 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 2 58 60
595 2 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
596 2 my $limit = scalar(() = $string =~ /($pattern)/oxmsg);
597  
598 # P.1024 Appendix W.10 Multibyte Processing
599 # of ISBN 1-56592-224-7 CJKV Information Processing
600 # (and so on)
601  
602 # the //m modifier is assumed when you split on the pattern /^/
603 # (and so on)
604  
605 2 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
606 # V
607 2 ▶ while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and $string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m) 9 2 11
Condition100%3/3
--$limit > 0 and $string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m
!ll&&!rl&&r
119
MC/DC100%2/2
--$limit > 0 and $string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m
--$limit > 0 $string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m
Truth table100%3/3
A and B
A= --$limit > 0B= $string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m
ABresult
0X0
100
111
608  
609 # if the $pattern contains parentheses, then the substring matched by each pair of parentheses
610 # is included in the resulting list, interspersed with the fields that are ordinarily returned
611 # (and so on)
612  
613 9 local $@;
614 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
615 9 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 9 9 18
616 9 push @split, CORE::eval('$' . $digit);
617 }
618 }
619 }
620  
621 else {
622 58 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
623  
624 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
625 # V
626 58 ▶ while ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin9::q_char)*?)$pattern//m) 163 58 221
627 163 local $@;
628 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
629 163 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 230 163 393
630 230 push @split, CORE::eval('$' . $digit);
631 }
632 }
633 }
634 }
635  
636 elsif ($limit > 0) {
637 0 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 0 0 0
638 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
639 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
640  
641 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
642 # V
643 0 ▶ if ($string =~ s/\A((?:$q_char)+?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin9::q_char)+?)$pattern//m) 0 0 0
644 0 local $@;
645 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
646 0 push @split, CORE::eval('$' . $digit);
647 }
648 }
649 }
650 }
651 else {
652 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
653 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
654  
655 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
656 # V
657 0 ▶ if ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Elatin9::q_char)*?)$pattern//m) 0 0 0
658 0 local $@;
659 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
660 0 push @split, CORE::eval('$' . $digit);
661 }
662 }
663 }
664 }
665 }
666  
667 60 ▶ if (CORE::length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 58 2 60
668 58 push @split, $string;
669 }
670  
671 # if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result
672 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
673 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
674 0 pop @split;
675 }
676 }
677  
678 # resulting list value in list context
679 60 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 58 2 60
680 58 return @split;
681 }
682  
683 # count of substrings in scalar context
684 else {
685 2 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 2 2
686 2 @_ = @split;
687 2 return scalar @_;
688 }
689 }
690  
691 #
692 # get last subexpression offsets
693 #
694 60 ▶sub _last_subexpression_offsets {
Subroutine _last_subexpression_offsets: called CC=3 SCAR=11.0
695 60 my $pattern = $_[0];
696  
697 # remove comment
698 60 $pattern =~ s/\(\?\# .*? \)//oxmsg;
699  
700 60 my $modifier = '';
701 60 ▶ if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/mosx) 11 49 60
702 11 $modifier = $1;
703 11 $modifier =~ s/-[A-Za-z]*//;
704 }
705  
706 # with /x modifier
707 60 my @char = ();
708 60 ▶ if ($modifier =~ /x/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /x/mosx) { } 5 55 60
709 5 @char = $pattern =~ /\G((?>
710 [^\\\#\[\(] |
711 \\ $q_char |
712 \# (?>[^\n]*) $ |
713 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
714 \(\? |
715 $q_char
716 ))/oxmsg;
717 }
718  
719 # without /x modifier
720 else {
721 55 @char = $pattern =~ /\G((?>
722 [^\\\[\(] |
723 \\ $q_char |
724 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
725 \(\? |
726 $q_char
727 ))/oxmsg;
728 }
729  
730 60 return scalar grep { $_ eq '(' } @char;
731 }
732  
733 #
734 # Latin-9 transliteration (tr///)
735 #
736 6 ▶sub Elatin9::tr($$$$;$) {
Subroutine tr: called CC=26 SCAR=48.6
Pod undocumented
737  
738 6 my $bind_operator = $_[1];
739 6 my $searchlist = $_[2];
740 6 my $replacementlist = $_[3];
741 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
742  
743 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) 5 1 6
744 5 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 5 5
745 0 croak "Using !~ with tr///r doesn't make sense";
746 }
747 }
748  
749 6 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
750 6 my @searchlist = _charlist_tr($searchlist);
751 6 my @replacementlist = _charlist_tr($replacementlist);
752  
753 6 my %tr = ();
754 6 ▶ for (my $i=0; $i <= $#searchlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#searchlist) 19 6 25
755 19 ▶ if (not exists $tr{$searchlist[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$searchlist[$i]}) 19 0 19
756 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
757 19 $tr{$searchlist[$i]} = $replacementlist[$i];
758 }
759 elsif ($modifier =~ /d/oxms) {
760 0 $tr{$searchlist[$i]} = '';
761 }
762 ▶ 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
763 0 $tr{$searchlist[$i]} = $replacementlist[-1];
764 }
765 else {
766 0 $tr{$searchlist[$i]} = $searchlist[$i];
767 }
768 }
769 }
770  
771 6 my $tr = 0;
772 6 my $replaced = '';
773 6 ▶ if ($modifier =~ /c/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /c/mosx) { } 0 6 6
774 0 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 0 0 0
775 0 ▶ if (not exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $tr{$char}) { } 0 0 0
776 0 ▶ if (defined $replacementlist[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $replacementlist[-1]) 0 0 0
777 0 $replaced .= $replacementlist[-1];
778 }
779 0 $tr++;
780 0 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 0 0
781 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
782 0 shift @char;
783 0 $tr++;
784 }
785 }
786 }
787 else {
788 0 $replaced .= $char;
789 }
790 }
791 }
792 else {
793 6 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 36 6 42
794 36 ▶ if (exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$char}) { } 19 17 36
795 19 $replaced .= $tr{$char};
796 19 $tr++;
797 19 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 19 19
798 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
799 0 shift @char;
800 0 $tr++;
801 }
802 }
803 }
804 else {
805 17 $replaced .= $char;
806 }
807 }
808 }
809  
810 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) { } 5 1 6
811 5 return $replaced;
812 }
813 else {
814 1 $_[0] = $replaced;
815 1 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) { } 0 1 1
816 0 return not $tr;
817 }
818 else {
819 1 return $tr;
820 }
821 }
822 }
823  
824 #
825 # Latin-9 chop
826 #
827 0 ▶sub Elatin9::chop(@) {
Subroutine chop: not called CC=3 SCAR=24.8
Pod undocumented
828  
829 0 my $chop;
830 0 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
831 0 my @char = /\G (?>$q_char) /oxmsg;
832 0 $chop = pop @char;
833 0 $_ = join '', @char;
834 }
835 else {
836 0 for (@_) {
837 0 my @char = /\G (?>$q_char) /oxmsg;
838 0 $chop = pop @char;
839 0 $_ = join '', @char;
840 }
841 }
842 0 return $chop;
843 }
844  
845 #
846 # Latin-9 index by octet
847 #
848 30 ▶sub Elatin9::index($$;$) {
Subroutine index: called CC=6 SCAR=20.8
Pod documented
849  
850 30 my($str,$substr,$position) = @_;
851 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
852 30 my $pos = 0;
853  
854 30 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str) 130 30 160
855 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
856 0 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 0 0 0
857 0 return $pos;
858 }
859 }
860 130 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Elatin9::q_char) /mosx) { } 130 0 130
861 130 $pos += CORE::length($1);
862 }
863 else {
864 0 $pos += 1;
865 }
866 }
867 30 return -1;
868 }
869  
870 #
871 # Latin-9 reverse index
872 #
873 0 ▶sub Elatin9::rindex($$;$) {
Subroutine rindex: not called CC=6 SCAR=37.4
Pod undocumented
874  
875 0 my($str,$substr,$position) = @_;
876 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
877 0 my $pos = 0;
878 0 my $rindex = -1;
879  
880 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
881 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
882 0 $rindex = $pos;
883 }
884 0 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Elatin9::q_char) /mosx) { } 0 0 0
885 0 $pos += CORE::length($1);
886 }
887 else {
888 0 $pos += 1;
889 }
890 }
891 0 return $rindex;
892 }
893  
894 #
895 # Latin-9 lower case first with parameter
896 #
897 0 ▶sub Elatin9::lcfirst(@) {
Subroutine lcfirst: not called CC=4 SCAR=30.0
Pod undocumented
898 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
899 0 my $s = shift @_;
900 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
901 0 return Elatin9::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
902 }
903 else {
904 0 return Elatin9::lc(CORE::substr($s,0,1)) . CORE::substr($s,1);
905 }
906 }
907 else {
908 0 return Elatin9::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
909 }
910 }
911  
912 #
913 # Latin-9 lower case first without parameter
914 #
915 0 ▶sub Elatin9::lcfirst_() {
Subroutine lcfirst_: not called CC=1 SCAR=6.9
Pod undocumented
916 0 return Elatin9::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
917 }
918  
919 #
920 # Latin-9 lower case with parameter
921 #
922 61 ▶sub Elatin9::lc(@) {
Subroutine lc: called CC=6 SCAR=24.2
Pod undocumented
923 61 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 61 0 61
924 61 my $s = shift @_;
925 61 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 61 61
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
6100
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
926 0 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
927 }
928 else {
929 61 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 63 0 63
930 }
931 }
932 else {
933 0 return Elatin9::lc_();
934 }
935 }
936  
937 #
938 # Latin-9 lower case without parameter
939 #
940 0 ▶sub Elatin9::lc_() {
Subroutine lc_: not called CC=2 SCAR=17.9
Pod undocumented
941 0 my $s = $_;
942 0 ▶ return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
943 }
944  
945 #
946 # Latin-9 upper case first with parameter
947 #
948 0 ▶sub Elatin9::ucfirst(@) {
Subroutine ucfirst: not called CC=4 SCAR=30.0
Pod undocumented
949 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
950 0 my $s = shift @_;
951 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
952 0 return Elatin9::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
953 }
954 else {
955 0 return Elatin9::uc(CORE::substr($s,0,1)) . CORE::substr($s,1);
956 }
957 }
958 else {
959 0 return Elatin9::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
960 }
961 }
962  
963 #
964 # Latin-9 upper case first without parameter
965 #
966 0 ▶sub Elatin9::ucfirst_() {
Subroutine ucfirst_: not called CC=1 SCAR=6.9
Pod undocumented
967 0 return Elatin9::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
968 }
969  
970 #
971 # Latin-9 upper case with parameter
972 #
973 2453 ▶sub Elatin9::uc(@) {
Subroutine uc: called CC=6 SCAR=22.9
Pod undocumented
974 2453 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2453 0 2453
975 2453 my $s = shift @_;
976 2453 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2453 2453
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
245300
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
977 0 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
978 }
979 else {
980 2453 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 877 1578 2455
981 }
982 }
983 else {
984 0 return Elatin9::uc_();
985 }
986 }
987  
988 #
989 # Latin-9 upper case without parameter
990 #
991 0 ▶sub Elatin9::uc_() {
Subroutine uc_: not called CC=2 SCAR=17.9
Pod undocumented
992 0 my $s = $_;
993 0 ▶ return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
994 }
995  
996 #
997 # Latin-9 fold case with parameter
998 #
999 2463 ▶sub Elatin9::fc(@) {
Subroutine fc: called CC=6 SCAR=22.9
Pod undocumented
1000 2463 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2463 0 2463
1001 2463 my $s = shift @_;
1002 2463 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2463 2463
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
246300
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
1003 0 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1004 }
1005 else {
1006 2463 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 1847 5743 7590
1007 }
1008 }
1009 else {
1010 0 return Elatin9::fc_();
1011 }
1012 }
1013  
1014 #
1015 # Latin-9 fold case without parameter
1016 #
1017 0 ▶sub Elatin9::fc_() {
Subroutine fc_: not called CC=2 SCAR=17.9
Pod undocumented
1018 0 my $s = $_;
1019 0 ▶ return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1020 }
1021  
1022 #
1023 # Latin-9 regexp capture
1024 #
1025 {
1026 0 ▶ sub Elatin9::capture {
Subroutine capture: not called CC=1 SCAR=6.9
Pod documented
1027 0 return $_[0];
1028 }
1029 }
1030  
1031 #
1032 # Latin-9 regexp ignore case modifier
1033 #
1034 424 ▶sub Elatin9::ignorecase {
Subroutine ignorecase: called CC=25 SCAR=52.1
Pod undocumented
1035  
1036 11 my @string = @_;
1037 11 my $metachar = qr/[\@\\|[\]{]/oxms;
1038  
1039 # ignore case of $scalar or @array
1040 11 for my $string (@string) {
1041  
1042 # split regexp
1043 11 my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg;
1044  
1045 # unescape character
1046 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 988 11 999
1047 988 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 988 988
1048  
1049 # open character class [...]
1050 988 ▶ if ($char[$i] eq '[') {
Branch: 4 branches
BranchTrueFalseTotal
if ($char[$i] eq '[') { } 0 988 988
elsif ($char[$i] eq '[^') { } 0 988 988
elsif (my $char = classic_character_class($char[$i])) { } 0 988 988
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/mosx) { } 988 0 988
1051 0 my $left = $i;
1052  
1053 # [] make die "unmatched [] in regexp ...\n"
1054  
1055 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1056 0 $i++;
1057 }
1058  
1059 0 while (1) {
1060 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1061 0 croak "Unmatched [] in regexp";
1062 }
1063 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1064 0 my $right = $i;
1065 0 my @charlist = charlist_qr(@char[$left+1..$right-1], 'i');
1066  
1067 # escape character
1068 0 for my $char (@charlist) {
1069 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1070 }
1071  
1072 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1073 0 $char = '\\' . $char;
1074 }
1075 }
1076  
1077 # [...]
1078 0 splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')';
1079  
1080 0 $i = $left;
1081 0 last;
1082 }
1083 }
1084 }
1085  
1086 # open character class [^...]
1087 elsif ($char[$i] eq '[^') {
1088 0 my $left = $i;
1089  
1090 # [^] make die "unmatched [] in regexp ...\n"
1091  
1092 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1093 0 $i++;
1094 }
1095  
1096 0 while (1) {
1097 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1098 0 croak "Unmatched [] in regexp";
1099 }
1100 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1101 0 my $right = $i;
1102 0 my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i');
1103  
1104 # escape character
1105 0 for my $char (@charlist) {
1106 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1107 }
1108  
1109 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1110 0 $char = '\\' . $char;
1111 }
1112 }
1113  
1114 # [^...]
1115 0 splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)";
1116  
1117 0 $i = $left;
1118 0 last;
1119 }
1120 }
1121 }
1122  
1123 # rewrite classic character class or escape character
1124 elsif (my $char = classic_character_class($char[$i])) {
1125 0 $char[$i] = $char;
1126 }
1127  
1128 # with /i modifier
1129 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1130 988 my $uc = Elatin9::uc($char[$i]);
1131 988 my $fc = Elatin9::fc($char[$i]);
1132 988 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) 508 480 988
1133 508 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 505 3 508
1134 505 $char[$i] = '[' . $uc . $fc . ']';
1135 }
1136 else {
1137 3 $char[$i] = '(?:' . $uc . '|' . $fc . ')';
1138 }
1139 }
1140 }
1141 }
1142  
1143 # characterize
1144 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 988 11 999
1145 988 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 988 988
1146  
1147 988 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx }) 0 999 999
1148 }
1149  
1150 # quote character before ? + * {
1151 0 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition66%2/3
$i >= 1 && $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
119770
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
1152 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
1153 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
1154 }
1155 }
1156 }
1157  
1158 11 $string = join '', @char;
1159 }
1160  
1161 # make regexp string
1162 11 return @string;
1163 }
1164  
1165 #
1166 # classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B )
1167 #
1168 2856 ▶sub Elatin9::classic_character_class {
Subroutine classic_character_class: called CC=2 SCAR=6.9
Pod undocumented
1169 2856 my($char) = @_;
1170  
1171 return {
1172 '\D' => '${Elatin9::eD}',
1173 '\S' => '${Elatin9::eS}',
1174 '\W' => '${Elatin9::eW}',
1175 '\d' => '[0-9]',
1176  
1177 # Before Perl 5.6, \s only matched the five whitespace characters
1178 # tab, newline, form-feed, carriage return, and the space character
1179 # itself, which, taken together, is the character class [\t\n\f\r ].
1180  
1181 # Vertical tabs are now whitespace
1182 # \s in a regex now matches a vertical tab in all circumstances.
1183 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1184 # \t \n \v \f \r space
1185 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1186 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1187 '\s' => '\s',
1188  
1189 '\w' => '[0-9A-Z_a-z]',
1190 '\C' => '[\x00-\xFF]',
1191 '\X' => 'X',
1192  
1193 # \h \v \H \V
1194  
1195 # P.114 Character Class Shortcuts
1196 # in Chapter 7: In the World of Regular Expressions
1197 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
1198  
1199 # P.357 13.2.3 Whitespace
1200 # in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes
1201 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1202 #
1203 # 0x00009 CHARACTER TABULATION h s
1204 # 0x0000a LINE FEED (LF) vs
1205 # 0x0000b LINE TABULATION v
1206 # 0x0000c FORM FEED (FF) vs
1207 # 0x0000d CARRIAGE RETURN (CR) vs
1208 # 0x00020 SPACE h s
1209  
1210 # P.196 Table 5-9. Alphanumeric regex metasymbols
1211 # in Chapter 5. Pattern Matching
1212 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1213  
1214 # (and so on)
1215  
1216 '\H' => '${Elatin9::eH}',
1217 '\V' => '${Elatin9::eV}',
1218 '\h' => '[\x09\x20]',
1219 '\v' => '[\x0A\x0B\x0C\x0D]',
1220 '\R' => '${Elatin9::eR}',
1221  
1222 # \N
1223 #
1224 # http://perldoc.perl.org/perlre.html
1225 # Character Classes and other Special Escapes
1226 # Any character but \n (experimental). Not affected by /s modifier
1227  
1228 '\N' => '${Elatin9::eN}',
1229  
1230 # \b \B
1231  
1232 # P.180 Boundaries: The \b and \B Assertions
1233 # in Chapter 5: Pattern Matching
1234 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1235  
1236 # P.219 Boundaries: The \b and \B Assertions
1237 # in Chapter 5: Pattern Matching
1238 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1239  
1240 # \b really means (?:(?<=\w)(?!\w)|(?<!\w)(?=\w))
1241 # or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z))
1242 '\b' => '${Elatin9::eb}',
1243  
1244 # \B really means (?:(?<=\w)(?=\w)|(?<!\w)(?!\w))
1245 # or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W))
1246 '\B' => '${Elatin9::eB}',
1247  
1248 2856 ▶ }->{$char} || '';
Condition100%2/2
{'\\D', '${Elatin9::eD}', '\\S', '${Elatin9::eS}', '\\W', '${Elatin9::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin9::eH}', '\\V', '${Elatin9::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin9::eR}', '\\N', '${Elatin9::eN}', '\\b', '${Elatin9::eb}', '\\B', '${Elatin9::eB}'}->{$char} || ''
l!l
1012755
MC/DC100%1/1
{'\\D', '${Elatin9::eD}', '\\S', '${Elatin9::eS}', '\\W', '${Elatin9::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin9::eH}', '\\V', '${Elatin9::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin9::eR}', '\\N', '${Elatin9::eN}', '\\b', '${Elatin9::eb}', '\\B', '${Elatin9::eB}'}->{$char} || ''
{'\\D', '${Elatin9::eD}', '\\S', '${Elatin9::eS}', '\\W', '${Elatin9::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin9::eH}', '\\V', '${Elatin9::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin9::eR}', '\\N', '${Elatin9::eN}', '\\b', '${Elatin9::eb}', '\\B', '${Elatin9::eB}'}->{$char}
Truth table100%2/2
A
A= {'\\D', '${Elatin9::eD}', '\\S', '${Elatin9::eS}', '\\W', '${Elatin9::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Elatin9::eH}', '\\V', '${Elatin9::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Elatin9::eR}', '\\N', '${Elatin9::eN}', '\\b', '${Elatin9::eb}', '\\B', '${Elatin9::eB}'}->{$char}
Aresult
11
00
1249 }
1250  
1251 #
1252 # prepare Latin-9 characters per length
1253 #
1254  
1255 # 1 octet characters
1256 424 my @chars1 = ();
1257 0 ▶sub chars1 {
Subroutine chars1: not called CC=5 SCAR=34.0
Pod undocumented
1258 0 ▶ if (@chars1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars1) 0 0 0
1259 0 return @chars1;
1260 }
1261 0 ▶ if (exists $range_tr{1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{1}) 0 0 0
1262 0 my @ranges = @{ $range_tr{1} };
1263 0 ▶ while (my @range = splice(@ranges,0,1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 1)) 0 0 0
1264 0 for my $oct0 (@{$range[0]}) {
1265 0 push @chars1, pack 'C', $oct0;
1266 }
1267 }
1268 }
1269 0 return @chars1;
1270 }
1271  
1272 # 2 octets characters
1273 424 my @chars2 = ();
1274 0 ▶sub chars2 {
Subroutine chars2: not called CC=6 SCAR=37.4
Pod undocumented
1275 0 ▶ if (@chars2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars2) 0 0 0
1276 0 return @chars2;
1277 }
1278 0 ▶ if (exists $range_tr{2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{2}) 0 0 0
1279 0 my @ranges = @{ $range_tr{2} };
1280 0 ▶ while (my @range = splice(@ranges,0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 2)) 0 0 0
1281 0 for my $oct0 (@{$range[0]}) {
1282 0 for my $oct1 (@{$range[1]}) {
1283 0 push @chars2, pack 'CC', $oct0,$oct1;
1284 }
1285 }
1286 }
1287 }
1288 0 return @chars2;
1289 }
1290  
1291 # 3 octets characters
1292 424 my @chars3 = ();
1293 0 ▶sub chars3 {
Subroutine chars3: not called CC=7 SCAR=40.3
Pod undocumented
1294 0 ▶ if (@chars3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars3) 0 0 0
1295 0 return @chars3;
1296 }
1297 0 ▶ if (exists $range_tr{3}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{3}) 0 0 0
1298 0 my @ranges = @{ $range_tr{3} };
1299 0 ▶ while (my @range = splice(@ranges,0,3)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 3)) 0 0 0
1300 0 for my $oct0 (@{$range[0]}) {
1301 0 for my $oct1 (@{$range[1]}) {
1302 0 for my $oct2 (@{$range[2]}) {
1303 0 push @chars3, pack 'CCC', $oct0,$oct1,$oct2;
1304 }
1305 }
1306 }
1307 }
1308 }
1309 0 return @chars3;
1310 }
1311  
1312 # 4 octets characters
1313 424 my @chars4 = ();
1314 0 ▶sub chars4 {
Subroutine chars4: not called CC=8 SCAR=42.8
Pod undocumented
1315 0 ▶ if (@chars4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars4) 0 0 0
1316 0 return @chars4;
1317 }
1318 0 ▶ if (exists $range_tr{4}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{4}) 0 0 0
1319 0 my @ranges = @{ $range_tr{4} };
1320 0 ▶ while (my @range = splice(@ranges,0,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 4)) 0 0 0
1321 0 for my $oct0 (@{$range[0]}) {
1322 0 for my $oct1 (@{$range[1]}) {
1323 0 for my $oct2 (@{$range[2]}) {
1324 0 for my $oct3 (@{$range[3]}) {
1325 0 push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3;
1326 }
1327 }
1328 }
1329 }
1330 }
1331 }
1332 0 return @chars4;
1333 }
1334  
1335 #
1336 # Latin-9 open character list for tr
1337 #
1338 12 ▶sub _charlist_tr {
Subroutine _charlist_tr: called CC=35 SCAR=66.4
1339  
1340 12 local $_ = shift @_;
1341  
1342 # unescape character
1343 12 my @char = ();
1344 12 ▶ while (not /\G \z/oxmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgmosx) 38 12 50
1345 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 \\ ($Elatin9::q_char) /cgmosx) { } 0 38 38
elsif (/\G ($Elatin9::q_char) /cgmosx) { } 38 0 38
1346 0 push @char, '\-';
1347 }
1348 elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) {
1349 0 push @char, CORE::chr(oct $1);
1350 }
1351 elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) {
1352 0 push @char, CORE::chr(hex $1);
1353 }
1354 elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) {
1355 0 push @char, CORE::chr(CORE::ord($1) & 0x1F);
1356 }
1357 elsif (/\G (\\ [0nrtfbae]) /oxmsgc) {
1358 push @char, {
1359 '\0' => "\0",
1360 '\n' => "\n",
1361 '\r' => "\r",
1362 '\t' => "\t",
1363 '\f' => "\f",
1364 '\b' => "\x08", # \b means backspace in character class
1365 '\a' => "\a",
1366 '\e' => "\e",
1367 0 }->{$1};
1368 }
1369 elsif (/\G \\ ($q_char) /oxmsgc) {
1370 0 push @char, $1;
1371 }
1372 elsif (/\G ($q_char) /oxmsgc) {
1373 38 push @char, $1;
1374 }
1375 }
1376  
1377 # join separated multiple-octet
1378 12 @char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg;
1379  
1380 # unescape '-'
1381 12 my @i = ();
1382 12 for my $i (0 .. $#char) {
1383 38 ▶ if ($char[$i] eq '\-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\-') { } 0 38 38
elsif ($char[$i] eq '-') { } 0 38 38
1384 0 $char[$i] = '-';
1385 }
1386 elsif ($char[$i] eq '-') {
1387 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
1388 0 push @i, $i;
1389 }
1390 }
1391 }
1392  
1393 # open character list (reverse for splice)
1394 12 for my $i (CORE::reverse @i) {
1395 0 my @range = ();
1396  
1397 # range error
1398 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
1399 0 croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1400 }
1401  
1402 # range of multiple-octet code
1403 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
1404 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
1405 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
1406 }
1407 elsif (CORE::length($char[$i+1]) == 2) {
1408 0 push @range, grep {$char[$i-1] le $_} chars1();
1409 0 push @range, grep {$_ le $char[$i+1]} chars2();
1410 }
1411 elsif (CORE::length($char[$i+1]) == 3) {
1412 0 push @range, grep {$char[$i-1] le $_} chars1();
1413 0 push @range, chars2();
1414 0 push @range, grep {$_ le $char[$i+1]} chars3();
1415 }
1416 elsif (CORE::length($char[$i+1]) == 4) {
1417 0 push @range, grep {$char[$i-1] le $_} chars1();
1418 0 push @range, chars2();
1419 0 push @range, chars3();
1420 0 push @range, grep {$_ le $char[$i+1]} chars4();
1421 }
1422 else {
1423 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1424 }
1425 }
1426 elsif (CORE::length($char[$i-1]) == 2) {
1427 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
1428 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
1429 }
1430 elsif (CORE::length($char[$i+1]) == 3) {
1431 0 push @range, grep {$char[$i-1] le $_} chars2();
1432 0 push @range, grep {$_ le $char[$i+1]} chars3();
1433 }
1434 elsif (CORE::length($char[$i+1]) == 4) {
1435 0 push @range, grep {$char[$i-1] le $_} chars2();
1436 0 push @range, 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]) == 3) {
1444 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
1445 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
1446 }
1447 elsif (CORE::length($char[$i+1]) == 4) {
1448 0 push @range, grep {$char[$i-1] le $_} chars3();
1449 0 push @range, grep {$_ le $char[$i+1]} chars4();
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 elsif (CORE::length($char[$i-1]) == 4) {
1456 0 ▶ if (CORE::length($char[$i+1]) == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i + 1] == 4) { } 0 0 0
1457 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
1458 }
1459 else {
1460 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1461 }
1462 }
1463 else {
1464 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1465 }
1466  
1467 0 splice @char, $i-1, 3, @range;
1468 }
1469  
1470 12 return @char;
1471 }
1472  
1473 #
1474 # Latin-9 open character class
1475 #
1476 0 ▶sub _cc {
Subroutine _cc: not called CC=7 SCAR=40.3
1477 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
1478 0 die __FILE__, ": subroutine cc got no parameter.\n";
1479 }
1480 elsif (scalar(@_) == 1) {
1481 0 return sprintf('\x%02X',$_[0]);
1482 }
1483 elsif (scalar(@_) == 2) {
1484 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
1485 0 die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n";
1486 }
1487 elsif ($_[0] == $_[1]) {
1488 0 return sprintf('\x%02X',$_[0]);
1489 }
1490 elsif (($_[0]+1) == $_[1]) {
1491 0 return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]);
1492 }
1493 else {
1494 0 return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]);
1495 }
1496 }
1497 else {
1498 0 die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n";
1499 }
1500 }
1501  
1502 #
1503 # Latin-9 octet range
1504 #
1505 246 ▶sub _octets {
Subroutine _octets: called CC=5 SCAR=19.3
1506 246 my $length = shift @_;
1507  
1508 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1509 246 my($a1) = unpack 'C', $_[0];
1510 246 my($z1) = unpack 'C', $_[1];
1511  
1512 246 ▶ if ($a1 > $z1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1 > $z1) 0 246 246
1513 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1);
1514 }
1515  
1516 246 ▶ if ($a1 == $z1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($a1 == $z1) { } 0 246 246
elsif ($a1 + 1 == $z1) { } 0 246 246
1517 0 return sprintf('\x%02X',$a1);
1518 }
1519 elsif (($a1+1) == $z1) {
1520 0 return sprintf('\x%02X\x%02X',$a1,$z1);
1521 }
1522 else {
1523 246 return sprintf('\x%02X-\x%02X',$a1,$z1);
1524 }
1525 }
1526 else {
1527 0 die __FILE__, ": subroutine _octets got invalid length ($length).\n";
1528 }
1529 }
1530  
1531 #
1532 # Latin-9 range regexp
1533 #
1534 246 ▶sub _range_regexp {
Subroutine _range_regexp: called CC=18 SCAR=41.7
1535 246 my($length,$first,$last) = @_;
1536  
1537 246 my @range_regexp = ();
1538 246 ▶ if (not exists $range_tr{$length}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $range_tr{$length}) 0 246 246
1539 0 return @range_regexp;
1540 }
1541  
1542 246 my @ranges = @{ $range_tr{$length} };
1543 246 ▶ while (my @range = splice(@ranges,0,$length)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, $length)) 246 246 492
1544 246 my $min = '';
1545 246 my $max = '';
1546 246 ▶ for (my $i=0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 246 246 492
1547 246 $min .= pack 'C', $range[$i][0];
1548 246 $max .= pack 'C', $range[$i][-1];
1549 }
1550  
1551 # min___max
1552 # FIRST_____________LAST
1553 # (nothing)
1554  
1555 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
1556 }
1557  
1558 # **********
1559 # min_________max
1560 # FIRST_____________LAST
1561 # **********
1562  
1563 ▶ 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
1564 0 push @range_regexp, _octets($length,$first,$max,$min,$max);
1565 }
1566  
1567 # **********************
1568 # min________________max
1569 # FIRST_____________LAST
1570 # **********************
1571  
1572 ▶ 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
1573 0 push @range_regexp, _octets($length,$first,$last,$min,$max);
1574 }
1575  
1576 # *********
1577 # min___max
1578 # FIRST_____________LAST
1579 # *********
1580  
1581 ▶ 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
1582 0 push @range_regexp, _octets($length,$min,$max,$min,$max);
1583 }
1584  
1585 # **********************
1586 # min__________________________max
1587 # FIRST_____________LAST
1588 # **********************
1589  
1590 ▶ 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
1591 246 push @range_regexp, _octets($length,$first,$last,$min,$max);
1592 }
1593  
1594 # *********
1595 # min________max
1596 # FIRST_____________LAST
1597 # *********
1598  
1599 ▶ 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
1600 0 push @range_regexp, _octets($length,$min,$last,$min,$max);
1601 }
1602  
1603 # min___max
1604 # FIRST_____________LAST
1605 # (nothing)
1606  
1607 elsif ($last lt $min) {
1608 }
1609  
1610 else {
1611 0 die __FILE__, ": subroutine _range_regexp panic.\n";
1612 }
1613 }
1614  
1615 246 return @range_regexp;
1616 }
1617  
1618 #
1619 # Latin-9 open character list for qr and not qr
1620 #
1621 650 ▶sub _charlist {
Subroutine _charlist: called CC=46 SCAR=45.9
1622  
1623 650 my $modifier = pop @_;
1624 650 my @char = @_;
1625  
1626 650 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 298 352 650
1627  
1628 # unescape character
1629 650 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1773 650 2423
1630  
1631 # escape - to ...
1632 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 \\ ($Elatin9::q_char) \z/mosx) { } 7 1371 1378
1633 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
1634 246 $char[$i] = '...';
1635 }
1636 }
1637  
1638 # octal escape sequence
1639 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
1640 0 $char[$i] = octchr($1);
1641 }
1642  
1643 # hexadecimal escape sequence
1644 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
1645 0 $char[$i] = hexchr($1);
1646 }
1647  
1648 # \b{...} --> b\{...}
1649 # \B{...} --> B\{...}
1650 # \N{CHARNAME} --> N\{CHARNAME}
1651 # \p{PROPERTY} --> p\{PROPERTY}
1652 # \P{PROPERTY} --> P\{PROPERTY}
1653 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
1654 0 $char[$i] = $1 . '\\' . $2;
1655 }
1656  
1657 # \p, \P, \X --> p, P, X
1658 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
1659 0 $char[$i] = $1;
1660 }
1661  
1662 elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) {
1663 0 $char[$i] = CORE::chr oct $1;
1664 }
1665 elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) {
1666 22 $char[$i] = CORE::chr hex $1;
1667 }
1668 elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) {
1669 0 $char[$i] = CORE::chr(CORE::ord($1) & 0x1F);
1670 }
1671 elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) {
1672 $char[$i] = {
1673 '\0' => "\0",
1674 '\n' => "\n",
1675 '\r' => "\r",
1676 '\t' => "\t",
1677 '\f' => "\f",
1678 '\b' => "\x08", # \b means backspace in character class
1679 '\a' => "\a",
1680 '\e' => "\e",
1681 '\d' => '[0-9]',
1682  
1683 # Vertical tabs are now whitespace
1684 # \s in a regex now matches a vertical tab in all circumstances.
1685 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1686 # \t \n \v \f \r space
1687 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1688 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1689 '\s' => '\s',
1690  
1691 '\w' => '[0-9A-Z_a-z]',
1692 '\D' => '${Elatin9::eD}',
1693 '\S' => '${Elatin9::eS}',
1694 '\W' => '${Elatin9::eW}',
1695  
1696 '\H' => '${Elatin9::eH}',
1697 '\V' => '${Elatin9::eV}',
1698 '\h' => '[\x09\x20]',
1699 '\v' => '[\x0A\x0B\x0C\x0D]',
1700 '\R' => '${Elatin9::eR}',
1701  
1702 25 }->{$1};
1703 }
1704  
1705 # POSIX-style character classes
1706 ▶ 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
1707 $char[$i] = {
1708  
1709 '[:lower:]' => '[\x41-\x5A\x61-\x7A]',
1710 '[:upper:]' => '[\x41-\x5A\x61-\x7A]',
1711 '[:^lower:]' => '${Elatin9::not_lower_i}',
1712 '[:^upper:]' => '${Elatin9::not_upper_i}',
1713  
1714 8 }->{$1};
1715 }
1716 elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) {
1717 $char[$i] = {
1718  
1719 '[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]',
1720 '[:alpha:]' => '[\x41-\x5A\x61-\x7A]',
1721 '[:ascii:]' => '[\x00-\x7F]',
1722 '[:blank:]' => '[\x09\x20]',
1723 '[:cntrl:]' => '[\x00-\x1F\x7F]',
1724 '[:digit:]' => '[\x30-\x39]',
1725 '[:graph:]' => '[\x21-\x7F]',
1726 '[:lower:]' => '[\x61-\x7A]',
1727 '[:print:]' => '[\x20-\x7F]',
1728 '[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]',
1729  
1730 # P.174 POSIX-Style Character Classes
1731 # in Chapter 5: Pattern Matching
1732 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1733  
1734 # P.311 11.2.4 Character Classes and other Special Escapes
1735 # in Chapter 11: perlre: Perl regular expressions
1736 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1737  
1738 # P.210 POSIX-Style Character Classes
1739 # in Chapter 5: Pattern Matching
1740 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1741  
1742 '[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK")
1743  
1744 '[:upper:]' => '[\x41-\x5A]',
1745 '[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]',
1746 '[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]',
1747 '[:^alnum:]' => '${Elatin9::not_alnum}',
1748 '[:^alpha:]' => '${Elatin9::not_alpha}',
1749 '[:^ascii:]' => '${Elatin9::not_ascii}',
1750 '[:^blank:]' => '${Elatin9::not_blank}',
1751 '[:^cntrl:]' => '${Elatin9::not_cntrl}',
1752 '[:^digit:]' => '${Elatin9::not_digit}',
1753 '[:^graph:]' => '${Elatin9::not_graph}',
1754 '[:^lower:]' => '${Elatin9::not_lower}',
1755 '[:^print:]' => '${Elatin9::not_print}',
1756 '[:^punct:]' => '${Elatin9::not_punct}',
1757 '[:^space:]' => '${Elatin9::not_space}',
1758 '[:^upper:]' => '${Elatin9::not_upper}',
1759 '[:^word:]' => '${Elatin9::not_word}',
1760 '[:^xdigit:]' => '${Elatin9::not_xdigit}',
1761  
1762 70 }->{$1};
1763 }
1764 elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) {
1765 7 $char[$i] = $1;
1766 }
1767 }
1768  
1769 # open character list
1770 650 my @singleoctet = ();
1771 650 my @multipleoctet = ();
1772 650 ▶ for (my $i=0; $i <= $#char; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1527 650 2177
1773  
1774 # escaped -
1775 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
1776 246 $i += 1;
1777 246 next;
1778 }
1779  
1780 # make range regexp
1781 elsif ($char[$i] eq '...') {
1782  
1783 # range error
1784 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
1785 0 croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1786 }
1787 elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) {
1788 246 ▶ if ($char[$i-1] gt $char[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] gt $char[$i + 1]) 0 246 246
1789 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1790 }
1791 }
1792  
1793 # make range regexp per length
1794 246 for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) {
1795 246 my @regexp = ();
1796  
1797 # is first and last
1798 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
1799 246 push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]);
1800 }
1801  
1802 # is first
1803 elsif ($length == CORE::length($char[$i-1])) {
1804 0 push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length);
1805 }
1806  
1807 # is inside in first and last
1808 ▶ 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
1809 0 push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length);
1810 }
1811  
1812 # is last
1813 elsif ($length == CORE::length($char[$i+1])) {
1814 0 push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]);
1815 }
1816  
1817 else {
1818 0 die __FILE__, ": subroutine make_regexp panic.\n";
1819 }
1820  
1821 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1822 246 push @singleoctet, @regexp;
1823 }
1824 else {
1825 0 push @multipleoctet, @regexp;
1826 }
1827 }
1828  
1829 246 $i += 2;
1830 }
1831  
1832 # with /i modifier
1833 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1834 949 ▶ if ($modifier =~ /i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) { } 480 469 949
1835 480 my $uc = Elatin9::uc($char[$i]);
1836 480 my $fc = Elatin9::fc($char[$i]);
1837 480 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) { } 240 240 480
1838 240 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 240 0 240
1839 240 push @singleoctet, $uc, $fc;
1840 }
1841 else {
1842 0 push @singleoctet, $uc;
1843 0 push @multipleoctet, $fc;
1844 }
1845 }
1846 else {
1847 240 push @singleoctet, $char[$i];
1848 }
1849 }
1850 else {
1851 469 push @singleoctet, $char[$i];
1852 }
1853 949 $i += 1;
1854 }
1855  
1856 # single character of single octet code
1857 elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) {
1858 0 push @singleoctet, "\t", "\x20";
1859 0 $i += 1;
1860 }
1861 elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) {
1862 0 push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D";
1863 0 $i += 1;
1864 }
1865 elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) {
1866 2 push @singleoctet, $char[$i];
1867 2 $i += 1;
1868 }
1869  
1870 # single character of multiple-octet code
1871 else {
1872 84 push @multipleoctet, $char[$i];
1873 84 $i += 1;
1874 }
1875 }
1876  
1877 # quote metachar
1878 650 for (@singleoctet) {
1879 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
1880 0 $_ = '-';
1881 }
1882 elsif (/\A \n \z/oxms) {
1883 8 $_ = '\n';
1884 }
1885 elsif (/\A \r \z/oxms) {
1886 8 $_ = '\r';
1887 }
1888 elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) {
1889 744 $_ = sprintf('\x%02X', CORE::ord $1);
1890 }
1891 elsif (/\A [\x00-\xFF] \z/oxms) {
1892 429 $_ = quotemeta $_;
1893 }
1894 }
1895  
1896 # return character list
1897 650 return \@singleoctet, \@multipleoctet;
1898 }
1899  
1900 #
1901 # Latin-9 octal escape sequence
1902 #
1903 5 ▶sub octchr {
Subroutine octchr: called CC=2 SCAR=6.9
Pod undocumented
1904 5 my($octdigit) = @_;
1905  
1906 5 my @binary = ();
1907 5 for my $octal (split(//,$octdigit)) {
1908 push @binary, {
1909 '0' => '000',
1910 '1' => '001',
1911 '2' => '010',
1912 '3' => '011',
1913 '4' => '100',
1914 '5' => '101',
1915 '6' => '110',
1916 '7' => '111',
1917 50 }->{$octal};
1918 }
1919 5 my $binary = join '', @binary;
1920  
1921 my $octchr = {
1922 # 1234567
1923 1 => pack('B*', "0000000$binary"),
1924 2 => pack('B*', "000000$binary"),
1925 3 => pack('B*', "00000$binary"),
1926 4 => pack('B*', "0000$binary"),
1927 5 => pack('B*', "000$binary"),
1928 6 => pack('B*', "00$binary"),
1929 7 => pack('B*', "0$binary"),
1930 0 => pack('B*', "$binary"),
1931  
1932 5 }->{CORE::length($binary) % 8};
1933  
1934 5 return $octchr;
1935 }
1936  
1937 #
1938 # Latin-9 hexadecimal escape sequence
1939 #
1940 5 ▶sub hexchr {
Subroutine hexchr: called CC=1 SCAR=0.0
Pod undocumented
1941 5 my($hexdigit) = @_;
1942  
1943 my $hexchr = {
1944 1 => pack('H*', "0$hexdigit"),
1945 0 => pack('H*', "$hexdigit"),
1946  
1947 5 }->{CORE::length($_[0]) % 2};
1948  
1949 5 return $hexchr;
1950 }
1951  
1952 #
1953 # Latin-9 open character list for qr
1954 #
1955 576 ▶sub charlist_qr {
Subroutine charlist_qr: called CC=17 SCAR=28.7
Pod undocumented
1956  
1957 576 my $modifier = pop @_;
1958 576 my @char = @_;
1959  
1960 576 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
1961 576 my @singleoctet = @$singleoctet;
1962 576 my @multipleoctet = @$multipleoctet;
1963  
1964 # return character list
1965 576 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) 498 78 576
1966  
1967 # with /i modifier
1968 498 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 265 233 498
1969 265 my %singleoctet_ignorecase = ();
1970 265 for (@singleoctet) {
1971 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
1972 745 for my $ord (hex($1) .. hex($2)) {
1973 795 my $char = CORE::chr($ord);
1974 795 my $uc = Elatin9::uc($char);
1975 795 my $fc = Elatin9::fc($char);
1976 795 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 240 555 795
1977 240 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
1978 }
1979 else {
1980 555 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 555 0 555
1981 555 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1982 555 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
1983 }
1984 else {
1985 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1986 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
1987 }
1988 }
1989 }
1990 }
1991 745 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 745 745
1992 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
1993 }
1994 }
1995 265 my $i = 0;
1996 265 my @singleoctet_ignorecase = ();
1997 265 for my $ord (0 .. 255) {
1998 67840 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 870 66970 67840
1999 870 push @{$singleoctet_ignorecase[$i]}, $ord;
2000 }
2001 else {
2002 66970 $i++;
2003 }
2004 }
2005 265 @singleoctet = ();
2006 265 for my $range (@singleoctet_ignorecase) {
2007 56160 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 770 55390 56160
2008 770 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 720 50 770
elsif (scalar @{$range;} == 2) { } 0 50 50
2009 720 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2010 }
2011 50 elsif (scalar(@{$range}) == 2) {
2012 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2013 }
2014 else {
2015 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2016 }
2017 }
2018 }
2019 }
2020  
2021 498 my $not_anchor = '';
2022  
2023 498 push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' );
2024 }
2025 576 ▶ if (scalar(@multipleoctet) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 2) { } 6 570 576
2026 6 return '(?:' . join('|', @multipleoctet) . ')';
2027 }
2028 else {
2029 570 return $multipleoctet[0];
2030 }
2031 }
2032  
2033 #
2034 # Latin-9 open character list for not qr
2035 #
2036 74 ▶sub charlist_not_qr {
Subroutine charlist_not_qr: called CC=18 SCAR=33.1
Pod undocumented
2037  
2038 74 my $modifier = pop @_;
2039 74 my @char = @_;
2040  
2041 74 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
2042 74 my @singleoctet = @$singleoctet;
2043 74 my @multipleoctet = @$multipleoctet;
2044  
2045 # with /i modifier
2046 74 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 25 49 74
2047 25 my %singleoctet_ignorecase = ();
2048 25 for (@singleoctet) {
2049 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
2050 25 for my $ord (hex($1) .. hex($2)) {
2051 75 my $char = CORE::chr($ord);
2052 75 my $uc = Elatin9::uc($char);
2053 75 my $fc = Elatin9::fc($char);
2054 75 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 0 75 75
2055 0 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
2056 }
2057 else {
2058 75 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 75 0 75
2059 75 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2060 75 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
2061 }
2062 else {
2063 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2064 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
2065 }
2066 }
2067 }
2068 }
2069 25 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 25 25
2070 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
2071 }
2072 }
2073 25 my $i = 0;
2074 25 my @singleoctet_ignorecase = ();
2075 25 for my $ord (0 .. 255) {
2076 6400 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 150 6250 6400
2077 150 push @{$singleoctet_ignorecase[$i]}, $ord;
2078 }
2079 else {
2080 6250 $i++;
2081 }
2082 }
2083 25 @singleoctet = ();
2084 25 for my $range (@singleoctet_ignorecase) {
2085 2400 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 50 2350 2400
2086 50 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 0 50 50
elsif (scalar @{$range;} == 2) { } 0 50 50
2087 0 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2088 }
2089 50 elsif (scalar(@{$range}) == 2) {
2090 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2091 }
2092 else {
2093 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2094 }
2095 }
2096 }
2097 }
2098  
2099 # return character list
2100 74 ▶ if (scalar(@multipleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 1) { } 0 74 74
2101 0 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 0 0 0
2102  
2103 # any character other than multiple-octet and single octet character class
2104 0 return '(?!' . join('|', @multipleoctet) . ')(?:[^' . join('', @singleoctet) . '])';
2105 }
2106 else {
2107  
2108 # any character other than multiple-octet character class
2109 0 return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)";
2110 }
2111 }
2112 else {
2113 74 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 74 0 74
2114  
2115 # any character other than single octet character class
2116 74 return '(?:[^' . join('', @singleoctet) . '])';
2117 }
2118 else {
2119  
2120 # any character
2121 0 return "(?:$your_char)";
2122 }
2123 }
2124 }
2125  
2126 #
2127 # open file in read mode
2128 #
2129 424 ▶sub _open_r {
Subroutine _open_r: called CC=1 SCAR=0.0
2130 424 my(undef,$file) = @_;
2131 424 ▶ use Fcntl qw(O_RDONLY);
Subroutine BEGIN: called CC=1 SCAR=0.0
2132 424 return CORE::sysopen($_[0], $file, &O_RDONLY);
2133 }
2134  
2135 #
2136 # open file in append mode
2137 #
2138 212 ▶sub _open_a {
Subroutine _open_a: called CC=1 SCAR=0.0
2139 212 my(undef,$file) = @_;
2140 424 ▶ use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
2141 212 return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT);
2142 }
2143  
2144 #
2145 # safe system
2146 #
2147 212 ▶sub _systemx {
Subroutine _systemx: called CC=1 SCAR=0.0
2148  
2149 # P.707 29.2.33. exec
2150 # in Chapter 29: Functions
2151 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2152 #
2153 # Be aware that in older releases of Perl, exec (and system) did not flush
2154 # your output buffer, so you needed to enable command buffering by setting $|
2155 # on one or more filehandles to avoid lost output in the case of exec, or
2156 # misordererd output in the case of system. This situation was largely remedied
2157 # in the 5.6 release of Perl. (So, 5.005 release not yet.)
2158  
2159 # P.855 exec
2160 # in Chapter 27: Functions
2161 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2162 #
2163 # In very old release of Perl (before v5.6), exec (and system) did not flush
2164 # your output buffer, so you needed to enable command buffering by setting $|
2165 # on one or more filehandles to avoid lost output with exec or misordered
2166 # output with system.
2167  
2168 212 $| = 1;
2169  
2170 # P.565 23.1.2. Cleaning Up Your Environment
2171 # in Chapter 23: Security
2172 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2173  
2174 # P.656 Cleaning Up Your Environment
2175 # in Chapter 20: Security
2176 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2177  
2178 # local $ENV{'PATH'} = '.';
2179 212 local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
2180  
2181 # P.707 29.2.33. exec
2182 # in Chapter 29: Functions
2183 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2184 #
2185 # As we mentioned earlier, exec treats a discrete list of arguments as an
2186 # indication that it should bypass shell processing. However, there is one
2187 # place where you might still get tripped up. The exec call (and system, too)
2188 # will not distinguish between a single scalar argument and an array containing
2189 # only one element.
2190 #
2191 # @args = ("echo surprise"); # just one element in list
2192 # exec @args # still subject to shell escapes
2193 # or die "exec: $!"; # because @args == 1
2194 #
2195 # To avoid this, you can use the PATHNAME syntax, explicitly duplicating the
2196 # first argument as the pathname, which forces the rest of the arguments to be
2197 # interpreted as a list, even if there is only one of them:
2198 #
2199 # exec { $args[0] } @args # safe even with one-argument list
2200 # or die "can't exec @args: $!";
2201  
2202 # P.855 exec
2203 # in Chapter 27: Functions
2204 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2205 #
2206 # As we mentioned earlier, exec treats a discrete list of arguments as a
2207 # directive to bypass shell processing. However, there is one place where
2208 # you might still get tripped up. The exec call (and system, too) cannot
2209 # distinguish between a single scalar argument and an array containing
2210 # only one element.
2211 #
2212 # @args = ("echo surprise"); # just one element in list
2213 # exec @args # still subject to shell escapes
2214 # || die "exec: $!"; # because @args == 1
2215 #
2216 # To avoid this, use the PATHNAME syntax, explicitly duplicating the first
2217 # argument as the pathname, which forces the rest of the arguments to be
2218 # interpreted as a list, even if there is only one of them:
2219 #
2220 # exec { $args[0] } @args # safe even with one-argument list
2221 # || die "can't exec @args: $!";
2222  
2223 212 return CORE::system { $_[0] } @_; # safe even with one-argument list
2224 }
2225  
2226 #
2227 # Latin-9 order to character (with parameter)
2228 #
2229 3469 ▶sub Elatin9::chr(;$) {
Subroutine chr: called CC=4 SCAR=13.9
Pod undocumented
2230  
2231 3469 ▶ my $c = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3469 0 3469
2232  
2233 3469 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 24 3445 3469
2234 24 return "\x00";
2235 }
2236 else {
2237 3445 my @chr = ();
2238 3445 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 3445 3445 6890
2239 3445 unshift @chr, ($c % 0x100);
2240 3445 $c = int($c / 0x100);
2241 }
2242 3445 return pack 'C*', @chr;
2243 }
2244 }
2245  
2246 #
2247 # Latin-9 order to character (without parameter)
2248 #
2249 0 ▶sub Elatin9::chr_() {
Subroutine chr_: not called CC=3 SCAR=24.8
Pod undocumented
2250  
2251 0 my $c = $_;
2252  
2253 0 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 0 0 0
2254 0 return "\x00";
2255 }
2256 else {
2257 0 my @chr = ();
2258 0 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 0 0 0
2259 0 unshift @chr, ($c % 0x100);
2260 0 $c = int($c / 0x100);
2261 }
2262 0 return pack 'C*', @chr;
2263 }
2264 }
2265  
2266 #
2267 # Latin-9 path globbing (with parameter)
2268 #
2269 0 ▶sub Elatin9::glob($) {
Subroutine glob: not called CC=3 SCAR=24.8
Pod undocumented
2270  
2271 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2272 0 my @glob = _DOS_like_glob(@_);
2273 0 for my $glob (@glob) {
2274 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2275 }
2276 0 return @glob;
2277 }
2278 else {
2279 0 my $glob = _DOS_like_glob(@_);
2280 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2281 0 return $glob;
2282 }
2283 }
2284  
2285 #
2286 # Latin-9 path globbing (without parameter)
2287 #
2288 0 ▶sub Elatin9::glob_() {
Subroutine glob_: not called CC=3 SCAR=24.8
Pod undocumented
2289  
2290 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2291 0 my @glob = _DOS_like_glob();
2292 0 for my $glob (@glob) {
2293 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2294 }
2295 0 return @glob;
2296 }
2297 else {
2298 0 my $glob = _DOS_like_glob();
2299 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2300 0 return $glob;
2301 }
2302 }
2303  
2304 #
2305 # Latin-9 path globbing via File::DosGlob 1.10
2306 #
2307 # Often I confuse "_dosglob" and "_doglob".
2308 # So, I renamed "_dosglob" to "_DOS_like_glob".
2309 #
2310 424 my %iter;
2311 my %entries;
2312 0 ▶sub _DOS_like_glob {
Subroutine _DOS_like_glob: not called CC=10 SCAR=47.0
2313  
2314 # context (keyed by second cxix argument provided by core)
2315 0 my($expr,$cxix) = @_;
2316  
2317 # glob without args defaults to $_
2318 0 ▶ $expr = $_ if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2319  
2320 # represents the current user's home directory
2321 #
2322 # 7.3. Expanding Tildes in Filenames
2323 # in Chapter 7. File Access
2324 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2325 #
2326 # and File::HomeDir, File::HomeDir::Windows module
2327  
2328 # DOS-like system
2329 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
2330 0 $expr =~ s{ \A ~ (?= [^/\\] ) }
2331 0 { my_home_MSWin32() }oxmse;
2332 }
2333  
2334 # UNIX-like system
2335 else {
2336 0 $expr =~ s{ \A ~ ( (?:[^/])* ) }
2337 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
2338 }
2339  
2340 # assume global context if not provided one
2341 0 ▶ $cxix = '_G_' if not defined $cxix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cxix 0 0 0
2342 0 ▶ $iter{$cxix} = 0 if not exists $iter{$cxix};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $iter{$cxix} 0 0 0
2343  
2344 # if we're just beginning, do it all first
2345 0 ▶ if ($iter{$cxix} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} == 0) 0 0 0
2346 0 $entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ];
2347 }
2348  
2349 # chuck it all out, quick or slow
2350 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2351 0 delete $iter{$cxix};
2352 0 return @{delete $entries{$cxix}};
2353 }
2354 else {
2355 0 ▶ if ($iter{$cxix} = scalar @{$entries{$cxix}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} = scalar @{$entries{$cxix};}) { } 0 0 0
2356 0 return shift @{$entries{$cxix}};
2357 }
2358 else {
2359 # return undef for EOL
2360 0 delete $iter{$cxix};
2361 0 delete $entries{$cxix};
2362 0 return undef;
2363 }
2364 }
2365 }
2366  
2367 #
2368 # Latin-9 path globbing subroutine
2369 #
2370 0 ▶sub _do_glob {
Subroutine _do_glob: not called CC=44 SCAR=75.9
2371  
2372 0 my($cond,@expr) = @_;
2373 0 my @glob = ();
2374 0 my $fix_drive_relative_paths = 0;
2375  
2376 OUTER:
2377 0 for my $expr (@expr) {
2378 0 ▶ next OUTER if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2379 0 ▶ next OUTER if $expr eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $expr eq "" 0 0 0
2380  
2381 0 my @matched = ();
2382 0 my @globdir = ();
2383 0 my $head = '.';
2384 0 my $pathsep = '/';
2385 0 my $tail;
2386  
2387 # if argument is within quotes strip em and do no globbing
2388 0 ▶ if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ /\A " ((?:$Elatin9::q_char)*?) " \z/mosx) 0 0 0
2389 0 $expr = $1;
2390 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2391 0 ▶ if (-d $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $expr) 0 0 0
2392 0 push @glob, $expr;
2393 }
2394 }
2395 else {
2396 0 ▶ if (-e $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $expr) 0 0 0
2397 0 push @glob, $expr;
2398 }
2399 }
2400 0 next OUTER;
2401 }
2402  
2403 # wildcards with a drive prefix such as h:*.pm must be changed
2404 # to h:./*.pm to expand correctly
2405 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
2406 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
2407 0 $fix_drive_relative_paths = 1;
2408 }
2409 }
2410  
2411 0 ▶ if (($head, $tail) = _parse_path($expr,$pathsep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($head, $tail) = _parse_path($expr, $pathsep)) 0 0 0
2412 0 ▶ if ($tail eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail eq "") 0 0 0
2413 0 push @glob, $expr;
2414 0 next OUTER;
2415 }
2416 0 ▶ if ($head =~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ / \A (?:$Elatin9::q_char)*? [*?] /mosx) 0 0 0
2417 0 ▶ if (@globdir = _do_glob('d', $head)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@globdir = _do_glob("d", $head)) 0 0 0
2418 0 push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir);
2419 0 next OUTER;
2420 }
2421 }
2422 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
2423 0 $head .= $pathsep;
2424 }
2425 0 $expr = $tail;
2426 }
2427  
2428 # If file component has no wildcards, we can avoid opendir
2429 0 ▶ if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expr =~ / \A (?:$Elatin9::q_char)*? [*?] /mosx) 0 0 0
2430 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2431 0 $head = '';
2432 }
2433 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2434 0 $head .= $pathsep;
2435 }
2436 0 $head .= $expr;
2437 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2438 0 ▶ if (-d $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $head) 0 0 0
2439 0 push @glob, $head;
2440 }
2441 }
2442 else {
2443 0 ▶ if (-e $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $head) 0 0 0
2444 0 push @glob, $head;
2445 }
2446 }
2447 0 next OUTER;
2448 }
2449 0 ▶ opendir(*DIR, $head) or next OUTER;
Branch: 1 branch
BranchTrueFalseTotal
opendir *DIR, $head or next OUTER 0 0 0
2450 0 my @leaf = readdir DIR;
2451 0 closedir DIR;
2452  
2453 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2454 0 $head = '';
2455 }
2456 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Elatin9::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2457 0 $head .= $pathsep;
2458 }
2459  
2460 0 my $pattern = '';
2461 0 ▶ while ($expr =~ / \G ($q_char) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ / \G ($Elatin9::q_char) /cgox) 0 0 0
2462 0 my $char = $1;
2463  
2464 # 6.9. Matching Shell Globs as Regular Expressions
2465 # in Chapter 6. Pattern Matching
2466 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2467 # (and so on)
2468  
2469 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
2470 0 $pattern .= "(?:$your_char)*",
2471 }
2472 elsif ($char eq '?') {
2473 0 $pattern .= "(?:$your_char)?", # DOS style
2474 # $pattern .= "(?:$your_char)", # UNIX style
2475 }
2476 elsif ((my $fc = Elatin9::fc($char)) ne $char) {
2477 0 $pattern .= $fc;
2478 }
2479 else {
2480 0 $pattern .= quotemeta $char;
2481 }
2482 }
2483 0 ▶ my $matchsub = sub { Elatin9::fc($_[0]) =~ /\A $pattern \z/xms };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2484  
2485 # if ($@) {
2486 # print STDERR "$0: $@\n";
2487 # next OUTER;
2488 # }
2489  
2490 INNER:
2491 0 for my $leaf (@leaf) {
2492 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
2493 0 next INNER;
2494 }
2495 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
2496 0 next INNER;
2497 }
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 # [DOS compatibility special case]
2505 # Failed, add a trailing dot and try again, but only...
2506  
2507 0 ▶ if (Elatin9::index($leaf,'.') == -1 and # if name does not have a dot in it *and*
Branch: 1 branch
BranchTrueFalseTotal
if (&Elatin9::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin9::index($pattern, "\\.") != -1) 0 0 0
Condition0%0/6
&Elatin9::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin9::index($pattern, "\\.") != -1
!ll&&!rl&&r
000
&Elatin9::index($leaf, ".") == -1 and length $leaf <= 8
!ll&&!rl&&r
000
MC/DC0%0/3
&Elatin9::index($leaf, ".") == -1 and length $leaf <= 8 and &Elatin9::index($pattern, "\\.") != -1
&Elatin9::index($leaf, ".") == -1 length $leaf <= 8 &Elatin9::index($pattern, "\\.") != -1
Truth table0%0/4
A and B and C
A= &Elatin9::index($leaf, ".") == -1B= length $leaf <= 8C= &Elatin9::index($pattern, "\\.") != -1
ABCresult
0XX0
10X0
1100
1111
2508 CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and*
2509 Elatin9::index($pattern,'\\.') != -1 # pattern has a dot.
2510 ) {
2511 0 ▶ if (&$matchsub("$leaf.")) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub("$leaf.")) 0 0 0
2512 0 push @matched, "$head$leaf";
2513 0 next INNER;
2514 }
2515 }
2516 }
2517 0 ▶ if (@matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matched) 0 0 0
2518 0 push @glob, @matched;
2519 }
2520 }
2521 0 ▶ if ($fix_drive_relative_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fix_drive_relative_paths) 0 0 0
2522 0 for my $glob (@glob) {
2523 0 $glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms;
2524 }
2525 }
2526 0 return @glob;
2527 }
2528  
2529 #
2530 # Latin-9 parse line
2531 #
2532 0 ▶sub _parse_line {
Subroutine _parse_line: not called CC=3 SCAR=24.8
2533  
2534 0 my($line) = @_;
2535  
2536 0 $line .= ' ';
2537 0 my @piece = ();
2538 0 ▶ while ($line =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / " ( (?>(?: [^"] )* ) ) " (?>\s+) | ( (?>(?: [^"\s] )* ) ) (?>\s+) /gmosx) 0 0 0
2539 " ( (?>(?: [^"] )* ) ) " (?>\s+) |
2540 ( (?>(?: [^"\s] )* ) ) (?>\s+)
2541 /oxmsg
2542 ) {
2543 0 ▶ push @piece, defined($1) ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
2544 }
2545 0 return @piece;
2546 }
2547  
2548 #
2549 # Latin-9 parse path
2550 #
2551 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=2 SCAR=17.9
2552  
2553 0 my($path,$pathsep) = @_;
2554  
2555 0 $path .= '/';
2556 0 my @subpath = ();
2557 0 ▶ while ($path =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m( ((?: [^/\\] )+?) [/\\] )gmosx) 0 0 0
2558 ((?: [^\/\\] )+?) [\/\\]
2559 /oxmsg
2560 ) {
2561 0 push @subpath, $1;
2562 }
2563  
2564 0 my $tail = pop @subpath;
2565 0 my $head = join $pathsep, @subpath;
2566 0 return $head, $tail;
2567 }
2568  
2569 #
2570 # via File::HomeDir::Windows 1.00
2571 #
2572 0 ▶sub my_home_MSWin32 {
Subroutine my_home_MSWin32: not called CC=9 SCAR=45.0
Pod undocumented
2573  
2574 # A lot of unix people and unix-derived tools rely on
2575 # the ability to overload HOME. We will support it too
2576 # so that they can replace raw HOME calls with File::HomeDir.
2577 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
2578 0 return $ENV{'HOME'};
2579 }
2580  
2581 # Do we have a user profile?
2582 ▶ 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
2583 0 return $ENV{'USERPROFILE'};
2584 }
2585  
2586 # Some Windows use something like $ENV{'HOME'}
2587 ▶ 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
2588 0 return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
2589 }
2590  
2591 0 return undef;
2592 }
2593  
2594 #
2595 # via File::HomeDir::Unix 1.00
2596 #
2597 0 ▶sub my_home {
Subroutine my_home: not called CC=7 SCAR=40.3
Pod undocumented
2598 0 my $home;
2599  
2600 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
2601 0 $home = $ENV{'HOME'};
2602 }
2603  
2604 # This is from the original code, but I'm guessing
2605 # it means "login directory" and exists on some Unixes.
2606 ▶ 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
2607 0 $home = $ENV{'LOGDIR'};
2608 }
2609  
2610 ### More-desperate methods
2611  
2612 # Light desperation on any (Unixish) platform
2613 else {
2614 0 $home = CORE::eval q{ (getpwuid($<))[7] };
2615 }
2616  
2617 # On Unix in general, a non-existant home means "no home"
2618 # For example, "nobody"-like users might use /nonexistant
2619 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
2620 0 $home = undef;
2621 }
2622 0 return $home;
2623 }
2624  
2625 #
2626 # ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched
2627 #
2628 56 ▶sub Elatin9::PREMATCH {
Subroutine PREMATCH: called CC=1 SCAR=0.0
Pod undocumented
2629 56 return $`;
2630 }
2631  
2632 #
2633 # ${^MATCH}, $MATCH, $& the string that matched
2634 #
2635 81 ▶sub Elatin9::MATCH {
Subroutine MATCH: called CC=1 SCAR=0.0
Pod undocumented
2636 81 return $&;
2637 }
2638  
2639 #
2640 # ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched
2641 #
2642 42 ▶sub Elatin9::POSTMATCH {
Subroutine POSTMATCH: called CC=1 SCAR=0.0
Pod undocumented
2643 42 return $';
2644 }
2645  
2646 #
2647 # Latin-9 character to order (with parameter)
2648 #
2649 0 ▶sub Latin9::ord(;$) {
Subroutine ord: not called CC=4 SCAR=30.0
2650  
2651 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2652  
2653 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Elatin9::q_char) /mosx) { } 0 0 0
2654 0 my @ord = unpack 'C*', $1;
2655 0 my $ord = 0;
2656 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2657 0 $ord = $ord * 0x100 + $o;
2658 }
2659 0 return $ord;
2660 }
2661 else {
2662 0 return CORE::ord $_;
2663 }
2664 }
2665  
2666 #
2667 # Latin-9 character to order (without parameter)
2668 #
2669 0 ▶sub Latin9::ord_() {
Subroutine ord_: not called CC=3 SCAR=24.8
2670  
2671 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Elatin9::q_char) /mosx) { } 0 0 0
2672 0 my @ord = unpack 'C*', $1;
2673 0 my $ord = 0;
2674 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2675 0 $ord = $ord * 0x100 + $o;
2676 }
2677 0 return $ord;
2678 }
2679 else {
2680 0 return CORE::ord $_;
2681 }
2682 }
2683  
2684 #
2685 # Latin-9 reverse
2686 #
2687 0 ▶sub Latin9::reverse(@) {
Subroutine reverse: not called CC=2 SCAR=17.9
2688  
2689 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2690 0 return CORE::reverse @_;
2691 }
2692 else {
2693  
2694 # One of us once cornered Larry in an elevator and asked him what
2695 # problem he was solving with this, but he looked as far off into
2696 # the distance as he could in an elevator and said, "It seemed like
2697 # a good idea at the time."
2698  
2699 0 return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg);
2700 }
2701 }
2702  
2703 #
2704 # Latin-9 getc (with parameter, without parameter)
2705 #
2706 20 ▶sub Latin9::getc(;*@) {
Subroutine getc: called CC=9 SCAR=26.7
2707  
2708 20 my($package) = caller;
2709 20 ▶ my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 20 0 20
2710 20 ▶ croak 'Too many arguments for Latin9::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
2711  
2712 0 my @length = sort { $a <=> $b } keys %range_tr;
2713 20 my $getc = '';
2714 20 for my $length ($length[0] .. $length[-1]) {
2715 20 $getc .= CORE::getc($fh);
2716 20 ▶ if (exists $range_tr{CORE::length($getc)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{length $getc}) 20 0 20
2717 20 ▶ if ($getc =~ /\A ${Elatin9::dot_s} \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A $Elatin9::dot_s \z/mosx) 20 0 20
2718 20 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 20 20
2719 }
2720 }
2721 }
2722 0 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2723 }
2724  
2725 #
2726 # Latin-9 length by character
2727 #
2728 0 ▶sub Latin9::length(;$) {
Subroutine length: not called CC=2 SCAR=17.9
2729  
2730 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2731  
2732 0 local @_ = /\G ($q_char) /oxmsg;
2733 0 return scalar @_;
2734 }
2735  
2736 #
2737 # Latin-9 substr by character
2738 #
2739 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
2740  
2741 # P.232 The lvalue Attribute
2742 # in Chapter 6: Subroutines
2743 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2744  
2745 # P.336 The lvalue Attribute
2746 # in Chapter 7: Subroutines
2747 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2748  
2749 # P.144 8.4 Lvalue subroutines
2750 # in Chapter 8: perlsub: Perl subroutines
2751 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
2752  
2753 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
2754 # vv----------------------*******
2755 sub Latin9::substr($$;$$) %s {
2756  
2757 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
2758  
2759 # If the substring is beyond either end of the string, substr() returns the undefined
2760 # value and produces a warning. When used as an lvalue, specifying a substring that
2761 # is entirely outside the string raises an exception.
2762 # http://perldoc.perl.org/functions/substr.html
2763  
2764 # A return with no argument returns the scalar value undef in scalar context,
2765 # an empty list () in list context, and (naturally) nothing at all in void
2766 # context.
2767  
2768 my $offset = $_[1];
2769 if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) {
2770 return;
2771 }
2772  
2773 # substr($string,$offset,$length,$replacement)
2774 if (@_ == 4) {
2775 my(undef,undef,$length,$replacement) = @_;
2776 my $substr = join '', splice(@char, $offset, $length, $replacement);
2777 $_[0] = join '', @char;
2778  
2779 # return $substr; this doesn't work, don't say "return"
2780 $substr;
2781 }
2782  
2783 # substr($string,$offset,$length)
2784 elsif (@_ == 3) {
2785 my(undef,undef,$length) = @_;
2786 my $octet_offset = 0;
2787 my $octet_length = 0;
2788 if ($offset == 0) {
2789 $octet_offset = 0;
2790 }
2791 elsif ($offset > 0) {
2792 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2793 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2794 }
2795 else {
2796 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2797 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2798 }
2799 if ($length == 0) {
2800 $octet_length = 0;
2801 }
2802 elsif ($length > 0) {
2803 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2804 $octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]);
2805 }
2806 else {
2807 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2808 $octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]);
2809 }
2810 CORE::substr($_[0], $octet_offset, $octet_length);
2811 }
2812  
2813 # substr($string,$offset)
2814 else {
2815 my $octet_offset = 0;
2816 if ($offset == 0) {
2817 $octet_offset = 0;
2818 }
2819 elsif ($offset > 0) {
2820 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2821 }
2822 else {
2823 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2824 }
2825 CORE::substr($_[0], $octet_offset);
2826 }
2827 }
2828 END
2829 }
2830  
2831 #
2832 # Latin-9 index by character
2833 #
2834 0 ▶sub Latin9::index($$;$) {
Subroutine index: not called CC=3 SCAR=24.8
2835  
2836 0 my $index;
2837 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2838 0 $index = Elatin9::index($_[0], $_[1], CORE::length(Latin9::substr($_[0], 0, $_[2])));
2839 }
2840 else {
2841 0 $index = Elatin9::index($_[0], $_[1]);
2842 }
2843  
2844 0 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 0 0 0
2845 0 return -1;
2846 }
2847 else {
2848 0 return Latin9::length(CORE::substr $_[0], 0, $index);
2849 }
2850 }
2851  
2852 #
2853 # Latin-9 rindex by character
2854 #
2855 0 ▶sub Latin9::rindex($$;$) {
Subroutine rindex: not called CC=3 SCAR=24.8
2856  
2857 0 my $rindex;
2858 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2859 0 $rindex = Elatin9::rindex($_[0], $_[1], CORE::length(Latin9::substr($_[0], 0, $_[2])));
2860 }
2861 else {
2862 0 $rindex = Elatin9::rindex($_[0], $_[1]);
2863 }
2864  
2865 0 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 0 0 0
2866 0 return -1;
2867 }
2868 else {
2869 0 return Latin9::length(CORE::substr $_[0], 0, $rindex);
2870 }
2871 }
2872  
2873 # when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??'
2874 # when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else)
2875 424 ▶use vars qw($slash); $slash = 'm//';
Subroutine BEGIN: called CC=1 SCAR=0.0
2876  
2877 # ord() to ord() or Latin9::ord()
2878 424 my $function_ord = 'ord';
2879  
2880 # ord to ord or Latin9::ord_
2881 424 my $function_ord_ = 'ord';
2882  
2883 # reverse to reverse or Latin9::reverse
2884 424 my $function_reverse = 'reverse';
2885  
2886 # getc to getc or Latin9::getc
2887 424 my $function_getc = 'getc';
2888  
2889 # P.1023 Appendix W.9 Multibyte Anchoring
2890 # of ISBN 1-56592-224-7 CJKV Information Processing
2891  
2892 424 my $anchor = '';
2893  
2894 424 ▶use vars qw($nest);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2895  
2896 # regexp of nested parens in qqXX
2897  
2898 # P.340 Matching Nested Constructs with Embedded Code
2899 # in Chapter 7: Perl
2900 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2901  
2902 my $qq_paren = qr{(?{local $nest=0}) (?>(?:
2903 [^\\()] |
2904 \( (?{$nest++}) |
2905 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2906 \\ [^c] |
2907 \\c[\x40-\x5F] |
2908 [\x00-\xFF]
2909 424 }xms;
2910  
2911 my $qq_brace = qr{(?{local $nest=0}) (?>(?:
2912 [^\\{}] |
2913 \{ (?{$nest++}) |
2914 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2915 \\ [^c] |
2916 \\c[\x40-\x5F] |
2917 [\x00-\xFF]
2918 424 }xms;
2919  
2920 my $qq_bracket = qr{(?{local $nest=0}) (?>(?:
2921 [^\\\[\]] |
2922 \[ (?{$nest++}) |
2923 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2924 \\ [^c] |
2925 \\c[\x40-\x5F] |
2926 [\x00-\xFF]
2927 424 }xms;
2928  
2929 my $qq_angle = qr{(?{local $nest=0}) (?>(?:
2930 [^\\<>] |
2931 \< (?{$nest++}) |
2932 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2933 \\ [^c] |
2934 \\c[\x40-\x5F] |
2935 [\x00-\xFF]
2936 424 }xms;
2937  
2938 424 my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} |
2939 (?: ::)? (?:
2940 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2941 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2942 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2943 ))
2944 }xms;
2945  
2946 424 my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} |
2947 (?: ::)? (?:
2948 (?>[0-9]+) |
2949 [^a-zA-Z_0-9\[\]] |
2950 ^[A-Z] |
2951 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2952 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2953 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2954 ))
2955 }xms;
2956  
2957 424 my $qq_substr = qr{(?> Char::substr | Latin9::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \)
2958 }xms;
2959  
2960 # regexp of nested parens in qXX
2961 my $q_paren = qr{(?{local $nest=0}) (?>(?:
2962 [^()] |
2963 \( (?{$nest++}) |
2964 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2965 [\x00-\xFF]
2966 424 }xms;
2967  
2968 my $q_brace = qr{(?{local $nest=0}) (?>(?:
2969 [^\{\}] |
2970 \{ (?{$nest++}) |
2971 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2972 [\x00-\xFF]
2973 424 }xms;
2974  
2975 my $q_bracket = qr{(?{local $nest=0}) (?>(?:
2976 [^\[\]] |
2977 \[ (?{$nest++}) |
2978 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2979 [\x00-\xFF]
2980 424 }xms;
2981  
2982 my $q_angle = qr{(?{local $nest=0}) (?>(?:
2983 [^<>] |
2984 \< (?{$nest++}) |
2985 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2986 [\x00-\xFF]
2987 424 }xms;
2988  
2989 424 my $matched = '';
2990 424 my $s_matched = '';
2991  
2992 424 my $tr_variable = ''; # variable of tr///
2993 424 my $sub_variable = ''; # variable of s///
2994 424 my $bind_operator = ''; # =~ or !~
2995  
2996 424 my @heredoc = (); # here document
2997 424 my @heredoc_delimiter = ();
2998 424 my $here_script = ''; # here script
2999  
3000 #
3001 # escape Latin-9 script
3002 #
3003 548 ▶sub Latin9::escape(;$) {
Subroutine escape: called CC=3 SCAR=11.0
3004 548 ▶ local($_) = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 292 256 548
3005  
3006 # P.359 The Study Function
3007 # in Chapter 7: Perl
3008 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3009  
3010 548 study $_; # Yes, I studied study yesterday.
3011  
3012 # while all script
3013  
3014 # 6.14. Matching from Where the Last Pattern Left Off
3015 # in Chapter 6. Pattern Matching
3016 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
3017 # (and so on)
3018  
3019 # one member of Tag-team
3020 #
3021 # P.128 Start of match (or end of previous match): \G
3022 # P.130 Advanced Use of \G with Perl
3023 # in Chapter 3: Overview of Regular Expression Features and Flavors
3024 # P.255 Use leading anchors
3025 # P.256 Expose ^ and \G at the front expressions
3026 # in Chapter 6: Crafting an Efficient Expression
3027 # P.315 "Tag-team" matching with /gc
3028 # in Chapter 7: Perl
3029 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3030  
3031 548 my $e_script = '';
3032 548 ▶ while (not /\G \z/oxgc) { # member
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 86434 548 86982
3033 86434 $e_script .= Latin9::escape_token();
3034 }
3035  
3036 548 return $e_script;
3037 }
3038  
3039 #
3040 # escape Latin-9 token of script
3041 #
3042 86434 ▶sub Latin9::escape_token {
Subroutine escape_token: called CC=504 SCAR=109.3
3043  
3044 # \n output here document
3045  
3046 86434 my $ignore_modules = join('|', qw(
3047 utf8
3048 bytes
3049 charnames
3050 I18N::Japanese
3051 I18N::Collate
3052 I18N::JExt
3053 File::DosGlob
3054 Wild
3055 Wildcard
3056 Japanese
3057 ));
3058  
3059 # another member of Tag-team
3060 #
3061 # P.315 "Tag-team" matching with /gc
3062 # in Chapter 7: Perl
3063 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3064  
3065 86434 ▶ if (/\G ( \n ) /oxgc) { # another member (and so on)
Branch: 139 branches
BranchTrueFalseTotal
if (/\G ( \n ) /cgox) { } 12811 73623 86434
elsif (/\G ((?>\s+)|\#.*) /cgox) { } 21297 52326 73623
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /cgox) { } 1644 50682 52326
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /cgox) { } 90 50592 50682
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx) { } 4 50588 50592
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 28 50560 50588
elsif (/\G ( \$' | \$\{'\} ) /cgmosx) { } 1 50559 50560
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 3 50556 50559
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /cgox) { } 1754 48802 50556
elsif (/\G ( [,;] ) /cgox) { } 5068 43734 48802
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 43734 43734
elsif (/\G ( \$ 0 ) /cgmosx) { } 2 43732 43734
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 43732 43732
elsif (/\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 1 43731 43732
elsif (/\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 4 43727 43731
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 43727 43727
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 43727 43727
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 43727 43727
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 43727 43727
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /cgmosx) { } 0 43727 43727
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 0 43727 43727
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 43685 43727
elsif (m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 63 43622 43685
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /cgox) { } 0 43622 43622
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /cgox) { } 0 43622 43622
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /cgox) { } 0 43622 43622
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /cgox) { } 0 43622 43622
elsif (/\G \b ( if | unless | while | until | for | when ) \b /cgox) { } 251 43371 43622
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 19 43352 43371
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 43352 43352
elsif (/\G \b Latin9::eval (?= (?>\s*) \{ ) /cgox) { } 22 43330 43352
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /cgox) { } 0 43330 43330
elsif (/\G \b Latin9::eval \b (?! (?>\s*) => ) /cgox) { } 168 43162 43330
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /cgox) { } 2 43160 43162
elsif (/\G \b chop \b (?! (?>\s*) => ) /cgox) { } 0 43160 43160
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /cgox) { } 2 43158 43160
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /cgox) { } 0 43158 43158
elsif (/\G \b Latin9::index \b (?! (?>\s*) => ) /cgox) { } 0 43158 43158
elsif (/\G \b index \b (?! (?>\s*) => ) /cgox) { } 0 43158 43158
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /cgox) { } 2 43156 43158
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /cgox) { } 0 43156 43156
elsif (/\G \b Latin9::rindex \b (?! (?>\s*) => ) /cgox) { } 0 43156 43156
elsif (/\G \b rindex \b (?! (?>\s*) => ) /cgox) { } 0 43156 43156
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 43155 43156
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43155 43155
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 43154 43155
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43154 43154
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 6 43148 43154
elsif (/\G -s (?>\s*) (\") ((?:$Elatin9::qq_char)+?) (\") /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Elatin9::qq_char)+?) (\#) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Elatin9::qq_char)+?) (\1) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Elatin9::q_char)+?) (\') /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Elatin9::q_char)+?) (\#) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Elatin9::q_char)+?) (\1) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 43148 43148
elsif (/\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 43148 43148
elsif (/\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 43148 43148
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43146 43148
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43144 43146
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 36 43108 43144
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 43106 43108
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 8 43098 43106
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 43098 43098
elsif (/\G \b lc \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b uc \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b fc \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G -s \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b chr \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b ord \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b glob \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b reverse \b (?! (?>\s*) => ) /cgox) { } 0 43098 43098
elsif (/\G \b getc \b (?! (?>\s*) => ) /cgox) { } 8 43090 43098
elsif (/\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 87 43003 43090
elsif (/\G \b ( tr | y ) \b /cgox) { } 4 42999 43003
elsif (/\G \b (qq) \b /cgox) { } 2252 40747 42999
elsif (/\G \b (qr) \b /cgox) { } 0 40747 40747
elsif (/\G \b (qw) \b /cgox) { } 16 40731 40747
elsif (/\G \b (qx) \b /cgox) { } 0 40731 40731
elsif (/\G \b (q) \b /cgox) { } 473 40258 40731
elsif (/\G \b (m) \b /cgox) { } 209 40049 40258
elsif (/\G \b (s) \b /cgox) { } 101 39948 40049
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39948 39948
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39948 39948
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39948 39948
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /cgmosx) { } 37 39911 39948
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39911 39911
elsif (/\G \b use ((?>\s+) strict) \b /cgmosx) { } 0 39911 39911
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 2 39909 39911
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 0 39909 39909
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 2 39907 39909
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39907 39907
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39907 39907
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39907 39907
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39907 39907
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39907 39907
elsif (/\G \b use \b /cgmosx) { } 0 39907 39907
elsif (/\G \b no \b /cgmosx) { } 2 39905 39907
elsif (/\G (?<![\w\$\@\%\&\*]) (\') /cgox) { } 1142 38763 39905
elsif (/\G (\") /cgox) { } 1883 36880 38763
elsif (/\G (\`) /cgox) { } 1 36879 36880
elsif ($Elatin9::slash eq 'm//' and m[\G (/) ]cgox) { } 681 36198 36879
elsif ($Elatin9::slash eq 'm//' and /\G (\?) /cgox) { } 0 36198 36198
elsif (/\G ( <<>> ) /cgox) { } 0 36198 36198
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 36198 36198
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 6 36192 36198
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 3 36189 36192
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 6 36183 36189
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 3 36180 36183
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 6 36174 36180
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 72 36102 36174
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 36102 36102
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 36 36066 36102
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 42 36024 36066
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 36024 36024
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 12 36012 36024
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 36012 36012
elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /cgox) { } 0 36012 36012
elsif (/\G ^ ( __DATA__ \n .*) \z /cgmosx) { } 0 36012 36012
elsif (/\G ^ ( __END__ \n .*) \z /cgmosx) { } 210 35802 36012
elsif (/\G ( \cD .*) \z /cgmosx) { } 0 35802 35802
elsif (/\G ( \cZ .*) \z /cgmosx) { } 0 35802 35802
elsif (/\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 5839 29963 35802
elsif (/\G ( \.\.\. ) /cgox) { } 7 29956 29963
elsif (m"\G ((?> !~~ | !~ | != | ! | %= | % | &&= | && | &= | &\.= | &\. | & | -= | -> | - | :(?>\s*)= | : | <<>> | <<= | <=> | <= | < | == | => | =~ | = | >>= | >> | >= | > | \*\*= | \*\* | \*= | \* | \+= | \+ | \.\. | \.= | \. | //= | // | /= | / | \? | \\ | \^= | \^\.= | \^\. | \^ | \b x= | \|\|= | \|\| | \|= | \|\.= | \|\. | \| | ~~ | ~\. | ~ | \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | \b(?: print )\b | [,;\(\{\[] )) "cgox) { } 9778 20178 29956
elsif (/\G ($Elatin9::q_char) /cgox) { } 20178 0 20178
3066 12811 my $heredoc = '';
3067 12811 ▶ if (scalar(@heredoc_delimiter) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @heredoc_delimiter >= 1) 174 12637 12811
3068 174 $slash = 'm//';
3069  
3070 174 $heredoc = join '', @heredoc;
3071 174 @heredoc = ();
3072  
3073 # skip here document
3074 174 for my $heredoc_delimiter (@heredoc_delimiter) {
3075 174 /\G .*? \n $heredoc_delimiter \n/xmsgc;
3076 }
3077 174 @heredoc_delimiter = ();
3078  
3079 174 $here_script = '';
3080 }
3081 12811 return "\n" . $heredoc;
3082 }
3083  
3084 # ignore space, comment
3085 21297 elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; }
3086  
3087 # if (, elsif (, unless (, while (, until (, given (, and when (
3088  
3089 # given, when
3090  
3091 # P.225 The given Statement
3092 # in Chapter 15: Smart Matching and given-when
3093 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3094  
3095 # P.133 The given Statement
3096 # in Chapter 4: Statements and Declarations
3097 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3098  
3099 elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) {
3100 1644 $slash = 'm//';
3101 1644 return $1;
3102 }
3103  
3104 # scalar variable ($scalar = ...) =~ tr///;
3105 # scalar variable ($scalar = ...) =~ s///;
3106  
3107 # state
3108  
3109 # P.68 Persistent, Private Variables
3110 # in Chapter 4: Subroutines
3111 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3112  
3113 # P.160 Persistent Lexically Scoped Variables: state
3114 # in Chapter 4: Statements and Declarations
3115 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3116  
3117 # (and so on)
3118  
3119 elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) {
3120 90 my $e_string = e_string($1);
3121  
3122 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
3123 0 $tr_variable = $e_string . e_string($1);
3124 0 $bind_operator = $2;
3125 0 $slash = 'm//';
3126 0 return '';
3127 }
3128 elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3129 0 $sub_variable = $e_string . e_string($1);
3130 0 $bind_operator = $2;
3131 0 $slash = 'm//';
3132 0 return '';
3133 }
3134 else {
3135 90 $slash = 'div';
3136 90 return $e_string;
3137 }
3138 }
3139  
3140 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
3141 elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
3142 4 $slash = 'div';
3143 4 return q{Elatin9::PREMATCH()};
3144 }
3145  
3146 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
3147 elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
3148 28 $slash = 'div';
3149 28 return q{Elatin9::MATCH()};
3150 }
3151  
3152 # $', ${'} --> $', ${'}
3153 elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) {
3154 1 $slash = 'div';
3155 1 return $1;
3156 }
3157  
3158 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
3159 elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
3160 3 $slash = 'div';
3161 3 return q{Elatin9::POSTMATCH()};
3162 }
3163  
3164 # scalar variable $scalar =~ tr///;
3165 # scalar variable $scalar =~ s///;
3166 # substr() =~ tr///;
3167 # substr() =~ s///;
3168 elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) {
3169 1754 my $scalar = e_string($1);
3170  
3171 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
3172 2 $tr_variable = $scalar;
3173 2 $bind_operator = $1;
3174 2 $slash = 'm//';
3175 2 return '';
3176 }
3177 elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3178 65 $sub_variable = $scalar;
3179 65 $bind_operator = $1;
3180 65 $slash = 'm//';
3181 65 return '';
3182 }
3183 else {
3184 1687 $slash = 'div';
3185 1687 return $scalar;
3186 }
3187 }
3188  
3189 # end of statement
3190 elsif (/\G ( [,;] ) /oxgc) {
3191 5068 $slash = 'm//';
3192  
3193 # clear tr/// variable
3194 5068 $tr_variable = '';
3195  
3196 # clear s/// variable
3197 5068 $sub_variable = '';
3198  
3199 5068 $bind_operator = '';
3200  
3201 5068 return $1;
3202 }
3203  
3204 # bareword
3205 elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
3206 0 return $1;
3207 }
3208  
3209 # $0 --> $0
3210 elsif (/\G ( \$ 0 ) /oxmsgc) {
3211 2 $slash = 'div';
3212 2 return $1;
3213 }
3214 elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
3215 0 $slash = 'div';
3216 0 return $1;
3217 }
3218  
3219 # $$ --> $$
3220 elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
3221 1 $slash = 'div';
3222 1 return $1;
3223 }
3224  
3225 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
3226 # $1, $2, $3 --> $1, $2, $3 otherwise
3227 elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
3228 4 $slash = 'div';
3229 4 return e_capture($1);
3230 }
3231 elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
3232 0 $slash = 'div';
3233 0 return e_capture($1);
3234 }
3235  
3236 # $$foo[ ... ] --> $ $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.'->'.$2);
3240 }
3241  
3242 # $$foo{ ... } --> $ $foo->{ ... }
3243 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
3244 0 $slash = 'div';
3245 0 return e_capture($1.'->'.$2);
3246 }
3247  
3248 # $$foo
3249 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
3250 0 $slash = 'div';
3251 0 return e_capture($1);
3252 }
3253  
3254 # ${ foo }
3255 elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) {
3256 0 $slash = 'div';
3257 0 return '${' . $1 . '}';
3258 }
3259  
3260 # ${ ... }
3261 elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
3262 0 $slash = 'div';
3263 0 return e_capture($1);
3264 }
3265  
3266 # variable or function
3267 # $ @ % & * $ #
3268 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) {
3269 42 $slash = 'div';
3270 42 return $1;
3271 }
3272 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
3273 # $ @ # \ ' " / ? ( ) [ ] < >
3274 elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
3275 63 $slash = 'div';
3276 63 return $1;
3277 }
3278  
3279 # while (<FILEHANDLE>)
3280 elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) {
3281 0 return $1;
3282 }
3283  
3284 # while (<WILDCARD>) --- glob
3285  
3286 # avoid "Error: Runtime exception" of perl version 5.005_03
3287  
3288 elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /oxgc) {
3289 0 return 'while ($_ = Elatin9::glob("' . $1 . '"))';
3290 }
3291  
3292 # while (glob)
3293 elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) {
3294 0 return 'while ($_ = Elatin9::glob_)';
3295 }
3296  
3297 # while (glob(WILDCARD))
3298 elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) {
3299 0 return 'while ($_ = Elatin9::glob';
3300 }
3301  
3302 # doit if, doit unless, doit while, doit until, doit for, doit when
3303 251 elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; }
3304  
3305 # subroutines of package Elatin9
3306 19 elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; }
3307 0 elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3308 22 elsif (/\G \b Latin9::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3309 0 elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; }
3310 168 elsif (/\G \b Latin9::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Latin9::escape'; }
3311 2 elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; }
3312 0 elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::chop'; }
3313 2 elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; }
3314 0 elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; }
3315 0 elsif (/\G \b Latin9::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Latin9::index'; }
3316 0 elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::index'; }
3317 2 elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; }
3318 0 elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; }
3319 0 elsif (/\G \b Latin9::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Latin9::rindex'; }
3320 0 elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::rindex'; }
3321 1 elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::lc'; }
3322 0 elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::lcfirst'; }
3323 1 elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::uc'; }
3324 0 elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::ucfirst'; }
3325 6 elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::fc'; }
3326  
3327 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
3328 0 elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); }
3329 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3330 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3331 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3332 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3333 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3334 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3335  
3336 0 elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); }
3337 0 elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3338 0 elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3339 0 elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3340 0 elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3341 0 elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3342 0 elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3343  
3344 elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc)
3345 0 { $slash = 'm//'; return "-s $1"; }
3346 0 elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; }
3347 0 elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; }
3348 0 elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; }
3349  
3350 2 elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; }
3351 2 elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; }
3352 36 elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::chr'; }
3353 2 elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; }
3354 8 elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; }
3355 0 elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Elatin9::glob'; }
3356 0 elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::lc_'; }
3357 0 elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::lcfirst_'; }
3358 0 elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::uc_'; }
3359 0 elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::ucfirst_'; }
3360 0 elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::fc_'; }
3361 0 elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; }
3362  
3363 0 elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; }
3364 0 elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; }
3365 0 elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::chr_'; }
3366 0 elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; }
3367 0 elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; }
3368 0 elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Elatin9::glob_'; }
3369 0 elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; }
3370 8 elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; }
3371 # split
3372 elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
3373 87 $slash = 'm//';
3374  
3375 87 my $e = '';
3376 87 ▶ while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( (?>\s+) | \( | \#.* ) /cgox) 85 87 172
3377 85 $e .= $1;
3378 }
3379  
3380 # end of split
3381 87 ▶ if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Elatin9::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
3382  
3383 # split scalar value
3384 1 elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Elatin9::split' . $e . e_string($1); }
3385  
3386 # split literal space
3387 0 elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Elatin9::split' . $e . qq {qq$1 $2}; }
3388 0 elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Elatin9::split' . $e . qq{$1qq$2 $3}; }
3389 0 elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Elatin9::split' . $e . qq{$1qq$2 $3}; }
3390 0 elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Elatin9::split' . $e . qq{$1qq$2 $3}; }
3391 0 elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Elatin9::split' . $e . qq{$1qq$2 $3}; }
3392 0 elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Elatin9::split' . $e . qq{$1qq$2 $3}; }
3393 0 elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Elatin9::split' . $e . qq {q$1 $2}; }
3394 0 elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Elatin9::split' . $e . qq {$1q$2 $3}; }
3395 0 elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Elatin9::split' . $e . qq {$1q$2 $3}; }
3396 0 elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Elatin9::split' . $e . qq {$1q$2 $3}; }
3397 0 elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Elatin9::split' . $e . qq {$1q$2 $3}; }
3398 0 elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Elatin9::split' . $e . qq {$1q$2 $3}; }
3399 10 elsif (/\G ' [ ] ' /oxgc) { return 'Elatin9::split' . $e . qq {' '}; }
3400 0 elsif (/\G " [ ] " /oxgc) { return 'Elatin9::split' . $e . qq {" "}; }
3401  
3402 # split qq//
3403 elsif (/\G \b (qq) \b /oxgc) {
3404 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) /cgox) { } 0 0 0
3405 else {
3406 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3407 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 ([*\-:?\\^|]) ((?:$Elatin9::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) /cgox) { } 0 0 0
3408 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( )
3409 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { }
3410 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ]
3411 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < >
3412 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { }
3413 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * *
3414 }
3415 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3416 }
3417 }
3418  
3419 # split qr//
3420 elsif (/\G \b (qr) \b /oxgc) {
3421 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 12 12
3422 else {
3423 12 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 12 0 12
3424 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin9::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 12 0 12
3425 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( )
3426 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { }
3427 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ]
3428 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < >
3429 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' '
3430 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { }
3431 12 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * *
3432 }
3433 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3434 }
3435 }
3436  
3437 # split q//
3438 elsif (/\G \b (q) \b /oxgc) {
3439 0 ▶ if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:\\\#|\\\\|$Elatin9::q_char)*?) (\#) /cgox) { } 0 0 0
3440 else {
3441 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3442 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 ([*\-:?\\^|]) ((?:$Elatin9::q_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:\\\\|\\\1| $Elatin9::q_char)*?) (\1) /cgox) { } 0 0 0
3443 0 elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( )
3444 0 elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { }
3445 0 elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ]
3446 0 elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < >
3447 0 elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { }
3448 0 elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * *
3449 }
3450 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3451 }
3452 }
3453  
3454 # split m//
3455 elsif (/\G \b (m) \b /oxgc) {
3456 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
3457 else {
3458 18 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 18 0 18
3459 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin9::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 18 0 18
3460 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( )
3461 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { }
3462 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ]
3463 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < >
3464 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' '
3465 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { }
3466 18 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * *
3467 }
3468 0 die __FILE__, ": Search pattern not terminated\n";
3469 }
3470 }
3471  
3472 # split ''
3473 elsif (/\G (\') /oxgc) {
3474 0 my $q_string = '';
3475 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3476 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 ($Elatin9::q_char) /cgox) { } 0 0 0
3477 0 elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
3478 0 elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' '
3479 0 elsif (/\G ($q_char) /oxgc) { $q_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 0 my $qq_string = '';
3487 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3488 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 ($Elatin9::q_char) /cgox) { } 0 0 0
3489 0 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
3490 0 elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " "
3491 0 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
3492 }
3493 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3494 }
3495  
3496 # split //
3497 elsif (/\G (\/) /oxgc) {
3498 44 my $regexp = '';
3499 44 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 381 0 381
3500 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 ($Elatin9::q_char) /cgox) { } 337 0 337
3501 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
3502 44 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / /
3503 337 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
3504 }
3505 0 die __FILE__, ": Search pattern not terminated\n";
3506 }
3507 }
3508  
3509 # tr/// or y///
3510  
3511 # about [cdsrbB]* (/B modifier)
3512 #
3513 # P.559 appendix C
3514 # of ISBN 4-89052-384-7 Programming perl
3515 # (Japanese title is: Perl puroguramingu)
3516  
3517 elsif (/\G \b ( tr | y ) \b /oxgc) {
3518 4 my $ope = $1;
3519  
3520 # $1 $2 $3 $4 $5 $6
3521 4 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ((?:$Elatin9::qq_char)*?) (\#) ([cdsrbB]*) /cgox) { } 0 4 4
3522 0 my @tr = ($tr_variable,$2);
3523 0 return e_tr(@tr,'',$4,$6);
3524 }
3525 else {
3526 4 my $e = '';
3527 4 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 4 0 4
3528 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) ((?:$Elatin9::qq_char)*?) (\1) ((?:$Elatin9::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 4 0 4
3529 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /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) ((?:$Elatin9::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_brace)*?) (\}) /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) ((?:$Elatin9::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_bracket)*?) (\]) /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) ((?:$Elatin9::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 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3566 0 my @tr = ($tr_variable,$2);
3567 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3568 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) ((?:$Elatin9::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3569 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( )
3570 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { }
3571 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ]
3572 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < >
3573 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * *
3574 }
3575 0 die __FILE__, ": Transliteration replacement not terminated\n";
3576 }
3577 # $1 $2 $3 $4 $5 $6
3578 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * *
3579 4 my @tr = ($tr_variable,$2);
3580 4 return e_tr(@tr,'',$4,$6);
3581 }
3582 }
3583 0 die __FILE__, ": Transliteration pattern not terminated\n";
3584 }
3585 }
3586  
3587 # qq//
3588 elsif (/\G \b (qq) \b /oxgc) {
3589 2252 my $ope = $1;
3590  
3591 # if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# #
3592 2252 ▶ if (/\G (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 2252 2252
3593 0 my $qq_string = '';
3594 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3595 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 ($Elatin9::qq_char) /cgox) { } 0 0 0
3596 0 elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; }
3597 0 elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); }
3598 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3599 }
3600 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3601 }
3602  
3603 else {
3604 2252 my $e = '';
3605 2252 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 2252 0 2252
3606 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
3607  
3608 # elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( )
3609 elsif (/\G (\() /oxgc) { # qq ( )
3610 0 my $qq_string = '';
3611 0 local $nest = 1;
3612 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3613 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 ($Elatin9::qq_char) /cgox) { } 0 0 0
3614 0 elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; }
3615 0 elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; }
3616 elsif (/\G (\)) /oxgc) {
3617 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 0 0 0
3618 0 else { $qq_string .= $1; }
3619 }
3620 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3621 }
3622 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3623 }
3624  
3625 # elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { }
3626 elsif (/\G (\{) /oxgc) { # qq { }
3627 2222 my $qq_string = '';
3628 2222 local $nest = 1;
3629 2222 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 85104 0 85104
3630 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 ($Elatin9::qq_char) /cgox) { } 79782 0 79782
3631 0 elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; }
3632 1189 elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; }
3633 elsif (/\G (\}) /oxgc) {
3634 3411 ▶ if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 2222 1189 3411
3635 1189 else { $qq_string .= $1; }
3636 }
3637 79782 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3638 }
3639 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3640 }
3641  
3642 # elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ]
3643 elsif (/\G (\[) /oxgc) { # qq [ ]
3644 0 my $qq_string = '';
3645 0 local $nest = 1;
3646 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3647 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 ($Elatin9::qq_char) /cgox) { } 0 0 0
3648 0 elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; }
3649 0 elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; }
3650 elsif (/\G (\]) /oxgc) {
3651 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 0 0 0
3652 0 else { $qq_string .= $1; }
3653 }
3654 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3655 }
3656 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3657 }
3658  
3659 # elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < >
3660 elsif (/\G (\<) /oxgc) { # qq < >
3661 30 my $qq_string = '';
3662 30 local $nest = 1;
3663 30 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 1166 0 1166
3664 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 ($Elatin9::qq_char) /cgox) { } 1114 0 1114
3665 0 elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; }
3666 0 elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; }
3667 elsif (/\G (\>) /oxgc) {
3668 30 ▶ if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 30 0 30
3669 0 else { $qq_string .= $1; }
3670 }
3671 1114 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3672 }
3673 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3674 }
3675  
3676 # elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * *
3677 elsif (/\G (\S) /oxgc) { # qq * *
3678 0 my $delimiter = $1;
3679 0 my $qq_string = '';
3680 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3681 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 ($Elatin9::qq_char) /cgox) { } 0 0 0
3682 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; }
3683 0 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); }
3684 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3685 }
3686 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3687 }
3688 }
3689 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3690 }
3691 }
3692  
3693 # qr//
3694 elsif (/\G \b (qr) \b /oxgc) {
3695 0 my $ope = $1;
3696 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3697 0 return e_qr($ope,$1,$3,$2,$4);
3698 }
3699 else {
3700 0 my $e = '';
3701 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3702 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin9::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3703 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( )
3704 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { }
3705 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ]
3706 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < >
3707 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' '
3708 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { }
3709 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * *
3710 }
3711 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3712 }
3713 }
3714  
3715 # qw//
3716 elsif (/\G \b (qw) \b /oxgc) {
3717 16 my $ope = $1;
3718 16 ▶ if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) (.*?) (\#) /cgmosx) { } 0 16 16
3719 0 return e_qw($ope,$1,$3,$2);
3720 }
3721 else {
3722 16 my $e = '';
3723 16 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 16 0 16
3724 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) ((?:$Elatin9::q_char)*?) (\1) /cgmosx) { } 0 0 0
3725  
3726 16 elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3727 0 elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3728  
3729 0 elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3730 0 elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3731  
3732 0 elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3733 0 elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3734  
3735 0 elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3736 0 elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3737  
3738 0 elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3739 0 elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3740 }
3741 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3742 }
3743 }
3744  
3745 # qx//
3746 elsif (/\G \b (qx) \b /oxgc) {
3747 0 my $ope = $1;
3748 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) /cgox) { } 0 0 0
3749 0 return e_qq($ope,$1,$3,$2);
3750 }
3751 else {
3752 0 my $e = '';
3753 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3754 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 (\') ((?:$Elatin9::qq_char)*?) (\') /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) /cgox) { } 0 0 0
3755 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( )
3756 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { }
3757 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ]
3758 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < >
3759 0 elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' '
3760 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * *
3761 }
3762 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3763 }
3764 }
3765  
3766 # q//
3767 elsif (/\G \b (q) \b /oxgc) {
3768 473 my $ope = $1;
3769  
3770 # if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# #
3771  
3772 # avoid "Error: Runtime exception" of perl version 5.005_03
3773 # (and so on)
3774  
3775 473 ▶ if (/\G (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 473 473
3776 0 my $q_string = '';
3777 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3778 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 ($Elatin9::q_char) /cgox) { } 0 0 0
3779 0 elsif (/\G (\\\#) /oxgc) { $q_string .= $1; }
3780 0 elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); }
3781 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3782 }
3783 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3784 }
3785  
3786 else {
3787 473 my $e = '';
3788 473 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 473 0 473
3789 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
3790  
3791 # elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( )
3792 elsif (/\G (\() /oxgc) { # q ( )
3793 0 my $q_string = '';
3794 0 local $nest = 1;
3795 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3796 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 ($Elatin9::q_char) /cgox) { } 0 0 0
3797 0 elsif (/\G (\\\)) /oxgc) { $q_string .= $1; }
3798 0 elsif (/\G (\\\() /oxgc) { $q_string .= $1; }
3799 0 elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; }
3800 elsif (/\G (\)) /oxgc) {
3801 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 0 0 0
3802 0 else { $q_string .= $1; }
3803 }
3804 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3805 }
3806 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3807 }
3808  
3809 # elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { }
3810 elsif (/\G (\{) /oxgc) { # q { }
3811 467 my $q_string = '';
3812 467 local $nest = 1;
3813 467 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 8249 0 8249
3814 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 ($Elatin9::q_char) /cgox) { } 7464 0 7464
3815 0 elsif (/\G (\\\}) /oxgc) { $q_string .= $1; }
3816 0 elsif (/\G (\\\{) /oxgc) { $q_string .= $1; }
3817 159 elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; }
3818 elsif (/\G (\}) /oxgc) {
3819 626 ▶ if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 467 159 626
3820 159 else { $q_string .= $1; }
3821 }
3822 7464 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3823 }
3824 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3825 }
3826  
3827 # elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ]
3828 elsif (/\G (\[) /oxgc) { # q [ ]
3829 0 my $q_string = '';
3830 0 local $nest = 1;
3831 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3832 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 ($Elatin9::q_char) /cgox) { } 0 0 0
3833 0 elsif (/\G (\\\]) /oxgc) { $q_string .= $1; }
3834 0 elsif (/\G (\\\[) /oxgc) { $q_string .= $1; }
3835 0 elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; }
3836 elsif (/\G (\]) /oxgc) {
3837 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 0 0 0
3838 0 else { $q_string .= $1; }
3839 }
3840 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3841 }
3842 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3843 }
3844  
3845 # elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < >
3846 elsif (/\G (\<) /oxgc) { # q < >
3847 5 my $q_string = '';
3848 5 local $nest = 1;
3849 5 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 88 0 88
3850 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 ($Elatin9::q_char) /cgox) { } 83 0 83
3851 0 elsif (/\G (\\\>) /oxgc) { $q_string .= $1; }
3852 0 elsif (/\G (\\\<) /oxgc) { $q_string .= $1; }
3853 0 elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; }
3854 elsif (/\G (\>) /oxgc) {
3855 5 ▶ if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Elatin9::nest == 0) { } 5 0 5
3856 0 else { $q_string .= $1; }
3857 }
3858 83 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3859 }
3860 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3861 }
3862  
3863 # elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * *
3864 elsif (/\G (\S) /oxgc) { # q * *
3865 1 my $delimiter = $1;
3866 1 my $q_string = '';
3867 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 14 0 14
3868 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 ($Elatin9::q_char) /cgox) { } 13 0 13
3869 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; }
3870 1 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); }
3871 13 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3872 }
3873 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3874 }
3875 }
3876 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3877 }
3878 }
3879  
3880 # m//
3881 elsif (/\G \b (m) \b /oxgc) {
3882 209 my $ope = $1;
3883 209 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
3884 0 return e_qr($ope,$1,$3,$2,$4);
3885 }
3886 else {
3887 209 my $e = '';
3888 209 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 209 0 209
3889 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 (\?) ((?:$Elatin9::qq_char)*?) (\?) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\') ((?:$Elatin9::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 10 199 209
elsif (/\G ([*\-:\\^|]) ((?:$Elatin9::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 199 199
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 199 0 199
3890 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( )
3891 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { }
3892 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ]
3893 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < >
3894 0 elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ?
3895 10 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' '
3896 0 elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { }
3897 199 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * *
3898 }
3899 0 die __FILE__, ": Search pattern not terminated\n";
3900 }
3901 }
3902  
3903 # s///
3904  
3905 # about [cegimosxpradlunbB]* (/cg modifier)
3906 #
3907 # P.67 Pattern-Matching Operators
3908 # of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition.
3909  
3910 elsif (/\G \b (s) \b /oxgc) {
3911 101 my $ope = $1;
3912  
3913 # $1 $2 $3 $4 $5 $6
3914 101 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Elatin9::qq_char)*?) (\#) ((?:$Elatin9::qq_char)*?) (\#) ([cegimosxpradlunbB]*) /cgox) { } 1 100 101
3915 1 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3916 }
3917 else {
3918 100 my $e = '';
3919 100 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 100 0 100
3920 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 (\') ((?:$Elatin9::qq_char)*?) (\') ((?:$Elatin9::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 21 79 100
elsif (/\G ([*\-:?\\^|]) ((?:$Elatin9::qq_char)*?) (\1) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\$) ((?:$Elatin9::qq_char)*?) (\1) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 79 0 79
3921 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3922 0 my @s = ($1,$2,$3);
3923 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3924 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin9::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin9::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin9::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3925 # $1 $2 $3 $4
3926 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3927 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3928 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3929 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3930 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3931 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3932 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3933 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3934 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3935 }
3936 0 die __FILE__, ": Substitution replacement not terminated\n";
3937 }
3938 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3939 0 my @s = ($1,$2,$3);
3940 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3941 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin9::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin9::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin9::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3942 # $1 $2 $3 $4
3943 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3944 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3945 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3946 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3947 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3948 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3949 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3950 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3951 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3952 }
3953 0 die __FILE__, ": Substitution replacement not terminated\n";
3954 }
3955 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3956 0 my @s = ($1,$2,$3);
3957 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3958 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin9::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3959 # $1 $2 $3 $4
3960 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3961 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3962 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3963 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3964 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3965 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3966 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3967 }
3968 0 die __FILE__, ": Substitution replacement not terminated\n";
3969 }
3970 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3971 0 my @s = ($1,$2,$3);
3972 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3973 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 (\') ((?:$Elatin9::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Elatin9::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Elatin9::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Elatin9::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Elatin9::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3974 # $1 $2 $3 $4
3975 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3976 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3977 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3978 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3979 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3980 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3981 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3982 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3983 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3984 }
3985 0 die __FILE__, ": Substitution replacement not terminated\n";
3986 }
3987 # $1 $2 $3 $4 $5 $6
3988 elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) {
3989 21 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3990 }
3991 # $1 $2 $3 $4 $5 $6
3992 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3993 0 return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { }
3994 }
3995 # $1 $2 $3 $4 $5 $6
3996 elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3997 0 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3998 }
3999 # $1 $2 $3 $4 $5 $6
4000 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
4001 79 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
4002 }
4003 }
4004 0 die __FILE__, ": Substitution pattern not terminated\n";
4005 }
4006 }
4007  
4008 # require ignore module
4009 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; }
4010 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# require$1\n$2"; }
4011 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; }
4012  
4013 # use strict; --> use strict; no strict qw(refs);
4014 37 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; }
4015 0 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; }
4016 0 elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; }
4017  
4018 # use 5.12.0; --> use 5.12.0; no strict qw(refs);
4019 elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4020 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
4021 0 return "use $1; no strict qw(refs);";
4022 }
4023 else {
4024 2 return "use $1;";
4025 }
4026 }
4027 elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4028 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
4029 0 return "use $1; no strict qw(refs);";
4030 }
4031 else {
4032 0 return "use $1;";
4033 }
4034 }
4035  
4036 # ignore use module
4037 2 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; }
4038 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# use$1\n$2"; }
4039 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; }
4040  
4041 # ignore no module
4042 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; }
4043 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# no$1\n$2"; }
4044 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; }
4045  
4046 # use else
4047 0 elsif (/\G \b use \b /oxmsgc) { return "use"; }
4048  
4049 # use else
4050 2 elsif (/\G \b no \b /oxmsgc) { return "no"; }
4051  
4052 # ''
4053 elsif (/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
4054 1142 my $q_string = '';
4055 1142 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 10175 0 10175
4056 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 ($Elatin9::q_char) /cgox) { } 8981 0 8981
4057 48 elsif (/\G (\\\') /oxgc) { $q_string .= $1; }
4058 1142 elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); }
4059 8981 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
4060 }
4061 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4062 }
4063  
4064 # ""
4065 elsif (/\G (\") /oxgc) {
4066 1883 my $qq_string = '';
4067 1883 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 37094 0 37094
4068 37094 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 67 37027 37094
elsif (/\G (\\\") /cgox) { } 12 37015 37027
elsif (/\G \" /cgox) { } 1883 35132 37015
elsif (/\G ($Elatin9::q_char) /cgox) { } 35132 0 35132
4069 12 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; }
4070 1883 elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); }
4071 35132 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
4072 }
4073 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4074 }
4075  
4076 # ``
4077 elsif (/\G (\`) /oxgc) {
4078 1 my $qx_string = '';
4079 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 19 0 19
4080 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 ($Elatin9::q_char) /cgox) { } 18 0 18
4081 0 elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; }
4082 1 elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); }
4083 18 elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; }
4084 }
4085 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4086 }
4087  
4088 # // --- not divide operator (num / num), not defined-or
4089 ▶ elsif (($slash eq 'm//') and /\G (\/) /oxgc) {
Condition100%3/3
$Elatin9::slash eq "m//" and m[\G (/) ]cgox
!ll&&!rl&&r
273508848681
MC/DC100%2/2
$Elatin9::slash eq "m//" and m[\G (/) ]cgox
$Elatin9::slash eq "m//" m[\G (/) ]cgox
Truth table100%3/3
A and B
A= $Elatin9::slash eq "m//"B= m[\G (/) ]cgox
ABresult
0X0
100
111
4090 681 my $regexp = '';
4091 681 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 5636 0 5636
4092 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 ($Elatin9::q_char) /cgox) { } 4955 0 4955
4093 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; }
4094 681 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); }
4095 4955 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4096 }
4097 0 die __FILE__, ": Search pattern not terminated\n";
4098 }
4099  
4100 # ?? --- not conditional operator (condition ? then : else)
4101 ▶ elsif (($slash eq 'm//') and /\G (\?) /oxgc) {
Condition66%2/3
$Elatin9::slash eq "m//" and /\G (\?) /cgox
!ll&&!rl&&r
2735088480
MC/DC0%0/2
$Elatin9::slash eq "m//" and /\G (\?) /cgox
$Elatin9::slash eq "m//" /\G (\?) /cgox
Truth table66%2/3
A and B
A= $Elatin9::slash eq "m//"B= /\G (\?) /cgox
ABresult
0X0
100
111
4102 0 my $regexp = '';
4103 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
4104 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 ($Elatin9::q_char) /cgox) { } 0 0 0
4105 0 elsif (/\G (\\\?) /oxgc) { $regexp .= $1; }
4106 0 elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); }
4107 0 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4108 }
4109 0 die __FILE__, ": Search pattern not terminated\n";
4110 }
4111  
4112 # <<>> (a safer ARGV)
4113 0 elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; }
4114  
4115 # << (bit shift) --- not here document
4116 0 elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; }
4117  
4118 # <<~'HEREDOC'
4119 elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4120 6 $slash = 'm//';
4121 6 my $here_quote = $1;
4122 6 my $delimiter = $2;
4123  
4124 # get here document
4125 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4126 6 $here_script = CORE::substr $_, pos $_;
4127 6 $here_script =~ s/.*?\n//oxm;
4128 }
4129 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
4130 6 my $heredoc = $1;
4131 6 my $indent = $2;
4132 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4133 6 push @heredoc, $heredoc . qq{\n$delimiter\n};
4134 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4135 }
4136 else {
4137 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4138 }
4139 6 return qq{<<'$delimiter'};
4140 }
4141  
4142 # <<~\HEREDOC
4143  
4144 # P.66 2.6.6. "Here" Documents
4145 # in Chapter 2: Bits and Pieces
4146 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4147  
4148 # P.73 "Here" Documents
4149 # in Chapter 2: Bits and Pieces
4150 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4151  
4152 elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4153 3 $slash = 'm//';
4154 3 my $here_quote = $1;
4155 3 my $delimiter = $2;
4156  
4157 # get here document
4158 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4159 3 $here_script = CORE::substr $_, pos $_;
4160 3 $here_script =~ s/.*?\n//oxm;
4161 }
4162 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
4163 3 my $heredoc = $1;
4164 3 my $indent = $2;
4165 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4166 3 push @heredoc, $heredoc . qq{\n$delimiter\n};
4167 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4168 }
4169 else {
4170 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4171 }
4172 3 return qq{<<\\$delimiter};
4173 }
4174  
4175 # <<~"HEREDOC"
4176 elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4177 6 $slash = 'm//';
4178 6 my $here_quote = $1;
4179 6 my $delimiter = $2;
4180  
4181 # get here document
4182 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4183 6 $here_script = CORE::substr $_, pos $_;
4184 6 $here_script =~ s/.*?\n//oxm;
4185 }
4186 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
4187 6 my $heredoc = $1;
4188 6 my $indent = $2;
4189 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4190 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4191 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4192 }
4193 else {
4194 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4195 }
4196 6 return qq{<<"$delimiter"};
4197 }
4198  
4199 # <<~HEREDOC
4200 elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4201 3 $slash = 'm//';
4202 3 my $here_quote = $1;
4203 3 my $delimiter = $2;
4204  
4205 # get here document
4206 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4207 3 $here_script = CORE::substr $_, pos $_;
4208 3 $here_script =~ s/.*?\n//oxm;
4209 }
4210 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
4211 3 my $heredoc = $1;
4212 3 my $indent = $2;
4213 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4214 3 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4215 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4216 }
4217 else {
4218 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4219 }
4220 3 return qq{<<$delimiter};
4221 }
4222  
4223 # <<~`HEREDOC`
4224 elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4225 6 $slash = 'm//';
4226 6 my $here_quote = $1;
4227 6 my $delimiter = $2;
4228  
4229 # get here document
4230 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4231 6 $here_script = CORE::substr $_, pos $_;
4232 6 $here_script =~ s/.*?\n//oxm;
4233 }
4234 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
4235 6 my $heredoc = $1;
4236 6 my $indent = $2;
4237 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4238 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4239 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4240 }
4241 else {
4242 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4243 }
4244 6 return qq{<<`$delimiter`};
4245 }
4246  
4247 # <<'HEREDOC'
4248 elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
4249 72 $slash = 'm//';
4250 72 my $here_quote = $1;
4251 72 my $delimiter = $2;
4252  
4253 # get here document
4254 72 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 72 0 72
4255 72 $here_script = CORE::substr $_, pos $_;
4256 72 $here_script =~ s/.*?\n//oxm;
4257 }
4258 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
4259 72 push @heredoc, $1 . qq{\n$delimiter\n};
4260 72 push @heredoc_delimiter, $delimiter;
4261 }
4262 else {
4263 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4264 }
4265 72 return $here_quote;
4266 }
4267  
4268 # <<\HEREDOC
4269  
4270 # P.66 2.6.6. "Here" Documents
4271 # in Chapter 2: Bits and Pieces
4272 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4273  
4274 # P.73 "Here" Documents
4275 # in Chapter 2: Bits and Pieces
4276 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4277  
4278 elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
4279 0 $slash = 'm//';
4280 0 my $here_quote = $1;
4281 0 my $delimiter = $2;
4282  
4283 # get here document
4284 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4285 0 $here_script = CORE::substr $_, pos $_;
4286 0 $here_script =~ s/.*?\n//oxm;
4287 }
4288 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
4289 0 push @heredoc, $1 . qq{\n$delimiter\n};
4290 0 push @heredoc_delimiter, $delimiter;
4291 }
4292 else {
4293 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4294 }
4295 0 return $here_quote;
4296 }
4297  
4298 # <<"HEREDOC"
4299 elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
4300 36 $slash = 'm//';
4301 36 my $here_quote = $1;
4302 36 my $delimiter = $2;
4303  
4304 # get here document
4305 36 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 36 0 36
4306 36 $here_script = CORE::substr $_, pos $_;
4307 36 $here_script =~ s/.*?\n//oxm;
4308 }
4309 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
4310 36 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4311 36 push @heredoc_delimiter, $delimiter;
4312 }
4313 else {
4314 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4315 }
4316 36 return $here_quote;
4317 }
4318  
4319 # <<HEREDOC
4320 elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
4321 42 $slash = 'm//';
4322 42 my $here_quote = $1;
4323 42 my $delimiter = $2;
4324  
4325 # get here document
4326 42 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 42 0 42
4327 42 $here_script = CORE::substr $_, pos $_;
4328 42 $here_script =~ s/.*?\n//oxm;
4329 }
4330 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
4331 42 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4332 42 push @heredoc_delimiter, $delimiter;
4333 }
4334 else {
4335 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4336 }
4337 42 return $here_quote;
4338 }
4339  
4340 # <<`HEREDOC`
4341 elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
4342 0 $slash = 'm//';
4343 0 my $here_quote = $1;
4344 0 my $delimiter = $2;
4345  
4346 # get here document
4347 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4348 0 $here_script = CORE::substr $_, pos $_;
4349 0 $here_script =~ s/.*?\n//oxm;
4350 }
4351 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
4352 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4353 0 push @heredoc_delimiter, $delimiter;
4354 }
4355 else {
4356 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4357 }
4358 0 return $here_quote;
4359 }
4360  
4361 # <<= <=> <= < operator
4362 elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
4363 12 return $1;
4364 }
4365  
4366 # <FILEHANDLE>
4367 elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
4368 0 return $1;
4369 }
4370  
4371 # <WILDCARD> --- glob
4372  
4373 # avoid "Error: Runtime exception" of perl version 5.005_03
4374  
4375 elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /oxgc) {
4376 0 return 'Elatin9::glob("' . $1 . '")';
4377 }
4378  
4379 # __DATA__
4380 0 elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; }
4381  
4382 # __END__
4383 210 elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; }
4384  
4385 # \cD Control-D
4386  
4387 # P.68 2.6.8. Other Literal Tokens
4388 # in Chapter 2: Bits and Pieces
4389 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4390  
4391 # P.76 Other Literal Tokens
4392 # in Chapter 2: Bits and Pieces
4393 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4394  
4395 0 elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; }
4396  
4397 # \cZ Control-Z
4398 0 elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; }
4399  
4400 # any operator before div
4401 elsif (/\G (
4402 -- | \+\+ |
4403 [\)\}\]]
4404  
4405 5839 ) /oxgc) { $slash = 'div'; return $1; }
4406  
4407 # yada-yada or triple-dot operator
4408 elsif (/\G (
4409 \.\.\.
4410  
4411 7 ) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; }
4412  
4413 # any operator before m//
4414  
4415 # //, //= (defined-or)
4416  
4417 # P.164 Logical Operators
4418 # in Chapter 10: More Control Structures
4419 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4420  
4421 # P.119 C-Style Logical (Short-Circuit) Operators
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 # ~~
4428  
4429 # P.221 The Smart Match Operator
4430 # in Chapter 15: Smart Matching and given-when
4431 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4432  
4433 # P.112 Smartmatch Operator
4434 # in Chapter 3: Unary and Binary Operators
4435 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4436  
4437 # (and so on)
4438  
4439 elsif (/\G ((?>
4440  
4441 !~~ | !~ | != | ! |
4442 %= | % |
4443 &&= | && | &= | &\.= | &\. | & |
4444 -= | -> | - |
4445 :(?>\s*)= |
4446 : |
4447 <<>> |
4448 <<= | <=> | <= | < |
4449 == | => | =~ | = |
4450 >>= | >> | >= | > |
4451 \*\*= | \*\* | \*= | \* |
4452 \+= | \+ |
4453 \.\. | \.= | \. |
4454 \/\/= | \/\/ |
4455 \/= | \/ |
4456 \? |
4457 \\ |
4458 \^= | \^\.= | \^\. | \^ |
4459 \b x= |
4460 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
4461 ~~ | ~\. | ~ |
4462 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
4463 \b(?: print )\b |
4464  
4465 [,;\(\{\[]
4466  
4467 9778 )) /oxgc) { $slash = 'm//'; return $1; }
4468  
4469 # other any character
4470 20178 elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; }
4471  
4472 # system error
4473 else {
4474 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4475 }
4476 }
4477  
4478 # escape Latin-9 string
4479 1873 ▶sub e_string {
Subroutine e_string: called CC=54 SCAR=72.5
Pod documented
4480 1873 my($string) = @_;
4481 1873 my $e_string = '';
4482  
4483 1873 local $slash = 'm//';
4484  
4485 # P.1024 Appendix W.10 Multibyte Processing
4486 # of ISBN 1-56592-224-7 CJKV Information Processing
4487 # (and so on)
4488  
4489 1873 my @char = $string =~ / \G (?>[^\\]|\\$q_char|$q_char) /oxmsg;
4490  
4491 # without { ... }
4492 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
4493 1854 ▶ if ($string !~ /<</oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /<</mosx) 1854 0 1854
4494 1854 return $string;
4495 }
4496 }
4497  
4498 E_STRING_LOOP:
4499 19 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 223 19 242
4500 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\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$Elatin9::q_char)*?) (\') /cgox) { } 0 213 213
elsif ($string =~ /\G (\") ((?:$Elatin9::qq_char)*?) (\") /cgox) { } 0 213 213
elsif ($string =~ /\G (\`) ((?:$Elatin9::qq_char)*?) (\`) /cgox) { } 0 213 213
elsif ($string =~ /\G ($Elatin9::q_char) /cgox) { } 213 0 213
4501 }
4502  
4503 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Elatin9::PREMATCH()]}
4504 elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
4505 0 $e_string .= q{Elatin9::PREMATCH()};
4506 0 $slash = 'div';
4507 }
4508  
4509 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Elatin9::MATCH()]}
4510 elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
4511 0 $e_string .= q{Elatin9::MATCH()};
4512 0 $slash = 'div';
4513 }
4514  
4515 # $', ${'} --> $', ${'}
4516 elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) {
4517 0 $e_string .= $1;
4518 0 $slash = 'div';
4519 }
4520  
4521 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Elatin9::POSTMATCH()]}
4522 elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
4523 0 $e_string .= q{Elatin9::POSTMATCH()};
4524 0 $slash = 'div';
4525 }
4526  
4527 # bareword
4528 elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
4529 0 $e_string .= $1;
4530 0 $slash = 'div';
4531 }
4532  
4533 # $0 --> $0
4534 elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) {
4535 0 $e_string .= $1;
4536 0 $slash = 'div';
4537 }
4538 elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
4539 0 $e_string .= $1;
4540 0 $slash = 'div';
4541 }
4542  
4543 # $$ --> $$
4544 elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
4545 0 $e_string .= $1;
4546 0 $slash = 'div';
4547 }
4548  
4549 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4550 # $1, $2, $3 --> $1, $2, $3 otherwise
4551 elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
4552 0 $e_string .= e_capture($1);
4553 0 $slash = 'div';
4554 }
4555 elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
4556 0 $e_string .= e_capture($1);
4557 0 $slash = 'div';
4558 }
4559  
4560 # $$foo[ ... ] --> $ $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.'->'.$2);
4563 0 $slash = 'div';
4564 }
4565  
4566 # $$foo{ ... } --> $ $foo->{ ... }
4567 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
4568 0 $e_string .= e_capture($1.'->'.$2);
4569 0 $slash = 'div';
4570 }
4571  
4572 # $$foo
4573 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
4574 0 $e_string .= e_capture($1);
4575 0 $slash = 'div';
4576 }
4577  
4578 # ${ foo }
4579 elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) {
4580 0 $e_string .= '${' . $1 . '}';
4581 0 $slash = 'div';
4582 }
4583  
4584 # ${ ... }
4585 elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
4586 3 $e_string .= e_capture($1);
4587 3 $slash = 'div';
4588 }
4589  
4590 # variable or function
4591 # $ @ % & * $ #
4592 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) {
4593 7 $e_string .= $1;
4594 7 $slash = 'div';
4595 }
4596 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
4597 # $ @ # \ ' " / ? ( ) [ ] < >
4598 elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
4599 0 $e_string .= $1;
4600 0 $slash = 'div';
4601 }
4602  
4603 # qq//
4604 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4605 0 my $ope = $1;
4606 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Elatin9::qq_char)*?) (\#) /cgox) { } 0 0 0
4607 0 $e_string .= e_qq($ope,$1,$3,$2);
4608 }
4609 else {
4610 0 my $e = '';
4611 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4612 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) ((?:$Elatin9::qq_char)*?) (\1) /cgox) { } 0 0 0
4613 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( )
4614 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { }
4615 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ]
4616 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < >
4617 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * *
4618 }
4619 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4620 }
4621 }
4622  
4623 # qx//
4624 elsif ($string =~ /\G \b (qx) \b /oxgc) {
4625 0 my $ope = $1;
4626 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Elatin9::qq_char)*?) (\#) /cgox) { } 0 0 0
4627 0 $e_string .= e_qq($ope,$1,$3,$2);
4628 }
4629 else {
4630 0 my $e = '';
4631 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4632 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 (\') ((?:$Elatin9::qq_char)*?) (\') /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Elatin9::qq_char)*?) (\1) /cgox) { } 0 0 0
4633 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( )
4634 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { }
4635 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ]
4636 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < >
4637 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' '
4638 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * *
4639 }
4640 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4641 }
4642 }
4643  
4644 # q//
4645 elsif ($string =~ /\G \b (q) \b /oxgc) {
4646 0 my $ope = $1;
4647 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Elatin9::q_char)*?) (\#) /cgox) { } 0 0 0
4648 0 $e_string .= e_q($ope,$1,$3,$2);
4649 }
4650 else {
4651 0 my $e = '';
4652 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4653 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| $Elatin9::q_char)*?) (\1) /cgox) { } 0 0 0
4654 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( )
4655 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { }
4656 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ]
4657 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < >
4658 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * *
4659 }
4660 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4661 }
4662 }
4663  
4664 # ''
4665 0 elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('',$1,$3,$2); }
4666  
4667 # ""
4668 0 elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4669  
4670 # ``
4671 0 elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4672  
4673 # other any character
4674 213 elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; }
4675  
4676 # system error
4677 else {
4678 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4679 }
4680 }
4681  
4682 19 return $e_string;
4683 }
4684  
4685 #
4686 # character class
4687 #
4688 1920 ▶sub character_class {
Subroutine character_class: called CC=3 SCAR=11.0
Pod undocumented
4689 1920 my($char,$modifier) = @_;
4690  
4691 1920 ▶ if ($char eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '.') { } 52 1868 1920
4692 52 ▶ if ($modifier =~ /s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/) { } 17 35 52
4693 17 return '${Elatin9::dot_s}';
4694 }
4695 else {
4696 35 return '${Elatin9::dot}';
4697 }
4698 }
4699 else {
4700 1868 return Elatin9::classic_character_class($char);
4701 }
4702 }
4703  
4704 #
4705 # escape capture ($1, $2, $3, ...)
4706 #
4707 212 ▶sub e_capture {
Subroutine e_capture: called CC=1 SCAR=0.0
Pod undocumented
4708  
4709 212 return join '', '${', $_[0], '}';
4710 }
4711  
4712 #
4713 # escape transliteration (tr/// or y///)
4714 #
4715 4 ▶sub e_tr {
Subroutine e_tr: called CC=5 SCAR=16.8
Pod undocumented
4716 4 my($variable,$charclass,$e,$charclass2,$modifier) = @_;
4717 4 my $e_tr = '';
4718 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
4719  
4720 4 $slash = 'div';
4721  
4722 # quote character class 1
4723 4 $charclass = q_tr($charclass);
4724  
4725 # quote character class 2
4726 4 $charclass2 = q_tr($charclass2);
4727  
4728 # /b /B modifier
4729 4 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) { } 0 4 4
4730 0 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 0 0 0
4731 0 $e_tr = qq{tr$charclass$e$charclass2$modifier};
4732 }
4733 else {
4734 0 $e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier};
4735 }
4736 }
4737 else {
4738 4 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 2 2 4
4739 2 $e_tr = qq{Elatin9::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')};
4740 }
4741 else {
4742 2 $e_tr = qq{Elatin9::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')};
4743 }
4744 }
4745  
4746 # clear tr/// variable
4747 4 $tr_variable = '';
4748 4 $bind_operator = '';
4749  
4750 4 return $e_tr;
4751 }
4752  
4753 #
4754 # quote for escape transliteration (tr/// or y///)
4755 #
4756 8 ▶sub q_tr {
Subroutine q_tr: called CC=9 SCAR=40.6
Pod undocumented
4757 8 my($charclass) = @_;
4758  
4759 # quote character class
4760 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
4761 8 return e_q('', "'", "'", $charclass); # --> q' '
4762 }
4763 elsif ($charclass !~ /\//oxms) {
4764 0 return e_q('q', '/', '/', $charclass); # --> q/ /
4765 }
4766 elsif ($charclass !~ /\#/oxms) {
4767 0 return e_q('q', '#', '#', $charclass); # --> q# #
4768 }
4769 elsif ($charclass !~ /[\<\>]/oxms) {
4770 0 return e_q('q', '<', '>', $charclass); # --> q< >
4771 }
4772 elsif ($charclass !~ /[\(\)]/oxms) {
4773 0 return e_q('q', '(', ')', $charclass); # --> q( )
4774 }
4775 elsif ($charclass !~ /[\{\}]/oxms) {
4776 0 return e_q('q', '{', '}', $charclass); # --> q{ }
4777 }
4778 else {
4779 0 for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
4780 0 ▶ if ($charclass !~ /\Q$char\E/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($charclass =~ /\Q$char\E/msx) 0 0 0
4781 0 return e_q('q', $char, $char, $charclass);
4782 }
4783 }
4784 }
4785  
4786 0 return e_q('q', '{', '}', $charclass);
4787 }
4788  
4789 #
4790 # escape q string (q//, '')
4791 #
4792 1623 ▶sub e_q {
Subroutine e_q: called CC=1 SCAR=0.0
Pod undocumented
4793 1623 my($ope,$delimiter,$end_delimiter,$string) = @_;
4794  
4795 1623 $slash = 'div';
4796  
4797 1623 return join '', $ope, $delimiter, $string, $end_delimiter;
4798 }
4799  
4800 #
4801 # escape qq string (qq//, "", qx//, ``)
4802 #
4803 4221 ▶sub e_qq {
Subroutine e_qq: called CC=37 SCAR=50.9
Pod undocumented
4804 4221 my($ope,$delimiter,$end_delimiter,$string) = @_;
4805  
4806 4221 $slash = 'div';
4807  
4808 4221 my $left_e = 0;
4809 4221 my $right_e = 0;
4810  
4811 # split regexp
4812 4221 my @char = $string =~ /\G((?>
4813 [^\\\$] |
4814 \\x\{ (?>[0-9A-Fa-f]+) \} |
4815 \\o\{ (?>[0-7]+) \} |
4816 \\N\{ (?>[^0-9\}][^\}]*) \} |
4817 \\ $q_char |
4818 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
4819 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
4820 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
4821 \$ (?>\s* [0-9]+) |
4822 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
4823 \$ \$ (?![\w\{]) |
4824 \$ (?>\s*) \$ (?>\s*) $qq_variable |
4825 $q_char
4826 ))/oxmsg;
4827  
4828 4221 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 116677 4221 120898
4829  
4830 # "\L\u" --> "\u\L"
4831 116677 ▶ 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 116677 116677
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 116677 116677
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 116676 116677
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 116675 116676
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 116675 116675
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
11667700
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
4832 0 @char[$i,$i+1] = @char[$i+1,$i];
4833 }
4834  
4835 # "\U\l" --> "\l\U"
4836 ▶ 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
11667700
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
4837 0 @char[$i,$i+1] = @char[$i+1,$i];
4838 }
4839  
4840 # octal escape sequence
4841 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
4842 1 $char[$i] = Elatin9::octchr($1);
4843 }
4844  
4845 # hexadecimal escape sequence
4846 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
4847 1 $char[$i] = Elatin9::hexchr($1);
4848 }
4849  
4850 # \N{CHARNAME} --> N{CHARNAME}
4851 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
4852 0 $char[$i] = $1;
4853 }
4854  
4855 116677 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 484 116193 116677
elsif ($char[$i] eq '\\u') { } 0 116193 116193
elsif ($char[$i] eq '\\l') { } 0 116193 116193
elsif ($char[$i] eq '\\U') { } 0 116193 116193
elsif ($char[$i] eq '\\L') { } 0 116193 116193
elsif ($char[$i] eq '\\F') { } 24 116169 116193
elsif ($char[$i] eq '\\Q') { } 0 116169 116169
elsif ($char[$i] eq '\\E') { } 24 116145 116169
elsif ($char[$i] eq '\\Q') { } 0 116145 116145
elsif ($char[$i] eq '\\E') { } 0 116145 116145
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 4 116141 116145
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 116141 116141
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 116141 116141
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 205 115936 116141
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 115936 115936
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 115936 115936
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 115936 115936
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 115936 115936
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 44 115892 115936
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 45 115847 115892
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 33 115814 115847
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 115814 115814
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 115814 115814
4856 }
4857  
4858 # \F
4859 #
4860 # P.69 Table 2-6. Translation escapes
4861 # in Chapter 2: Bits and Pieces
4862 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4863 # (and so on)
4864  
4865 # \u \l \U \L \F \Q \E
4866 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
4867 484 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 484 484
4868 0 $char[$i] = '\\' . $char[$i];
4869 }
4870 }
4871 elsif ($char[$i] eq '\u') {
4872  
4873 # "STRING @{[ LIST EXPR ]} MORE STRING"
4874  
4875 # P.257 Other Tricks You Can Do with Hard References
4876 # in Chapter 8: References
4877 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4878  
4879 # P.353 Other Tricks You Can Do with Hard References
4880 # in Chapter 8: References
4881 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4882  
4883 # (and so on)
4884  
4885 0 $char[$i] = '@{[Elatin9::ucfirst qq<';
4886 0 $left_e++;
4887 }
4888 elsif ($char[$i] eq '\l') {
4889 0 $char[$i] = '@{[Elatin9::lcfirst qq<';
4890 0 $left_e++;
4891 }
4892 elsif ($char[$i] eq '\U') {
4893 0 $char[$i] = '@{[Elatin9::uc qq<';
4894 0 $left_e++;
4895 }
4896 elsif ($char[$i] eq '\L') {
4897 0 $char[$i] = '@{[Elatin9::lc qq<';
4898 0 $left_e++;
4899 }
4900 elsif ($char[$i] eq '\F') {
4901 24 $char[$i] = '@{[Elatin9::fc qq<';
4902 24 $left_e++;
4903 }
4904 elsif ($char[$i] eq '\Q') {
4905 0 $char[$i] = '@{[CORE::quotemeta qq<';
4906 0 $left_e++;
4907 }
4908 elsif ($char[$i] eq '\E') {
4909 24 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 24 0 24
4910 24 $char[$i] = '>]}';
4911 24 $right_e++;
4912 }
4913 else {
4914 0 $char[$i] = '';
4915 }
4916 }
4917 elsif ($char[$i] eq '\Q') {
4918 0 while (1) {
4919 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
4920 0 last;
4921 }
4922 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
4923 0 last;
4924 }
4925 }
4926 }
4927 elsif ($char[$i] eq '\E') {
4928 }
4929  
4930 # $0 --> $0
4931 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
4932 }
4933 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
4934 }
4935  
4936 # $$ --> $$
4937 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
4938 }
4939  
4940 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4941 # $1, $2, $3 --> $1, $2, $3 otherwise
4942 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
4943 205 $char[$i] = e_capture($1);
4944 }
4945 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
4946 0 $char[$i] = e_capture($1);
4947 }
4948  
4949 # $$foo[ ... ] --> $ $foo->[ ... ]
4950 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
4951 0 $char[$i] = e_capture($1.'->'.$2);
4952 }
4953  
4954 # $$foo{ ... } --> $ $foo->{ ... }
4955 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
4956 0 $char[$i] = e_capture($1.'->'.$2);
4957 }
4958  
4959 # $$foo
4960 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
4961 0 $char[$i] = e_capture($1);
4962 }
4963  
4964 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
4965 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
4966 44 $char[$i] = '@{[Elatin9::PREMATCH()]}';
4967 }
4968  
4969 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
4970 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
4971 45 $char[$i] = '@{[Elatin9::MATCH()]}';
4972 }
4973  
4974 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
4975 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
4976 33 $char[$i] = '@{[Elatin9::POSTMATCH()]}';
4977 }
4978  
4979 # ${ foo } --> ${ foo }
4980 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
4981 }
4982  
4983 # ${ ... }
4984 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
4985 0 $char[$i] = e_capture($1);
4986 }
4987 }
4988  
4989 # return string
4990 4221 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 4221 4221
4991 0 return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter;
4992 }
4993 4221 return join '', $ope, $delimiter, @char, $end_delimiter;
4994 }
4995  
4996 #
4997 # escape qw string (qw//)
4998 #
4999 16 ▶sub e_qw {
Subroutine e_qw: called CC=11 SCAR=43.1
Pod undocumented
5000 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
5001  
5002 16 $slash = 'div';
5003  
5004 # choice again delimiter
5005 16 my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg);
5006 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
5007 16 return join '', $ope, $delimiter, $string, $end_delimiter;
5008 }
5009 elsif (not $octet{')'}) {
5010 0 return join '', $ope, '(', $string, ')';
5011 }
5012 elsif (not $octet{'}'}) {
5013 0 return join '', $ope, '{', $string, '}';
5014 }
5015 elsif (not $octet{']'}) {
5016 0 return join '', $ope, '[', $string, ']';
5017 }
5018 elsif (not $octet{'>'}) {
5019 0 return join '', $ope, '<', $string, '>';
5020 }
5021 else {
5022 0 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5023 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5024 0 return join '', $ope, $char, $string, $char;
5025 }
5026 }
5027 }
5028  
5029 # qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC')
5030 0 my @string = CORE::split(/\s+/, $string);
5031 0 for my $string (@string) {
5032 0 my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5033 0 for my $octet (@octet) {
5034 0 ▶ if ($octet =~ /\A (['\\]) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet =~ /\A (['\\]) \z/mosx) 0 0 0
5035 0 $octet = '\\' . $1;
5036 }
5037 }
5038 0 $string = join '', @octet;
5039 }
5040 0 return join '', '(', (join ', ', map { "'$_'" } @string), ')';
5041 }
5042  
5043 #
5044 # escape here document (<<"HEREDOC", <<HEREDOC, <<`HEREDOC`, <<~"HEREDOC", <<~HEREDOC, <<~`HEREDOC`)
5045 #
5046 93 ▶sub e_heredoc {
Subroutine e_heredoc: called CC=37 SCAR=56.3
Pod undocumented
5047 93 my($string) = @_;
5048  
5049 93 $slash = 'm//';
5050  
5051 93 my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC`
5052  
5053 93 my $left_e = 0;
5054 93 my $right_e = 0;
5055  
5056 # split regexp
5057 93 my @char = $string =~ /\G((?>
5058 [^\\\$] |
5059 \\x\{ (?>[0-9A-Fa-f]+) \} |
5060 \\o\{ (?>[0-7]+) \} |
5061 \\N\{ (?>[^0-9\}][^\}]*) \} |
5062 \\ $q_char |
5063 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5064 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5065 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5066 \$ (?>\s* [0-9]+) |
5067 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5068 \$ \$ (?![\w\{]) |
5069 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5070 $q_char
5071 ))/oxmsg;
5072  
5073 93 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 3177 93 3270
5074  
5075 # "\L\u" --> "\u\L"
5076 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
5077 0 @char[$i,$i+1] = @char[$i+1,$i];
5078 }
5079  
5080 # "\U\l" --> "\l\U"
5081 ▶ 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
5082 0 @char[$i,$i+1] = @char[$i+1,$i];
5083 }
5084  
5085 # octal escape sequence
5086 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5087 1 $char[$i] = Elatin9::octchr($1);
5088 }
5089  
5090 # hexadecimal escape sequence
5091 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5092 1 $char[$i] = Elatin9::hexchr($1);
5093 }
5094  
5095 # \N{CHARNAME} --> N{CHARNAME}
5096 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5097 0 $char[$i] = $1;
5098 }
5099  
5100 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
5101 }
5102  
5103 # \u \l \U \L \F \Q \E
5104 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5105 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
5106 0 $char[$i] = '\\' . $char[$i];
5107 }
5108 }
5109 elsif ($char[$i] eq '\u') {
5110 0 $char[$i] = '@{[Elatin9::ucfirst qq<';
5111 0 $left_e++;
5112 }
5113 elsif ($char[$i] eq '\l') {
5114 0 $char[$i] = '@{[Elatin9::lcfirst qq<';
5115 0 $left_e++;
5116 }
5117 elsif ($char[$i] eq '\U') {
5118 0 $char[$i] = '@{[Elatin9::uc qq<';
5119 0 $left_e++;
5120 }
5121 elsif ($char[$i] eq '\L') {
5122 0 $char[$i] = '@{[Elatin9::lc qq<';
5123 0 $left_e++;
5124 }
5125 elsif ($char[$i] eq '\F') {
5126 0 $char[$i] = '@{[Elatin9::fc qq<';
5127 0 $left_e++;
5128 }
5129 elsif ($char[$i] eq '\Q') {
5130 0 $char[$i] = '@{[CORE::quotemeta qq<';
5131 0 $left_e++;
5132 }
5133 elsif ($char[$i] eq '\E') {
5134 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
5135 0 $char[$i] = '>]}';
5136 0 $right_e++;
5137 }
5138 else {
5139 0 $char[$i] = '';
5140 }
5141 }
5142 elsif ($char[$i] eq '\Q') {
5143 0 while (1) {
5144 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5145 0 last;
5146 }
5147 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5148 0 last;
5149 }
5150 }
5151 }
5152 elsif ($char[$i] eq '\E') {
5153 }
5154  
5155 # $0 --> $0
5156 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5157 }
5158 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5159 }
5160  
5161 # $$ --> $$
5162 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5163 }
5164  
5165 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5166 # $1, $2, $3 --> $1, $2, $3 otherwise
5167 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5168 0 $char[$i] = e_capture($1);
5169 }
5170 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5171 0 $char[$i] = e_capture($1);
5172 }
5173  
5174 # $$foo[ ... ] --> $ $foo->[ ... ]
5175 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5176 0 $char[$i] = e_capture($1.'->'.$2);
5177 }
5178  
5179 # $$foo{ ... } --> $ $foo->{ ... }
5180 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5181 0 $char[$i] = e_capture($1.'->'.$2);
5182 }
5183  
5184 # $$foo
5185 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5186 0 $char[$i] = e_capture($1);
5187 }
5188  
5189 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
5190 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5191 8 $char[$i] = '@{[Elatin9::PREMATCH()]}';
5192 }
5193  
5194 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
5195 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5196 8 $char[$i] = '@{[Elatin9::MATCH()]}';
5197 }
5198  
5199 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
5200 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5201 6 $char[$i] = '@{[Elatin9::POSTMATCH()]}';
5202 }
5203  
5204 # ${ foo } --> ${ foo }
5205 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5206 }
5207  
5208 # ${ ... }
5209 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5210 0 $char[$i] = e_capture($1);
5211 }
5212 }
5213  
5214 # return string
5215 93 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 93 93
5216 0 return join '', @char, '>]}' x ($left_e - $right_e);
5217 }
5218 93 return join '', @char;
5219 }
5220  
5221 #
5222 # escape regexp (m//, qr//)
5223 #
5224 880 ▶sub e_qr {
Subroutine e_qr: called CC=110 SCAR=73.6
Pod undocumented
5225 880 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5226 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
5227  
5228 880 $modifier =~ tr/p//d;
5229 880 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 880 880
5230 0 my $line = 0;
5231 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5232 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5233 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5234 0 last;
5235 }
5236 }
5237 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5238 }
5239  
5240 880 $slash = 'div';
5241  
5242 # literal null string pattern
5243 880 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 872 880
elsif ($modifier =~ tr/Bb//d) { } 2 870 872
5244 8 $modifier =~ tr/bB//d;
5245 8 $modifier =~ tr/i//d;
5246 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5247 }
5248  
5249 # /b /B modifier
5250 elsif ($modifier =~ tr/bB//d) {
5251  
5252 # choice again delimiter
5253 2 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 2 2
5254 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5255 0 my %octet = map {$_ => 1} @char;
5256 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
5257 0 $delimiter = '(';
5258 0 $end_delimiter = ')';
5259 }
5260 elsif (not $octet{'}'}) {
5261 0 $delimiter = '{';
5262 0 $end_delimiter = '}';
5263 }
5264 elsif (not $octet{']'}) {
5265 0 $delimiter = '[';
5266 0 $end_delimiter = ']';
5267 }
5268 elsif (not $octet{'>'}) {
5269 0 $delimiter = '<';
5270 0 $end_delimiter = '>';
5271 }
5272 else {
5273 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5274 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5275 0 $delimiter = $char;
5276 0 $end_delimiter = $char;
5277 0 last;
5278 }
5279 }
5280 }
5281 }
5282  
5283 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
5284 0 return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier;
5285 }
5286 else {
5287 2 return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5288 }
5289 }
5290  
5291 870 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 312 558 870
5292 870 my $metachar = qr/[\@\\|[\]{^]/oxms;
5293  
5294 # split regexp
5295 870 my @char = $string =~ /\G((?>
5296 [^\\\$\@\[\(] |
5297 \\x (?>[0-9A-Fa-f]{1,2}) |
5298 \\ (?>[0-7]{2,3}) |
5299 \\c [\x40-\x5F] |
5300 \\x\{ (?>[0-9A-Fa-f]+) \} |
5301 \\o\{ (?>[0-7]+) \} |
5302 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5303 \\ $q_char |
5304 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5305 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5306 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5307 [\$\@] $qq_variable |
5308 \$ (?>\s* [0-9]+) |
5309 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5310 \$ \$ (?![\w\{]) |
5311 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5312 \[\^ |
5313 \[\: (?>[a-z]+) :\] |
5314 \[\:\^ (?>[a-z]+) :\] |
5315 \(\? |
5316 $q_char
5317 ))/oxmsg;
5318  
5319 # choice again delimiter
5320 870 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 870 870
5321 0 my %octet = map {$_ => 1} @char;
5322 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
5323 0 $delimiter = '(';
5324 0 $end_delimiter = ')';
5325 }
5326 elsif (not $octet{'}'}) {
5327 0 $delimiter = '{';
5328 0 $end_delimiter = '}';
5329 }
5330 elsif (not $octet{']'}) {
5331 0 $delimiter = '[';
5332 0 $end_delimiter = ']';
5333 }
5334 elsif (not $octet{'>'}) {
5335 0 $delimiter = '<';
5336 0 $end_delimiter = '>';
5337 }
5338 else {
5339 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5340 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5341 0 $delimiter = $char;
5342 0 $end_delimiter = $char;
5343 0 last;
5344 }
5345 }
5346 }
5347 }
5348  
5349 870 my $left_e = 0;
5350 870 my $right_e = 0;
5351 870 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2100 870 2970
5352  
5353 # "\L\u" --> "\u\L"
5354 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
5355 0 @char[$i,$i+1] = @char[$i+1,$i];
5356 }
5357  
5358 # "\U\l" --> "\l\U"
5359 ▶ 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
5360 0 @char[$i,$i+1] = @char[$i+1,$i];
5361 }
5362  
5363 # octal escape sequence
5364 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5365 1 $char[$i] = Elatin9::octchr($1);
5366 }
5367  
5368 # hexadecimal escape sequence
5369 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5370 1 $char[$i] = Elatin9::hexchr($1);
5371 }
5372  
5373 # \b{...} --> b\{...}
5374 # \B{...} --> B\{...}
5375 # \N{CHARNAME} --> N\{CHARNAME}
5376 # \p{PROPERTY} --> p\{PROPERTY}
5377 # \P{PROPERTY} --> P\{PROPERTY}
5378 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5379 6 $char[$i] = $1 . '\\' . $2;
5380 }
5381  
5382 # \p, \P, \X --> p, P, X
5383 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
5384 4 $char[$i] = $1;
5385 }
5386  
5387 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 &Elatin9::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
5388 }
5389  
5390 # join separated multiple-octet
5391 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
5392 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5393 0 $char[$i] .= join '', splice @char, $i+1, 3;
5394 }
5395 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5396 0 $char[$i] .= join '', splice @char, $i+1, 2;
5397 }
5398 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5399 0 $char[$i] .= join '', splice @char, $i+1, 1;
5400 }
5401 }
5402  
5403 # open character class [...]
5404 elsif ($char[$i] eq '[') {
5405 556 my $left = $i;
5406  
5407 # [] make die "Unmatched [] in regexp ...\n"
5408 # (and so on)
5409  
5410 556 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 3 553 556
5411 3 $i++;
5412 }
5413  
5414 556 while (1) {
5415 2063 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 2063 2063
5416 0 die __FILE__, ": Unmatched [] in regexp\n";
5417 }
5418 2063 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 556 1507 2063
5419 556 my $right = $i;
5420  
5421 # [...]
5422 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
5423 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5424 }
5425 else {
5426 526 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
5427 }
5428  
5429 556 $i = $left;
5430 556 last;
5431 }
5432 }
5433 }
5434  
5435 # open character class [^...]
5436 elsif ($char[$i] eq '[^') {
5437 74 my $left = $i;
5438  
5439 # [^] make die "Unmatched [] in regexp ...\n"
5440 # (and so on)
5441  
5442 74 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 4 70 74
5443 4 $i++;
5444 }
5445  
5446 74 while (1) {
5447 272 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 272 272
5448 0 die __FILE__, ": Unmatched [] in regexp\n";
5449 }
5450 272 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 74 198 272
5451 74 my $right = $i;
5452  
5453 # [^...]
5454 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
5455 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5456 }
5457 else {
5458 44 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5459 }
5460  
5461 74 $i = $left;
5462 74 last;
5463 }
5464 }
5465 }
5466  
5467 # rewrite character class or escape character
5468 elsif (my $char = character_class($char[$i],$modifier)) {
5469 139 $char[$i] = $char;
5470 }
5471  
5472 # /i modifier
5473 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition100%6/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5474 20 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 20 0 20
5475 20 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
5476 }
5477 else {
5478 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
5479 }
5480 }
5481  
5482 # \u \l \U \L \F \Q \E
5483 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
5484 1 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 1 1
5485 0 $char[$i] = '\\' . $char[$i];
5486 }
5487 }
5488 elsif ($char[$i] eq '\u') {
5489 0 $char[$i] = '@{[Elatin9::ucfirst qq<';
5490 0 $left_e++;
5491 }
5492 elsif ($char[$i] eq '\l') {
5493 0 $char[$i] = '@{[Elatin9::lcfirst qq<';
5494 0 $left_e++;
5495 }
5496 elsif ($char[$i] eq '\U') {
5497 1 $char[$i] = '@{[Elatin9::uc qq<';
5498 1 $left_e++;
5499 }
5500 elsif ($char[$i] eq '\L') {
5501 1 $char[$i] = '@{[Elatin9::lc qq<';
5502 1 $left_e++;
5503 }
5504 elsif ($char[$i] eq '\F') {
5505 18 $char[$i] = '@{[Elatin9::fc qq<';
5506 18 $left_e++;
5507 }
5508 elsif ($char[$i] eq '\Q') {
5509 1 $char[$i] = '@{[CORE::quotemeta qq<';
5510 1 $left_e++;
5511 }
5512 elsif ($char[$i] eq '\E') {
5513 21 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 21 0 21
5514 21 $char[$i] = '>]}';
5515 21 $right_e++;
5516 }
5517 else {
5518 0 $char[$i] = '';
5519 }
5520 }
5521 elsif ($char[$i] eq '\Q') {
5522 0 while (1) {
5523 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5524 0 last;
5525 }
5526 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5527 0 last;
5528 }
5529 }
5530 }
5531 elsif ($char[$i] eq '\E') {
5532 }
5533  
5534 # $0 --> $0
5535 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5536 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5537 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5538 }
5539 }
5540 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5541 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5542 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5543 }
5544 }
5545  
5546 # $$ --> $$
5547 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5548 }
5549  
5550 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5551 # $1, $2, $3 --> $1, $2, $3 otherwise
5552 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5553 0 $char[$i] = e_capture($1);
5554 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5555 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5556 }
5557 }
5558 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5559 0 $char[$i] = e_capture($1);
5560 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5561 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5562 }
5563 }
5564  
5565 # $$foo[ ... ] --> $ $foo->[ ... ]
5566 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5567 0 $char[$i] = e_capture($1.'->'.$2);
5568 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5569 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5570 }
5571 }
5572  
5573 # $$foo{ ... } --> $ $foo->{ ... }
5574 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5575 0 $char[$i] = e_capture($1.'->'.$2);
5576 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5577 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5578 }
5579 }
5580  
5581 # $$foo
5582 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5583 0 $char[$i] = e_capture($1);
5584 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5585 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5586 }
5587 }
5588  
5589 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
5590 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5591 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5592 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::PREMATCH())]}';
5593 }
5594 else {
5595 8 $char[$i] = '@{[Elatin9::PREMATCH()]}';
5596 }
5597 }
5598  
5599 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
5600 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5601 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5602 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::MATCH())]}';
5603 }
5604 else {
5605 8 $char[$i] = '@{[Elatin9::MATCH()]}';
5606 }
5607 }
5608  
5609 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
5610 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5611 6 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 6 6
5612 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::POSTMATCH())]}';
5613 }
5614 else {
5615 6 $char[$i] = '@{[Elatin9::POSTMATCH()]}';
5616 }
5617 }
5618  
5619 # ${ foo }
5620 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
5621 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5622 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5623 }
5624 }
5625  
5626 # ${ ... }
5627 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5628 0 $char[$i] = e_capture($1);
5629 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5630 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5631 }
5632 }
5633  
5634 # $scalar or @array
5635 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
5636 21 $char[$i] = e_string($char[$i]);
5637 21 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 11 10 21
5638 11 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
5639 }
5640 }
5641  
5642 # quote character before ? + * {
5643 ▶ 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
5644 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
5645 }
5646 ▶ 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
5647 0 my $char = $char[$i-1];
5648 0 ▶ if ($char[$i] eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq '{') { } 0 0 0
5649 0 die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n};
5650 }
5651 else {
5652 0 die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n};
5653 }
5654 }
5655 else {
5656 127 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5657 }
5658 }
5659 }
5660  
5661 # make regexp string
5662 870 $modifier =~ tr/i//d;
5663 870 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 870 870
5664 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
5665 0 return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier;
5666 }
5667 else {
5668 0 return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
5669 }
5670 }
5671 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
5672 0 return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier;
5673 }
5674 else {
5675 870 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5676 }
5677 }
5678  
5679 #
5680 # double quote stuff
5681 #
5682 180 ▶sub qq_stuff {
Subroutine qq_stuff: called CC=6 SCAR=18.5
Pod undocumented
5683 180 my($delimiter,$end_delimiter,$stuff) = @_;
5684  
5685 # scalar variable or array variable
5686 180 ▶ if ($stuff =~ /\A [\$\@] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff =~ /\A [\$\@] /mosx) 100 80 180
5687 100 return $stuff;
5688 }
5689  
5690 # quote by delimiter
5691 80 my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg);
5692 80 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5693 80 ▶ next if $char eq $delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $delimiter 0 80 80
5694 80 ▶ next if $char eq $end_delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $end_delimiter 0 80 80
5695 80 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 80 0 80
5696 80 return join '', 'qq', $char, $stuff, $char;
5697 }
5698 }
5699 0 return join '', 'qq', '<', $stuff, '>';
5700 }
5701  
5702 #
5703 # escape regexp (m'', qr'', and m''b, qr''b)
5704 #
5705 10 ▶sub e_qr_q {
Subroutine e_qr_q: called CC=7 SCAR=25.3
Pod undocumented
5706 10 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5707 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
5708  
5709 10 $modifier =~ tr/p//d;
5710 10 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 10 10
5711 0 my $line = 0;
5712 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5713 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5714 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5715 0 last;
5716 }
5717 }
5718 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5719 }
5720  
5721 10 $slash = 'div';
5722  
5723 # literal null string pattern
5724 10 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 2 10
elsif ($modifier =~ tr/Bb//d) { } 0 2 2
5725 8 $modifier =~ tr/bB//d;
5726 8 $modifier =~ tr/i//d;
5727 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5728 }
5729  
5730 # with /b /B modifier
5731 elsif ($modifier =~ tr/bB//d) {
5732 0 return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
5733 }
5734  
5735 # without /b /B modifier
5736 else {
5737 2 return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
5738 }
5739 }
5740  
5741 #
5742 # escape regexp (m'', qr'')
5743 #
5744 2 ▶sub e_qr_qt {
Subroutine e_qr_qt: called CC=20 SCAR=51.8
Pod undocumented
5745 2 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5746  
5747 2 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 2 2
5748  
5749 # split regexp
5750 2 my @char = $string =~ /\G((?>
5751 [^\\\[\$\@\/] |
5752 [\x00-\xFF] |
5753 \[\^ |
5754 \[\: (?>[a-z]+) \:\] |
5755 \[\:\^ (?>[a-z]+) \:\] |
5756 [\$\@\/] |
5757 \\ (?:$q_char) |
5758 (?:$q_char)
5759 ))/oxmsg;
5760  
5761 # unescape character
5762 2 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2 2 4
5763 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 &Elatin9::uc($char[$i]) ne &fc($char[$i])) { } 0 2 2
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 4 4
5764 }
5765  
5766 # open character class [...]
5767 elsif ($char[$i] eq '[') {
5768 0 my $left = $i;
5769 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5770 0 $i++;
5771 }
5772 0 while (1) {
5773 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5774 0 die __FILE__, ": Unmatched [] in regexp\n";
5775 }
5776 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5777 0 my $right = $i;
5778  
5779 # [...]
5780 0 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
5781  
5782 0 $i = $left;
5783 0 last;
5784 }
5785 }
5786 }
5787  
5788 # open character class [^...]
5789 elsif ($char[$i] eq '[^') {
5790 0 my $left = $i;
5791 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5792 0 $i++;
5793 }
5794 0 while (1) {
5795 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5796 0 die __FILE__, ": Unmatched [] in regexp\n";
5797 }
5798 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5799 0 my $right = $i;
5800  
5801 # [^...]
5802 0 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5803  
5804 0 $i = $left;
5805 0 last;
5806 }
5807 }
5808 }
5809  
5810 # escape $ @ / and \
5811 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5812 0 $char[$i] = '\\' . $char[$i];
5813 }
5814  
5815 # rewrite character class or escape character
5816 elsif (my $char = character_class($char[$i],$modifier)) {
5817 0 $char[$i] = $char;
5818 }
5819  
5820 # /i modifier
5821 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5822 0 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
5823 0 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
5824 }
5825 else {
5826 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
5827 }
5828 }
5829  
5830 # quote character before ? + * {
5831 ▶ 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
5832 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
5833 }
5834 else {
5835 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5836 }
5837 }
5838 }
5839  
5840 2 $delimiter = '/';
5841 2 $end_delimiter = '/';
5842  
5843 2 $modifier =~ tr/i//d;
5844 2 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5845 }
5846  
5847 #
5848 # escape regexp (m''b, qr''b)
5849 #
5850 0 ▶sub e_qr_qb {
Subroutine e_qr_qb: not called CC=4 SCAR=30.0
Pod undocumented
5851 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5852  
5853 # split regexp
5854 0 my @char = $string =~ /\G ((?>[^\\]|\\\\)) /oxmsg;
5855  
5856 # unescape character
5857 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
5858 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
5859 }
5860  
5861 # remain \\
5862 elsif ($char[$i] eq '\\\\') {
5863 }
5864  
5865 # escape $ @ / and \
5866 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5867 0 $char[$i] = '\\' . $char[$i];
5868 }
5869 }
5870  
5871 0 $delimiter = '/';
5872 0 $end_delimiter = '/';
5873 0 return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5874 }
5875  
5876 #
5877 # escape regexp (s/here//)
5878 #
5879 80 ▶sub e_s1 {
Subroutine e_s1: called CC=106 SCAR=81.1
Pod undocumented
5880 80 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5881 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
5882  
5883 80 $modifier =~ tr/p//d;
5884 80 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 80 80
5885 0 my $line = 0;
5886 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5887 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5888 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5889 0 last;
5890 }
5891 }
5892 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5893 }
5894  
5895 80 $slash = 'div';
5896  
5897 # literal null string pattern
5898 80 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 72 80
elsif ($modifier =~ tr/Bb//d) { } 0 72 72
5899 8 $modifier =~ tr/bB//d;
5900 8 $modifier =~ tr/i//d;
5901 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5902 }
5903  
5904 # /b /B modifier
5905 elsif ($modifier =~ tr/bB//d) {
5906  
5907 # choice again delimiter
5908 0 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 0 0
5909 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5910 0 my %octet = map {$_ => 1} @char;
5911 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
5912 0 $delimiter = '(';
5913 0 $end_delimiter = ')';
5914 }
5915 elsif (not $octet{'}'}) {
5916 0 $delimiter = '{';
5917 0 $end_delimiter = '}';
5918 }
5919 elsif (not $octet{']'}) {
5920 0 $delimiter = '[';
5921 0 $end_delimiter = ']';
5922 }
5923 elsif (not $octet{'>'}) {
5924 0 $delimiter = '<';
5925 0 $end_delimiter = '>';
5926 }
5927 else {
5928 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5929 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5930 0 $delimiter = $char;
5931 0 $end_delimiter = $char;
5932 0 last;
5933 }
5934 }
5935 }
5936 }
5937  
5938 0 my $prematch = '';
5939 0 return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5940 }
5941  
5942 72 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 1 71 72
5943 72 my $metachar = qr/[\@\\|[\]{^]/oxms;
5944  
5945 # split regexp
5946 72 my @char = $string =~ /\G((?>
5947 [^\\\$\@\[\(] |
5948 \\ (?>[1-9][0-9]*) |
5949 \\g (?>\s*) (?>[1-9][0-9]*) |
5950 \\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5951 \\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5952 \\x (?>[0-9A-Fa-f]{1,2}) |
5953 \\ (?>[0-7]{2,3}) |
5954 \\c [\x40-\x5F] |
5955 \\x\{ (?>[0-9A-Fa-f]+) \} |
5956 \\o\{ (?>[0-7]+) \} |
5957 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5958 \\ $q_char |
5959 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5960 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5961 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5962 [\$\@] $qq_variable |
5963 \$ (?>\s* [0-9]+) |
5964 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5965 \$ \$ (?![\w\{]) |
5966 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5967 \[\^ |
5968 \[\: (?>[a-z]+) :\] |
5969 \[\:\^ (?>[a-z]+) :\] |
5970 \(\? |
5971 $q_char
5972 ))/oxmsg;
5973  
5974 # choice again delimiter
5975 72 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 72 72
5976 0 my %octet = map {$_ => 1} @char;
5977 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
5978 0 $delimiter = '(';
5979 0 $end_delimiter = ')';
5980 }
5981 elsif (not $octet{'}'}) {
5982 0 $delimiter = '{';
5983 0 $end_delimiter = '}';
5984 }
5985 elsif (not $octet{']'}) {
5986 0 $delimiter = '[';
5987 0 $end_delimiter = ']';
5988 }
5989 elsif (not $octet{'>'}) {
5990 0 $delimiter = '<';
5991 0 $end_delimiter = '>';
5992 }
5993 else {
5994 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5995 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5996 0 $delimiter = $char;
5997 0 $end_delimiter = $char;
5998 0 last;
5999 }
6000 }
6001 }
6002 }
6003  
6004 # count '('
6005 72 my $parens = grep { $_ eq '(' } @char;
6006  
6007 72 my $left_e = 0;
6008 72 my $right_e = 0;
6009 72 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 200 72 272
6010  
6011 # "\L\u" --> "\u\L"
6012 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
6013 0 @char[$i,$i+1] = @char[$i+1,$i];
6014 }
6015  
6016 # "\U\l" --> "\l\U"
6017 ▶ 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
6018 0 @char[$i,$i+1] = @char[$i+1,$i];
6019 }
6020  
6021 # octal escape sequence
6022 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6023 1 $char[$i] = Elatin9::octchr($1);
6024 }
6025  
6026 # hexadecimal escape sequence
6027 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6028 1 $char[$i] = Elatin9::hexchr($1);
6029 }
6030  
6031 # \b{...} --> b\{...}
6032 # \B{...} --> B\{...}
6033 # \N{CHARNAME} --> N\{CHARNAME}
6034 # \p{PROPERTY} --> p\{PROPERTY}
6035 # \P{PROPERTY} --> P\{PROPERTY}
6036 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6037 0 $char[$i] = $1 . '\\' . $2;
6038 }
6039  
6040 # \p, \P, \X --> p, P, X
6041 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6042 0 $char[$i] = $1;
6043 }
6044  
6045 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 &Elatin9::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
6046 }
6047  
6048 # join separated multiple-octet
6049 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6050 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6051 0 $char[$i] .= join '', splice @char, $i+1, 3;
6052 }
6053 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6054 0 $char[$i] .= join '', splice @char, $i+1, 2;
6055 }
6056 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6057 0 $char[$i] .= join '', splice @char, $i+1, 1;
6058 }
6059 }
6060  
6061 # open character class [...]
6062 elsif ($char[$i] eq '[') {
6063 17 my $left = $i;
6064 17 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 17 17
6065 0 $i++;
6066 }
6067 17 while (1) {
6068 74 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 74 74
6069 0 die __FILE__, ": Unmatched [] in regexp\n";
6070 }
6071 74 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 17 57 74
6072 17 my $right = $i;
6073  
6074 # [...]
6075 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
6076 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6077 }
6078 else {
6079 17 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
6080 }
6081  
6082 17 $i = $left;
6083 17 last;
6084 }
6085 }
6086 }
6087  
6088 # open character class [^...]
6089 elsif ($char[$i] eq '[^') {
6090 0 my $left = $i;
6091 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6092 0 $i++;
6093 }
6094 0 while (1) {
6095 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6096 0 die __FILE__, ": Unmatched [] in regexp\n";
6097 }
6098 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6099 0 my $right = $i;
6100  
6101 # [^...]
6102 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
6103 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6104 }
6105 else {
6106 0 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6107 }
6108  
6109 0 $i = $left;
6110 0 last;
6111 }
6112 }
6113 }
6114  
6115 # rewrite character class or escape character
6116 elsif (my $char = character_class($char[$i],$modifier)) {
6117 7 $char[$i] = $char;
6118 }
6119  
6120 # /i modifier
6121 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition66%4/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6122 3 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 3 0 3
6123 3 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
6124 }
6125 else {
6126 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
6127 }
6128 }
6129  
6130 # \u \l \U \L \F \Q \E
6131 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
6132 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6133 0 $char[$i] = '\\' . $char[$i];
6134 }
6135 }
6136 elsif ($char[$i] eq '\u') {
6137 0 $char[$i] = '@{[Elatin9::ucfirst qq<';
6138 0 $left_e++;
6139 }
6140 elsif ($char[$i] eq '\l') {
6141 0 $char[$i] = '@{[Elatin9::lcfirst qq<';
6142 0 $left_e++;
6143 }
6144 elsif ($char[$i] eq '\U') {
6145 0 $char[$i] = '@{[Elatin9::uc qq<';
6146 0 $left_e++;
6147 }
6148 elsif ($char[$i] eq '\L') {
6149 0 $char[$i] = '@{[Elatin9::lc qq<';
6150 0 $left_e++;
6151 }
6152 elsif ($char[$i] eq '\F') {
6153 0 $char[$i] = '@{[Elatin9::fc qq<';
6154 0 $left_e++;
6155 }
6156 elsif ($char[$i] eq '\Q') {
6157 0 $char[$i] = '@{[CORE::quotemeta qq<';
6158 0 $left_e++;
6159 }
6160 elsif ($char[$i] eq '\E') {
6161 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6162 0 $char[$i] = '>]}';
6163 0 $right_e++;
6164 }
6165 else {
6166 0 $char[$i] = '';
6167 }
6168 }
6169 elsif ($char[$i] eq '\Q') {
6170 0 while (1) {
6171 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6172 0 last;
6173 }
6174 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6175 0 last;
6176 }
6177 }
6178 }
6179 elsif ($char[$i] eq '\E') {
6180 }
6181  
6182 # \0 --> \0
6183 elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) {
6184 }
6185  
6186 # \g{N}, \g{-N}
6187  
6188 # P.108 Using Simple Patterns
6189 # in Chapter 7: In the World of Regular Expressions
6190 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
6191  
6192 # P.221 Capturing
6193 # in Chapter 5: Pattern Matching
6194 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6195  
6196 # \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3}
6197 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6198 }
6199  
6200 # \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable)
6201 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6202 }
6203  
6204 # \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable)
6205 elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6206 }
6207  
6208 # \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable)
6209 elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6210 }
6211  
6212 # $0 --> $0
6213 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6214 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6215 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6216 }
6217 }
6218 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6219 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6220 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6221 }
6222 }
6223  
6224 # $$ --> $$
6225 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6226 }
6227  
6228 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6229 # $1, $2, $3 --> $1, $2, $3 otherwise
6230 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6231 0 $char[$i] = e_capture($1);
6232 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6233 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6234 }
6235 }
6236 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6237 0 $char[$i] = e_capture($1);
6238 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6239 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6240 }
6241 }
6242  
6243 # $$foo[ ... ] --> $ $foo->[ ... ]
6244 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6245 0 $char[$i] = e_capture($1.'->'.$2);
6246 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6247 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6248 }
6249 }
6250  
6251 # $$foo{ ... } --> $ $foo->{ ... }
6252 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6253 0 $char[$i] = e_capture($1.'->'.$2);
6254 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6255 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6256 }
6257 }
6258  
6259 # $$foo
6260 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6261 0 $char[$i] = e_capture($1);
6262 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6263 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6264 }
6265 }
6266  
6267 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
6268 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6269 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6270 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::PREMATCH())]}';
6271 }
6272 else {
6273 4 $char[$i] = '@{[Elatin9::PREMATCH()]}';
6274 }
6275 }
6276  
6277 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
6278 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6279 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6280 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::MATCH())]}';
6281 }
6282 else {
6283 4 $char[$i] = '@{[Elatin9::MATCH()]}';
6284 }
6285 }
6286  
6287 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
6288 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6289 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 3 3
6290 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::POSTMATCH())]}';
6291 }
6292 else {
6293 3 $char[$i] = '@{[Elatin9::POSTMATCH()]}';
6294 }
6295 }
6296  
6297 # ${ foo }
6298 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6299 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6300 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6301 }
6302 }
6303  
6304 # ${ ... }
6305 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6306 0 $char[$i] = e_capture($1);
6307 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6308 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6309 }
6310 }
6311  
6312 # $scalar or @array
6313 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6314 4 $char[$i] = e_string($char[$i]);
6315 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 4 4
6316 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6317 }
6318 }
6319  
6320 # quote character before ? + * {
6321 ▶ 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
6322 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
6323 }
6324 else {
6325 14 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6326 }
6327 }
6328 }
6329  
6330 # make regexp string
6331 72 my $prematch = '';
6332 72 $modifier =~ tr/i//d;
6333 72 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 72 72
6334 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6335 }
6336 72 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6337 }
6338  
6339 #
6340 # escape regexp (s'here'' or s'here''b)
6341 #
6342 21 ▶sub e_s1_q {
Subroutine e_s1_q: called CC=7 SCAR=24.3
Pod undocumented
6343 21 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6344 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
6345  
6346 21 $modifier =~ tr/p//d;
6347 21 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 21 21
6348 0 my $line = 0;
6349 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6350 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6351 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6352 0 last;
6353 }
6354 }
6355 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6356 }
6357  
6358 21 $slash = 'div';
6359  
6360 # literal null string pattern
6361 21 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 13 21
elsif ($modifier =~ tr/Bb//d) { } 0 13 13
6362 8 $modifier =~ tr/bB//d;
6363 8 $modifier =~ tr/i//d;
6364 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6365 }
6366  
6367 # with /b /B modifier
6368 elsif ($modifier =~ tr/bB//d) {
6369 0 return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6370 }
6371  
6372 # without /b /B modifier
6373 else {
6374 13 return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6375 }
6376 }
6377  
6378 #
6379 # escape regexp (s'here'')
6380 #
6381 13 ▶sub e_s1_qt {
Subroutine e_s1_qt: called CC=20 SCAR=50.1
Pod undocumented
6382 13 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6383  
6384 13 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 13 13
6385  
6386 # split regexp
6387 13 my @char = $string =~ /\G((?>
6388 [^\\\[\$\@\/] |
6389 [\x00-\xFF] |
6390 \[\^ |
6391 \[\: (?>[a-z]+) \:\] |
6392 \[\:\^ (?>[a-z]+) \:\] |
6393 [\$\@\/] |
6394 \\ (?:$q_char) |
6395 (?:$q_char)
6396 ))/oxmsg;
6397  
6398 # unescape character
6399 13 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 25 13 38
6400 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 &Elatin9::uc($char[$i]) ne &fc($char[$i])) { } 0 19 19
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 32 32
6401 }
6402  
6403 # open character class [...]
6404 elsif ($char[$i] eq '[') {
6405 0 my $left = $i;
6406 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6407 0 $i++;
6408 }
6409 0 while (1) {
6410 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6411 0 die __FILE__, ": Unmatched [] in regexp\n";
6412 }
6413 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6414 0 my $right = $i;
6415  
6416 # [...]
6417 0 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
6418  
6419 0 $i = $left;
6420 0 last;
6421 }
6422 }
6423 }
6424  
6425 # open character class [^...]
6426 elsif ($char[$i] eq '[^') {
6427 0 my $left = $i;
6428 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6429 0 $i++;
6430 }
6431 0 while (1) {
6432 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6433 0 die __FILE__, ": Unmatched [] in regexp\n";
6434 }
6435 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6436 0 my $right = $i;
6437  
6438 # [^...]
6439 0 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6440  
6441 0 $i = $left;
6442 0 last;
6443 }
6444 }
6445 }
6446  
6447 # escape $ @ / and \
6448 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6449 0 $char[$i] = '\\' . $char[$i];
6450 }
6451  
6452 # rewrite character class or escape character
6453 elsif (my $char = character_class($char[$i],$modifier)) {
6454 6 $char[$i] = $char;
6455 }
6456  
6457 # /i modifier
6458 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6459 0 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6460 0 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
6461 }
6462 else {
6463 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
6464 }
6465 }
6466  
6467 # quote character before ? + * {
6468 ▶ 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
6469 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
6470 }
6471 else {
6472 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6473 }
6474 }
6475 }
6476  
6477 13 $modifier =~ tr/i//d;
6478 13 $delimiter = '/';
6479 13 $end_delimiter = '/';
6480 13 my $prematch = '';
6481 13 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6482 }
6483  
6484 #
6485 # escape regexp (s'here''b)
6486 #
6487 0 ▶sub e_s1_qb {
Subroutine e_s1_qb: not called CC=4 SCAR=30.0
Pod undocumented
6488 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6489  
6490 # split regexp
6491 0 my @char = $string =~ /\G (?>[^\\]|\\\\) /oxmsg;
6492  
6493 # unescape character
6494 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6495 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
6496 }
6497  
6498 # remain \\
6499 elsif ($char[$i] eq '\\\\') {
6500 }
6501  
6502 # escape $ @ / and \
6503 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6504 0 $char[$i] = '\\' . $char[$i];
6505 }
6506 }
6507  
6508 0 $delimiter = '/';
6509 0 $end_delimiter = '/';
6510 0 my $prematch = '';
6511 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6512 }
6513  
6514 #
6515 # escape regexp (s''here')
6516 #
6517 16 ▶sub e_s2_q {
Subroutine e_s2_q: called CC=4 SCAR=13.9
Pod undocumented
6518 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
6519  
6520 16 $slash = 'div';
6521  
6522 16 my @char = $string =~ / \G (?>[^\\]|\\\\|$q_char) /oxmsg;
6523 16 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 9 16 25
6524 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
6525 }
6526  
6527 # not escape \\
6528 elsif ($char[$i] =~ /\A \\\\ \z/oxms) {
6529 }
6530  
6531 # escape $ @ / and \
6532 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6533 5 $char[$i] = '\\' . $char[$i];
6534 }
6535 }
6536  
6537 16 return join '', $ope, $delimiter, @char, $end_delimiter;
6538 }
6539  
6540 #
6541 # escape regexp (s/here/and here/modifier)
6542 #
6543 101 ▶sub e_sub {
Subroutine e_sub: called CC=20 SCAR=32.6
Pod undocumented
6544 101 my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_;
6545 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
6546  
6547 101 $modifier =~ tr/p//d;
6548 101 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 101 101
6549 0 my $line = 0;
6550 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6551 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6552 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6553 0 last;
6554 }
6555 }
6556 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6557 }
6558  
6559 101 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq "") 36 65 101
6560 36 $variable = '$_';
6561 36 $bind_operator = ' =~ ';
6562 }
6563  
6564 101 $slash = 'div';
6565  
6566 # P.128 Start of match (or end of previous match): \G
6567 # P.130 Advanced Use of \G with Perl
6568 # in Chapter 3: Overview of Regular Expression Features and Flavors
6569 # P.312 Iterative Matching: Scalar Context, with /g
6570 # in Chapter 7: Perl
6571 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
6572  
6573 # P.181 Where You Left Off: The \G Assertion
6574 # in Chapter 5: Pattern Matching
6575 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6576  
6577 # P.220 Where You Left Off: The \G Assertion
6578 # in Chapter 5: Pattern Matching
6579 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6580  
6581 101 my $e_modifier = $modifier =~ tr/e//d;
6582 101 my $r_modifier = $modifier =~ tr/r//d;
6583  
6584 101 my $my = '';
6585 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
6586 0 $my = $variable;
6587 0 $variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms;
6588 0 $variable =~ s/ = .+ \z//oxms;
6589 }
6590  
6591 101 (my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms;
6592 101 $variable_basename =~ s/ \s+ \z//oxms;
6593  
6594 # quote replacement string
6595 101 my $e_replacement = '';
6596 101 ▶ if ($e_modifier >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e_modifier >= 1) { } 17 84 101
6597 17 $e_replacement = e_qq('', '', '', $replacement);
6598 17 $e_modifier--;
6599 }
6600 else {
6601 84 ▶ if ($delimiter2 eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter2 eq q[']) { } 16 68 84
6602 16 $e_replacement = e_s2_q('qq', '/', '/', $replacement);
6603 }
6604 else {
6605 68 $e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement);
6606 }
6607 }
6608  
6609 101 my $sub = '';
6610  
6611 # with /r
6612 101 ▶ if ($r_modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r_modifier) { } 10 91 101
6613 10 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 5 5 10
6614 }
6615  
6616 # s///gr without multibyte anchoring
6617 elsif ($modifier =~ /g/oxms) {
6618 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6619 # 1 2 3 4 5
6620 q<CORE::eval{local $Elatin9::re_t=%s; while($Elatin9::re_t =~ %s){%s local $^W=0; local $Elatin9::re_r=%s; %s$Elatin9::re_t="$`$Elatin9::re_r$'"; pos($Elatin9::re_t)=length "$`$Elatin9::re_r"; } return $Elatin9::re_t}>,
6621  
6622 $variable, # 1
6623 ($delimiter1 eq "'") ? # 2
6624 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6625 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6626 $s_matched, # 3
6627 $e_replacement, # 4
6628 '$Elatin9::re_r=CORE::eval $Elatin9::re_r; ' x $e_modifier, # 5
6629 );
6630 }
6631  
6632 # s///r
6633 else {
6634  
6635 5 my $prematch = q{$`};
6636  
6637 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6638 # 1 2 3 4 5 6 7
6639 q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Elatin9::re_r=%s; %s"%s$Elatin9::re_r$'" } : %s>,
6640  
6641 $variable, # 1
6642 ($delimiter1 eq "'") ? # 2
6643 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6644 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6645 $s_matched, # 3
6646 $e_replacement, # 4
6647 '$Elatin9::re_r=CORE::eval $Elatin9::re_r; ' x $e_modifier, # 5
6648 $prematch, # 6
6649 $variable, # 7
6650 );
6651 }
6652  
6653 # $var !~ s///r doesn't make sense
6654 10 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 10 10
6655 0 $sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub;
6656 }
6657 }
6658  
6659 # without /r
6660 else {
6661 91 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 23 68 91
6662 }
6663  
6664 # s///g without multibyte anchoring
6665 elsif ($modifier =~ /g/oxms) {
6666 23 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 3 20 23
$bind_operator =~ / !~ /mosx ? : 3 20 23
6667 # 1 2 3 4 5 6 7 8
6668 q<CORE::eval{local $Elatin9::re_n=0; while(%s =~ %s){%s local $^W=0; local $Elatin9::re_r=%s; %s%s="$`$Elatin9::re_r$'"; pos(%s)=length "$`$Elatin9::re_r"; $Elatin9::re_n++} return %s$Elatin9::re_n}>,
6669  
6670 $variable, # 1
6671 ($delimiter1 eq "'") ? # 2
6672 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6673 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6674 $s_matched, # 3
6675 $e_replacement, # 4
6676 '$Elatin9::re_r=CORE::eval $Elatin9::re_r; ' x $e_modifier, # 5
6677 $variable, # 6
6678 $variable, # 7
6679 ($bind_operator =~ / !~ /oxms) ? '!' : '', # 8
6680 );
6681 }
6682  
6683 # s///
6684 else {
6685  
6686 68 my $prematch = q{$`};
6687  
6688 68 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$bind_operator =~ / =~ /mosx ? : 65 3 68
$delimiter1 eq q['] ? : 18 50 68
6689  
6690 ($bind_operator =~ / =~ /oxms) ?
6691  
6692 # 1 2 3 4 5 6 7 8
6693 q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Elatin9::re_r=%s; %s%s="%s$Elatin9::re_r$'"; 1 } : undef> :
6694  
6695 # 1 2 3 4 5 6 7 8
6696 q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Elatin9::re_r=%s; %s%s="%s$Elatin9::re_r$'"; undef }>,
6697  
6698 $variable, # 1
6699 $bind_operator, # 2
6700 ($delimiter1 eq "'") ? # 3
6701 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6702 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6703 $s_matched, # 4
6704 $e_replacement, # 5
6705 '$Elatin9::re_r=CORE::eval $Elatin9::re_r; ' x $e_modifier, # 6
6706 $variable, # 7
6707 $prematch, # 8
6708 );
6709 }
6710 }
6711  
6712 # (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1]
6713 101 ▶ if ($my ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($my ne "") 0 101 101
6714 0 $sub = "($my, $sub)[1]";
6715 }
6716  
6717 # clear s/// variable
6718 101 $sub_variable = '';
6719 101 $bind_operator = '';
6720  
6721 101 return $sub;
6722 }
6723  
6724 #
6725 # escape regexp of split qr//
6726 #
6727 74 ▶sub e_split {
Subroutine e_split: called CC=88 SCAR=76.4
Pod undocumented
6728 74 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6729 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
6730  
6731 74 $modifier =~ tr/p//d;
6732 74 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 74 74
6733 0 my $line = 0;
6734 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6735 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6736 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6737 0 last;
6738 }
6739 }
6740 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6741 }
6742  
6743 74 $slash = 'div';
6744  
6745 # /b /B modifier
6746 74 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 74 74
6747 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
6748 }
6749  
6750 74 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 74 74
6751 74 my $metachar = qr/[\@\\|[\]{^]/oxms;
6752  
6753 # split regexp
6754 74 my @char = $string =~ /\G((?>
6755 [^\\\$\@\[\(] |
6756 \\x (?>[0-9A-Fa-f]{1,2}) |
6757 \\ (?>[0-7]{2,3}) |
6758 \\c [\x40-\x5F] |
6759 \\x\{ (?>[0-9A-Fa-f]+) \} |
6760 \\o\{ (?>[0-7]+) \} |
6761 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
6762 \\ $q_char |
6763 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
6764 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
6765 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
6766 [\$\@] $qq_variable |
6767 \$ (?>\s* [0-9]+) |
6768 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
6769 \$ \$ (?![\w\{]) |
6770 \$ (?>\s*) \$ (?>\s*) $qq_variable |
6771 \[\^ |
6772 \[\: (?>[a-z]+) :\] |
6773 \[\:\^ (?>[a-z]+) :\] |
6774 \(\? |
6775 $q_char
6776 ))/oxmsg;
6777  
6778 74 my $left_e = 0;
6779 74 my $right_e = 0;
6780 74 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 249 74 323
6781  
6782 # "\L\u" --> "\u\L"
6783 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
6784 0 @char[$i,$i+1] = @char[$i+1,$i];
6785 }
6786  
6787 # "\U\l" --> "\l\U"
6788 ▶ 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
6789 0 @char[$i,$i+1] = @char[$i+1,$i];
6790 }
6791  
6792 # octal escape sequence
6793 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6794 1 $char[$i] = Elatin9::octchr($1);
6795 }
6796  
6797 # hexadecimal escape sequence
6798 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6799 1 $char[$i] = Elatin9::hexchr($1);
6800 }
6801  
6802 # \b{...} --> b\{...}
6803 # \B{...} --> B\{...}
6804 # \N{CHARNAME} --> N\{CHARNAME}
6805 # \p{PROPERTY} --> p\{PROPERTY}
6806 # \P{PROPERTY} --> P\{PROPERTY}
6807 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6808 0 $char[$i] = $1 . '\\' . $2;
6809 }
6810  
6811 # \p, \P, \X --> p, P, X
6812 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6813 0 $char[$i] = $1;
6814 }
6815  
6816 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 &Elatin9::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
6817 }
6818  
6819 # join separated multiple-octet
6820 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6821 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6822 0 $char[$i] .= join '', splice @char, $i+1, 3;
6823 }
6824 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6825 0 $char[$i] .= join '', splice @char, $i+1, 2;
6826 }
6827 ▶ 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 $Elatin9::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 $Elatin9::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 $Elatin9::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 $Elatin9::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6828 0 $char[$i] .= join '', splice @char, $i+1, 1;
6829 }
6830 }
6831  
6832 # open character class [...]
6833 elsif ($char[$i] eq '[') {
6834 3 my $left = $i;
6835 3 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 3 3
6836 0 $i++;
6837 }
6838 3 while (1) {
6839 7 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 7 7
6840 0 die __FILE__, ": Unmatched [] in regexp\n";
6841 }
6842 7 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 3 4 7
6843 3 my $right = $i;
6844  
6845 # [...]
6846 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
6847 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6848 }
6849 else {
6850 3 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
6851 }
6852  
6853 3 $i = $left;
6854 3 last;
6855 }
6856 }
6857 }
6858  
6859 # open character class [^...]
6860 elsif ($char[$i] eq '[^') {
6861 0 my $left = $i;
6862 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6863 0 $i++;
6864 }
6865 0 while (1) {
6866 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6867 0 die __FILE__, ": Unmatched [] in regexp\n";
6868 }
6869 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6870 0 my $right = $i;
6871  
6872 # [^...]
6873 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
6874 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Elatin9::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6875 }
6876 else {
6877 0 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6878 }
6879  
6880 0 $i = $left;
6881 0 last;
6882 }
6883 }
6884 }
6885  
6886 # rewrite character class or escape character
6887 elsif (my $char = character_class($char[$i],$modifier)) {
6888 1 $char[$i] = $char;
6889 }
6890  
6891 # P.794 29.2.161. split
6892 # in Chapter 29: Functions
6893 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6894  
6895 # P.951 split
6896 # in Chapter 27: Functions
6897 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6898  
6899 # said "The //m modifier is assumed when you split on the pattern /^/",
6900 # but perl5.008 is not so. Therefore, this software adds //m.
6901 # (and so on)
6902  
6903 # split(m/^/) --> split(m/^/m)
6904 ▶ 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
6905 7 $modifier .= 'm';
6906 }
6907  
6908 # /i modifier
6909 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6910 0 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6911 0 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
6912 }
6913 else {
6914 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
6915 }
6916 }
6917  
6918 # \u \l \U \L \F \Q \E
6919 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
6920 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6921 0 $char[$i] = '\\' . $char[$i];
6922 }
6923 }
6924 elsif ($char[$i] eq '\u') {
6925 0 $char[$i] = '@{[Elatin9::ucfirst qq<';
6926 0 $left_e++;
6927 }
6928 elsif ($char[$i] eq '\l') {
6929 0 $char[$i] = '@{[Elatin9::lcfirst qq<';
6930 0 $left_e++;
6931 }
6932 elsif ($char[$i] eq '\U') {
6933 0 $char[$i] = '@{[Elatin9::uc qq<';
6934 0 $left_e++;
6935 }
6936 elsif ($char[$i] eq '\L') {
6937 0 $char[$i] = '@{[Elatin9::lc qq<';
6938 0 $left_e++;
6939 }
6940 elsif ($char[$i] eq '\F') {
6941 0 $char[$i] = '@{[Elatin9::fc qq<';
6942 0 $left_e++;
6943 }
6944 elsif ($char[$i] eq '\Q') {
6945 0 $char[$i] = '@{[CORE::quotemeta qq<';
6946 0 $left_e++;
6947 }
6948 elsif ($char[$i] eq '\E') {
6949 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6950 0 $char[$i] = '>]}';
6951 0 $right_e++;
6952 }
6953 else {
6954 0 $char[$i] = '';
6955 }
6956 }
6957 elsif ($char[$i] eq '\Q') {
6958 0 while (1) {
6959 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6960 0 last;
6961 }
6962 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6963 0 last;
6964 }
6965 }
6966 }
6967 elsif ($char[$i] eq '\E') {
6968 }
6969  
6970 # $0 --> $0
6971 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6972 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6973 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6974 }
6975 }
6976 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6977 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6978 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6979 }
6980 }
6981  
6982 # $$ --> $$
6983 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6984 }
6985  
6986 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6987 # $1, $2, $3 --> $1, $2, $3 otherwise
6988 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6989 0 $char[$i] = e_capture($1);
6990 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6991 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6992 }
6993 }
6994 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6995 0 $char[$i] = e_capture($1);
6996 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6997 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
6998 }
6999 }
7000  
7001 # $$foo[ ... ] --> $ $foo->[ ... ]
7002 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
7003 0 $char[$i] = e_capture($1.'->'.$2);
7004 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7005 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
7006 }
7007 }
7008  
7009 # $$foo{ ... } --> $ $foo->{ ... }
7010 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
7011 0 $char[$i] = e_capture($1.'->'.$2);
7012 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7013 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
7014 }
7015 }
7016  
7017 # $$foo
7018 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
7019 0 $char[$i] = e_capture($1);
7020 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7021 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
7022 }
7023 }
7024  
7025 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Elatin9::PREMATCH()
7026 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
7027 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7028 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::PREMATCH())]}';
7029 }
7030 else {
7031 12 $char[$i] = '@{[Elatin9::PREMATCH()]}';
7032 }
7033 }
7034  
7035 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Elatin9::MATCH()
7036 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
7037 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7038 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::MATCH())]}';
7039 }
7040 else {
7041 12 $char[$i] = '@{[Elatin9::MATCH()]}';
7042 }
7043 }
7044  
7045 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Elatin9::POSTMATCH()
7046 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
7047 9 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 9 9
7048 0 $char[$i] = '@{[Elatin9::ignorecase(Elatin9::POSTMATCH())]}';
7049 }
7050 else {
7051 9 $char[$i] = '@{[Elatin9::POSTMATCH()]}';
7052 }
7053 }
7054  
7055 # ${ foo }
7056 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
7057 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7058 0 $char[$i] = '@{[Elatin9::ignorecase(' . $1 . ')]}';
7059 }
7060 }
7061  
7062 # ${ ... }
7063 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
7064 0 $char[$i] = e_capture($1);
7065 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7066 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
7067 }
7068 }
7069  
7070 # $scalar or @array
7071 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
7072 3 $char[$i] = e_string($char[$i]);
7073 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 3 3
7074 0 $char[$i] = '@{[Elatin9::ignorecase(' . $char[$i] . ')]}';
7075 }
7076 }
7077  
7078 # quote character before ? + * {
7079 ▶ 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
7080 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
7081 }
7082 else {
7083 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7084 }
7085 }
7086 }
7087  
7088 # make regexp string
7089 74 $modifier =~ tr/i//d;
7090 74 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 74 74
7091 0 return join '', 'Elatin9::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier;
7092 }
7093 74 return join '', 'Elatin9::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7094 }
7095  
7096 #
7097 # escape regexp of split qr''
7098 #
7099 0 ▶sub e_split_q {
Subroutine e_split_q: not called CC=26 SCAR=65.5
Pod undocumented
7100 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7101 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
7102  
7103 0 $modifier =~ tr/p//d;
7104 0 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 0 0
7105 0 my $line = 0;
7106 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7107 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7108 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7109 0 last;
7110 }
7111 }
7112 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7113 }
7114  
7115 0 $slash = 'div';
7116  
7117 # /b /B modifier
7118 0 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 0 0
7119 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7120 }
7121  
7122 0 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 0 0
7123  
7124 # split regexp
7125 0 my @char = $string =~ /\G((?>
7126 [^\\\[] |
7127 [\x00-\xFF] |
7128 \[\^ |
7129 \[\: (?>[a-z]+) \:\] |
7130 \[\:\^ (?>[a-z]+) \:\] |
7131 \\ (?:$q_char) |
7132 (?:$q_char)
7133 ))/oxmsg;
7134  
7135 # unescape character
7136 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
7137 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 &Elatin9::uc($char[$i]) ne &fc($char[$i])) { } 0 0 0
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 0 0
7138 }
7139  
7140 # open character class [...]
7141 elsif ($char[$i] eq '[') {
7142 0 my $left = $i;
7143 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7144 0 $i++;
7145 }
7146 0 while (1) {
7147 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7148 0 die __FILE__, ": Unmatched [] in regexp\n";
7149 }
7150 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7151 0 my $right = $i;
7152  
7153 # [...]
7154 0 splice @char, $left, $right-$left+1, Elatin9::charlist_qr(@char[$left+1..$right-1], $modifier);
7155  
7156 0 $i = $left;
7157 0 last;
7158 }
7159 }
7160 }
7161  
7162 # open character class [^...]
7163 elsif ($char[$i] eq '[^') {
7164 0 my $left = $i;
7165 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7166 0 $i++;
7167 }
7168 0 while (1) {
7169 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7170 0 die __FILE__, ": Unmatched [] in regexp\n";
7171 }
7172 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7173 0 my $right = $i;
7174  
7175 # [^...]
7176 0 splice @char, $left, $right-$left+1, Elatin9::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7177  
7178 0 $i = $left;
7179 0 last;
7180 }
7181 }
7182 }
7183  
7184 # rewrite character class or escape character
7185 elsif (my $char = character_class($char[$i],$modifier)) {
7186 0 $char[$i] = $char;
7187 }
7188  
7189 # split(m/^/) --> split(m/^/m)
7190 ▶ 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
7191 0 $modifier .= 'm';
7192 }
7193  
7194 # /i modifier
7195 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Elatin9::uc($char[$i]) ne Elatin9::fc($char[$i]))) {
Condition0%0/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Elatin9::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 &Elatin9::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Elatin9::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= &Elatin9::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7196 0 ▶ if (CORE::length(Elatin9::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7197 0 $char[$i] = '[' . Elatin9::uc($char[$i]) . Elatin9::fc($char[$i]) . ']';
7198 }
7199 else {
7200 0 $char[$i] = '(?:' . Elatin9::uc($char[$i]) . '|' . Elatin9::fc($char[$i]) . ')';
7201 }
7202 }
7203  
7204 # quote character before ? + * {
7205 ▶ 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
7206 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
7207 }
7208 else {
7209 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7210 }
7211 }
7212 }
7213  
7214 0 $modifier =~ tr/i//d;
7215 0 return join '', 'Elatin9::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7216 }
7217  
7218 #
7219 # instead of Carp::carp
7220 #
7221 0 ▶sub carp {
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
7222 0 my($package,$filename,$line) = caller(1);
7223 0 print STDERR "@_ at $filename line $line.\n";
7224 }
7225  
7226 #
7227 # instead of Carp::croak
7228 #
7229 0 ▶sub croak {
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
7230 0 my($package,$filename,$line) = caller(1);
7231 0 print STDERR "@_ at $filename line $line.\n";
7232 0 die "\n";
7233 }
7234  
7235 #
7236 # instead of Carp::cluck
7237 #
7238 0 ▶sub cluck {
Subroutine cluck: not called CC=2 SCAR=17.9
Pod undocumented
7239 0 my $i = 0;
7240 0 my @cluck = ();
7241 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7242 0 push @cluck, "[$i] $filename($line) $package::$subroutine\n";
7243 0 $i++;
7244 }
7245 0 print STDERR CORE::reverse @cluck;
7246 0 print STDERR "\n";
7247 0 print STDERR @_;
7248 }
7249  
7250 #
7251 # instead of Carp::confess
7252 #
7253 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
7254 0 my $i = 0;
7255 0 my @confess = ();
7256 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7257 0 push @confess, "[$i] $filename($line) $package::$subroutine\n";
7258 0 $i++;
7259 }
7260 0 print STDERR CORE::reverse @confess;
7261 0 print STDERR "\n";
7262 0 print STDERR @_;
7263 0 die "\n";
7264 }
7265  
7266 424 1;
7267  
7268 __END__
↑ Summary Latin9.pm »