blib/lib/Ekoi8u.pm

filter: Statementstmt 36.4% 1197 / 3286 Branchbran 38.5% 1140 / 2954 Conditioncond 31.0% 115 / 370 MC/DCmcdc 15.9% 35 / 220 Subroutinesub 60.8% 73 / 120 Podpod 4.6% 3 / 64 totaltotal 36.5% 2563 / 7014 CC 1648 SCAR 99.4
CC
1648
Cov
37%
escape_token
55669.4
e_string
33636.6
e_s1
3320.4
CRAP 20709.7
↑ Summary blib/lib/KOI8U.pm »
1 package Ekoi8u;
2 422 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 ######################################################################
4 #
5 # Ekoi8u - Run-time routines for KOI8U.pm
6 #
7 # http://search.cpan.org/dist/Char-KOI8U/
8 #
9 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
10 ######################################################################
11  
12 422 ▶use 5.00503; # Galapagos Consensus 1998 for primetools
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # use 5.008001; # Lancaster Consensus 2013 for toolchains
14  
15 # 12.3. Delaying use Until Runtime
16 # in Chapter 12. Packages, Libraries, and Modules
17 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
18 # (and so on)
19  
20 # Version numbers should be boring
21 # http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
22 # For the impatient, the disinterested or those who just want to follow
23 # a recipe, my advice for all modules is this:
24 # our $VERSION = "0.001"; # or "0.001_001" for a dev release
25 # $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1'
26  
27 422 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 422 $VERSION = '1.15';
29 422 $VERSION = $VERSION;
30  
31 422 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
32 422 ▶ if ($^X =~ / jperl /oxmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^X =~ / jperl /imosx) 0 422 422
33 0 die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n";
34 }
35 422 if (CORE::ord('A') == 193) {
36 die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n";
37 }
38 422 if (CORE::ord('A') != 0x41) {
39 die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n";
40 }
41 }
42  
43 422 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=9.5
44  
45 # instead of utf8.pm
46 422 ▶ 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
47 no warnings qw(redefine);
48 *utf8::upgrade = sub { CORE::length $_[0] };
49 *utf8::downgrade = sub { 1 };
50 *utf8::encode = sub { };
51 *utf8::decode = sub { 1 };
52 *utf8::is_utf8 = sub { };
53 *utf8::valid = sub { 1 };
54 };
55 422 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 422 422
56 0 ▶ *utf8::upgrade = sub { CORE::length $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 ▶ *utf8::downgrade = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 ▶ *utf8::encode = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 ▶ *utf8::decode = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ *utf8::is_utf8 = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ *utf8::valid = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 }
63 }
64  
65 # instead of Symbol.pm
66 BEGIN {
67 0 ▶ sub gensym () {
Subroutine gensym: not called CC=2 SCAR=17.9
Pod undocumented
68 0 ▶ if ($] < 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.006) { } 0 0 0
69 0 return \do { local *_ };
70 }
71 else {
72 0 return undef;
73 }
74 }
75  
76 20 ▶ sub qualify ($$) {
Subroutine qualify: called CC=8 SCAR=28.9
Pod undocumented
77 20 my($name) = @_;
78  
79 20 ▶ if (ref $name) {
Branch: 7 branches
BranchTrueFalseTotal
if (ref $name) { } 5 15 20
elsif (&Ekoi8u::index($name, '::') >= 0) { } 0 15 15
elsif (&Ekoi8u::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
80 5 return $name;
81 }
82 elsif (Ekoi8u::index($name,'::') >= 0) {
83 0 return $name;
84 }
85 elsif (Ekoi8u::index($name,"'") >= 0) {
86 0 return $name;
87 }
88  
89 # special character, "^xyz"
90 elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) {
91  
92 # RGS 2001-11-05 : translate leading ^X to control-char
93 0 $name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee;
94 0 return 'main::' . $name;
95 }
96  
97 # Global names
98 elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) {
99 0 return 'main::' . $name;
100 }
101  
102 # or other
103 elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) {
104 0 return 'main::' . $name;
105 }
106  
107 elsif (defined $_[1]) {
108 15 return $_[1] . '::' . $name;
109 }
110 else {
111 0 return (caller)[0] . '::' . $name;
112 }
113 }
114  
115 20 ▶ sub qualify_to_ref ($;$) {
Subroutine qualify_to_ref: called CC=2 SCAR=7.2
Pod undocumented
116 20 ▶ if (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) { } 20 0 20
117 422 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
118 20 return \*{ qualify $_[0], $_[1] };
119 }
120 else {
121 422 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
122 0 return \*{ qualify $_[0], (caller)[0] };
123 }
124 }
125 }
126  
127 # P.714 29.2.39. flock
128 # in Chapter 29: Functions
129 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
130  
131 # P.863 flock
132 # in Chapter 27: Functions
133 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
134  
135 sub LOCK_SH() {1}
136 sub LOCK_EX() {2}
137 sub LOCK_UN() {8}
138 sub LOCK_NB() {4}
139  
140 # instead of Carp.pm
141 sub carp;
142 sub croak;
143 sub cluck;
144 sub confess;
145  
146 # 6.18. Matching Multiple-Byte Characters
147 # in Chapter 6. Pattern Matching
148 # of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
149 # (and so on)
150  
151 # regexp of character
152 422 my $your_char = q{[\x00-\xFF]};
153 422 ▶use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
154 422 ▶use vars qw($q_char); $q_char = qr/$your_char/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
155  
156 #
157 # KOI8-U character range per length
158 #
159 422 my %range_tr = ();
160  
161 #
162 # KOI8-U case conversion
163 #
164 422 my %lc = ();
165 422 @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)} =
166 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 422 my %uc = ();
168 422 @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)} =
169 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 422 my %fc = ();
171 422 @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)} =
172 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  
174 422 ▶if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { __PACKAGE__ =~ / \b Ekoi8u \z/mosx }) { } 422 0 422
175 }
176  
177 elsif (__PACKAGE__ =~ / \b Ekoi8u \z/oxms) {
178 422 %range_tr = (
179 1 => [ [0x00..0xFF],
180 ],
181 );
182  
183 422 %lc = (%lc,
184 "\xB3" => "\xA3", # CYRILLIC LETTER IO
185 "\xB4" => "\xA4", # CYRILLIC LETTER UKRAINIAN IE
186 "\xB6" => "\xA6", # CYRILLIC LETTER BYELORUSSIAN-UKRAINIAN I
187 "\xB7" => "\xA7", # CYRILLIC LETTER YI (UKRAINIAN)
188 "\xBD" => "\xAD", # CYRILLIC LETTER GHE WITH UPTURN
189 "\xE0" => "\xC0", # CYRILLIC LETTER YU
190 "\xE1" => "\xC1", # CYRILLIC LETTER A
191 "\xE2" => "\xC2", # CYRILLIC LETTER BE
192 "\xE3" => "\xC3", # CYRILLIC LETTER TSE
193 "\xE4" => "\xC4", # CYRILLIC LETTER DE
194 "\xE5" => "\xC5", # CYRILLIC LETTER IE
195 "\xE6" => "\xC6", # CYRILLIC LETTER EF
196 "\xE7" => "\xC7", # CYRILLIC LETTER GHE
197 "\xE8" => "\xC8", # CYRILLIC LETTER KHA
198 "\xE9" => "\xC9", # CYRILLIC LETTER I
199 "\xEA" => "\xCA", # CYRILLIC LETTER SHORT I
200 "\xEB" => "\xCB", # CYRILLIC LETTER KA
201 "\xEC" => "\xCC", # CYRILLIC LETTER EL
202 "\xED" => "\xCD", # CYRILLIC LETTER EM
203 "\xEE" => "\xCE", # CYRILLIC LETTER EN
204 "\xEF" => "\xCF", # CYRILLIC LETTER O
205 "\xF0" => "\xD0", # CYRILLIC LETTER PE
206 "\xF1" => "\xD1", # CYRILLIC LETTER YA
207 "\xF2" => "\xD2", # CYRILLIC LETTER ER
208 "\xF3" => "\xD3", # CYRILLIC LETTER ES
209 "\xF4" => "\xD4", # CYRILLIC LETTER TE
210 "\xF5" => "\xD5", # CYRILLIC LETTER U
211 "\xF6" => "\xD6", # CYRILLIC LETTER ZHE
212 "\xF7" => "\xD7", # CYRILLIC LETTER VE
213 "\xF8" => "\xD8", # CYRILLIC LETTER SOFT SIGN
214 "\xF9" => "\xD9", # CYRILLIC LETTER YERU
215 "\xFA" => "\xDA", # CYRILLIC LETTER ZE
216 "\xFB" => "\xDB", # CYRILLIC LETTER SHA
217 "\xFC" => "\xDC", # CYRILLIC LETTER E
218 "\xFD" => "\xDD", # CYRILLIC LETTER SHCHA
219 "\xFE" => "\xDE", # CYRILLIC LETTER CHE
220 "\xFF" => "\xDF", # CYRILLIC LETTER HARD SIGN
221 );
222  
223 422 %uc = (%uc,
224 "\xA3" => "\xB3", # CYRILLIC LETTER IO
225 "\xA4" => "\xB4", # CYRILLIC LETTER UKRAINIAN IE
226 "\xA6" => "\xB6", # CYRILLIC LETTER BYELORUSSIAN-UKRAINIAN I
227 "\xA7" => "\xB7", # CYRILLIC LETTER YI (UKRAINIAN)
228 "\xAD" => "\xBD", # CYRILLIC LETTER GHE WITH UPTURN
229 "\xC0" => "\xE0", # CYRILLIC LETTER YU
230 "\xC1" => "\xE1", # CYRILLIC LETTER A
231 "\xC2" => "\xE2", # CYRILLIC LETTER BE
232 "\xC3" => "\xE3", # CYRILLIC LETTER TSE
233 "\xC4" => "\xE4", # CYRILLIC LETTER DE
234 "\xC5" => "\xE5", # CYRILLIC LETTER IE
235 "\xC6" => "\xE6", # CYRILLIC LETTER EF
236 "\xC7" => "\xE7", # CYRILLIC LETTER GHE
237 "\xC8" => "\xE8", # CYRILLIC LETTER KHA
238 "\xC9" => "\xE9", # CYRILLIC LETTER I
239 "\xCA" => "\xEA", # CYRILLIC LETTER SHORT I
240 "\xCB" => "\xEB", # CYRILLIC LETTER KA
241 "\xCC" => "\xEC", # CYRILLIC LETTER EL
242 "\xCD" => "\xED", # CYRILLIC LETTER EM
243 "\xCE" => "\xEE", # CYRILLIC LETTER EN
244 "\xCF" => "\xEF", # CYRILLIC LETTER O
245 "\xD0" => "\xF0", # CYRILLIC LETTER PE
246 "\xD1" => "\xF1", # CYRILLIC LETTER YA
247 "\xD2" => "\xF2", # CYRILLIC LETTER ER
248 "\xD3" => "\xF3", # CYRILLIC LETTER ES
249 "\xD4" => "\xF4", # CYRILLIC LETTER TE
250 "\xD5" => "\xF5", # CYRILLIC LETTER U
251 "\xD6" => "\xF6", # CYRILLIC LETTER ZHE
252 "\xD7" => "\xF7", # CYRILLIC LETTER VE
253 "\xD8" => "\xF8", # CYRILLIC LETTER SOFT SIGN
254 "\xD9" => "\xF9", # CYRILLIC LETTER YERU
255 "\xDA" => "\xFA", # CYRILLIC LETTER ZE
256 "\xDB" => "\xFB", # CYRILLIC LETTER SHA
257 "\xDC" => "\xFC", # CYRILLIC LETTER E
258 "\xDD" => "\xFD", # CYRILLIC LETTER SHCHA
259 "\xDE" => "\xFE", # CYRILLIC LETTER CHE
260 "\xDF" => "\xFF", # CYRILLIC LETTER HARD SIGN
261 );
262  
263 422 %fc = (%fc,
264 "\xB3" => "\xA3", # CYRILLIC CAPITAL LETTER IO --> CYRILLIC SMALL LETTER IO
265 "\xB4" => "\xA4", # CYRILLIC CAPITAL LETTER UKRAINIAN IE --> CYRILLIC SMALL LETTER UKRAINIAN IE
266 "\xB6" => "\xA6", # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I --> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
267 "\xB7" => "\xA7", # CYRILLIC CAPITAL LETTER YI --> CYRILLIC SMALL LETTER YI
268 "\xBD" => "\xAD", # CYRILLIC CAPITAL LETTER GHE WITH UPTURN --> CYRILLIC SMALL LETTER GHE WITH UPTURN
269 "\xE0" => "\xC0", # CYRILLIC CAPITAL LETTER YU --> CYRILLIC SMALL LETTER YU
270 "\xE1" => "\xC1", # CYRILLIC CAPITAL LETTER A --> CYRILLIC SMALL LETTER A
271 "\xE2" => "\xC2", # CYRILLIC CAPITAL LETTER BE --> CYRILLIC SMALL LETTER BE
272 "\xE3" => "\xC3", # CYRILLIC CAPITAL LETTER TSE --> CYRILLIC SMALL LETTER TSE
273 "\xE4" => "\xC4", # CYRILLIC CAPITAL LETTER DE --> CYRILLIC SMALL LETTER DE
274 "\xE5" => "\xC5", # CYRILLIC CAPITAL LETTER IE --> CYRILLIC SMALL LETTER IE
275 "\xE6" => "\xC6", # CYRILLIC CAPITAL LETTER EF --> CYRILLIC SMALL LETTER EF
276 "\xE7" => "\xC7", # CYRILLIC CAPITAL LETTER GHE --> CYRILLIC SMALL LETTER GHE
277 "\xE8" => "\xC8", # CYRILLIC CAPITAL LETTER HA --> CYRILLIC SMALL LETTER HA
278 "\xE9" => "\xC9", # CYRILLIC CAPITAL LETTER I --> CYRILLIC SMALL LETTER I
279 "\xEA" => "\xCA", # CYRILLIC CAPITAL LETTER SHORT I --> CYRILLIC SMALL LETTER SHORT I
280 "\xEB" => "\xCB", # CYRILLIC CAPITAL LETTER KA --> CYRILLIC SMALL LETTER KA
281 "\xEC" => "\xCC", # CYRILLIC CAPITAL LETTER EL --> CYRILLIC SMALL LETTER EL
282 "\xED" => "\xCD", # CYRILLIC CAPITAL LETTER EM --> CYRILLIC SMALL LETTER EM
283 "\xEE" => "\xCE", # CYRILLIC CAPITAL LETTER EN --> CYRILLIC SMALL LETTER EN
284 "\xEF" => "\xCF", # CYRILLIC CAPITAL LETTER O --> CYRILLIC SMALL LETTER O
285 "\xF0" => "\xD0", # CYRILLIC CAPITAL LETTER PE --> CYRILLIC SMALL LETTER PE
286 "\xF1" => "\xD1", # CYRILLIC CAPITAL LETTER YA --> CYRILLIC SMALL LETTER YA
287 "\xF2" => "\xD2", # CYRILLIC CAPITAL LETTER ER --> CYRILLIC SMALL LETTER ER
288 "\xF3" => "\xD3", # CYRILLIC CAPITAL LETTER ES --> CYRILLIC SMALL LETTER ES
289 "\xF4" => "\xD4", # CYRILLIC CAPITAL LETTER TE --> CYRILLIC SMALL LETTER TE
290 "\xF5" => "\xD5", # CYRILLIC CAPITAL LETTER U --> CYRILLIC SMALL LETTER U
291 "\xF6" => "\xD6", # CYRILLIC CAPITAL LETTER ZHE --> CYRILLIC SMALL LETTER ZHE
292 "\xF7" => "\xD7", # CYRILLIC CAPITAL LETTER VE --> CYRILLIC SMALL LETTER VE
293 "\xF8" => "\xD8", # CYRILLIC CAPITAL LETTER SOFT SIGN --> CYRILLIC SMALL LETTER SOFT SIGN
294 "\xF9" => "\xD9", # CYRILLIC CAPITAL LETTER YERU --> CYRILLIC SMALL LETTER YERU
295 "\xFA" => "\xDA", # CYRILLIC CAPITAL LETTER ZE --> CYRILLIC SMALL LETTER ZE
296 "\xFB" => "\xDB", # CYRILLIC CAPITAL LETTER SHA --> CYRILLIC SMALL LETTER SHA
297 "\xFC" => "\xDC", # CYRILLIC CAPITAL LETTER E --> CYRILLIC SMALL LETTER E
298 "\xFD" => "\xDD", # CYRILLIC CAPITAL LETTER SHCHA --> CYRILLIC SMALL LETTER SHCHA
299 "\xFE" => "\xDE", # CYRILLIC CAPITAL LETTER CHE --> CYRILLIC SMALL LETTER CHE
300 "\xFF" => "\xDF", # CYRILLIC CAPITAL LETTER HARD SIGN --> CYRILLIC SMALL LETTER HARD SIGN
301 );
302 }
303  
304 else {
305 0 croak "Don't know my package name '@{[__PACKAGE__]}'";
306 }
307  
308 #
309 # @ARGV wildcard globbing
310 #
311 211 ▶sub import {
Subroutine import: called CC=7 SCAR=28.3
312  
313 211 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) 0 211 211
314 0 my @argv = ();
315 0 for (@ARGV) {
316  
317 # has space
318 0 ▶ if (/\A (?:$q_char)*? [ ] /oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\A (?:$Ekoi8u::q_char)*? [ ] /mosx) { } 0 0 0
elsif (/\A (?:$Ekoi8u::q_char)*? [*?] /mosx) { } 0 0 0
319 0 ▶ if (my @glob = Ekoi8u::glob(qq{"$_"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8u::glob(qq["$_"])) { } 0 0 0
320 0 push @argv, @glob;
321 }
322 else {
323 0 push @argv, $_;
324 }
325 }
326  
327 # has wildcard metachar
328 elsif (/\A (?:$q_char)*? [*?] /oxms) {
329 0 ▶ if (my @glob = Ekoi8u::glob($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8u::glob($_)) { } 0 0 0
330 0 push @argv, @glob;
331 }
332 else {
333 0 push @argv, $_;
334 }
335 }
336  
337 # no wildcard globbing
338 else {
339 0 push @argv, $_;
340 }
341 }
342 0 @ARGV = @argv;
343 }
344  
345 211 *Char::ord = \&KOI8U::ord;
346 211 *Char::ord_ = \&KOI8U::ord_;
347 211 *Char::reverse = \&KOI8U::reverse;
348 211 *Char::getc = \&KOI8U::getc;
349 211 *Char::length = \&KOI8U::length;
350 211 *Char::substr = \&KOI8U::substr;
351 211 *Char::index = \&KOI8U::index;
352 211 *Char::rindex = \&KOI8U::rindex;
353 211 *Char::eval = \&KOI8U::eval;
354 211 *Char::escape = \&KOI8U::escape;
355 211 *Char::escape_token = \&KOI8U::escape_token;
356 211 *Char::escape_script = \&KOI8U::escape_script;
357 }
358  
359 # P.230 Care with Prototypes
360 # in Chapter 6: Subroutines
361 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
362 #
363 # If you aren't careful, you can get yourself into trouble with prototypes.
364 # But if you are careful, you can do a lot of neat things with them. This is
365 # all very powerful, of course, and should only be used in moderation to make
366 # the world a better place.
367  
368 # P.332 Care with Prototypes
369 # in Chapter 7: Subroutines
370 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
371 #
372 # If you aren't careful, you can get yourself into trouble with prototypes.
373 # But if you are careful, you can do a lot of neat things with them. This is
374 # all very powerful, of course, and should only be used in moderation to make
375 # the world a better place.
376  
377 #
378 # Prototypes of subroutines
379 #
380 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
381 sub Ekoi8u::split(;$$$);
382 sub Ekoi8u::tr($$$$;$);
383 sub Ekoi8u::chop(@);
384 sub Ekoi8u::index($$;$);
385 sub Ekoi8u::rindex($$;$);
386 sub Ekoi8u::lcfirst(@);
387 sub Ekoi8u::lcfirst_();
388 sub Ekoi8u::lc(@);
389 sub Ekoi8u::lc_();
390 sub Ekoi8u::ucfirst(@);
391 sub Ekoi8u::ucfirst_();
392 sub Ekoi8u::uc(@);
393 sub Ekoi8u::uc_();
394 sub Ekoi8u::fc(@);
395 sub Ekoi8u::fc_();
396 sub Ekoi8u::ignorecase;
397 sub Ekoi8u::classic_character_class;
398 sub Ekoi8u::capture;
399 sub Ekoi8u::chr(;$);
400 sub Ekoi8u::chr_();
401 sub Ekoi8u::glob($);
402 sub Ekoi8u::glob_();
403  
404 sub KOI8U::ord(;$);
405 sub KOI8U::ord_();
406 sub KOI8U::reverse(@);
407 sub KOI8U::getc(;*@);
408 sub KOI8U::length(;$);
409 sub KOI8U::substr($$;$$);
410 sub KOI8U::index($$;$);
411 sub KOI8U::rindex($$;$);
412 sub KOI8U::escape(;$);
413  
414 #
415 # Regexp work
416 #
417 422 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
418 $re_a
419 $re_t
420 $re_n
421 $re_r
422 422 );
423  
424 #
425 # Character class
426 #
427 422 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
428 $dot
429 $dot_s
430 $eD
431 $eS
432 $eW
433 $eH
434 $eV
435 $eR
436 $eN
437 $not_alnum
438 $not_alpha
439 $not_ascii
440 $not_blank
441 $not_cntrl
442 $not_digit
443 $not_graph
444 $not_lower
445 $not_lower_i
446 $not_print
447 $not_punct
448 $not_space
449 $not_upper
450 $not_upper_i
451 $not_word
452 $not_xdigit
453 $eb
454 $eB
455 422 );
456  
457 422 ${Ekoi8u::dot} = qr{(?>[^\x0A])};
458 422 ${Ekoi8u::dot_s} = qr{(?>[\x00-\xFF])};
459 422 ${Ekoi8u::eD} = qr{(?>[^0-9])};
460  
461 # Vertical tabs are now whitespace
462 # \s in a regex now matches a vertical tab in all circumstances.
463 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
464 # ${Ekoi8u::eS} = qr{(?>[^\x09\x0A \x0C\x0D\x20])};
465 # ${Ekoi8u::eS} = qr{(?>[^\x09\x0A\x0B\x0C\x0D\x20])};
466 422 ${Ekoi8u::eS} = qr{(?>[^\s])};
467  
468 422 ${Ekoi8u::eW} = qr{(?>[^0-9A-Z_a-z])};
469 422 ${Ekoi8u::eH} = qr{(?>[^\x09\x20])};
470 422 ${Ekoi8u::eV} = qr{(?>[^\x0A\x0B\x0C\x0D])};
471 422 ${Ekoi8u::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])};
472 422 ${Ekoi8u::eN} = qr{(?>[^\x0A])};
473 422 ${Ekoi8u::not_alnum} = qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
474 422 ${Ekoi8u::not_alpha} = qr{(?>[^\x41-\x5A\x61-\x7A])};
475 422 ${Ekoi8u::not_ascii} = qr{(?>[^\x00-\x7F])};
476 422 ${Ekoi8u::not_blank} = qr{(?>[^\x09\x20])};
477 422 ${Ekoi8u::not_cntrl} = qr{(?>[^\x00-\x1F\x7F])};
478 422 ${Ekoi8u::not_digit} = qr{(?>[^\x30-\x39])};
479 422 ${Ekoi8u::not_graph} = qr{(?>[^\x21-\x7F])};
480 422 ${Ekoi8u::not_lower} = qr{(?>[^\x61-\x7A])};
481 422 ${Ekoi8u::not_lower_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
482 # ${Ekoi8u::not_lower_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
483 422 ${Ekoi8u::not_print} = qr{(?>[^\x20-\x7F])};
484 422 ${Ekoi8u::not_punct} = qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
485 422 ${Ekoi8u::not_space} = qr{(?>[^\s\x0B])};
486 422 ${Ekoi8u::not_upper} = qr{(?>[^\x41-\x5A])};
487 422 ${Ekoi8u::not_upper_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
488 # ${Ekoi8u::not_upper_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
489 422 ${Ekoi8u::not_word} = qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
490 422 ${Ekoi8u::not_xdigit} = qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
491 422 ${Ekoi8u::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))};
492 422 ${Ekoi8u::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]))};
493  
494 # avoid: Name "Ekoi8u::foo" used only once: possible typo at here.
495 422 ${Ekoi8u::dot} = ${Ekoi8u::dot};
496 422 ${Ekoi8u::dot_s} = ${Ekoi8u::dot_s};
497 422 ${Ekoi8u::eD} = ${Ekoi8u::eD};
498 422 ${Ekoi8u::eS} = ${Ekoi8u::eS};
499 422 ${Ekoi8u::eW} = ${Ekoi8u::eW};
500 422 ${Ekoi8u::eH} = ${Ekoi8u::eH};
501 422 ${Ekoi8u::eV} = ${Ekoi8u::eV};
502 422 ${Ekoi8u::eR} = ${Ekoi8u::eR};
503 422 ${Ekoi8u::eN} = ${Ekoi8u::eN};
504 422 ${Ekoi8u::not_alnum} = ${Ekoi8u::not_alnum};
505 422 ${Ekoi8u::not_alpha} = ${Ekoi8u::not_alpha};
506 422 ${Ekoi8u::not_ascii} = ${Ekoi8u::not_ascii};
507 422 ${Ekoi8u::not_blank} = ${Ekoi8u::not_blank};
508 422 ${Ekoi8u::not_cntrl} = ${Ekoi8u::not_cntrl};
509 422 ${Ekoi8u::not_digit} = ${Ekoi8u::not_digit};
510 422 ${Ekoi8u::not_graph} = ${Ekoi8u::not_graph};
511 422 ${Ekoi8u::not_lower} = ${Ekoi8u::not_lower};
512 422 ${Ekoi8u::not_lower_i} = ${Ekoi8u::not_lower_i};
513 422 ${Ekoi8u::not_print} = ${Ekoi8u::not_print};
514 422 ${Ekoi8u::not_punct} = ${Ekoi8u::not_punct};
515 422 ${Ekoi8u::not_space} = ${Ekoi8u::not_space};
516 422 ${Ekoi8u::not_upper} = ${Ekoi8u::not_upper};
517 422 ${Ekoi8u::not_upper_i} = ${Ekoi8u::not_upper_i};
518 422 ${Ekoi8u::not_word} = ${Ekoi8u::not_word};
519 422 ${Ekoi8u::not_xdigit} = ${Ekoi8u::not_xdigit};
520 422 ${Ekoi8u::eb} = ${Ekoi8u::eb};
521 422 ${Ekoi8u::eB} = ${Ekoi8u::eB};
522  
523 #
524 # KOI8-U split
525 #
526 72 ▶sub Ekoi8u::split(;$$$) {
Subroutine split: called CC=34 SCAR=46.9
Pod undocumented
527  
528 # P.794 29.2.161. split
529 # in Chapter 29: Functions
530 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
531  
532 # P.951 split
533 # in Chapter 27: Functions
534 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
535  
536 72 my $pattern = $_[0];
537 72 my $string = $_[1];
538 72 my $limit = $_[2];
539  
540 # if $pattern is also omitted or is the literal space, " "
541 72 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 2 70 72
542 2 $pattern = ' ';
543 }
544  
545 # if $string is omitted, the function splits the $_ string
546 72 ▶ if (not defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 6 66 72
547 6 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 6 6
548 0 $string = $_;
549 }
550 else {
551 6 $string = '';
552 }
553 }
554  
555 72 my @split = ();
556  
557 # when string is empty
558 72 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 10 62 72
elsif ($pattern eq ' ') { } 2 60 62
559  
560 # resulting list value in list context
561 10 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 5 5 10
562 5 return @split;
563 }
564  
565 # count of substrings in scalar context
566 else {
567 5 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 5 5
568 5 @_ = @split;
569 5 return scalar @_;
570 }
571 }
572  
573 # split's first argument is more consistently interpreted
574 #
575 # After some changes earlier in v5.17, split's behavior has been simplified:
576 # if the PATTERN argument evaluates to a string containing one space, it is
577 # treated the way that a literal string containing one space once was.
578 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
579  
580 # if $pattern is also omitted or is the literal space, " ", the function splits
581 # on whitespace, /\s+/, after skipping any leading whitespace
582 # (and so on)
583  
584 elsif ($pattern eq ' ') {
585 2 ▶ if (not defined $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit) { } 2 0 2
586 2 return CORE::split(' ', $string);
587 }
588 else {
589 0 return CORE::split(' ', $string, $limit);
590 }
591 }
592  
593 # if $limit is negative, it is treated as if an arbitrarily large $limit has been specified
594 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
595  
596 # a pattern capable of matching either the null string or something longer than the
597 # null string will split the value of $string into separate characters wherever it
598 # matches the null string between characters
599 # (and so on)
600  
601 60 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 2 58 60
602 2 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
603 2 my $limit = scalar(() = $string =~ /($pattern)/oxmsg);
604  
605 # P.1024 Appendix W.10 Multibyte Processing
606 # of ISBN 1-56592-224-7 CJKV Information Processing
607 # (and so on)
608  
609 # the //m modifier is assumed when you split on the pattern /^/
610 # (and so on)
611  
612 # V
613 2 ▶ while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and $string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m) 9 2 11
Condition100%3/3
--$limit > 0 and $string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m
!ll&&!rl&&r
119
MC/DC100%2/2
--$limit > 0 and $string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m
--$limit > 0 $string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m
Truth table100%3/3
A and B
A= --$limit > 0B= $string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m
ABresult
0X0
100
111
614  
615 # if the $pattern contains parentheses, then the substring matched by each pair of parentheses
616 # is included in the resulting list, interspersed with the fields that are ordinarily returned
617 # (and so on)
618  
619 9 local $@;
620 9 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 9 9 18
621 9 push @split, CORE::eval('$' . $digit);
622 }
623 }
624 }
625  
626 else {
627 58 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
628  
629 # V
630 58 ▶ while ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8u::q_char)*?)$pattern//m) 163 58 221
631 163 local $@;
632 163 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 230 163 393
633 230 push @split, CORE::eval('$' . $digit);
634 }
635 }
636 }
637 }
638  
639 elsif ($limit > 0) {
640 0 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 0 0 0
641 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
642 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
643  
644 # V
645 0 ▶ if ($string =~ s/\A((?:$q_char)+?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8u::q_char)+?)$pattern//m) 0 0 0
646 0 local $@;
647 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
648 0 push @split, CORE::eval('$' . $digit);
649 }
650 }
651 }
652 }
653 else {
654 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
655 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
656  
657 # V
658 0 ▶ if ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8u::q_char)*?)$pattern//m) 0 0 0
659 0 local $@;
660 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
661 0 push @split, CORE::eval('$' . $digit);
662 }
663 }
664 }
665 }
666 }
667  
668 60 ▶ if (CORE::length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 58 2 60
669 58 push @split, $string;
670 }
671  
672 # if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result
673 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
674 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
675 0 pop @split;
676 }
677 }
678  
679 # resulting list value in list context
680 60 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 58 2 60
681 58 return @split;
682 }
683  
684 # count of substrings in scalar context
685 else {
686 2 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 2 2
687 2 @_ = @split;
688 2 return scalar @_;
689 }
690 }
691  
692 #
693 # get last subexpression offsets
694 #
695 60 ▶sub _last_subexpression_offsets {
Subroutine _last_subexpression_offsets: called CC=3 SCAR=11.0
696 60 my $pattern = $_[0];
697  
698 # remove comment
699 60 $pattern =~ s/\(\?\# .*? \)//oxmsg;
700  
701 60 my $modifier = '';
702 60 ▶ if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/mosx) 11 49 60
703 11 $modifier = $1;
704 11 $modifier =~ s/-[A-Za-z]*//;
705 }
706  
707 # with /x modifier
708 60 my @char = ();
709 60 ▶ if ($modifier =~ /x/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /x/mosx) { } 5 55 60
710 5 @char = $pattern =~ /\G((?>
711 [^\\\#\[\(] |
712 \\ $q_char |
713 \# (?>[^\n]*) $ |
714 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
715 \(\? |
716 $q_char
717 ))/oxmsg;
718 }
719  
720 # without /x modifier
721 else {
722 55 @char = $pattern =~ /\G((?>
723 [^\\\[\(] |
724 \\ $q_char |
725 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
726 \(\? |
727 $q_char
728 ))/oxmsg;
729 }
730  
731 60 return scalar grep { $_ eq '(' } @char;
732 }
733  
734 #
735 # KOI8-U transliteration (tr///)
736 #
737 6 ▶sub Ekoi8u::tr($$$$;$) {
Subroutine tr: called CC=26 SCAR=48.6
Pod undocumented
738  
739 6 my $bind_operator = $_[1];
740 6 my $searchlist = $_[2];
741 6 my $replacementlist = $_[3];
742 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
743  
744 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) 5 1 6
745 5 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 5 5
746 0 croak "Using !~ with tr///r doesn't make sense";
747 }
748 }
749  
750 6 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
751 6 my @searchlist = _charlist_tr($searchlist);
752 6 my @replacementlist = _charlist_tr($replacementlist);
753  
754 6 my %tr = ();
755 6 ▶ for (my $i=0; $i <= $#searchlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#searchlist) 19 6 25
756 19 ▶ if (not exists $tr{$searchlist[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$searchlist[$i]}) 19 0 19
757 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
758 19 $tr{$searchlist[$i]} = $replacementlist[$i];
759 }
760 elsif ($modifier =~ /d/oxms) {
761 0 $tr{$searchlist[$i]} = '';
762 }
763 ▶ 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
764 0 $tr{$searchlist[$i]} = $replacementlist[-1];
765 }
766 else {
767 0 $tr{$searchlist[$i]} = $searchlist[$i];
768 }
769 }
770 }
771  
772 6 my $tr = 0;
773 6 my $replaced = '';
774 6 ▶ if ($modifier =~ /c/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /c/mosx) { } 0 6 6
775 0 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 0 0 0
776 0 ▶ if (not exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $tr{$char}) { } 0 0 0
777 0 ▶ if (defined $replacementlist[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $replacementlist[0]) 0 0 0
778 0 $replaced .= $replacementlist[0];
779 }
780 0 $tr++;
781 0 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 0 0
782 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
783 0 shift @char;
784 0 $tr++;
785 }
786 }
787 }
788 else {
789 0 $replaced .= $char;
790 }
791 }
792 }
793 else {
794 6 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 36 6 42
795 36 ▶ if (exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$char}) { } 19 17 36
796 19 $replaced .= $tr{$char};
797 19 $tr++;
798 19 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 19 19
799 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
800 0 shift @char;
801 0 $tr++;
802 }
803 }
804 }
805 else {
806 17 $replaced .= $char;
807 }
808 }
809 }
810  
811 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) { } 5 1 6
812 5 return $replaced;
813 }
814 else {
815 1 $_[0] = $replaced;
816 1 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) { } 0 1 1
817 0 return not $tr;
818 }
819 else {
820 1 return $tr;
821 }
822 }
823 }
824  
825 #
826 # KOI8-U chop
827 #
828 0 ▶sub Ekoi8u::chop(@) {
Subroutine chop: not called CC=3 SCAR=24.8
Pod undocumented
829  
830 0 my $chop;
831 0 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
832 0 my @char = /\G (?>$q_char) /oxmsg;
833 0 $chop = pop @char;
834 0 $_ = join '', @char;
835 }
836 else {
837 0 for (@_) {
838 0 my @char = /\G (?>$q_char) /oxmsg;
839 0 $chop = pop @char;
840 0 $_ = join '', @char;
841 }
842 }
843 0 return $chop;
844 }
845  
846 #
847 # KOI8-U index by octet
848 #
849 30 ▶sub Ekoi8u::index($$;$) {
Subroutine index: called CC=6 SCAR=20.8
Pod documented
850  
851 30 my($str,$substr,$position) = @_;
852 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
853 30 my $pos = 0;
854  
855 30 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str) 130 30 160
856 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
857 0 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 0 0 0
858 0 return $pos;
859 }
860 }
861 130 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Ekoi8u::q_char) /mosx) { } 130 0 130
862 130 $pos += CORE::length($1);
863 }
864 else {
865 0 $pos += 1;
866 }
867 }
868 30 return -1;
869 }
870  
871 #
872 # KOI8-U reverse index
873 #
874 0 ▶sub Ekoi8u::rindex($$;$) {
Subroutine rindex: not called CC=6 SCAR=37.4
Pod undocumented
875  
876 0 my($str,$substr,$position) = @_;
877 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
878 0 my $pos = 0;
879 0 my $rindex = -1;
880  
881 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
882 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
883 0 $rindex = $pos;
884 }
885 0 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Ekoi8u::q_char) /mosx) { } 0 0 0
886 0 $pos += CORE::length($1);
887 }
888 else {
889 0 $pos += 1;
890 }
891 }
892 0 return $rindex;
893 }
894  
895 #
896 # KOI8-U lower case first with parameter
897 #
898 0 ▶sub Ekoi8u::lcfirst(@) {
Subroutine lcfirst: not called CC=4 SCAR=30.0
Pod undocumented
899 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
900 0 my $s = shift @_;
901 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
902 0 return Ekoi8u::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
903 }
904 else {
905 0 return Ekoi8u::lc(CORE::substr($s,0,1)) . CORE::substr($s,1);
906 }
907 }
908 else {
909 0 return Ekoi8u::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
910 }
911 }
912  
913 #
914 # KOI8-U lower case first without parameter
915 #
916 0 ▶sub Ekoi8u::lcfirst_() {
Subroutine lcfirst_: not called CC=1 SCAR=6.9
Pod undocumented
917 0 return Ekoi8u::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
918 }
919  
920 #
921 # KOI8-U lower case with parameter
922 #
923 64 ▶sub Ekoi8u::lc(@) {
Subroutine lc: called CC=6 SCAR=24.2
Pod undocumented
924 64 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 64 0 64
925 64 my $s = shift @_;
926 64 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 64 64
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
6400
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
927 0 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
928 }
929 else {
930 64 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 66 0 66
931 }
932 }
933 else {
934 0 return Ekoi8u::lc_();
935 }
936 }
937  
938 #
939 # KOI8-U lower case without parameter
940 #
941 0 ▶sub Ekoi8u::lc_() {
Subroutine lc_: not called CC=2 SCAR=17.9
Pod undocumented
942 0 my $s = $_;
943 0 ▶ return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
944 }
945  
946 #
947 # KOI8-U upper case first with parameter
948 #
949 0 ▶sub Ekoi8u::ucfirst(@) {
Subroutine ucfirst: not called CC=4 SCAR=30.0
Pod undocumented
950 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
951 0 my $s = shift @_;
952 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
953 0 return Ekoi8u::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
954 }
955 else {
956 0 return Ekoi8u::uc(CORE::substr($s,0,1)) . CORE::substr($s,1);
957 }
958 }
959 else {
960 0 return Ekoi8u::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
961 }
962 }
963  
964 #
965 # KOI8-U upper case first without parameter
966 #
967 0 ▶sub Ekoi8u::ucfirst_() {
Subroutine ucfirst_: not called CC=1 SCAR=6.9
Pod undocumented
968 0 return Ekoi8u::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
969 }
970  
971 #
972 # KOI8-U upper case with parameter
973 #
974 2483 ▶sub Ekoi8u::uc(@) {
Subroutine uc: called CC=6 SCAR=22.9
Pod undocumented
975 2483 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2483 0 2483
976 2483 my $s = shift @_;
977 2483 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2483 2483
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
248300
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
978 0 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
979 }
980 else {
981 2483 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 645 1840 2485
982 }
983 }
984 else {
985 0 return Ekoi8u::uc_();
986 }
987 }
988  
989 #
990 # KOI8-U upper case without parameter
991 #
992 0 ▶sub Ekoi8u::uc_() {
Subroutine uc_: not called CC=2 SCAR=17.9
Pod undocumented
993 0 my $s = $_;
994 0 ▶ return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
995 }
996  
997 #
998 # KOI8-U fold case with parameter
999 #
1000 2490 ▶sub Ekoi8u::fc(@) {
Subroutine fc: called CC=6 SCAR=22.9
Pod undocumented
1001 2490 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2490 0 2490
1002 2490 my $s = shift @_;
1003 2490 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2490 2490
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
249000
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
1004 0 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1005 }
1006 else {
1007 2490 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 2128 5616 7744
1008 }
1009 }
1010 else {
1011 0 return Ekoi8u::fc_();
1012 }
1013 }
1014  
1015 #
1016 # KOI8-U fold case without parameter
1017 #
1018 0 ▶sub Ekoi8u::fc_() {
Subroutine fc_: not called CC=2 SCAR=17.9
Pod undocumented
1019 0 my $s = $_;
1020 0 ▶ return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1021 }
1022  
1023 #
1024 # KOI8-U regexp capture
1025 #
1026 {
1027 0 ▶ sub Ekoi8u::capture {
Subroutine capture: not called CC=1 SCAR=6.9
Pod documented
1028 0 return $_[0];
1029 }
1030 }
1031  
1032 #
1033 # KOI8-U regexp ignore case modifier
1034 #
1035 422 ▶sub Ekoi8u::ignorecase {
Subroutine ignorecase: called CC=25 SCAR=52.9
Pod undocumented
1036  
1037 11 my @string = @_;
1038 11 my $metachar = qr/[\@\\|[\]{]/oxms;
1039  
1040 # ignore case of $scalar or @array
1041 11 for my $string (@string) {
1042  
1043 # split regexp
1044 11 my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg;
1045  
1046 # unescape character
1047 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1015 11 1026
1048 1015 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 1015 1015
1049  
1050 # open character class [...]
1051 1015 ▶ if ($char[$i] eq '[') {
Branch: 4 branches
BranchTrueFalseTotal
if ($char[$i] eq '[') { } 0 1015 1015
elsif ($char[$i] eq '[^') { } 0 1015 1015
elsif (my $char = classic_character_class($char[$i])) { } 0 1015 1015
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/mosx) { } 1015 0 1015
1052 0 my $left = $i;
1053  
1054 # [] make die "unmatched [] in regexp ...\n"
1055  
1056 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1057 0 $i++;
1058 }
1059  
1060 0 while (1) {
1061 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1062 0 croak "Unmatched [] in regexp";
1063 }
1064 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1065 0 my $right = $i;
1066 0 my @charlist = charlist_qr(@char[$left+1..$right-1], 'i');
1067  
1068 # escape character
1069 0 for my $char (@charlist) {
1070 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1071 }
1072  
1073 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1074 0 $char = '\\' . $char;
1075 }
1076 }
1077  
1078 # [...]
1079 0 splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')';
1080  
1081 0 $i = $left;
1082 0 last;
1083 }
1084 }
1085 }
1086  
1087 # open character class [^...]
1088 elsif ($char[$i] eq '[^') {
1089 0 my $left = $i;
1090  
1091 # [^] make die "unmatched [] in regexp ...\n"
1092  
1093 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1094 0 $i++;
1095 }
1096  
1097 0 while (1) {
1098 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1099 0 croak "Unmatched [] in regexp";
1100 }
1101 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1102 0 my $right = $i;
1103 0 my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i');
1104  
1105 # escape character
1106 0 for my $char (@charlist) {
1107 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1108 }
1109  
1110 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1111 0 $char = '\\' . $char;
1112 }
1113 }
1114  
1115 # [^...]
1116 0 splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)";
1117  
1118 0 $i = $left;
1119 0 last;
1120 }
1121 }
1122 }
1123  
1124 # rewrite classic character class or escape character
1125 elsif (my $char = classic_character_class($char[$i])) {
1126 0 $char[$i] = $char;
1127 }
1128  
1129 # with /i modifier
1130 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1131 1015 my $uc = Ekoi8u::uc($char[$i]);
1132 1015 my $fc = Ekoi8u::fc($char[$i]);
1133 1015 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) 519 496 1015
1134 519 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 519 0 519
1135 519 $char[$i] = '[' . $uc . $fc . ']';
1136 }
1137 else {
1138 0 $char[$i] = '(?:' . $uc . '|' . $fc . ')';
1139 }
1140 }
1141 }
1142 }
1143  
1144 # characterize
1145 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1015 11 1026
1146 1015 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 1015 1015
1147  
1148 1015 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx }) 0 1026 1026
1149 }
1150  
1151 # quote character before ? + * {
1152 0 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition66%2/3
$i >= 1 && $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
1110040
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
1153 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
1154 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
1155 }
1156 }
1157 }
1158  
1159 11 $string = join '', @char;
1160 }
1161  
1162 # make regexp string
1163 11 return @string;
1164 }
1165  
1166 #
1167 # classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B )
1168 #
1169 2883 ▶sub Ekoi8u::classic_character_class {
Subroutine classic_character_class: called CC=2 SCAR=6.9
Pod undocumented
1170 2883 my($char) = @_;
1171  
1172 return {
1173 '\D' => '${Ekoi8u::eD}',
1174 '\S' => '${Ekoi8u::eS}',
1175 '\W' => '${Ekoi8u::eW}',
1176 '\d' => '[0-9]',
1177  
1178 # Before Perl 5.6, \s only matched the five whitespace characters
1179 # tab, newline, form-feed, carriage return, and the space character
1180 # itself, which, taken together, is the character class [\t\n\f\r ].
1181  
1182 # Vertical tabs are now whitespace
1183 # \s in a regex now matches a vertical tab in all circumstances.
1184 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1185 # \t \n \v \f \r space
1186 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1187 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1188 '\s' => '\s',
1189  
1190 '\w' => '[0-9A-Z_a-z]',
1191 '\C' => '[\x00-\xFF]',
1192 '\X' => 'X',
1193  
1194 # \h \v \H \V
1195  
1196 # P.114 Character Class Shortcuts
1197 # in Chapter 7: In the World of Regular Expressions
1198 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
1199  
1200 # P.357 13.2.3 Whitespace
1201 # in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes
1202 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1203 #
1204 # 0x00009 CHARACTER TABULATION h s
1205 # 0x0000a LINE FEED (LF) vs
1206 # 0x0000b LINE TABULATION v
1207 # 0x0000c FORM FEED (FF) vs
1208 # 0x0000d CARRIAGE RETURN (CR) vs
1209 # 0x00020 SPACE h s
1210  
1211 # P.196 Table 5-9. Alphanumeric regex metasymbols
1212 # in Chapter 5. Pattern Matching
1213 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1214  
1215 # (and so on)
1216  
1217 '\H' => '${Ekoi8u::eH}',
1218 '\V' => '${Ekoi8u::eV}',
1219 '\h' => '[\x09\x20]',
1220 '\v' => '[\x0A\x0B\x0C\x0D]',
1221 '\R' => '${Ekoi8u::eR}',
1222  
1223 # \N
1224 #
1225 # http://perldoc.perl.org/perlre.html
1226 # Character Classes and other Special Escapes
1227 # Any character but \n (experimental). Not affected by /s modifier
1228  
1229 '\N' => '${Ekoi8u::eN}',
1230  
1231 # \b \B
1232  
1233 # P.180 Boundaries: The \b and \B Assertions
1234 # in Chapter 5: Pattern Matching
1235 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1236  
1237 # P.219 Boundaries: The \b and \B Assertions
1238 # in Chapter 5: Pattern Matching
1239 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1240  
1241 # \b really means (?:(?<=\w)(?!\w)|(?<!\w)(?=\w))
1242 # or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z))
1243 '\b' => '${Ekoi8u::eb}',
1244  
1245 # \B really means (?:(?<=\w)(?=\w)|(?<!\w)(?!\w))
1246 # or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W))
1247 '\B' => '${Ekoi8u::eB}',
1248  
1249 2883 ▶ }->{$char} || '';
Condition100%2/2
{'\\D', '${Ekoi8u::eD}', '\\S', '${Ekoi8u::eS}', '\\W', '${Ekoi8u::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8u::eH}', '\\V', '${Ekoi8u::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8u::eR}', '\\N', '${Ekoi8u::eN}', '\\b', '${Ekoi8u::eb}', '\\B', '${Ekoi8u::eB}'}->{$char} || ''
l!l
1012782
MC/DC100%1/1
{'\\D', '${Ekoi8u::eD}', '\\S', '${Ekoi8u::eS}', '\\W', '${Ekoi8u::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8u::eH}', '\\V', '${Ekoi8u::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8u::eR}', '\\N', '${Ekoi8u::eN}', '\\b', '${Ekoi8u::eb}', '\\B', '${Ekoi8u::eB}'}->{$char} || ''
{'\\D', '${Ekoi8u::eD}', '\\S', '${Ekoi8u::eS}', '\\W', '${Ekoi8u::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8u::eH}', '\\V', '${Ekoi8u::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8u::eR}', '\\N', '${Ekoi8u::eN}', '\\b', '${Ekoi8u::eb}', '\\B', '${Ekoi8u::eB}'}->{$char}
Truth table100%2/2
A
A= {'\\D', '${Ekoi8u::eD}', '\\S', '${Ekoi8u::eS}', '\\W', '${Ekoi8u::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8u::eH}', '\\V', '${Ekoi8u::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8u::eR}', '\\N', '${Ekoi8u::eN}', '\\b', '${Ekoi8u::eb}', '\\B', '${Ekoi8u::eB}'}->{$char}
Aresult
11
00
1250 }
1251  
1252 #
1253 # prepare KOI8-U characters per length
1254 #
1255  
1256 # 1 octet characters
1257 422 my @chars1 = ();
1258 0 ▶sub chars1 {
Subroutine chars1: not called CC=5 SCAR=34.0
Pod undocumented
1259 0 ▶ if (@chars1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars1) 0 0 0
1260 0 return @chars1;
1261 }
1262 0 ▶ if (exists $range_tr{1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{1}) 0 0 0
1263 0 my @ranges = @{ $range_tr{1} };
1264 0 ▶ while (my @range = splice(@ranges,0,1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 1)) 0 0 0
1265 0 for my $oct0 (@{$range[0]}) {
1266 0 push @chars1, pack 'C', $oct0;
1267 }
1268 }
1269 }
1270 0 return @chars1;
1271 }
1272  
1273 # 2 octets characters
1274 422 my @chars2 = ();
1275 0 ▶sub chars2 {
Subroutine chars2: not called CC=6 SCAR=37.4
Pod undocumented
1276 0 ▶ if (@chars2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars2) 0 0 0
1277 0 return @chars2;
1278 }
1279 0 ▶ if (exists $range_tr{2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{2}) 0 0 0
1280 0 my @ranges = @{ $range_tr{2} };
1281 0 ▶ while (my @range = splice(@ranges,0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 2)) 0 0 0
1282 0 for my $oct0 (@{$range[0]}) {
1283 0 for my $oct1 (@{$range[1]}) {
1284 0 push @chars2, pack 'CC', $oct0,$oct1;
1285 }
1286 }
1287 }
1288 }
1289 0 return @chars2;
1290 }
1291  
1292 # 3 octets characters
1293 422 my @chars3 = ();
1294 0 ▶sub chars3 {
Subroutine chars3: not called CC=7 SCAR=40.3
Pod undocumented
1295 0 ▶ if (@chars3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars3) 0 0 0
1296 0 return @chars3;
1297 }
1298 0 ▶ if (exists $range_tr{3}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{3}) 0 0 0
1299 0 my @ranges = @{ $range_tr{3} };
1300 0 ▶ while (my @range = splice(@ranges,0,3)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 3)) 0 0 0
1301 0 for my $oct0 (@{$range[0]}) {
1302 0 for my $oct1 (@{$range[1]}) {
1303 0 for my $oct2 (@{$range[2]}) {
1304 0 push @chars3, pack 'CCC', $oct0,$oct1,$oct2;
1305 }
1306 }
1307 }
1308 }
1309 }
1310 0 return @chars3;
1311 }
1312  
1313 # 4 octets characters
1314 422 my @chars4 = ();
1315 0 ▶sub chars4 {
Subroutine chars4: not called CC=8 SCAR=42.8
Pod undocumented
1316 0 ▶ if (@chars4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars4) 0 0 0
1317 0 return @chars4;
1318 }
1319 0 ▶ if (exists $range_tr{4}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{4}) 0 0 0
1320 0 my @ranges = @{ $range_tr{4} };
1321 0 ▶ while (my @range = splice(@ranges,0,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 4)) 0 0 0
1322 0 for my $oct0 (@{$range[0]}) {
1323 0 for my $oct1 (@{$range[1]}) {
1324 0 for my $oct2 (@{$range[2]}) {
1325 0 for my $oct3 (@{$range[3]}) {
1326 0 push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3;
1327 }
1328 }
1329 }
1330 }
1331 }
1332 }
1333 0 return @chars4;
1334 }
1335  
1336 #
1337 # KOI8-U open character list for tr
1338 #
1339 12 ▶sub _charlist_tr {
Subroutine _charlist_tr: called CC=35 SCAR=66.4
1340  
1341 12 local $_ = shift @_;
1342  
1343 # unescape character
1344 12 my @char = ();
1345 12 ▶ while (not /\G \z/oxmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgmosx) 38 12 50
1346 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 \\ ($Ekoi8u::q_char) /cgmosx) { } 0 38 38
elsif (/\G ($Ekoi8u::q_char) /cgmosx) { } 38 0 38
1347 0 push @char, '\-';
1348 }
1349 elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) {
1350 0 push @char, CORE::chr(oct $1);
1351 }
1352 elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) {
1353 0 push @char, CORE::chr(hex $1);
1354 }
1355 elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) {
1356 0 push @char, CORE::chr(CORE::ord($1) & 0x1F);
1357 }
1358 elsif (/\G (\\ [0nrtfbae]) /oxmsgc) {
1359 push @char, {
1360 '\0' => "\0",
1361 '\n' => "\n",
1362 '\r' => "\r",
1363 '\t' => "\t",
1364 '\f' => "\f",
1365 '\b' => "\x08", # \b means backspace in character class
1366 '\a' => "\a",
1367 '\e' => "\e",
1368 0 }->{$1};
1369 }
1370 elsif (/\G \\ ($q_char) /oxmsgc) {
1371 0 push @char, $1;
1372 }
1373 elsif (/\G ($q_char) /oxmsgc) {
1374 38 push @char, $1;
1375 }
1376 }
1377  
1378 # join separated multiple-octet
1379 12 @char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg;
1380  
1381 # unescape '-'
1382 12 my @i = ();
1383 12 for my $i (0 .. $#char) {
1384 38 ▶ if ($char[$i] eq '\-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\-') { } 0 38 38
elsif ($char[$i] eq '-') { } 0 38 38
1385 0 $char[$i] = '-';
1386 }
1387 elsif ($char[$i] eq '-') {
1388 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
1389 0 push @i, $i;
1390 }
1391 }
1392 }
1393  
1394 # open character list (reverse for splice)
1395 12 for my $i (CORE::reverse @i) {
1396 0 my @range = ();
1397  
1398 # range error
1399 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
1400 0 croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1401 }
1402  
1403 # range of multiple-octet code
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 ▶ 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
1406 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
1407 }
1408 elsif (CORE::length($char[$i+1]) == 2) {
1409 0 push @range, grep {$char[$i-1] le $_} chars1();
1410 0 push @range, grep {$_ le $char[$i+1]} chars2();
1411 }
1412 elsif (CORE::length($char[$i+1]) == 3) {
1413 0 push @range, grep {$char[$i-1] le $_} chars1();
1414 0 push @range, chars2();
1415 0 push @range, grep {$_ le $char[$i+1]} chars3();
1416 }
1417 elsif (CORE::length($char[$i+1]) == 4) {
1418 0 push @range, grep {$char[$i-1] le $_} chars1();
1419 0 push @range, chars2();
1420 0 push @range, chars3();
1421 0 push @range, grep {$_ le $char[$i+1]} chars4();
1422 }
1423 else {
1424 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1425 }
1426 }
1427 elsif (CORE::length($char[$i-1]) == 2) {
1428 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
1429 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
1430 }
1431 elsif (CORE::length($char[$i+1]) == 3) {
1432 0 push @range, grep {$char[$i-1] le $_} chars2();
1433 0 push @range, grep {$_ le $char[$i+1]} chars3();
1434 }
1435 elsif (CORE::length($char[$i+1]) == 4) {
1436 0 push @range, grep {$char[$i-1] le $_} chars2();
1437 0 push @range, chars3();
1438 0 push @range, grep {$_ le $char[$i+1]} chars4();
1439 }
1440 else {
1441 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1442 }
1443 }
1444 elsif (CORE::length($char[$i-1]) == 3) {
1445 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
1446 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
1447 }
1448 elsif (CORE::length($char[$i+1]) == 4) {
1449 0 push @range, grep {$char[$i-1] le $_} chars3();
1450 0 push @range, grep {$_ le $char[$i+1]} chars4();
1451 }
1452 else {
1453 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1454 }
1455 }
1456 elsif (CORE::length($char[$i-1]) == 4) {
1457 0 ▶ if (CORE::length($char[$i+1]) == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i + 1] == 4) { } 0 0 0
1458 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
1459 }
1460 else {
1461 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1462 }
1463 }
1464 else {
1465 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1466 }
1467  
1468 0 splice @char, $i-1, 3, @range;
1469 }
1470  
1471 12 return @char;
1472 }
1473  
1474 #
1475 # KOI8-U open character class
1476 #
1477 0 ▶sub _cc {
Subroutine _cc: not called CC=7 SCAR=40.3
1478 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
1479 0 die __FILE__, ": subroutine cc got no parameter.\n";
1480 }
1481 elsif (scalar(@_) == 1) {
1482 0 return sprintf('\x%02X',$_[0]);
1483 }
1484 elsif (scalar(@_) == 2) {
1485 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
1486 0 die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n";
1487 }
1488 elsif ($_[0] == $_[1]) {
1489 0 return sprintf('\x%02X',$_[0]);
1490 }
1491 elsif (($_[0]+1) == $_[1]) {
1492 0 return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]);
1493 }
1494 else {
1495 0 return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]);
1496 }
1497 }
1498 else {
1499 0 die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n";
1500 }
1501 }
1502  
1503 #
1504 # KOI8-U octet range
1505 #
1506 246 ▶sub _octets {
Subroutine _octets: called CC=5 SCAR=19.3
1507 246 my $length = shift @_;
1508  
1509 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1510 246 my($a1) = unpack 'C', $_[0];
1511 246 my($z1) = unpack 'C', $_[1];
1512  
1513 246 ▶ if ($a1 > $z1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1 > $z1) 0 246 246
1514 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1);
1515 }
1516  
1517 246 ▶ if ($a1 == $z1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($a1 == $z1) { } 0 246 246
elsif ($a1 + 1 == $z1) { } 0 246 246
1518 0 return sprintf('\x%02X',$a1);
1519 }
1520 elsif (($a1+1) == $z1) {
1521 0 return sprintf('\x%02X\x%02X',$a1,$z1);
1522 }
1523 else {
1524 246 return sprintf('\x%02X-\x%02X',$a1,$z1);
1525 }
1526 }
1527 else {
1528 0 die __FILE__, ": subroutine _octets got invalid length ($length).\n";
1529 }
1530 }
1531  
1532 #
1533 # KOI8-U range regexp
1534 #
1535 246 ▶sub _range_regexp {
Subroutine _range_regexp: called CC=18 SCAR=41.7
1536 246 my($length,$first,$last) = @_;
1537  
1538 246 my @range_regexp = ();
1539 246 ▶ if (not exists $range_tr{$length}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $range_tr{$length}) 0 246 246
1540 0 return @range_regexp;
1541 }
1542  
1543 246 my @ranges = @{ $range_tr{$length} };
1544 246 ▶ while (my @range = splice(@ranges,0,$length)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, $length)) 246 246 492
1545 246 my $min = '';
1546 246 my $max = '';
1547 246 ▶ for (my $i=0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 246 246 492
1548 246 $min .= pack 'C', $range[$i][0];
1549 246 $max .= pack 'C', $range[$i][-1];
1550 }
1551  
1552 # min___max
1553 # FIRST_____________LAST
1554 # (nothing)
1555  
1556 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
1557 }
1558  
1559 # **********
1560 # min_________max
1561 # FIRST_____________LAST
1562 # **********
1563  
1564 ▶ 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
1565 0 push @range_regexp, _octets($length,$first,$max,$min,$max);
1566 }
1567  
1568 # **********************
1569 # min________________max
1570 # FIRST_____________LAST
1571 # **********************
1572  
1573 ▶ 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
1574 0 push @range_regexp, _octets($length,$first,$last,$min,$max);
1575 }
1576  
1577 # *********
1578 # min___max
1579 # FIRST_____________LAST
1580 # *********
1581  
1582 ▶ 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
1583 0 push @range_regexp, _octets($length,$min,$max,$min,$max);
1584 }
1585  
1586 # **********************
1587 # min__________________________max
1588 # FIRST_____________LAST
1589 # **********************
1590  
1591 ▶ 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
1592 246 push @range_regexp, _octets($length,$first,$last,$min,$max);
1593 }
1594  
1595 # *********
1596 # min________max
1597 # FIRST_____________LAST
1598 # *********
1599  
1600 ▶ 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
1601 0 push @range_regexp, _octets($length,$min,$last,$min,$max);
1602 }
1603  
1604 # min___max
1605 # FIRST_____________LAST
1606 # (nothing)
1607  
1608 elsif ($last lt $min) {
1609 }
1610  
1611 else {
1612 0 die __FILE__, ": subroutine _range_regexp panic.\n";
1613 }
1614 }
1615  
1616 246 return @range_regexp;
1617 }
1618  
1619 #
1620 # KOI8-U open character list for qr and not qr
1621 #
1622 650 ▶sub _charlist {
Subroutine _charlist: called CC=46 SCAR=45.9
1623  
1624 650 my $modifier = pop @_;
1625 650 my @char = @_;
1626  
1627 650 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 298 352 650
1628  
1629 # unescape character
1630 650 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1773 650 2423
1631  
1632 # escape - to ...
1633 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 \\ ($Ekoi8u::q_char) \z/mosx) { } 7 1371 1378
1634 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
1635 246 $char[$i] = '...';
1636 }
1637 }
1638  
1639 # octal escape sequence
1640 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
1641 0 $char[$i] = octchr($1);
1642 }
1643  
1644 # hexadecimal escape sequence
1645 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
1646 0 $char[$i] = hexchr($1);
1647 }
1648  
1649 # \b{...} --> b\{...}
1650 # \B{...} --> B\{...}
1651 # \N{CHARNAME} --> N\{CHARNAME}
1652 # \p{PROPERTY} --> p\{PROPERTY}
1653 # \P{PROPERTY} --> P\{PROPERTY}
1654 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
1655 0 $char[$i] = $1 . '\\' . $2;
1656 }
1657  
1658 # \p, \P, \X --> p, P, X
1659 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
1660 0 $char[$i] = $1;
1661 }
1662  
1663 elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) {
1664 0 $char[$i] = CORE::chr oct $1;
1665 }
1666 elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) {
1667 22 $char[$i] = CORE::chr hex $1;
1668 }
1669 elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) {
1670 0 $char[$i] = CORE::chr(CORE::ord($1) & 0x1F);
1671 }
1672 elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) {
1673 $char[$i] = {
1674 '\0' => "\0",
1675 '\n' => "\n",
1676 '\r' => "\r",
1677 '\t' => "\t",
1678 '\f' => "\f",
1679 '\b' => "\x08", # \b means backspace in character class
1680 '\a' => "\a",
1681 '\e' => "\e",
1682 '\d' => '[0-9]',
1683  
1684 # Vertical tabs are now whitespace
1685 # \s in a regex now matches a vertical tab in all circumstances.
1686 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1687 # \t \n \v \f \r space
1688 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1689 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1690 '\s' => '\s',
1691  
1692 '\w' => '[0-9A-Z_a-z]',
1693 '\D' => '${Ekoi8u::eD}',
1694 '\S' => '${Ekoi8u::eS}',
1695 '\W' => '${Ekoi8u::eW}',
1696  
1697 '\H' => '${Ekoi8u::eH}',
1698 '\V' => '${Ekoi8u::eV}',
1699 '\h' => '[\x09\x20]',
1700 '\v' => '[\x0A\x0B\x0C\x0D]',
1701 '\R' => '${Ekoi8u::eR}',
1702  
1703 25 }->{$1};
1704 }
1705  
1706 # POSIX-style character classes
1707 ▶ 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
1708 $char[$i] = {
1709  
1710 '[:lower:]' => '[\x41-\x5A\x61-\x7A]',
1711 '[:upper:]' => '[\x41-\x5A\x61-\x7A]',
1712 '[:^lower:]' => '${Ekoi8u::not_lower_i}',
1713 '[:^upper:]' => '${Ekoi8u::not_upper_i}',
1714  
1715 8 }->{$1};
1716 }
1717 elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) {
1718 $char[$i] = {
1719  
1720 '[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]',
1721 '[:alpha:]' => '[\x41-\x5A\x61-\x7A]',
1722 '[:ascii:]' => '[\x00-\x7F]',
1723 '[:blank:]' => '[\x09\x20]',
1724 '[:cntrl:]' => '[\x00-\x1F\x7F]',
1725 '[:digit:]' => '[\x30-\x39]',
1726 '[:graph:]' => '[\x21-\x7F]',
1727 '[:lower:]' => '[\x61-\x7A]',
1728 '[:print:]' => '[\x20-\x7F]',
1729 '[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]',
1730  
1731 # P.174 POSIX-Style Character Classes
1732 # in Chapter 5: Pattern Matching
1733 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1734  
1735 # P.311 11.2.4 Character Classes and other Special Escapes
1736 # in Chapter 11: perlre: Perl regular expressions
1737 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1738  
1739 # P.210 POSIX-Style Character Classes
1740 # in Chapter 5: Pattern Matching
1741 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1742  
1743 '[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK")
1744  
1745 '[:upper:]' => '[\x41-\x5A]',
1746 '[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]',
1747 '[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]',
1748 '[:^alnum:]' => '${Ekoi8u::not_alnum}',
1749 '[:^alpha:]' => '${Ekoi8u::not_alpha}',
1750 '[:^ascii:]' => '${Ekoi8u::not_ascii}',
1751 '[:^blank:]' => '${Ekoi8u::not_blank}',
1752 '[:^cntrl:]' => '${Ekoi8u::not_cntrl}',
1753 '[:^digit:]' => '${Ekoi8u::not_digit}',
1754 '[:^graph:]' => '${Ekoi8u::not_graph}',
1755 '[:^lower:]' => '${Ekoi8u::not_lower}',
1756 '[:^print:]' => '${Ekoi8u::not_print}',
1757 '[:^punct:]' => '${Ekoi8u::not_punct}',
1758 '[:^space:]' => '${Ekoi8u::not_space}',
1759 '[:^upper:]' => '${Ekoi8u::not_upper}',
1760 '[:^word:]' => '${Ekoi8u::not_word}',
1761 '[:^xdigit:]' => '${Ekoi8u::not_xdigit}',
1762  
1763 70 }->{$1};
1764 }
1765 elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) {
1766 7 $char[$i] = $1;
1767 }
1768 }
1769  
1770 # open character list
1771 650 my @singleoctet = ();
1772 650 my @multipleoctet = ();
1773 650 ▶ for (my $i=0; $i <= $#char; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1527 650 2177
1774  
1775 # escaped -
1776 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
1777 246 $i += 1;
1778 246 next;
1779 }
1780  
1781 # make range regexp
1782 elsif ($char[$i] eq '...') {
1783  
1784 # range error
1785 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
1786 0 croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1787 }
1788 elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) {
1789 246 ▶ if ($char[$i-1] gt $char[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] gt $char[$i + 1]) 0 246 246
1790 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1791 }
1792 }
1793  
1794 # make range regexp per length
1795 246 for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) {
1796 246 my @regexp = ();
1797  
1798 # is first and last
1799 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
1800 246 push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]);
1801 }
1802  
1803 # is first
1804 elsif ($length == CORE::length($char[$i-1])) {
1805 0 push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length);
1806 }
1807  
1808 # is inside in first and last
1809 ▶ 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
1810 0 push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length);
1811 }
1812  
1813 # is last
1814 elsif ($length == CORE::length($char[$i+1])) {
1815 0 push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]);
1816 }
1817  
1818 else {
1819 0 die __FILE__, ": subroutine make_regexp panic.\n";
1820 }
1821  
1822 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1823 246 push @singleoctet, @regexp;
1824 }
1825 else {
1826 0 push @multipleoctet, @regexp;
1827 }
1828 }
1829  
1830 246 $i += 2;
1831 }
1832  
1833 # with /i modifier
1834 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1835 949 ▶ if ($modifier =~ /i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) { } 480 469 949
1836 480 my $uc = Ekoi8u::uc($char[$i]);
1837 480 my $fc = Ekoi8u::fc($char[$i]);
1838 480 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) { } 240 240 480
1839 240 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 240 0 240
1840 240 push @singleoctet, $uc, $fc;
1841 }
1842 else {
1843 0 push @singleoctet, $uc;
1844 0 push @multipleoctet, $fc;
1845 }
1846 }
1847 else {
1848 240 push @singleoctet, $char[$i];
1849 }
1850 }
1851 else {
1852 469 push @singleoctet, $char[$i];
1853 }
1854 949 $i += 1;
1855 }
1856  
1857 # single character of single octet code
1858 elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) {
1859 0 push @singleoctet, "\t", "\x20";
1860 0 $i += 1;
1861 }
1862 elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) {
1863 0 push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D";
1864 0 $i += 1;
1865 }
1866 elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) {
1867 2 push @singleoctet, $char[$i];
1868 2 $i += 1;
1869 }
1870  
1871 # single character of multiple-octet code
1872 else {
1873 84 push @multipleoctet, $char[$i];
1874 84 $i += 1;
1875 }
1876 }
1877  
1878 # quote metachar
1879 650 for (@singleoctet) {
1880 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
1881 0 $_ = '-';
1882 }
1883 elsif (/\A \n \z/oxms) {
1884 8 $_ = '\n';
1885 }
1886 elsif (/\A \r \z/oxms) {
1887 8 $_ = '\r';
1888 }
1889 elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) {
1890 744 $_ = sprintf('\x%02X', CORE::ord $1);
1891 }
1892 elsif (/\A [\x00-\xFF] \z/oxms) {
1893 429 $_ = quotemeta $_;
1894 }
1895 }
1896  
1897 # return character list
1898 650 return \@singleoctet, \@multipleoctet;
1899 }
1900  
1901 #
1902 # KOI8-U octal escape sequence
1903 #
1904 5 ▶sub octchr {
Subroutine octchr: called CC=2 SCAR=6.9
Pod undocumented
1905 5 my($octdigit) = @_;
1906  
1907 5 my @binary = ();
1908 5 for my $octal (split(//,$octdigit)) {
1909 push @binary, {
1910 '0' => '000',
1911 '1' => '001',
1912 '2' => '010',
1913 '3' => '011',
1914 '4' => '100',
1915 '5' => '101',
1916 '6' => '110',
1917 '7' => '111',
1918 50 }->{$octal};
1919 }
1920 5 my $binary = join '', @binary;
1921  
1922 my $octchr = {
1923 # 1234567
1924 1 => pack('B*', "0000000$binary"),
1925 2 => pack('B*', "000000$binary"),
1926 3 => pack('B*', "00000$binary"),
1927 4 => pack('B*', "0000$binary"),
1928 5 => pack('B*', "000$binary"),
1929 6 => pack('B*', "00$binary"),
1930 7 => pack('B*', "0$binary"),
1931 0 => pack('B*', "$binary"),
1932  
1933 5 }->{CORE::length($binary) % 8};
1934  
1935 5 return $octchr;
1936 }
1937  
1938 #
1939 # KOI8-U hexadecimal escape sequence
1940 #
1941 5 ▶sub hexchr {
Subroutine hexchr: called CC=1 SCAR=0.0
Pod undocumented
1942 5 my($hexdigit) = @_;
1943  
1944 my $hexchr = {
1945 1 => pack('H*', "0$hexdigit"),
1946 0 => pack('H*', "$hexdigit"),
1947  
1948 5 }->{CORE::length($_[0]) % 2};
1949  
1950 5 return $hexchr;
1951 }
1952  
1953 #
1954 # KOI8-U open character list for qr
1955 #
1956 576 ▶sub charlist_qr {
Subroutine charlist_qr: called CC=17 SCAR=28.7
Pod undocumented
1957  
1958 576 my $modifier = pop @_;
1959 576 my @char = @_;
1960  
1961 576 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
1962 576 my @singleoctet = @$singleoctet;
1963 576 my @multipleoctet = @$multipleoctet;
1964  
1965 # return character list
1966 576 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) 498 78 576
1967  
1968 # with /i modifier
1969 498 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 265 233 498
1970 265 my %singleoctet_ignorecase = ();
1971 265 for (@singleoctet) {
1972 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
1973 745 for my $ord (hex($1) .. hex($2)) {
1974 795 my $char = CORE::chr($ord);
1975 795 my $uc = Ekoi8u::uc($char);
1976 795 my $fc = Ekoi8u::fc($char);
1977 795 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 240 555 795
1978 240 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
1979 }
1980 else {
1981 555 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 555 0 555
1982 555 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1983 555 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
1984 }
1985 else {
1986 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1987 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
1988 }
1989 }
1990 }
1991 }
1992 745 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 745 745
1993 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
1994 }
1995 }
1996 265 my $i = 0;
1997 265 my @singleoctet_ignorecase = ();
1998 265 for my $ord (0 .. 255) {
1999 67840 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 870 66970 67840
2000 870 push @{$singleoctet_ignorecase[$i]}, $ord;
2001 }
2002 else {
2003 66970 $i++;
2004 }
2005 }
2006 265 @singleoctet = ();
2007 265 for my $range (@singleoctet_ignorecase) {
2008 56160 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 770 55390 56160
2009 770 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 720 50 770
elsif (scalar @{$range;} == 2) { } 0 50 50
2010 720 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2011 }
2012 50 elsif (scalar(@{$range}) == 2) {
2013 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2014 }
2015 else {
2016 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2017 }
2018 }
2019 }
2020 }
2021  
2022 498 my $not_anchor = '';
2023  
2024 498 push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' );
2025 }
2026 576 ▶ if (scalar(@multipleoctet) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 2) { } 6 570 576
2027 6 return '(?:' . join('|', @multipleoctet) . ')';
2028 }
2029 else {
2030 570 return $multipleoctet[0];
2031 }
2032 }
2033  
2034 #
2035 # KOI8-U open character list for not qr
2036 #
2037 74 ▶sub charlist_not_qr {
Subroutine charlist_not_qr: called CC=18 SCAR=33.1
Pod undocumented
2038  
2039 74 my $modifier = pop @_;
2040 74 my @char = @_;
2041  
2042 74 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
2043 74 my @singleoctet = @$singleoctet;
2044 74 my @multipleoctet = @$multipleoctet;
2045  
2046 # with /i modifier
2047 74 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 25 49 74
2048 25 my %singleoctet_ignorecase = ();
2049 25 for (@singleoctet) {
2050 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
2051 25 for my $ord (hex($1) .. hex($2)) {
2052 75 my $char = CORE::chr($ord);
2053 75 my $uc = Ekoi8u::uc($char);
2054 75 my $fc = Ekoi8u::fc($char);
2055 75 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 0 75 75
2056 0 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
2057 }
2058 else {
2059 75 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 75 0 75
2060 75 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2061 75 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
2062 }
2063 else {
2064 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2065 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
2066 }
2067 }
2068 }
2069 }
2070 25 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 25 25
2071 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
2072 }
2073 }
2074 25 my $i = 0;
2075 25 my @singleoctet_ignorecase = ();
2076 25 for my $ord (0 .. 255) {
2077 6400 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 150 6250 6400
2078 150 push @{$singleoctet_ignorecase[$i]}, $ord;
2079 }
2080 else {
2081 6250 $i++;
2082 }
2083 }
2084 25 @singleoctet = ();
2085 25 for my $range (@singleoctet_ignorecase) {
2086 2400 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 50 2350 2400
2087 50 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 0 50 50
elsif (scalar @{$range;} == 2) { } 0 50 50
2088 0 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2089 }
2090 50 elsif (scalar(@{$range}) == 2) {
2091 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2092 }
2093 else {
2094 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2095 }
2096 }
2097 }
2098 }
2099  
2100 # return character list
2101 74 ▶ if (scalar(@multipleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 1) { } 0 74 74
2102 0 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 0 0 0
2103  
2104 # any character other than multiple-octet and single octet character class
2105 0 return '(?!' . join('|', @multipleoctet) . ')(?:[^' . join('', @singleoctet) . '])';
2106 }
2107 else {
2108  
2109 # any character other than multiple-octet character class
2110 0 return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)";
2111 }
2112 }
2113 else {
2114 74 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 74 0 74
2115  
2116 # any character other than single octet character class
2117 74 return '(?:[^' . join('', @singleoctet) . '])';
2118 }
2119 else {
2120  
2121 # any character
2122 0 return "(?:$your_char)";
2123 }
2124 }
2125 }
2126  
2127 #
2128 # open file in read mode
2129 #
2130 422 ▶sub _open_r {
Subroutine _open_r: called CC=1 SCAR=0.0
2131 422 my(undef,$file) = @_;
2132 422 ▶ use Fcntl qw(O_RDONLY);
Subroutine BEGIN: called CC=1 SCAR=0.0
2133 422 return CORE::sysopen($_[0], $file, &O_RDONLY);
2134 }
2135  
2136 #
2137 # open file in append mode
2138 #
2139 211 ▶sub _open_a {
Subroutine _open_a: called CC=1 SCAR=0.0
2140 211 my(undef,$file) = @_;
2141 422 ▶ use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
2142 211 return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT);
2143 }
2144  
2145 #
2146 # safe system
2147 #
2148 211 ▶sub _systemx {
Subroutine _systemx: called CC=1 SCAR=0.0
2149  
2150 # P.707 29.2.33. exec
2151 # in Chapter 29: Functions
2152 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2153 #
2154 # Be aware that in older releases of Perl, exec (and system) did not flush
2155 # your output buffer, so you needed to enable command buffering by setting $|
2156 # on one or more filehandles to avoid lost output in the case of exec, or
2157 # misordererd output in the case of system. This situation was largely remedied
2158 # in the 5.6 release of Perl. (So, 5.005 release not yet.)
2159  
2160 # P.855 exec
2161 # in Chapter 27: Functions
2162 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2163 #
2164 # In very old release of Perl (before v5.6), exec (and system) did not flush
2165 # your output buffer, so you needed to enable command buffering by setting $|
2166 # on one or more filehandles to avoid lost output with exec or misordered
2167 # output with system.
2168  
2169 211 $| = 1;
2170  
2171 # P.565 23.1.2. Cleaning Up Your Environment
2172 # in Chapter 23: Security
2173 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2174  
2175 # P.656 Cleaning Up Your Environment
2176 # in Chapter 20: Security
2177 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2178  
2179 # local $ENV{'PATH'} = '.';
2180 211 local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
2181  
2182 # P.707 29.2.33. exec
2183 # in Chapter 29: Functions
2184 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2185 #
2186 # As we mentioned earlier, exec treats a discrete list of arguments as an
2187 # indication that it should bypass shell processing. However, there is one
2188 # place where you might still get tripped up. The exec call (and system, too)
2189 # will not distinguish between a single scalar argument and an array containing
2190 # only one element.
2191 #
2192 # @args = ("echo surprise"); # just one element in list
2193 # exec @args # still subject to shell escapes
2194 # or die "exec: $!"; # because @args == 1
2195 #
2196 # To avoid this, you can use the PATHNAME syntax, explicitly duplicating the
2197 # first argument as the pathname, which forces the rest of the arguments to be
2198 # interpreted as a list, even if there is only one of them:
2199 #
2200 # exec { $args[0] } @args # safe even with one-argument list
2201 # or die "can't exec @args: $!";
2202  
2203 # P.855 exec
2204 # in Chapter 27: Functions
2205 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2206 #
2207 # As we mentioned earlier, exec treats a discrete list of arguments as a
2208 # directive to bypass shell processing. However, there is one place where
2209 # you might still get tripped up. The exec call (and system, too) cannot
2210 # distinguish between a single scalar argument and an array containing
2211 # only one element.
2212 #
2213 # @args = ("echo surprise"); # just one element in list
2214 # exec @args # still subject to shell escapes
2215 # || die "exec: $!"; # because @args == 1
2216 #
2217 # To avoid this, use the PATHNAME syntax, explicitly duplicating the first
2218 # argument as the pathname, which forces the rest of the arguments to be
2219 # interpreted as a list, even if there is only one of them:
2220 #
2221 # exec { $args[0] } @args # safe even with one-argument list
2222 # || die "can't exec @args: $!";
2223  
2224 211 return CORE::system { $_[0] } @_; # safe even with one-argument list
2225 }
2226  
2227 #
2228 # KOI8-U order to character (with parameter)
2229 #
2230 3469 ▶sub Ekoi8u::chr(;$) {
Subroutine chr: called CC=4 SCAR=13.9
Pod undocumented
2231  
2232 3469 ▶ my $c = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3469 0 3469
2233  
2234 3469 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 24 3445 3469
2235 24 return "\x00";
2236 }
2237 else {
2238 3445 my @chr = ();
2239 3445 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 3445 3445 6890
2240 3445 unshift @chr, ($c % 0x100);
2241 3445 $c = int($c / 0x100);
2242 }
2243 3445 return pack 'C*', @chr;
2244 }
2245 }
2246  
2247 #
2248 # KOI8-U order to character (without parameter)
2249 #
2250 0 ▶sub Ekoi8u::chr_() {
Subroutine chr_: not called CC=3 SCAR=24.8
Pod undocumented
2251  
2252 0 my $c = $_;
2253  
2254 0 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 0 0 0
2255 0 return "\x00";
2256 }
2257 else {
2258 0 my @chr = ();
2259 0 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 0 0 0
2260 0 unshift @chr, ($c % 0x100);
2261 0 $c = int($c / 0x100);
2262 }
2263 0 return pack 'C*', @chr;
2264 }
2265 }
2266  
2267 #
2268 # KOI8-U path globbing (with parameter)
2269 #
2270 0 ▶sub Ekoi8u::glob($) {
Subroutine glob: not called CC=3 SCAR=24.8
Pod undocumented
2271  
2272 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2273 0 my @glob = _DOS_like_glob(@_);
2274 0 for my $glob (@glob) {
2275 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2276 }
2277 0 return @glob;
2278 }
2279 else {
2280 0 my $glob = _DOS_like_glob(@_);
2281 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2282 0 return $glob;
2283 }
2284 }
2285  
2286 #
2287 # KOI8-U path globbing (without parameter)
2288 #
2289 0 ▶sub Ekoi8u::glob_() {
Subroutine glob_: not called CC=3 SCAR=24.8
Pod undocumented
2290  
2291 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2292 0 my @glob = _DOS_like_glob();
2293 0 for my $glob (@glob) {
2294 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2295 }
2296 0 return @glob;
2297 }
2298 else {
2299 0 my $glob = _DOS_like_glob();
2300 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2301 0 return $glob;
2302 }
2303 }
2304  
2305 #
2306 # KOI8-U path globbing via File::DosGlob 1.10
2307 #
2308 # Often I confuse "_dosglob" and "_doglob".
2309 # So, I renamed "_dosglob" to "_DOS_like_glob".
2310 #
2311 422 my %iter;
2312 my %entries;
2313 0 ▶sub _DOS_like_glob {
Subroutine _DOS_like_glob: not called CC=10 SCAR=47.0
2314  
2315 # context (keyed by second cxix argument provided by core)
2316 0 my($expr,$cxix) = @_;
2317  
2318 # glob without args defaults to $_
2319 0 ▶ $expr = $_ if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2320  
2321 # represents the current user's home directory
2322 #
2323 # 7.3. Expanding Tildes in Filenames
2324 # in Chapter 7. File Access
2325 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2326 #
2327 # and File::HomeDir, File::HomeDir::Windows module
2328  
2329 # DOS-like system
2330 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
2331 0 $expr =~ s{ \A ~ (?= [^/\\] ) }
2332 0 { my_home_MSWin32() }oxmse;
2333 }
2334  
2335 # UNIX-like system
2336 else {
2337 0 $expr =~ s{ \A ~ ( (?:[^/])* ) }
2338 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
2339 }
2340  
2341 # assume global context if not provided one
2342 0 ▶ $cxix = '_G_' if not defined $cxix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cxix 0 0 0
2343 0 ▶ $iter{$cxix} = 0 if not exists $iter{$cxix};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $iter{$cxix} 0 0 0
2344  
2345 # if we're just beginning, do it all first
2346 0 ▶ if ($iter{$cxix} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} == 0) 0 0 0
2347 0 $entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ];
2348 }
2349  
2350 # chuck it all out, quick or slow
2351 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2352 0 delete $iter{$cxix};
2353 0 return @{delete $entries{$cxix}};
2354 }
2355 else {
2356 0 ▶ if ($iter{$cxix} = scalar @{$entries{$cxix}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} = scalar @{$entries{$cxix};}) { } 0 0 0
2357 0 return shift @{$entries{$cxix}};
2358 }
2359 else {
2360 # return undef for EOL
2361 0 delete $iter{$cxix};
2362 0 delete $entries{$cxix};
2363 0 return undef;
2364 }
2365 }
2366 }
2367  
2368 #
2369 # KOI8-U path globbing subroutine
2370 #
2371 0 ▶sub _do_glob {
Subroutine _do_glob: not called CC=44 SCAR=75.9
2372  
2373 0 my($cond,@expr) = @_;
2374 0 my @glob = ();
2375 0 my $fix_drive_relative_paths = 0;
2376  
2377 OUTER:
2378 0 for my $expr (@expr) {
2379 0 ▶ next OUTER if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2380 0 ▶ next OUTER if $expr eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $expr eq "" 0 0 0
2381  
2382 0 my @matched = ();
2383 0 my @globdir = ();
2384 0 my $head = '.';
2385 0 my $pathsep = '/';
2386 0 my $tail;
2387  
2388 # if argument is within quotes strip em and do no globbing
2389 0 ▶ if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ /\A " ((?:$Ekoi8u::q_char)*?) " \z/mosx) 0 0 0
2390 0 $expr = $1;
2391 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2392 0 ▶ if (-d $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $expr) 0 0 0
2393 0 push @glob, $expr;
2394 }
2395 }
2396 else {
2397 0 ▶ if (-e $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $expr) 0 0 0
2398 0 push @glob, $expr;
2399 }
2400 }
2401 0 next OUTER;
2402 }
2403  
2404 # wildcards with a drive prefix such as h:*.pm must be changed
2405 # to h:./*.pm to expand correctly
2406 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
2407 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
2408 0 $fix_drive_relative_paths = 1;
2409 }
2410 }
2411  
2412 0 ▶ if (($head, $tail) = _parse_path($expr,$pathsep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($head, $tail) = _parse_path($expr, $pathsep)) 0 0 0
2413 0 ▶ if ($tail eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail eq "") 0 0 0
2414 0 push @glob, $expr;
2415 0 next OUTER;
2416 }
2417 0 ▶ if ($head =~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ / \A (?:$Ekoi8u::q_char)*? [*?] /mosx) 0 0 0
2418 0 ▶ if (@globdir = _do_glob('d', $head)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@globdir = _do_glob("d", $head)) 0 0 0
2419 0 push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir);
2420 0 next OUTER;
2421 }
2422 }
2423 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
2424 0 $head .= $pathsep;
2425 }
2426 0 $expr = $tail;
2427 }
2428  
2429 # If file component has no wildcards, we can avoid opendir
2430 0 ▶ if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expr =~ / \A (?:$Ekoi8u::q_char)*? [*?] /mosx) 0 0 0
2431 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2432 0 $head = '';
2433 }
2434 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2435 0 $head .= $pathsep;
2436 }
2437 0 $head .= $expr;
2438 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2439 0 ▶ if (-d $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $head) 0 0 0
2440 0 push @glob, $head;
2441 }
2442 }
2443 else {
2444 0 ▶ if (-e $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $head) 0 0 0
2445 0 push @glob, $head;
2446 }
2447 }
2448 0 next OUTER;
2449 }
2450 0 ▶ opendir(*DIR, $head) or next OUTER;
Branch: 1 branch
BranchTrueFalseTotal
opendir *DIR, $head or next OUTER 0 0 0
2451 0 my @leaf = readdir DIR;
2452 0 closedir DIR;
2453  
2454 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2455 0 $head = '';
2456 }
2457 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Ekoi8u::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2458 0 $head .= $pathsep;
2459 }
2460  
2461 0 my $pattern = '';
2462 0 ▶ while ($expr =~ / \G ($q_char) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ / \G ($Ekoi8u::q_char) /cgox) 0 0 0
2463 0 my $char = $1;
2464  
2465 # 6.9. Matching Shell Globs as Regular Expressions
2466 # in Chapter 6. Pattern Matching
2467 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2468 # (and so on)
2469  
2470 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
2471 0 $pattern .= "(?:$your_char)*",
2472 }
2473 elsif ($char eq '?') {
2474 0 $pattern .= "(?:$your_char)?", # DOS style
2475 # $pattern .= "(?:$your_char)", # UNIX style
2476 }
2477 elsif ((my $fc = Ekoi8u::fc($char)) ne $char) {
2478 0 $pattern .= $fc;
2479 }
2480 else {
2481 0 $pattern .= quotemeta $char;
2482 }
2483 }
2484 0 ▶ my $matchsub = sub { Ekoi8u::fc($_[0]) =~ /\A $pattern \z/xms };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2485  
2486 # if ($@) {
2487 # print STDERR "$0: $@\n";
2488 # next OUTER;
2489 # }
2490  
2491 INNER:
2492 0 for my $leaf (@leaf) {
2493 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
2494 0 next INNER;
2495 }
2496 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
2497 0 next INNER;
2498 }
2499  
2500 0 ▶ if (&$matchsub($leaf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub($leaf)) 0 0 0
2501 0 push @matched, "$head$leaf";
2502 0 next INNER;
2503 }
2504  
2505 # [DOS compatibility special case]
2506 # Failed, add a trailing dot and try again, but only...
2507  
2508 0 ▶ if (Ekoi8u::index($leaf,'.') == -1 and # if name does not have a dot in it *and*
Branch: 1 branch
BranchTrueFalseTotal
if (&Ekoi8u::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8u::index($pattern, "\\.") != -1) 0 0 0
Condition0%0/6
&Ekoi8u::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8u::index($pattern, "\\.") != -1
!ll&&!rl&&r
000
&Ekoi8u::index($leaf, ".") == -1 and length $leaf <= 8
!ll&&!rl&&r
000
MC/DC0%0/3
&Ekoi8u::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8u::index($pattern, "\\.") != -1
&Ekoi8u::index($leaf, ".") == -1 length $leaf <= 8 &Ekoi8u::index($pattern, "\\.") != -1
Truth table0%0/4
A and B and C
A= &Ekoi8u::index($leaf, ".") == -1B= length $leaf <= 8C= &Ekoi8u::index($pattern, "\\.") != -1
ABCresult
0XX0
10X0
1100
1111
2509 CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and*
2510 Ekoi8u::index($pattern,'\\.') != -1 # pattern has a dot.
2511 ) {
2512 0 ▶ if (&$matchsub("$leaf.")) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub("$leaf.")) 0 0 0
2513 0 push @matched, "$head$leaf";
2514 0 next INNER;
2515 }
2516 }
2517 }
2518 0 ▶ if (@matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matched) 0 0 0
2519 0 push @glob, @matched;
2520 }
2521 }
2522 0 ▶ if ($fix_drive_relative_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fix_drive_relative_paths) 0 0 0
2523 0 for my $glob (@glob) {
2524 0 $glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms;
2525 }
2526 }
2527 0 return @glob;
2528 }
2529  
2530 #
2531 # KOI8-U parse line
2532 #
2533 0 ▶sub _parse_line {
Subroutine _parse_line: not called CC=3 SCAR=24.8
2534  
2535 0 my($line) = @_;
2536  
2537 0 $line .= ' ';
2538 0 my @piece = ();
2539 0 ▶ while ($line =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / " ( (?>(?: [^"] )* ) ) " (?>\s+) | ( (?>(?: [^"\s] )* ) ) (?>\s+) /gmosx) 0 0 0
2540 " ( (?>(?: [^"] )* ) ) " (?>\s+) |
2541 ( (?>(?: [^"\s] )* ) ) (?>\s+)
2542 /oxmsg
2543 ) {
2544 0 ▶ push @piece, defined($1) ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
2545 }
2546 0 return @piece;
2547 }
2548  
2549 #
2550 # KOI8-U parse path
2551 #
2552 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=2 SCAR=17.9
2553  
2554 0 my($path,$pathsep) = @_;
2555  
2556 0 $path .= '/';
2557 0 my @subpath = ();
2558 0 ▶ while ($path =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m( ((?: [^/\\] )+?) [/\\] )gmosx) 0 0 0
2559 ((?: [^\/\\] )+?) [\/\\]
2560 /oxmsg
2561 ) {
2562 0 push @subpath, $1;
2563 }
2564  
2565 0 my $tail = pop @subpath;
2566 0 my $head = join $pathsep, @subpath;
2567 0 return $head, $tail;
2568 }
2569  
2570 #
2571 # via File::HomeDir::Windows 1.00
2572 #
2573 0 ▶sub my_home_MSWin32 {
Subroutine my_home_MSWin32: not called CC=9 SCAR=45.0
Pod undocumented
2574  
2575 # A lot of unix people and unix-derived tools rely on
2576 # the ability to overload HOME. We will support it too
2577 # so that they can replace raw HOME calls with File::HomeDir.
2578 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
2579 0 return $ENV{'HOME'};
2580 }
2581  
2582 # Do we have a user profile?
2583 ▶ 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
2584 0 return $ENV{'USERPROFILE'};
2585 }
2586  
2587 # Some Windows use something like $ENV{'HOME'}
2588 ▶ 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
2589 0 return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
2590 }
2591  
2592 0 return undef;
2593 }
2594  
2595 #
2596 # via File::HomeDir::Unix 1.00
2597 #
2598 0 ▶sub my_home {
Subroutine my_home: not called CC=7 SCAR=40.3
Pod undocumented
2599 0 my $home;
2600  
2601 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
2602 0 $home = $ENV{'HOME'};
2603 }
2604  
2605 # This is from the original code, but I'm guessing
2606 # it means "login directory" and exists on some Unixes.
2607 ▶ 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
2608 0 $home = $ENV{'LOGDIR'};
2609 }
2610  
2611 ### More-desperate methods
2612  
2613 # Light desperation on any (Unixish) platform
2614 else {
2615 0 $home = CORE::eval q{ (getpwuid($<))[7] };
2616 }
2617  
2618 # On Unix in general, a non-existant home means "no home"
2619 # For example, "nobody"-like users might use /nonexistant
2620 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
2621 0 $home = undef;
2622 }
2623 0 return $home;
2624 }
2625  
2626 #
2627 # ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched
2628 #
2629 56 ▶sub Ekoi8u::PREMATCH {
Subroutine PREMATCH: called CC=1 SCAR=0.0
Pod undocumented
2630 56 return $`;
2631 }
2632  
2633 #
2634 # ${^MATCH}, $MATCH, $& the string that matched
2635 #
2636 81 ▶sub Ekoi8u::MATCH {
Subroutine MATCH: called CC=1 SCAR=0.0
Pod undocumented
2637 81 return $&;
2638 }
2639  
2640 #
2641 # ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched
2642 #
2643 42 ▶sub Ekoi8u::POSTMATCH {
Subroutine POSTMATCH: called CC=1 SCAR=0.0
Pod undocumented
2644 42 return $';
2645 }
2646  
2647 #
2648 # KOI8-U character to order (with parameter)
2649 #
2650 0 ▶sub KOI8U::ord(;$) {
Subroutine ord: not called CC=4 SCAR=30.0
2651  
2652 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2653  
2654 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8u::q_char) /mosx) { } 0 0 0
2655 0 my @ord = unpack 'C*', $1;
2656 0 my $ord = 0;
2657 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2658 0 $ord = $ord * 0x100 + $o;
2659 }
2660 0 return $ord;
2661 }
2662 else {
2663 0 return CORE::ord $_;
2664 }
2665 }
2666  
2667 #
2668 # KOI8-U character to order (without parameter)
2669 #
2670 0 ▶sub KOI8U::ord_() {
Subroutine ord_: not called CC=3 SCAR=24.8
2671  
2672 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8u::q_char) /mosx) { } 0 0 0
2673 0 my @ord = unpack 'C*', $1;
2674 0 my $ord = 0;
2675 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2676 0 $ord = $ord * 0x100 + $o;
2677 }
2678 0 return $ord;
2679 }
2680 else {
2681 0 return CORE::ord $_;
2682 }
2683 }
2684  
2685 #
2686 # KOI8-U reverse
2687 #
2688 0 ▶sub KOI8U::reverse(@) {
Subroutine reverse: not called CC=2 SCAR=17.9
2689  
2690 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2691 0 return CORE::reverse @_;
2692 }
2693 else {
2694  
2695 # One of us once cornered Larry in an elevator and asked him what
2696 # problem he was solving with this, but he looked as far off into
2697 # the distance as he could in an elevator and said, "It seemed like
2698 # a good idea at the time."
2699  
2700 0 return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg);
2701 }
2702 }
2703  
2704 #
2705 # KOI8-U getc (with parameter, without parameter)
2706 #
2707 20 ▶sub KOI8U::getc(;*@) {
Subroutine getc: called CC=9 SCAR=26.7
2708  
2709 20 my($package) = caller;
2710 20 ▶ my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 20 0 20
2711 20 ▶ croak 'Too many arguments for KOI8U::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
2712  
2713 0 my @length = sort { $a <=> $b } keys %range_tr;
2714 20 my $getc = '';
2715 20 for my $length ($length[0] .. $length[-1]) {
2716 20 $getc .= CORE::getc($fh);
2717 20 ▶ if (exists $range_tr{CORE::length($getc)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{length $getc}) 20 0 20
2718 20 ▶ if ($getc =~ /\A ${Ekoi8u::dot_s} \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A $Ekoi8u::dot_s \z/mosx) 20 0 20
2719 20 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 20 20
2720 }
2721 }
2722 }
2723 0 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2724 }
2725  
2726 #
2727 # KOI8-U length by character
2728 #
2729 0 ▶sub KOI8U::length(;$) {
Subroutine length: not called CC=2 SCAR=17.9
2730  
2731 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2732  
2733 0 local @_ = /\G ($q_char) /oxmsg;
2734 0 return scalar @_;
2735 }
2736  
2737 #
2738 # KOI8-U substr by character
2739 #
2740 422 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
2741  
2742 # P.232 The lvalue Attribute
2743 # in Chapter 6: Subroutines
2744 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2745  
2746 # P.336 The lvalue Attribute
2747 # in Chapter 7: Subroutines
2748 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2749  
2750 # P.144 8.4 Lvalue subroutines
2751 # in Chapter 8: perlsub: Perl subroutines
2752 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
2753  
2754 0 ▶ CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : '');
Subroutine substr: called CC=11 SCAR=24.4
Branch: 10 branches
BranchTrueFalseTotal
$] >= 5.014 ? : 422 0 422
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
2755 # vv----------------------*******
2756 sub KOI8U::substr($$;$$) %s {
2757  
2758 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
2759  
2760 # If the substring is beyond either end of the string, substr() returns the undefined
2761 # value and produces a warning. When used as an lvalue, specifying a substring that
2762 # is entirely outside the string raises an exception.
2763 # http://perldoc.perl.org/functions/substr.html
2764  
2765 # A return with no argument returns the scalar value undef in scalar context,
2766 # an empty list () in list context, and (naturally) nothing at all in void
2767 # context.
2768  
2769 my $offset = $_[1];
2770 if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) {
2771 return;
2772 }
2773  
2774 # substr($string,$offset,$length,$replacement)
2775 if (@_ == 4) {
2776 my(undef,undef,$length,$replacement) = @_;
2777 my $substr = join '', splice(@char, $offset, $length, $replacement);
2778 $_[0] = join '', @char;
2779  
2780 # return $substr; this doesn't work, don't say "return"
2781 $substr;
2782 }
2783  
2784 # substr($string,$offset,$length)
2785 elsif (@_ == 3) {
2786 my(undef,undef,$length) = @_;
2787 my $octet_offset = 0;
2788 my $octet_length = 0;
2789 if ($offset == 0) {
2790 $octet_offset = 0;
2791 }
2792 elsif ($offset > 0) {
2793 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2794 }
2795 else {
2796 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2797 }
2798 if ($length == 0) {
2799 $octet_length = 0;
2800 }
2801 elsif ($length > 0) {
2802 $octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]);
2803 }
2804 else {
2805 $octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]);
2806 }
2807 CORE::substr($_[0], $octet_offset, $octet_length);
2808 }
2809  
2810 # substr($string,$offset)
2811 else {
2812 my $octet_offset = 0;
2813 if ($offset == 0) {
2814 $octet_offset = 0;
2815 }
2816 elsif ($offset > 0) {
2817 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2818 }
2819 else {
2820 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2821 }
2822 CORE::substr($_[0], $octet_offset);
2823 }
2824 }
2825 END
2826 }
2827  
2828 #
2829 # KOI8-U index by character
2830 #
2831 0 ▶sub KOI8U::index($$;$) {
Subroutine index: not called CC=3 SCAR=24.8
2832  
2833 0 my $index;
2834 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2835 0 $index = Ekoi8u::index($_[0], $_[1], CORE::length(KOI8U::substr($_[0], 0, $_[2])));
2836 }
2837 else {
2838 0 $index = Ekoi8u::index($_[0], $_[1]);
2839 }
2840  
2841 0 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 0 0 0
2842 0 return -1;
2843 }
2844 else {
2845 0 return KOI8U::length(CORE::substr $_[0], 0, $index);
2846 }
2847 }
2848  
2849 #
2850 # KOI8-U rindex by character
2851 #
2852 0 ▶sub KOI8U::rindex($$;$) {
Subroutine rindex: not called CC=3 SCAR=24.8
2853  
2854 0 my $rindex;
2855 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2856 0 $rindex = Ekoi8u::rindex($_[0], $_[1], CORE::length(KOI8U::substr($_[0], 0, $_[2])));
2857 }
2858 else {
2859 0 $rindex = Ekoi8u::rindex($_[0], $_[1]);
2860 }
2861  
2862 0 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 0 0 0
2863 0 return -1;
2864 }
2865 else {
2866 0 return KOI8U::length(CORE::substr $_[0], 0, $rindex);
2867 }
2868 }
2869  
2870 # when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??'
2871 # when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else)
2872 422 ▶use vars qw($slash); $slash = 'm//';
Subroutine BEGIN: called CC=1 SCAR=0.0
2873  
2874 # ord() to ord() or KOI8U::ord()
2875 422 my $function_ord = 'ord';
2876  
2877 # ord to ord or KOI8U::ord_
2878 422 my $function_ord_ = 'ord';
2879  
2880 # reverse to reverse or KOI8U::reverse
2881 422 my $function_reverse = 'reverse';
2882  
2883 # getc to getc or KOI8U::getc
2884 422 my $function_getc = 'getc';
2885  
2886 # P.1023 Appendix W.9 Multibyte Anchoring
2887 # of ISBN 1-56592-224-7 CJKV Information Processing
2888  
2889 422 my $anchor = '';
2890  
2891 422 ▶use vars qw($nest);
Subroutine BEGIN: called CC=1 SCAR=0.0
2892  
2893 # regexp of nested parens in qqXX
2894  
2895 # P.340 Matching Nested Constructs with Embedded Code
2896 # in Chapter 7: Perl
2897 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2898  
2899 my $qq_paren = qr{(?{local $nest=0}) (?>(?:
2900 [^\\()] |
2901 \( (?{$nest++}) |
2902 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2903 \\ [^c] |
2904 \\c[\x40-\x5F] |
2905 [\x00-\xFF]
2906 422 }xms;
2907  
2908 my $qq_brace = qr{(?{local $nest=0}) (?>(?:
2909 [^\\{}] |
2910 \{ (?{$nest++}) |
2911 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2912 \\ [^c] |
2913 \\c[\x40-\x5F] |
2914 [\x00-\xFF]
2915 422 }xms;
2916  
2917 my $qq_bracket = qr{(?{local $nest=0}) (?>(?:
2918 [^\\\[\]] |
2919 \[ (?{$nest++}) |
2920 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2921 \\ [^c] |
2922 \\c[\x40-\x5F] |
2923 [\x00-\xFF]
2924 422 }xms;
2925  
2926 my $qq_angle = qr{(?{local $nest=0}) (?>(?:
2927 [^\\<>] |
2928 \< (?{$nest++}) |
2929 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2930 \\ [^c] |
2931 \\c[\x40-\x5F] |
2932 [\x00-\xFF]
2933 422 }xms;
2934  
2935 422 my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} |
2936 (?: ::)? (?:
2937 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2938 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2939 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2940 ))
2941 }xms;
2942  
2943 422 my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} |
2944 (?: ::)? (?:
2945 (?>[0-9]+) |
2946 [^a-zA-Z_0-9\[\]] |
2947 ^[A-Z] |
2948 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2949 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2950 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2951 ))
2952 }xms;
2953  
2954 422 my $qq_substr = qr{(?> Char::substr | KOI8U::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \)
2955 }xms;
2956  
2957 # regexp of nested parens in qXX
2958 my $q_paren = qr{(?{local $nest=0}) (?>(?:
2959 [^()] |
2960 \( (?{$nest++}) |
2961 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2962 [\x00-\xFF]
2963 422 }xms;
2964  
2965 my $q_brace = qr{(?{local $nest=0}) (?>(?:
2966 [^\{\}] |
2967 \{ (?{$nest++}) |
2968 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2969 [\x00-\xFF]
2970 422 }xms;
2971  
2972 my $q_bracket = qr{(?{local $nest=0}) (?>(?:
2973 [^\[\]] |
2974 \[ (?{$nest++}) |
2975 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2976 [\x00-\xFF]
2977 422 }xms;
2978  
2979 my $q_angle = qr{(?{local $nest=0}) (?>(?:
2980 [^<>] |
2981 \< (?{$nest++}) |
2982 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2983 [\x00-\xFF]
2984 422 }xms;
2985  
2986 422 my $matched = '';
2987 422 my $s_matched = '';
2988  
2989 422 my $tr_variable = ''; # variable of tr///
2990 422 my $sub_variable = ''; # variable of s///
2991 422 my $bind_operator = ''; # =~ or !~
2992  
2993 422 my @heredoc = (); # here document
2994 422 my @heredoc_delimiter = ();
2995 422 my $here_script = ''; # here script
2996  
2997 #
2998 # escape KOI8-U script
2999 #
3000 547 ▶sub KOI8U::escape(;$) {
Subroutine escape: called CC=3 SCAR=11.0
3001 547 ▶ local($_) = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 292 255 547
3002  
3003 # P.359 The Study Function
3004 # in Chapter 7: Perl
3005 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3006  
3007 547 study $_; # Yes, I studied study yesterday.
3008  
3009 # while all script
3010  
3011 # 6.14. Matching from Where the Last Pattern Left Off
3012 # in Chapter 6. Pattern Matching
3013 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
3014 # (and so on)
3015  
3016 # one member of Tag-team
3017 #
3018 # P.128 Start of match (or end of previous match): \G
3019 # P.130 Advanced Use of \G with Perl
3020 # in Chapter 3: Overview of Regular Expression Features and Flavors
3021 # P.255 Use leading anchors
3022 # P.256 Expose ^ and \G at the front expressions
3023 # in Chapter 6: Crafting an Efficient Expression
3024 # P.315 "Tag-team" matching with /gc
3025 # in Chapter 7: Perl
3026 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3027  
3028 547 my $e_script = '';
3029 547 ▶ while (not /\G \z/oxgc) { # member
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 86270 547 86817
3030 86270 $e_script .= KOI8U::escape_token();
3031 }
3032  
3033 547 return $e_script;
3034 }
3035  
3036 #
3037 # escape KOI8-U token of script
3038 #
3039 86270 ▶sub KOI8U::escape_token {
Subroutine escape_token: called CC=504 SCAR=109.3
3040  
3041 # \n output here document
3042  
3043 86270 my $ignore_modules = join('|', qw(
3044 utf8
3045 bytes
3046 charnames
3047 I18N::Japanese
3048 I18N::Collate
3049 I18N::JExt
3050 File::DosGlob
3051 Wild
3052 Wildcard
3053 Japanese
3054 ));
3055  
3056 # another member of Tag-team
3057 #
3058 # P.315 "Tag-team" matching with /gc
3059 # in Chapter 7: Perl
3060 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3061  
3062 86270 ▶ if (/\G ( \n ) /oxgc) { # another member (and so on)
Branch: 139 branches
BranchTrueFalseTotal
if (/\G ( \n ) /cgox) { } 12811 73459 86270
elsif (/\G ((?>\s+)|\#.*) /cgox) { } 21323 52136 73459
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /cgox) { } 1644 50492 52136
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /cgox) { } 90 50402 50492
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx) { } 4 50398 50402
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 28 50370 50398
elsif (/\G ( \$' | \$\{'\} ) /cgmosx) { } 1 50369 50370
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 3 50366 50369
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /cgox) { } 1752 48614 50366
elsif (/\G ( [,;] ) /cgox) { } 5070 43544 48614
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 43544 43544
elsif (/\G ( \$ 0 ) /cgmosx) { } 2 43542 43544
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 43542 43542
elsif (/\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 1 43541 43542
elsif (/\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 4 43537 43541
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 43537 43537
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 43537 43537
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 43537 43537
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 43537 43537
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /cgmosx) { } 0 43537 43537
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 0 43537 43537
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 43495 43537
elsif (m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 63 43432 43495
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /cgox) { } 0 43432 43432
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /cgox) { } 0 43432 43432
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /cgox) { } 0 43432 43432
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /cgox) { } 0 43432 43432
elsif (/\G \b ( if | unless | while | until | for | when ) \b /cgox) { } 251 43181 43432
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 19 43162 43181
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 43162 43162
elsif (/\G \b KOI8U::eval (?= (?>\s*) \{ ) /cgox) { } 22 43140 43162
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /cgox) { } 0 43140 43140
elsif (/\G \b KOI8U::eval \b (?! (?>\s*) => ) /cgox) { } 168 42972 43140
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /cgox) { } 2 42970 42972
elsif (/\G \b chop \b (?! (?>\s*) => ) /cgox) { } 0 42970 42970
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /cgox) { } 2 42968 42970
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /cgox) { } 0 42968 42968
elsif (/\G \b KOI8U::index \b (?! (?>\s*) => ) /cgox) { } 0 42968 42968
elsif (/\G \b index \b (?! (?>\s*) => ) /cgox) { } 0 42968 42968
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /cgox) { } 2 42966 42968
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b KOI8U::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b rindex \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42965 42966
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42965 42965
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42964 42965
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42964 42964
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 6 42958 42964
elsif (/\G -s (?>\s*) (\") ((?:$Ekoi8u::qq_char)+?) (\") /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Ekoi8u::qq_char)+?) (\#) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Ekoi8u::qq_char)+?) (\1) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Ekoi8u::q_char)+?) (\') /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Ekoi8u::q_char)+?) (\#) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Ekoi8u::q_char)+?) (\1) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 42958 42958
elsif (/\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 42958 42958
elsif (/\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 42958 42958
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42956 42958
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42954 42956
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 36 42918 42954
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42916 42918
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 8 42908 42916
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42908 42908
elsif (/\G \b lc \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b uc \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b fc \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G -s \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b chr \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b ord \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b glob \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b reverse \b (?! (?>\s*) => ) /cgox) { } 0 42908 42908
elsif (/\G \b getc \b (?! (?>\s*) => ) /cgox) { } 8 42900 42908
elsif (/\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 87 42813 42900
elsif (/\G \b ( tr | y ) \b /cgox) { } 4 42809 42813
elsif (/\G \b (qq) \b /cgox) { } 2252 40557 42809
elsif (/\G \b (qr) \b /cgox) { } 0 40557 40557
elsif (/\G \b (qw) \b /cgox) { } 16 40541 40557
elsif (/\G \b (qx) \b /cgox) { } 0 40541 40541
elsif (/\G \b (q) \b /cgox) { } 473 40068 40541
elsif (/\G \b (m) \b /cgox) { } 209 39859 40068
elsif (/\G \b (s) \b /cgox) { } 101 39758 39859
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39758 39758
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39758 39758
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39758 39758
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /cgmosx) { } 37 39721 39758
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39721 39721
elsif (/\G \b use ((?>\s+) strict) \b /cgmosx) { } 0 39721 39721
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 2 39719 39721
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 0 39719 39719
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 2 39717 39719
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39717 39717
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39717 39717
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39717 39717
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39717 39717
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39717 39717
elsif (/\G \b use \b /cgmosx) { } 0 39717 39717
elsif (/\G \b no \b /cgmosx) { } 2 39715 39717
elsif (/\G (?<![\w\$\@\%\&\*]) (\') /cgox) { } 1142 38573 39715
elsif (/\G (\") /cgox) { } 1897 36676 38573
elsif (/\G (\`) /cgox) { } 1 36675 36676
elsif ($Ekoi8u::slash eq 'm//' and m[\G (/) ]cgox) { } 681 35994 36675
elsif ($Ekoi8u::slash eq 'm//' and /\G (\?) /cgox) { } 0 35994 35994
elsif (/\G ( <<>> ) /cgox) { } 0 35994 35994
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 35994 35994
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 6 35988 35994
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 3 35985 35988
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 6 35979 35985
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 3 35976 35979
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 6 35970 35976
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 72 35898 35970
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 35898 35898
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 36 35862 35898
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 42 35820 35862
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 35820 35820
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 12 35808 35820
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 35808 35808
elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /cgox) { } 0 35808 35808
elsif (/\G ^ ( __DATA__ \n .*) \z /cgmosx) { } 0 35808 35808
elsif (/\G ^ ( __END__ \n .*) \z /cgmosx) { } 210 35598 35808
elsif (/\G ( \cD .*) \z /cgmosx) { } 0 35598 35598
elsif (/\G ( \cZ .*) \z /cgmosx) { } 0 35598 35598
elsif (/\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 5837 29761 35598
elsif (/\G ( \.\.\. ) /cgox) { } 7 29754 29761
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 19976 29754
elsif (/\G ($Ekoi8u::q_char) /cgox) { } 19976 0 19976
3063 12811 my $heredoc = '';
3064 12811 ▶ if (scalar(@heredoc_delimiter) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @heredoc_delimiter >= 1) 174 12637 12811
3065 174 $slash = 'm//';
3066  
3067 174 $heredoc = join '', @heredoc;
3068 174 @heredoc = ();
3069  
3070 # skip here document
3071 174 for my $heredoc_delimiter (@heredoc_delimiter) {
3072 174 /\G .*? \n $heredoc_delimiter \n/xmsgc;
3073 }
3074 174 @heredoc_delimiter = ();
3075  
3076 174 $here_script = '';
3077 }
3078 12811 return "\n" . $heredoc;
3079 }
3080  
3081 # ignore space, comment
3082 21323 elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; }
3083  
3084 # if (, elsif (, unless (, while (, until (, given (, and when (
3085  
3086 # given, when
3087  
3088 # P.225 The given Statement
3089 # in Chapter 15: Smart Matching and given-when
3090 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3091  
3092 # P.133 The given Statement
3093 # in Chapter 4: Statements and Declarations
3094 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3095  
3096 elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) {
3097 1644 $slash = 'm//';
3098 1644 return $1;
3099 }
3100  
3101 # scalar variable ($scalar = ...) =~ tr///;
3102 # scalar variable ($scalar = ...) =~ s///;
3103  
3104 # state
3105  
3106 # P.68 Persistent, Private Variables
3107 # in Chapter 4: Subroutines
3108 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3109  
3110 # P.160 Persistent Lexically Scoped Variables: state
3111 # in Chapter 4: Statements and Declarations
3112 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3113  
3114 # (and so on)
3115  
3116 elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) {
3117 90 my $e_string = e_string($1);
3118  
3119 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
3120 0 $tr_variable = $e_string . e_string($1);
3121 0 $bind_operator = $2;
3122 0 $slash = 'm//';
3123 0 return '';
3124 }
3125 elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3126 0 $sub_variable = $e_string . e_string($1);
3127 0 $bind_operator = $2;
3128 0 $slash = 'm//';
3129 0 return '';
3130 }
3131 else {
3132 90 $slash = 'div';
3133 90 return $e_string;
3134 }
3135 }
3136  
3137 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
3138 elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
3139 4 $slash = 'div';
3140 4 return q{Ekoi8u::PREMATCH()};
3141 }
3142  
3143 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
3144 elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
3145 28 $slash = 'div';
3146 28 return q{Ekoi8u::MATCH()};
3147 }
3148  
3149 # $', ${'} --> $', ${'}
3150 elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) {
3151 1 $slash = 'div';
3152 1 return $1;
3153 }
3154  
3155 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
3156 elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
3157 3 $slash = 'div';
3158 3 return q{Ekoi8u::POSTMATCH()};
3159 }
3160  
3161 # scalar variable $scalar =~ tr///;
3162 # scalar variable $scalar =~ s///;
3163 # substr() =~ tr///;
3164 # substr() =~ s///;
3165 elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) {
3166 1752 my $scalar = e_string($1);
3167  
3168 1752 ▶ if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /cgox) { } 2 1750 1752
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /cgox) { } 65 1685 1750
3169 2 $tr_variable = $scalar;
3170 2 $bind_operator = $1;
3171 2 $slash = 'm//';
3172 2 return '';
3173 }
3174 elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3175 65 $sub_variable = $scalar;
3176 65 $bind_operator = $1;
3177 65 $slash = 'm//';
3178 65 return '';
3179 }
3180 else {
3181 1685 $slash = 'div';
3182 1685 return $scalar;
3183 }
3184 }
3185  
3186 # end of statement
3187 elsif (/\G ( [,;] ) /oxgc) {
3188 5070 $slash = 'm//';
3189  
3190 # clear tr/// variable
3191 5070 $tr_variable = '';
3192  
3193 # clear s/// variable
3194 5070 $sub_variable = '';
3195  
3196 5070 $bind_operator = '';
3197  
3198 5070 return $1;
3199 }
3200  
3201 # bareword
3202 elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
3203 0 return $1;
3204 }
3205  
3206 # $0 --> $0
3207 elsif (/\G ( \$ 0 ) /oxmsgc) {
3208 2 $slash = 'div';
3209 2 return $1;
3210 }
3211 elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
3212 0 $slash = 'div';
3213 0 return $1;
3214 }
3215  
3216 # $$ --> $$
3217 elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
3218 1 $slash = 'div';
3219 1 return $1;
3220 }
3221  
3222 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
3223 # $1, $2, $3 --> $1, $2, $3 otherwise
3224 elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
3225 4 $slash = 'div';
3226 4 return e_capture($1);
3227 }
3228 elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
3229 0 $slash = 'div';
3230 0 return e_capture($1);
3231 }
3232  
3233 # $$foo[ ... ] --> $ $foo->[ ... ]
3234 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
3235 0 $slash = 'div';
3236 0 return e_capture($1.'->'.$2);
3237 }
3238  
3239 # $$foo{ ... } --> $ $foo->{ ... }
3240 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
3241 0 $slash = 'div';
3242 0 return e_capture($1.'->'.$2);
3243 }
3244  
3245 # $$foo
3246 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
3247 0 $slash = 'div';
3248 0 return e_capture($1);
3249 }
3250  
3251 # ${ foo }
3252 elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) {
3253 0 $slash = 'div';
3254 0 return '${' . $1 . '}';
3255 }
3256  
3257 # ${ ... }
3258 elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
3259 0 $slash = 'div';
3260 0 return e_capture($1);
3261 }
3262  
3263 # variable or function
3264 # $ @ % & * $ #
3265 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) {
3266 42 $slash = 'div';
3267 42 return $1;
3268 }
3269 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
3270 # $ @ # \ ' " / ? ( ) [ ] < >
3271 elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
3272 63 $slash = 'div';
3273 63 return $1;
3274 }
3275  
3276 # while (<FILEHANDLE>)
3277 elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) {
3278 0 return $1;
3279 }
3280  
3281 # while (<WILDCARD>) --- glob
3282  
3283 # avoid "Error: Runtime exception" of perl version 5.005_03
3284  
3285 elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /oxgc) {
3286 0 return 'while ($_ = Ekoi8u::glob("' . $1 . '"))';
3287 }
3288  
3289 # while (glob)
3290 elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) {
3291 0 return 'while ($_ = Ekoi8u::glob_)';
3292 }
3293  
3294 # while (glob(WILDCARD))
3295 elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) {
3296 0 return 'while ($_ = Ekoi8u::glob';
3297 }
3298  
3299 # doit if, doit unless, doit while, doit until, doit for, doit when
3300 251 elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; }
3301  
3302 # subroutines of package Ekoi8u
3303 19 elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; }
3304 0 elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3305 22 elsif (/\G \b KOI8U::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3306 0 elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; }
3307 168 elsif (/\G \b KOI8U::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval KOI8U::escape'; }
3308 2 elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; }
3309 0 elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::chop'; }
3310 2 elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; }
3311 0 elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; }
3312 0 elsif (/\G \b KOI8U::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8U::index'; }
3313 0 elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::index'; }
3314 2 elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; }
3315 0 elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; }
3316 0 elsif (/\G \b KOI8U::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8U::rindex'; }
3317 0 elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::rindex'; }
3318 1 elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::lc'; }
3319 0 elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::lcfirst'; }
3320 1 elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::uc'; }
3321 0 elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::ucfirst'; }
3322 6 elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::fc'; }
3323  
3324 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
3325 0 elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); }
3326 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3327 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3328 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3329 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3330 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3331 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3332  
3333 0 elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); }
3334 0 elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3335 0 elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3336 0 elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3337 0 elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3338 0 elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3339 0 elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3340  
3341 elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc)
3342 0 { $slash = 'm//'; return "-s $1"; }
3343 0 elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; }
3344 0 elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; }
3345 0 elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; }
3346  
3347 2 elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; }
3348 2 elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; }
3349 36 elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::chr'; }
3350 2 elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; }
3351 8 elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; }
3352 0 elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8u::glob'; }
3353 0 elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::lc_'; }
3354 0 elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::lcfirst_'; }
3355 0 elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::uc_'; }
3356 0 elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::ucfirst_'; }
3357 0 elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::fc_'; }
3358 0 elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; }
3359  
3360 0 elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; }
3361 0 elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; }
3362 0 elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::chr_'; }
3363 0 elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; }
3364 0 elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; }
3365 0 elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8u::glob_'; }
3366 0 elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; }
3367 8 elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; }
3368 # split
3369 elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
3370 87 $slash = 'm//';
3371  
3372 87 my $e = '';
3373 87 ▶ while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( (?>\s+) | \( | \#.* ) /cgox) 85 87 172
3374 85 $e .= $1;
3375 }
3376  
3377 # end of split
3378 87 ▶ if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Ekoi8u::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
3379  
3380 # split scalar value
3381 1 elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Ekoi8u::split' . $e . e_string($1); }
3382  
3383 # split literal space
3384 0 elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Ekoi8u::split' . $e . qq {qq$1 $2}; }
3385 0 elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; }
3386 0 elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; }
3387 0 elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; }
3388 0 elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; }
3389 0 elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; }
3390 0 elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Ekoi8u::split' . $e . qq {q$1 $2}; }
3391 0 elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8u::split' . $e . qq {$1q$2 $3}; }
3392 0 elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8u::split' . $e . qq {$1q$2 $3}; }
3393 0 elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8u::split' . $e . qq {$1q$2 $3}; }
3394 0 elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8u::split' . $e . qq {$1q$2 $3}; }
3395 0 elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8u::split' . $e . qq {$1q$2 $3}; }
3396 10 elsif (/\G ' [ ] ' /oxgc) { return 'Ekoi8u::split' . $e . qq {' '}; }
3397 0 elsif (/\G " [ ] " /oxgc) { return 'Ekoi8u::split' . $e . qq {" "}; }
3398  
3399 # split qq//
3400 elsif (/\G \b (qq) \b /oxgc) {
3401 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) /cgox) { } 0 0 0
3402 else {
3403 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3404 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 ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
3405 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( )
3406 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { }
3407 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ]
3408 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < >
3409 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { }
3410 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * *
3411 }
3412 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3413 }
3414 }
3415  
3416 # split qr//
3417 elsif (/\G \b (qr) \b /oxgc) {
3418 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 12 12
3419 else {
3420 12 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 12 0 12
3421 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 12 0 12
3422 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( )
3423 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { }
3424 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ]
3425 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < >
3426 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' '
3427 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { }
3428 12 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * *
3429 }
3430 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3431 }
3432 }
3433  
3434 # split q//
3435 elsif (/\G \b (q) \b /oxgc) {
3436 0 ▶ if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:\\\#|\\\\|$Ekoi8u::q_char)*?) (\#) /cgox) { } 0 0 0
3437 else {
3438 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3439 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 ([*\-:?\\^|]) ((?:$Ekoi8u::q_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:\\\\|\\\1| $Ekoi8u::q_char)*?) (\1) /cgox) { } 0 0 0
3440 0 elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( )
3441 0 elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { }
3442 0 elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ]
3443 0 elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < >
3444 0 elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { }
3445 0 elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * *
3446 }
3447 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3448 }
3449 }
3450  
3451 # split m//
3452 elsif (/\G \b (m) \b /oxgc) {
3453 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
3454 else {
3455 18 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 18 0 18
3456 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 18 0 18
3457 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( )
3458 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { }
3459 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ]
3460 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < >
3461 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' '
3462 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { }
3463 18 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * *
3464 }
3465 0 die __FILE__, ": Search pattern not terminated\n";
3466 }
3467 }
3468  
3469 # split ''
3470 elsif (/\G (\') /oxgc) {
3471 0 my $q_string = '';
3472 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3473 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
3474 0 elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
3475 0 elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' '
3476 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3477 }
3478 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3479 }
3480  
3481 # split ""
3482 elsif (/\G (\") /oxgc) {
3483 0 my $qq_string = '';
3484 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3485 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
3486 0 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
3487 0 elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " "
3488 0 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
3489 }
3490 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3491 }
3492  
3493 # split //
3494 elsif (/\G (\/) /oxgc) {
3495 44 my $regexp = '';
3496 44 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 381 0 381
3497 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 ($Ekoi8u::q_char) /cgox) { } 337 0 337
3498 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
3499 44 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / /
3500 337 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
3501 }
3502 0 die __FILE__, ": Search pattern not terminated\n";
3503 }
3504 }
3505  
3506 # tr/// or y///
3507  
3508 # about [cdsrbB]* (/B modifier)
3509 #
3510 # P.559 appendix C
3511 # of ISBN 4-89052-384-7 Programming perl
3512 # (Japanese title is: Perl puroguramingu)
3513  
3514 elsif (/\G \b ( tr | y ) \b /oxgc) {
3515 4 my $ope = $1;
3516  
3517 # $1 $2 $3 $4 $5 $6
3518 4 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([cdsrbB]*) /cgox) { } 0 4 4
3519 0 my @tr = ($tr_variable,$2);
3520 0 return e_tr(@tr,'',$4,$6);
3521 }
3522 else {
3523 4 my $e = '';
3524 4 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 4 0 4
3525 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) ((?:$Ekoi8u::qq_char)*?) (\1) ((?:$Ekoi8u::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 4 0 4
3526 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3527 0 my @tr = ($tr_variable,$2);
3528 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3529 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) ((?:$Ekoi8u::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3530 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( )
3531 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { }
3532 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ]
3533 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < >
3534 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * *
3535 }
3536 0 die __FILE__, ": Transliteration replacement not terminated\n";
3537 }
3538 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3539 0 my @tr = ($tr_variable,$2);
3540 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3541 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) ((?:$Ekoi8u::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3542 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( )
3543 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { }
3544 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ]
3545 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < >
3546 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * *
3547 }
3548 0 die __FILE__, ": Transliteration replacement not terminated\n";
3549 }
3550 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3551 0 my @tr = ($tr_variable,$2);
3552 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3553 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) ((?:$Ekoi8u::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3554 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( )
3555 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { }
3556 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ]
3557 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < >
3558 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * *
3559 }
3560 0 die __FILE__, ": Transliteration replacement not terminated\n";
3561 }
3562 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3563 0 my @tr = ($tr_variable,$2);
3564 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3565 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) ((?:$Ekoi8u::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3566 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( )
3567 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { }
3568 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ]
3569 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < >
3570 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * *
3571 }
3572 0 die __FILE__, ": Transliteration replacement not terminated\n";
3573 }
3574 # $1 $2 $3 $4 $5 $6
3575 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * *
3576 4 my @tr = ($tr_variable,$2);
3577 4 return e_tr(@tr,'',$4,$6);
3578 }
3579 }
3580 0 die __FILE__, ": Transliteration pattern not terminated\n";
3581 }
3582 }
3583  
3584 # qq//
3585 elsif (/\G \b (qq) \b /oxgc) {
3586 2252 my $ope = $1;
3587  
3588 # if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# #
3589 2252 ▶ if (/\G (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 2252 2252
3590 0 my $qq_string = '';
3591 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3592 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 ($Ekoi8u::qq_char) /cgox) { } 0 0 0
3593 0 elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; }
3594 0 elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); }
3595 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3596 }
3597 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3598 }
3599  
3600 else {
3601 2252 my $e = '';
3602 2252 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 2252 0 2252
3603 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
3604  
3605 # elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( )
3606 elsif (/\G (\() /oxgc) { # qq ( )
3607 0 my $qq_string = '';
3608 0 local $nest = 1;
3609 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3610 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 ($Ekoi8u::qq_char) /cgox) { } 0 0 0
3611 0 elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; }
3612 0 elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; }
3613 elsif (/\G (\)) /oxgc) {
3614 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 0 0 0
3615 0 else { $qq_string .= $1; }
3616 }
3617 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3618 }
3619 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3620 }
3621  
3622 # elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { }
3623 elsif (/\G (\{) /oxgc) { # qq { }
3624 2222 my $qq_string = '';
3625 2222 local $nest = 1;
3626 2222 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 85091 0 85091
3627 85091 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 722 84369 85091
elsif (/\G (\\\}) /cgox) { } 0 84369 84369
elsif (/\G (\{) /cgox) { } 1189 83180 84369
elsif (/\G (\}) /cgox) { } 3411 79769 83180
elsif (/\G ($Ekoi8u::qq_char) /cgox) { } 79769 0 79769
3628 0 elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; }
3629 1189 elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; }
3630 elsif (/\G (\}) /oxgc) {
3631 3411 ▶ if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 2222 1189 3411
3632 1189 else { $qq_string .= $1; }
3633 }
3634 79769 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3635 }
3636 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3637 }
3638  
3639 # elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ]
3640 elsif (/\G (\[) /oxgc) { # qq [ ]
3641 0 my $qq_string = '';
3642 0 local $nest = 1;
3643 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3644 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 ($Ekoi8u::qq_char) /cgox) { } 0 0 0
3645 0 elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; }
3646 0 elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; }
3647 elsif (/\G (\]) /oxgc) {
3648 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 0 0 0
3649 0 else { $qq_string .= $1; }
3650 }
3651 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3652 }
3653 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3654 }
3655  
3656 # elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < >
3657 elsif (/\G (\<) /oxgc) { # qq < >
3658 30 my $qq_string = '';
3659 30 local $nest = 1;
3660 30 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 1166 0 1166
3661 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 ($Ekoi8u::qq_char) /cgox) { } 1114 0 1114
3662 0 elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; }
3663 0 elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; }
3664 elsif (/\G (\>) /oxgc) {
3665 30 ▶ if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 30 0 30
3666 0 else { $qq_string .= $1; }
3667 }
3668 1114 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3669 }
3670 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3671 }
3672  
3673 # elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * *
3674 elsif (/\G (\S) /oxgc) { # qq * *
3675 0 my $delimiter = $1;
3676 0 my $qq_string = '';
3677 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3678 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 ($Ekoi8u::qq_char) /cgox) { } 0 0 0
3679 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; }
3680 0 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); }
3681 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3682 }
3683 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3684 }
3685 }
3686 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3687 }
3688 }
3689  
3690 # qr//
3691 elsif (/\G \b (qr) \b /oxgc) {
3692 0 my $ope = $1;
3693 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3694 0 return e_qr($ope,$1,$3,$2,$4);
3695 }
3696 else {
3697 0 my $e = '';
3698 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3699 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3700 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( )
3701 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { }
3702 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ]
3703 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < >
3704 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' '
3705 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { }
3706 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * *
3707 }
3708 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3709 }
3710 }
3711  
3712 # qw//
3713 elsif (/\G \b (qw) \b /oxgc) {
3714 16 my $ope = $1;
3715 16 ▶ if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) (.*?) (\#) /cgmosx) { } 0 16 16
3716 0 return e_qw($ope,$1,$3,$2);
3717 }
3718 else {
3719 16 my $e = '';
3720 16 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 16 0 16
3721 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) ((?:$Ekoi8u::q_char)*?) (\1) /cgmosx) { } 0 0 0
3722  
3723 16 elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3724 0 elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3725  
3726 0 elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3727 0 elsif (/\G (\{) ((?:$q_brace)*?) (\}) /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_bracket)*?) (\]) /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_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3734  
3735 0 elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3736 0 elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3737 }
3738 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3739 }
3740 }
3741  
3742 # qx//
3743 elsif (/\G \b (qx) \b /oxgc) {
3744 0 my $ope = $1;
3745 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) /cgox) { } 0 0 0
3746 0 return e_qq($ope,$1,$3,$2);
3747 }
3748 else {
3749 0 my $e = '';
3750 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3751 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
3752 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( )
3753 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { }
3754 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ]
3755 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < >
3756 0 elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' '
3757 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * *
3758 }
3759 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3760 }
3761 }
3762  
3763 # q//
3764 elsif (/\G \b (q) \b /oxgc) {
3765 473 my $ope = $1;
3766  
3767 # if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# #
3768  
3769 # avoid "Error: Runtime exception" of perl version 5.005_03
3770 # (and so on)
3771  
3772 473 ▶ if (/\G (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 473 473
3773 0 my $q_string = '';
3774 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3775 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
3776 0 elsif (/\G (\\\#) /oxgc) { $q_string .= $1; }
3777 0 elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); }
3778 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3779 }
3780 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3781 }
3782  
3783 else {
3784 473 my $e = '';
3785 473 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 473 0 473
3786 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
3787  
3788 # elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( )
3789 elsif (/\G (\() /oxgc) { # q ( )
3790 0 my $q_string = '';
3791 0 local $nest = 1;
3792 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3793 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
3794 0 elsif (/\G (\\\)) /oxgc) { $q_string .= $1; }
3795 0 elsif (/\G (\\\() /oxgc) { $q_string .= $1; }
3796 0 elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; }
3797 elsif (/\G (\)) /oxgc) {
3798 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 0 0 0
3799 0 else { $q_string .= $1; }
3800 }
3801 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3802 }
3803 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3804 }
3805  
3806 # elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { }
3807 elsif (/\G (\{) /oxgc) { # q { }
3808 467 my $q_string = '';
3809 467 local $nest = 1;
3810 467 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 8236 0 8236
3811 0 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 0 8236 8236
elsif (/\G (\\\}) /cgox) { } 0 8236 8236
elsif (/\G (\\\{) /cgox) { } 0 8236 8236
elsif (/\G (\{) /cgox) { } 159 8077 8236
elsif (/\G (\}) /cgox) { } 626 7451 8077
elsif (/\G ($Ekoi8u::q_char) /cgox) { } 7451 0 7451
3812 0 elsif (/\G (\\\}) /oxgc) { $q_string .= $1; }
3813 0 elsif (/\G (\\\{) /oxgc) { $q_string .= $1; }
3814 159 elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; }
3815 elsif (/\G (\}) /oxgc) {
3816 626 ▶ if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 467 159 626
3817 159 else { $q_string .= $1; }
3818 }
3819 7451 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3820 }
3821 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3822 }
3823  
3824 # elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ]
3825 elsif (/\G (\[) /oxgc) { # q [ ]
3826 0 my $q_string = '';
3827 0 local $nest = 1;
3828 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3829 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
3830 0 elsif (/\G (\\\]) /oxgc) { $q_string .= $1; }
3831 0 elsif (/\G (\\\[) /oxgc) { $q_string .= $1; }
3832 0 elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; }
3833 elsif (/\G (\]) /oxgc) {
3834 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 0 0 0
3835 0 else { $q_string .= $1; }
3836 }
3837 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3838 }
3839 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3840 }
3841  
3842 # elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < >
3843 elsif (/\G (\<) /oxgc) { # q < >
3844 5 my $q_string = '';
3845 5 local $nest = 1;
3846 5 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 88 0 88
3847 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 ($Ekoi8u::q_char) /cgox) { } 83 0 83
3848 0 elsif (/\G (\\\>) /oxgc) { $q_string .= $1; }
3849 0 elsif (/\G (\\\<) /oxgc) { $q_string .= $1; }
3850 0 elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; }
3851 elsif (/\G (\>) /oxgc) {
3852 5 ▶ if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8u::nest == 0) { } 5 0 5
3853 0 else { $q_string .= $1; }
3854 }
3855 83 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3856 }
3857 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3858 }
3859  
3860 # elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * *
3861 elsif (/\G (\S) /oxgc) { # q * *
3862 1 my $delimiter = $1;
3863 1 my $q_string = '';
3864 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 14 0 14
3865 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 ($Ekoi8u::q_char) /cgox) { } 13 0 13
3866 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; }
3867 1 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); }
3868 13 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3869 }
3870 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3871 }
3872 }
3873 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3874 }
3875 }
3876  
3877 # m//
3878 elsif (/\G \b (m) \b /oxgc) {
3879 209 my $ope = $1;
3880 209 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
3881 0 return e_qr($ope,$1,$3,$2,$4);
3882 }
3883 else {
3884 209 my $e = '';
3885 209 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 209 0 209
3886 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 (\?) ((?:$Ekoi8u::qq_char)*?) (\?) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 10 199 209
elsif (/\G ([*\-:\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 199 199
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 199 0 199
3887 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( )
3888 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { }
3889 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ]
3890 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < >
3891 0 elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ?
3892 10 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' '
3893 0 elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { }
3894 199 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * *
3895 }
3896 0 die __FILE__, ": Search pattern not terminated\n";
3897 }
3898 }
3899  
3900 # s///
3901  
3902 # about [cegimosxpradlunbB]* (/cg modifier)
3903 #
3904 # P.67 Pattern-Matching Operators
3905 # of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition.
3906  
3907 elsif (/\G \b (s) \b /oxgc) {
3908 101 my $ope = $1;
3909  
3910 # $1 $2 $3 $4 $5 $6
3911 101 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([cegimosxpradlunbB]*) /cgox) { } 1 100 101
3912 1 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3913 }
3914 else {
3915 100 my $e = '';
3916 100 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 100 0 100
3917 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 21 79 100
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\$) ((?:$Ekoi8u::qq_char)*?) (\1) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 79 0 79
3918 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3919 0 my @s = ($1,$2,$3);
3920 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3921 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8u::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8u::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8u::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3922 # $1 $2 $3 $4
3923 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3924 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3925 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3926 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3927 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3928 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3929 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([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 (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3932 }
3933 0 die __FILE__, ": Substitution replacement not terminated\n";
3934 }
3935 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3936 0 my @s = ($1,$2,$3);
3937 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3938 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8u::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8u::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8u::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3939 # $1 $2 $3 $4
3940 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3941 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3942 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3943 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3944 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3945 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3946 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([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 (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3949 }
3950 0 die __FILE__, ": Substitution replacement not terminated\n";
3951 }
3952 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3953 0 my @s = ($1,$2,$3);
3954 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3955 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8u::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3956 # $1 $2 $3 $4
3957 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3958 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3959 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3960 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3961 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3962 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3963 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3964 }
3965 0 die __FILE__, ": Substitution replacement not terminated\n";
3966 }
3967 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3968 0 my @s = ($1,$2,$3);
3969 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3970 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8u::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8u::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8u::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3971 # $1 $2 $3 $4
3972 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3973 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3974 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3975 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3976 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3977 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3978 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([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 (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3981 }
3982 0 die __FILE__, ": Substitution replacement not terminated\n";
3983 }
3984 # $1 $2 $3 $4 $5 $6
3985 elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) {
3986 21 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3987 }
3988 # $1 $2 $3 $4 $5 $6
3989 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3990 0 return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { }
3991 }
3992 # $1 $2 $3 $4 $5 $6
3993 elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3994 0 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3995 }
3996 # $1 $2 $3 $4 $5 $6
3997 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3998 79 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3999 }
4000 }
4001 0 die __FILE__, ": Substitution pattern not terminated\n";
4002 }
4003 }
4004  
4005 # require ignore module
4006 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; }
4007 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# require$1\n$2"; }
4008 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; }
4009  
4010 # use strict; --> use strict; no strict qw(refs);
4011 37 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; }
4012 0 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; }
4013 0 elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; }
4014  
4015 # use 5.12.0; --> use 5.12.0; no strict qw(refs);
4016 elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4017 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
4018 0 return "use $1; no strict qw(refs);";
4019 }
4020 else {
4021 2 return "use $1;";
4022 }
4023 }
4024 elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4025 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
4026 0 return "use $1; no strict qw(refs);";
4027 }
4028 else {
4029 0 return "use $1;";
4030 }
4031 }
4032  
4033 # ignore use module
4034 2 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; }
4035 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# use$1\n$2"; }
4036 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; }
4037  
4038 # ignore no module
4039 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; }
4040 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# no$1\n$2"; }
4041 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; }
4042  
4043 # use else
4044 0 elsif (/\G \b use \b /oxmsgc) { return "use"; }
4045  
4046 # use else
4047 2 elsif (/\G \b no \b /oxmsgc) { return "no"; }
4048  
4049 # ''
4050 elsif (/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
4051 1142 my $q_string = '';
4052 1142 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 10162 0 10162
4053 10162 ▶ if (/\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 4 10158 10162
elsif (/\G (\\\') /cgox) { } 48 10110 10158
elsif (/\G \' /cgox) { } 1142 8968 10110
elsif (/\G ($Ekoi8u::q_char) /cgox) { } 8968 0 8968
4054 48 elsif (/\G (\\\') /oxgc) { $q_string .= $1; }
4055 1142 elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); }
4056 8968 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
4057 }
4058 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4059 }
4060  
4061 # ""
4062 elsif (/\G (\") /oxgc) {
4063 1897 my $qq_string = '';
4064 1897 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 36960 0 36960
4065 36960 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 67 36893 36960
elsif (/\G (\\\") /cgox) { } 12 36881 36893
elsif (/\G \" /cgox) { } 1897 34984 36881
elsif (/\G ($Ekoi8u::q_char) /cgox) { } 34984 0 34984
4066 12 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; }
4067 1897 elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); }
4068 34984 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
4069 }
4070 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4071 }
4072  
4073 # ``
4074 elsif (/\G (\`) /oxgc) {
4075 1 my $qx_string = '';
4076 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 19 0 19
4077 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 ($Ekoi8u::q_char) /cgox) { } 18 0 18
4078 0 elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; }
4079 1 elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); }
4080 18 elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; }
4081 }
4082 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4083 }
4084  
4085 # // --- not divide operator (num / num), not defined-or
4086 ▶ elsif (($slash eq 'm//') and /\G (\/) /oxgc) {
Condition100%3/3
$Ekoi8u::slash eq "m//" and m[\G (/) ]cgox
!ll&&!rl&&r
271588836681
MC/DC100%2/2
$Ekoi8u::slash eq "m//" and m[\G (/) ]cgox
$Ekoi8u::slash eq "m//" m[\G (/) ]cgox
Truth table100%3/3
A and B
A= $Ekoi8u::slash eq "m//"B= m[\G (/) ]cgox
ABresult
0X0
100
111
4087 681 my $regexp = '';
4088 681 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 5636 0 5636
4089 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 ($Ekoi8u::q_char) /cgox) { } 4955 0 4955
4090 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; }
4091 681 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); }
4092 4955 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4093 }
4094 0 die __FILE__, ": Search pattern not terminated\n";
4095 }
4096  
4097 # ?? --- not conditional operator (condition ? then : else)
4098 ▶ elsif (($slash eq 'm//') and /\G (\?) /oxgc) {
Condition66%2/3
$Ekoi8u::slash eq "m//" and /\G (\?) /cgox
!ll&&!rl&&r
2715888360
MC/DC0%0/2
$Ekoi8u::slash eq "m//" and /\G (\?) /cgox
$Ekoi8u::slash eq "m//" /\G (\?) /cgox
Truth table66%2/3
A and B
A= $Ekoi8u::slash eq "m//"B= /\G (\?) /cgox
ABresult
0X0
100
111
4099 0 my $regexp = '';
4100 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
4101 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 ($Ekoi8u::q_char) /cgox) { } 0 0 0
4102 0 elsif (/\G (\\\?) /oxgc) { $regexp .= $1; }
4103 0 elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); }
4104 0 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4105 }
4106 0 die __FILE__, ": Search pattern not terminated\n";
4107 }
4108  
4109 # <<>> (a safer ARGV)
4110 0 elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; }
4111  
4112 # << (bit shift) --- not here document
4113 0 elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; }
4114  
4115 # <<~'HEREDOC'
4116 elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4117 6 $slash = 'm//';
4118 6 my $here_quote = $1;
4119 6 my $delimiter = $2;
4120  
4121 # get here document
4122 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4123 6 $here_script = CORE::substr $_, pos $_;
4124 6 $here_script =~ s/.*?\n//oxm;
4125 }
4126 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
4127 6 my $heredoc = $1;
4128 6 my $indent = $2;
4129 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4130 6 push @heredoc, $heredoc . qq{\n$delimiter\n};
4131 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4132 }
4133 else {
4134 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4135 }
4136 6 return qq{<<'$delimiter'};
4137 }
4138  
4139 # <<~\HEREDOC
4140  
4141 # P.66 2.6.6. "Here" Documents
4142 # in Chapter 2: Bits and Pieces
4143 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4144  
4145 # P.73 "Here" Documents
4146 # in Chapter 2: Bits and Pieces
4147 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4148  
4149 elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4150 3 $slash = 'm//';
4151 3 my $here_quote = $1;
4152 3 my $delimiter = $2;
4153  
4154 # get here document
4155 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4156 3 $here_script = CORE::substr $_, pos $_;
4157 3 $here_script =~ s/.*?\n//oxm;
4158 }
4159 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
4160 3 my $heredoc = $1;
4161 3 my $indent = $2;
4162 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4163 3 push @heredoc, $heredoc . qq{\n$delimiter\n};
4164 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4165 }
4166 else {
4167 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4168 }
4169 3 return qq{<<\\$delimiter};
4170 }
4171  
4172 # <<~"HEREDOC"
4173 elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4174 6 $slash = 'm//';
4175 6 my $here_quote = $1;
4176 6 my $delimiter = $2;
4177  
4178 # get here document
4179 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4180 6 $here_script = CORE::substr $_, pos $_;
4181 6 $here_script =~ s/.*?\n//oxm;
4182 }
4183 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
4184 6 my $heredoc = $1;
4185 6 my $indent = $2;
4186 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4187 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4188 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4189 }
4190 else {
4191 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4192 }
4193 6 return qq{<<"$delimiter"};
4194 }
4195  
4196 # <<~HEREDOC
4197 elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4198 3 $slash = 'm//';
4199 3 my $here_quote = $1;
4200 3 my $delimiter = $2;
4201  
4202 # get here document
4203 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4204 3 $here_script = CORE::substr $_, pos $_;
4205 3 $here_script =~ s/.*?\n//oxm;
4206 }
4207 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
4208 3 my $heredoc = $1;
4209 3 my $indent = $2;
4210 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4211 3 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4212 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4213 }
4214 else {
4215 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4216 }
4217 3 return qq{<<$delimiter};
4218 }
4219  
4220 # <<~`HEREDOC`
4221 elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4222 6 $slash = 'm//';
4223 6 my $here_quote = $1;
4224 6 my $delimiter = $2;
4225  
4226 # get here document
4227 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4228 6 $here_script = CORE::substr $_, pos $_;
4229 6 $here_script =~ s/.*?\n//oxm;
4230 }
4231 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
4232 6 my $heredoc = $1;
4233 6 my $indent = $2;
4234 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4235 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4236 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4237 }
4238 else {
4239 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4240 }
4241 6 return qq{<<`$delimiter`};
4242 }
4243  
4244 # <<'HEREDOC'
4245 elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
4246 72 $slash = 'm//';
4247 72 my $here_quote = $1;
4248 72 my $delimiter = $2;
4249  
4250 # get here document
4251 72 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 72 0 72
4252 72 $here_script = CORE::substr $_, pos $_;
4253 72 $here_script =~ s/.*?\n//oxm;
4254 }
4255 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
4256 72 push @heredoc, $1 . qq{\n$delimiter\n};
4257 72 push @heredoc_delimiter, $delimiter;
4258 }
4259 else {
4260 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4261 }
4262 72 return $here_quote;
4263 }
4264  
4265 # <<\HEREDOC
4266  
4267 # P.66 2.6.6. "Here" Documents
4268 # in Chapter 2: Bits and Pieces
4269 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4270  
4271 # P.73 "Here" Documents
4272 # in Chapter 2: Bits and Pieces
4273 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4274  
4275 elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
4276 0 $slash = 'm//';
4277 0 my $here_quote = $1;
4278 0 my $delimiter = $2;
4279  
4280 # get here document
4281 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4282 0 $here_script = CORE::substr $_, pos $_;
4283 0 $here_script =~ s/.*?\n//oxm;
4284 }
4285 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
4286 0 push @heredoc, $1 . qq{\n$delimiter\n};
4287 0 push @heredoc_delimiter, $delimiter;
4288 }
4289 else {
4290 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4291 }
4292 0 return $here_quote;
4293 }
4294  
4295 # <<"HEREDOC"
4296 elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
4297 36 $slash = 'm//';
4298 36 my $here_quote = $1;
4299 36 my $delimiter = $2;
4300  
4301 # get here document
4302 36 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 36 0 36
4303 36 $here_script = CORE::substr $_, pos $_;
4304 36 $here_script =~ s/.*?\n//oxm;
4305 }
4306 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
4307 36 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4308 36 push @heredoc_delimiter, $delimiter;
4309 }
4310 else {
4311 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4312 }
4313 36 return $here_quote;
4314 }
4315  
4316 # <<HEREDOC
4317 elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
4318 42 $slash = 'm//';
4319 42 my $here_quote = $1;
4320 42 my $delimiter = $2;
4321  
4322 # get here document
4323 42 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 42 0 42
4324 42 $here_script = CORE::substr $_, pos $_;
4325 42 $here_script =~ s/.*?\n//oxm;
4326 }
4327 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
4328 42 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4329 42 push @heredoc_delimiter, $delimiter;
4330 }
4331 else {
4332 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4333 }
4334 42 return $here_quote;
4335 }
4336  
4337 # <<`HEREDOC`
4338 elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
4339 0 $slash = 'm//';
4340 0 my $here_quote = $1;
4341 0 my $delimiter = $2;
4342  
4343 # get here document
4344 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4345 0 $here_script = CORE::substr $_, pos $_;
4346 0 $here_script =~ s/.*?\n//oxm;
4347 }
4348 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
4349 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4350 0 push @heredoc_delimiter, $delimiter;
4351 }
4352 else {
4353 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4354 }
4355 0 return $here_quote;
4356 }
4357  
4358 # <<= <=> <= < operator
4359 elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
4360 12 return $1;
4361 }
4362  
4363 # <FILEHANDLE>
4364 elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
4365 0 return $1;
4366 }
4367  
4368 # <WILDCARD> --- glob
4369  
4370 # avoid "Error: Runtime exception" of perl version 5.005_03
4371  
4372 elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /oxgc) {
4373 0 return 'Ekoi8u::glob("' . $1 . '")';
4374 }
4375  
4376 # __DATA__
4377 0 elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; }
4378  
4379 # __END__
4380 210 elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; }
4381  
4382 # \cD Control-D
4383  
4384 # P.68 2.6.8. Other Literal Tokens
4385 # in Chapter 2: Bits and Pieces
4386 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4387  
4388 # P.76 Other Literal Tokens
4389 # in Chapter 2: Bits and Pieces
4390 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4391  
4392 0 elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; }
4393  
4394 # \cZ Control-Z
4395 0 elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; }
4396  
4397 # any operator before div
4398 elsif (/\G (
4399 -- | \+\+ |
4400 [\)\}\]]
4401  
4402 5837 ) /oxgc) { $slash = 'div'; return $1; }
4403  
4404 # yada-yada or triple-dot operator
4405 elsif (/\G (
4406 \.\.\.
4407  
4408 7 ) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; }
4409  
4410 # any operator before m//
4411  
4412 # //, //= (defined-or)
4413  
4414 # P.164 Logical Operators
4415 # in Chapter 10: More Control Structures
4416 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4417  
4418 # P.119 C-Style Logical (Short-Circuit) Operators
4419 # in Chapter 3: Unary and Binary Operators
4420 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4421  
4422 # (and so on)
4423  
4424 # ~~
4425  
4426 # P.221 The Smart Match Operator
4427 # in Chapter 15: Smart Matching and given-when
4428 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4429  
4430 # P.112 Smartmatch Operator
4431 # in Chapter 3: Unary and Binary Operators
4432 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4433  
4434 # (and so on)
4435  
4436 elsif (/\G ((?>
4437  
4438 !~~ | !~ | != | ! |
4439 %= | % |
4440 &&= | && | &= | &\.= | &\. | & |
4441 -= | -> | - |
4442 :(?>\s*)= |
4443 : |
4444 <<>> |
4445 <<= | <=> | <= | < |
4446 == | => | =~ | = |
4447 >>= | >> | >= | > |
4448 \*\*= | \*\* | \*= | \* |
4449 \+= | \+ |
4450 \.\. | \.= | \. |
4451 \/\/= | \/\/ |
4452 \/= | \/ |
4453 \? |
4454 \\ |
4455 \^= | \^\.= | \^\. | \^ |
4456 \b x= |
4457 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
4458 ~~ | ~\. | ~ |
4459 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
4460 \b(?: print )\b |
4461  
4462 [,;\(\{\[]
4463  
4464 9778 )) /oxgc) { $slash = 'm//'; return $1; }
4465  
4466 # other any character
4467 19976 elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; }
4468  
4469 # system error
4470 else {
4471 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4472 }
4473 }
4474  
4475 # escape KOI8-U string
4476 1871 ▶sub e_string {
Subroutine e_string: called CC=228 SCAR=104.2
Pod documented
4477 1871 my($string) = @_;
4478 1871 my $e_string = '';
4479  
4480 1871 local $slash = 'm//';
4481  
4482 # P.1024 Appendix W.10 Multibyte Processing
4483 # of ISBN 1-56592-224-7 CJKV Information Processing
4484 # (and so on)
4485  
4486 1871 my @char = $string =~ / \G (?>[^\\]|\\$q_char|$q_char) /oxmsg;
4487  
4488 # without { ... }
4489 1871 ▶ 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 17 1871
Condition66%2/3
grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char
!ll&&!rl&&r
1854017
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
4490 1854 ▶ if ($string !~ /<</oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /<</mosx) 1854 0 1854
4491 1854 return $string;
4492 }
4493 }
4494  
4495 E_STRING_LOOP:
4496 17 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 190 17 207
4497 190 ▶ if (0) {
Branch: 101 branches
BranchTrueFalseTotal
if (do { $string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx }) { } 0 190 190
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \$' | \$\{'\} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \$ 0 ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /cgmosx) { } 0 190 190
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 3 187 190
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 180 187
elsif ($string =~ m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 0 180 180
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 180 180
elsif ($string =~ /\G \b KOI8U::eval (?= (?>\s*) \{ ) /cgox) { } 0 180 180
elsif ($string =~ /\G \b Char::eval \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b KOI8U::eval \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::substr \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b chop \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::index \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b Char::index \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b KOI8U::index \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b index \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::rindex \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b Char::rindex \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b KOI8U::rindex \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b rindex \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$Ekoi8u::qq_char)+?) (\") /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Ekoi8u::qq_char)+?) (\#) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Ekoi8u::qq_char)+?) (\1) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Ekoi8u::q_char)+?) (\') /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Ekoi8u::q_char)+?) (\#) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Ekoi8u::q_char)+?) (\1) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 180 180
elsif ($string =~ /\G \b lc \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b lcfirst \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b uc \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b ucfirst \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b fc \b /cgox) { } 0 180 180
elsif ($string =~ /\G -s \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::length \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::chr \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b chr \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b bytes::ord \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b ord \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b glob \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b reverse \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b getc \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 0 180 180
elsif ($string =~ /\G \b (qq) \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b (qx) \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b (q) \b /cgox) { } 0 180 180
elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$Ekoi8u::q_char)*?) (\') /cgox) { } 0 180 180
elsif ($string =~ /\G (\") ((?:$Ekoi8u::qq_char)*?) (\") /cgox) { } 0 180 180
elsif ($string =~ /\G (\`) ((?:$Ekoi8u::qq_char)*?) (\`) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<>> ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 0 180 180
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 180 180
elsif ($string =~ /\G < ((?:$Ekoi8u::q_char)+?) > /cgox) { } 0 180 180
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 180 180
elsif ($string =~ /\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 18 162 180
elsif ($string =~ /\G ( \.\.\. ) /cgox) { } 0 162 162
elsif ($string =~ m"\G ((?> !~~ | !~ | != | ! | %= | % | &&= | && | &= | &\.= | &\. | & | -= | -> | - | :(?>\s*)= | : | <<>> | <<= | <=> | <= | < | == | => | =~ | = | >>= | >> | >= | > | \*\*= | \*\* | \*= | \* | \+= | \+ | \.\. | \.= | \. | //= | // | /= | / | \? | \\ | \^= | \^\.= | \^\. | \^ | \b x= | \|\|= | \|\| | \|= | \|\.= | \|\. | \| | ~~ | ~\. | ~ | \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | \b(?: print )\b | [,;\(\{\[] )) "cgox) { } 31 131 162
elsif ($string =~ /\G ($Ekoi8u::q_char) /cgox) { } 131 0 131
4498 }
4499  
4500 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Ekoi8u::PREMATCH()]}
4501 elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
4502 0 $e_string .= q{Ekoi8u::PREMATCH()};
4503 0 $slash = 'div';
4504 }
4505  
4506 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Ekoi8u::MATCH()]}
4507 elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
4508 0 $e_string .= q{Ekoi8u::MATCH()};
4509 0 $slash = 'div';
4510 }
4511  
4512 # $', ${'} --> $', ${'}
4513 elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) {
4514 0 $e_string .= $1;
4515 0 $slash = 'div';
4516 }
4517  
4518 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Ekoi8u::POSTMATCH()]}
4519 elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
4520 0 $e_string .= q{Ekoi8u::POSTMATCH()};
4521 0 $slash = 'div';
4522 }
4523  
4524 # bareword
4525 elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
4526 0 $e_string .= $1;
4527 0 $slash = 'div';
4528 }
4529  
4530 # $0 --> $0
4531 elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) {
4532 0 $e_string .= $1;
4533 0 $slash = 'div';
4534 }
4535 elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
4536 0 $e_string .= $1;
4537 0 $slash = 'div';
4538 }
4539  
4540 # $$ --> $$
4541 elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
4542 0 $e_string .= $1;
4543 0 $slash = 'div';
4544 }
4545  
4546 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4547 # $1, $2, $3 --> $1, $2, $3 otherwise
4548 elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
4549 0 $e_string .= e_capture($1);
4550 0 $slash = 'div';
4551 }
4552 elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
4553 0 $e_string .= e_capture($1);
4554 0 $slash = 'div';
4555 }
4556  
4557 # $$foo[ ... ] --> $ $foo->[ ... ]
4558 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
4559 0 $e_string .= e_capture($1.'->'.$2);
4560 0 $slash = 'div';
4561 }
4562  
4563 # $$foo{ ... } --> $ $foo->{ ... }
4564 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
4565 0 $e_string .= e_capture($1.'->'.$2);
4566 0 $slash = 'div';
4567 }
4568  
4569 # $$foo
4570 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
4571 0 $e_string .= e_capture($1);
4572 0 $slash = 'div';
4573 }
4574  
4575 # ${ foo }
4576 elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) {
4577 0 $e_string .= '${' . $1 . '}';
4578 0 $slash = 'div';
4579 }
4580  
4581 # ${ ... }
4582 elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
4583 3 $e_string .= e_capture($1);
4584 3 $slash = 'div';
4585 }
4586  
4587 # variable or function
4588 # $ @ % & * $ #
4589 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) {
4590 7 $e_string .= $1;
4591 7 $slash = 'div';
4592 }
4593 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
4594 # $ @ # \ ' " / ? ( ) [ ] < >
4595 elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
4596 0 $e_string .= $1;
4597 0 $slash = 'div';
4598 }
4599  
4600 # subroutines of package Ekoi8u
4601 0 elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; }
4602 0 elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; }
4603 0 elsif ($string =~ /\G \b KOI8U::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; }
4604 0 elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; }
4605 0 elsif ($string =~ /\G \b KOI8U::eval \b /oxgc) { $e_string .= 'eval KOI8U::escape'; $slash = 'm//'; }
4606 0 elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; }
4607 0 elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Ekoi8u::chop'; $slash = 'm//'; }
4608 0 elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; }
4609 0 elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; }
4610 0 elsif ($string =~ /\G \b KOI8U::index \b /oxgc) { $e_string .= 'KOI8U::index'; $slash = 'm//'; }
4611 0 elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Ekoi8u::index'; $slash = 'm//'; }
4612 0 elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; }
4613 0 elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; }
4614 0 elsif ($string =~ /\G \b KOI8U::rindex \b /oxgc) { $e_string .= 'KOI8U::rindex'; $slash = 'm//'; }
4615 0 elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Ekoi8u::rindex'; $slash = 'm//'; }
4616 0 elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::lc'; $slash = 'm//'; }
4617 0 elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::lcfirst'; $slash = 'm//'; }
4618 0 elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::uc'; $slash = 'm//'; }
4619 0 elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::ucfirst'; $slash = 'm//'; }
4620 0 elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::fc'; $slash = 'm//'; }
4621  
4622 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
4623 0 elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; }
4624 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4625 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4626 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4627 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4628 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4629 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4630  
4631 0 elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; }
4632 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4633 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4634 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4635 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4636 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4637 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4638  
4639 elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc)
4640 0 { $e_string .= "-s $1"; $slash = 'm//'; }
4641 0 elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; }
4642 0 elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; }
4643 0 elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; }
4644  
4645 0 elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; }
4646 0 elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; }
4647 0 elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::chr'; $slash = 'm//'; }
4648 0 elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; }
4649 0 elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; }
4650 0 elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8u::glob'; $slash = 'm//'; }
4651 0 elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Ekoi8u::lc_'; $slash = 'm//'; }
4652 0 elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Ekoi8u::lcfirst_'; $slash = 'm//'; }
4653 0 elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Ekoi8u::uc_'; $slash = 'm//'; }
4654 0 elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Ekoi8u::ucfirst_'; $slash = 'm//'; }
4655 0 elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Ekoi8u::fc_'; $slash = 'm//'; }
4656 0 elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; }
4657  
4658 0 elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; }
4659 0 elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; }
4660 0 elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Ekoi8u::chr_'; $slash = 'm//'; }
4661 0 elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; }
4662 0 elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; }
4663 0 elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Ekoi8u::glob_'; $slash = 'm//'; }
4664 0 elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; }
4665 0 elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; }
4666 # split
4667 elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
4668 0 $slash = 'm//';
4669  
4670 0 my $e = '';
4671 0 ▶ while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G ( (?>\s+) | \( | \#.* ) /cgox) 0 0 0
4672 0 $e .= $1;
4673 }
4674  
4675 # end of split
4676 0 ▶ if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Ekoi8u::split' . $e; }
Branch: 23 branches
BranchTrueFalseTotal
if ($string =~ /\G (?= [,;\)\}\]] ) /cgox) { } 0 0 0
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /cgox) { } 0 0 0
elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q (\#) [ ] (\#) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /cgox) { } 0 0 0
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /cgox) { } 0 0 0
elsif ($string =~ /\G ' [ ] ' /cgox) { } 0 0 0
elsif ($string =~ /\G " [ ] " /cgox) { } 0 0 0
elsif ($string =~ /\G \b (qq) \b /cgox) { } 0 0 0
elsif ($string =~ /\G \b (qr) \b /cgox) { } 0 0 0
elsif ($string =~ /\G \b (q) \b /cgox) { } 0 0 0
elsif ($string =~ /\G \b (m) \b /cgox) { } 0 0 0
elsif ($string =~ /\G (\') /cgox) { } 0 0 0
elsif ($string =~ /\G (\") /cgox) { } 0 0 0
elsif ($string =~ m[\G (/) ]cgox) { } 0 0 0
4677  
4678 # split scalar value
4679 0 elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . e_string($1); next E_STRING_LOOP; }
4680  
4681 # split literal space
4682 0 elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; }
4683 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4684 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4685 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4686 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4687 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4688 0 elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; }
4689 0 elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4690 0 elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4691 0 elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4692 0 elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4693 0 elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4694 0 elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {' '}; next E_STRING_LOOP; }
4695 0 elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Ekoi8u::split' . $e . qq {" "}; next E_STRING_LOOP; }
4696  
4697 # split qq//
4698 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4699 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) /cgox) { } 0 0 0
4700 else {
4701 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4702 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $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 ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
4703 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq ( ) --> qr ( )
4704 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq { } --> qr { }
4705 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq [ ] --> qr [ ]
4706 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < >
4707 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { }
4708 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * *
4709 }
4710 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4711 }
4712 }
4713  
4714 # split qr//
4715 elsif ($string =~ /\G \b (qr) \b /oxgc) {
4716 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # qr# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
4717 else {
4718 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4719 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; }
Branch: 8 branches
BranchTrueFalseTotal
if ($string =~ /\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\') ((?:$Ekoi8u::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
4720 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ( )
4721 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr { }
4722 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr [ ]
4723 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr < >
4724 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' '
4725 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { }
4726 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr * *
4727 }
4728 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4729 }
4730 }
4731  
4732 # split q//
4733 elsif ($string =~ /\G \b (q) \b /oxgc) {
4734 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Ekoi8u::q_char)*?) (\#) /cgox) { } 0 0 0
4735 else {
4736 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4737 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; }
Branch: 7 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 ([*\-:?\\^|]) ((?:$Ekoi8u::q_char)*?) (\1) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $Ekoi8u::q_char)*?) (\1) /cgox) { } 0 0 0
4738 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q ( ) --> qr ( )
4739 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q { } --> qr { }
4740 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q [ ] --> qr [ ]
4741 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < >
4742 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { }
4743 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q * * --> qr * *
4744 }
4745 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4746 }
4747 }
4748  
4749 # split m//
4750 elsif ($string =~ /\G \b (m) \b /oxgc) {
4751 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # m# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
4752 else {
4753 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4754 0 ▶ if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; }
Branch: 8 branches
BranchTrueFalseTotal
if ($string =~ /\G ((?>\s+)|\#.*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\') ((?:$Ekoi8u::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
4755 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ( ) --> qr ( )
4756 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m { } --> qr { }
4757 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m [ ] --> qr [ ]
4758 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m < > --> qr < >
4759 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ' ' --> qr ' '
4760 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { }
4761 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m * * --> qr * *
4762 }
4763 0 die __FILE__, ": Search pattern not terminated\n";
4764 }
4765 }
4766  
4767 # split ''
4768 elsif ($string =~ /\G (\') /oxgc) {
4769 0 my $q_string = '';
4770 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4771 0 ▶ if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if ($string =~ /\G (\\\\) /cgox) { } 0 0 0
elsif ($string =~ /\G (\\\') /cgox) { } 0 0 0
elsif ($string =~ /\G \' /cgox) { } 0 0 0
elsif ($string =~ /\G ($Ekoi8u::q_char) /cgox) { } 0 0 0
4772 0 elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
4773 0 elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' '
4774 0 elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; }
4775 }
4776 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4777 }
4778  
4779 # split ""
4780 elsif ($string =~ /\G (\") /oxgc) {
4781 0 my $qq_string = '';
4782 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4783 0 ▶ if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if ($string =~ /\G (\\\\) /cgox) { } 0 0 0
elsif ($string =~ /\G (\\\") /cgox) { } 0 0 0
elsif ($string =~ /\G \" /cgox) { } 0 0 0
elsif ($string =~ /\G ($Ekoi8u::q_char) /cgox) { } 0 0 0
4784 0 elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
4785 0 elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " "
4786 0 elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; }
4787 }
4788 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4789 }
4790  
4791 # split //
4792 elsif ($string =~ /\G (\/) /oxgc) {
4793 0 my $regexp = '';
4794 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4795 0 ▶ if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if ($string =~ /\G (\\\\) /cgox) { } 0 0 0
elsif ($string =~ m[\G (\\/) ]cgox) { } 0 0 0
elsif ($string =~ m[\G / ([cgimosxpadlunbB]*) ]cgox) { } 0 0 0
elsif ($string =~ /\G ($Ekoi8u::q_char) /cgox) { } 0 0 0
4796 0 elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
4797 0 elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / /
4798 0 elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; }
4799 }
4800 0 die __FILE__, ": Search pattern not terminated\n";
4801 }
4802 }
4803  
4804 # qq//
4805 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4806 0 my $ope = $1;
4807 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) /cgox) { } 0 0 0
4808 0 $e_string .= e_qq($ope,$1,$3,$2);
4809 }
4810 else {
4811 0 my $e = '';
4812 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4813 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) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
4814 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( )
4815 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { }
4816 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ]
4817 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < >
4818 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * *
4819 }
4820 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4821 }
4822 }
4823  
4824 # qx//
4825 elsif ($string =~ /\G \b (qx) \b /oxgc) {
4826 0 my $ope = $1;
4827 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8u::qq_char)*?) (\#) /cgox) { } 0 0 0
4828 0 $e_string .= e_qq($ope,$1,$3,$2);
4829 }
4830 else {
4831 0 my $e = '';
4832 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4833 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 (\') ((?:$Ekoi8u::qq_char)*?) (\') /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8u::qq_char)*?) (\1) /cgox) { } 0 0 0
4834 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( )
4835 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { }
4836 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ]
4837 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < >
4838 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' '
4839 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * *
4840 }
4841 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4842 }
4843 }
4844  
4845 # q//
4846 elsif ($string =~ /\G \b (q) \b /oxgc) {
4847 0 my $ope = $1;
4848 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Ekoi8u::q_char)*?) (\#) /cgox) { } 0 0 0
4849 0 $e_string .= e_q($ope,$1,$3,$2);
4850 }
4851 else {
4852 0 my $e = '';
4853 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4854 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| $Ekoi8u::q_char)*?) (\1) /cgox) { } 0 0 0
4855 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( )
4856 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { }
4857 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ]
4858 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < >
4859 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * *
4860 }
4861 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4862 }
4863 }
4864  
4865 # ''
4866 0 elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('',$1,$3,$2); }
4867  
4868 # ""
4869 0 elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4870  
4871 # ``
4872 0 elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4873  
4874 # <<>> (a safer ARGV)
4875 0 elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; }
4876  
4877 # <<= <=> <= < operator
4878 0 elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; }
4879  
4880 # <FILEHANDLE>
4881 0 elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; }
4882  
4883 # <WILDCARD> --- glob
4884 elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) {
4885 0 $e_string .= 'Ekoi8u::glob("' . $1 . '")';
4886 }
4887  
4888 # << (bit shift) --- not here document
4889 elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) {
4890 0 $slash = 'm//';
4891 0 $e_string .= $1;
4892 }
4893  
4894 # <<~'HEREDOC'
4895 elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4896 0 $slash = 'm//';
4897 0 my $here_quote = $1;
4898 0 my $delimiter = $2;
4899  
4900 # get here document
4901 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4902 0 $here_script = CORE::substr $_, pos $_;
4903 0 $here_script =~ s/.*?\n//oxm;
4904 }
4905 0 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 0 0 0
4906 0 my $heredoc = $1;
4907 0 my $indent = $2;
4908 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4909 0 push @heredoc, $heredoc . qq{\n$delimiter\n};
4910 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4911 }
4912 else {
4913 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4914 }
4915 0 $e_string .= qq{<<'$delimiter'};
4916 }
4917  
4918 # <<~\HEREDOC
4919 elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4920 0 $slash = 'm//';
4921 0 my $here_quote = $1;
4922 0 my $delimiter = $2;
4923  
4924 # get here document
4925 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4926 0 $here_script = CORE::substr $_, pos $_;
4927 0 $here_script =~ s/.*?\n//oxm;
4928 }
4929 0 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 0 0 0
4930 0 my $heredoc = $1;
4931 0 my $indent = $2;
4932 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4933 0 push @heredoc, $heredoc . qq{\n$delimiter\n};
4934 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4935 }
4936 else {
4937 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4938 }
4939 0 $e_string .= qq{<<\\$delimiter};
4940 }
4941  
4942 # <<~"HEREDOC"
4943 elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4944 0 $slash = 'm//';
4945 0 my $here_quote = $1;
4946 0 my $delimiter = $2;
4947  
4948 # get here document
4949 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4950 0 $here_script = CORE::substr $_, pos $_;
4951 0 $here_script =~ s/.*?\n//oxm;
4952 }
4953 0 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 0 0 0
4954 0 my $heredoc = $1;
4955 0 my $indent = $2;
4956 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4957 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4958 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4959 }
4960 else {
4961 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4962 }
4963 0 $e_string .= qq{<<"$delimiter"};
4964 }
4965  
4966 # <<~HEREDOC
4967 elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4968 0 $slash = 'm//';
4969 0 my $here_quote = $1;
4970 0 my $delimiter = $2;
4971  
4972 # get here document
4973 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4974 0 $here_script = CORE::substr $_, pos $_;
4975 0 $here_script =~ s/.*?\n//oxm;
4976 }
4977 0 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 0 0 0
4978 0 my $heredoc = $1;
4979 0 my $indent = $2;
4980 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4981 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4982 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4983 }
4984 else {
4985 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4986 }
4987 0 $e_string .= qq{<<$delimiter};
4988 }
4989  
4990 # <<~`HEREDOC`
4991 elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4992 0 $slash = 'm//';
4993 0 my $here_quote = $1;
4994 0 my $delimiter = $2;
4995  
4996 # get here document
4997 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4998 0 $here_script = CORE::substr $_, pos $_;
4999 0 $here_script =~ s/.*?\n//oxm;
5000 }
5001 0 ▶ if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //msx) { } 0 0 0
5002 0 my $heredoc = $1;
5003 0 my $indent = $2;
5004 0 $heredoc =~ s{^$indent}{}msg; # no /ox
5005 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
5006 0 push @heredoc_delimiter, qq{\\s*$delimiter};
5007 }
5008 else {
5009 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5010 }
5011 0 $e_string .= qq{<<`$delimiter`};
5012 }
5013  
5014 # <<'HEREDOC'
5015 elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
5016 0 $slash = 'm//';
5017 0 my $here_quote = $1;
5018 0 my $delimiter = $2;
5019  
5020 # get here document
5021 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5022 0 $here_script = CORE::substr $_, pos $_;
5023 0 $here_script =~ s/.*?\n//oxm;
5024 }
5025 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
5026 0 push @heredoc, $1 . qq{\n$delimiter\n};
5027 0 push @heredoc_delimiter, $delimiter;
5028 }
5029 else {
5030 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5031 }
5032 0 $e_string .= $here_quote;
5033 }
5034  
5035 # <<\HEREDOC
5036 elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
5037 0 $slash = 'm//';
5038 0 my $here_quote = $1;
5039 0 my $delimiter = $2;
5040  
5041 # get here document
5042 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5043 0 $here_script = CORE::substr $_, pos $_;
5044 0 $here_script =~ s/.*?\n//oxm;
5045 }
5046 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
5047 0 push @heredoc, $1 . qq{\n$delimiter\n};
5048 0 push @heredoc_delimiter, $delimiter;
5049 }
5050 else {
5051 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5052 }
5053 0 $e_string .= $here_quote;
5054 }
5055  
5056 # <<"HEREDOC"
5057 elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
5058 0 $slash = 'm//';
5059 0 my $here_quote = $1;
5060 0 my $delimiter = $2;
5061  
5062 # get here document
5063 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5064 0 $here_script = CORE::substr $_, pos $_;
5065 0 $here_script =~ s/.*?\n//oxm;
5066 }
5067 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
5068 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5069 0 push @heredoc_delimiter, $delimiter;
5070 }
5071 else {
5072 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5073 }
5074 0 $e_string .= $here_quote;
5075 }
5076  
5077 # <<HEREDOC
5078 elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
5079 0 $slash = 'm//';
5080 0 my $here_quote = $1;
5081 0 my $delimiter = $2;
5082  
5083 # get here document
5084 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5085 0 $here_script = CORE::substr $_, pos $_;
5086 0 $here_script =~ s/.*?\n//oxm;
5087 }
5088 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
5089 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5090 0 push @heredoc_delimiter, $delimiter;
5091 }
5092 else {
5093 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5094 }
5095 0 $e_string .= $here_quote;
5096 }
5097  
5098 # <<`HEREDOC`
5099 elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
5100 0 $slash = 'm//';
5101 0 my $here_quote = $1;
5102 0 my $delimiter = $2;
5103  
5104 # get here document
5105 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5106 0 $here_script = CORE::substr $_, pos $_;
5107 0 $here_script =~ s/.*?\n//oxm;
5108 }
5109 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
5110 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5111 0 push @heredoc_delimiter, $delimiter;
5112 }
5113 else {
5114 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5115 }
5116 0 $e_string .= $here_quote;
5117 }
5118  
5119 # any operator before div
5120 elsif ($string =~ /\G (
5121 -- | \+\+ |
5122 [\)\}\]]
5123  
5124 18 ) /oxgc) { $slash = 'div'; $e_string .= $1; }
5125  
5126 # yada-yada or triple-dot operator
5127 elsif ($string =~ /\G (
5128 \.\.\.
5129  
5130 0 ) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; }
5131  
5132 # any operator before m//
5133 elsif ($string =~ /\G ((?>
5134  
5135 !~~ | !~ | != | ! |
5136 %= | % |
5137 &&= | && | &= | &\.= | &\. | & |
5138 -= | -> | - |
5139 :(?>\s*)= |
5140 : |
5141 <<>> |
5142 <<= | <=> | <= | < |
5143 == | => | =~ | = |
5144 >>= | >> | >= | > |
5145 \*\*= | \*\* | \*= | \* |
5146 \+= | \+ |
5147 \.\. | \.= | \. |
5148 \/\/= | \/\/ |
5149 \/= | \/ |
5150 \? |
5151 \\ |
5152 \^= | \^\.= | \^\. | \^ |
5153 \b x= |
5154 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
5155 ~~ | ~\. | ~ |
5156 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
5157 \b(?: print )\b |
5158  
5159 [,;\(\{\[]
5160  
5161 31 )) /oxgc) { $slash = 'm//'; $e_string .= $1; }
5162  
5163 # other any character
5164 131 elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; }
5165  
5166 # system error
5167 else {
5168 0 die __FILE__, ": Oops, this shouldn't happen!\n";
5169 }
5170 }
5171  
5172 17 return $e_string;
5173 }
5174  
5175 #
5176 # character class
5177 #
5178 1920 ▶sub character_class {
Subroutine character_class: called CC=3 SCAR=11.0
Pod undocumented
5179 1920 my($char,$modifier) = @_;
5180  
5181 1920 ▶ if ($char eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '.') { } 52 1868 1920
5182 52 ▶ if ($modifier =~ /s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/) { } 17 35 52
5183 17 return '${Ekoi8u::dot_s}';
5184 }
5185 else {
5186 35 return '${Ekoi8u::dot}';
5187 }
5188 }
5189 else {
5190 1868 return Ekoi8u::classic_character_class($char);
5191 }
5192 }
5193  
5194 #
5195 # escape capture ($1, $2, $3, ...)
5196 #
5197 212 ▶sub e_capture {
Subroutine e_capture: called CC=1 SCAR=0.0
Pod undocumented
5198  
5199 212 return join '', '${', $_[0], '}';
5200 }
5201  
5202 #
5203 # escape transliteration (tr/// or y///)
5204 #
5205 4 ▶sub e_tr {
Subroutine e_tr: called CC=5 SCAR=16.8
Pod undocumented
5206 4 my($variable,$charclass,$e,$charclass2,$modifier) = @_;
5207 4 my $e_tr = '';
5208 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
5209  
5210 4 $slash = 'div';
5211  
5212 # quote character class 1
5213 4 $charclass = q_tr($charclass);
5214  
5215 # quote character class 2
5216 4 $charclass2 = q_tr($charclass2);
5217  
5218 # /b /B modifier
5219 4 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) { } 0 4 4
5220 0 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 0 0 0
5221 0 $e_tr = qq{tr$charclass$e$charclass2$modifier};
5222 }
5223 else {
5224 0 $e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier};
5225 }
5226 }
5227 else {
5228 4 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 2 2 4
5229 2 $e_tr = qq{Ekoi8u::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')};
5230 }
5231 else {
5232 2 $e_tr = qq{Ekoi8u::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')};
5233 }
5234 }
5235  
5236 # clear tr/// variable
5237 4 $tr_variable = '';
5238 4 $bind_operator = '';
5239  
5240 4 return $e_tr;
5241 }
5242  
5243 #
5244 # quote for escape transliteration (tr/// or y///)
5245 #
5246 8 ▶sub q_tr {
Subroutine q_tr: called CC=9 SCAR=40.6
Pod undocumented
5247 8 my($charclass) = @_;
5248  
5249 # quote character class
5250 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
5251 8 return e_q('', "'", "'", $charclass); # --> q' '
5252 }
5253 elsif ($charclass !~ /\//oxms) {
5254 0 return e_q('q', '/', '/', $charclass); # --> q/ /
5255 }
5256 elsif ($charclass !~ /\#/oxms) {
5257 0 return e_q('q', '#', '#', $charclass); # --> q# #
5258 }
5259 elsif ($charclass !~ /[\<\>]/oxms) {
5260 0 return e_q('q', '<', '>', $charclass); # --> q< >
5261 }
5262 elsif ($charclass !~ /[\(\)]/oxms) {
5263 0 return e_q('q', '(', ')', $charclass); # --> q( )
5264 }
5265 elsif ($charclass !~ /[\{\}]/oxms) {
5266 0 return e_q('q', '{', '}', $charclass); # --> q{ }
5267 }
5268 else {
5269 0 for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5270 0 ▶ if ($charclass !~ /\Q$char\E/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($charclass =~ /\Q$char\E/msx) 0 0 0
5271 0 return e_q('q', $char, $char, $charclass);
5272 }
5273 }
5274 }
5275  
5276 0 return e_q('q', '{', '}', $charclass);
5277 }
5278  
5279 #
5280 # escape q string (q//, '')
5281 #
5282 1623 ▶sub e_q {
Subroutine e_q: called CC=1 SCAR=0.0
Pod undocumented
5283 1623 my($ope,$delimiter,$end_delimiter,$string) = @_;
5284  
5285 1623 $slash = 'div';
5286  
5287 1623 return join '', $ope, $delimiter, $string, $end_delimiter;
5288 }
5289  
5290 #
5291 # escape qq string (qq//, "", qx//, ``)
5292 #
5293 4235 ▶sub e_qq {
Subroutine e_qq: called CC=37 SCAR=50.9
Pod undocumented
5294 4235 my($ope,$delimiter,$end_delimiter,$string) = @_;
5295  
5296 4235 $slash = 'div';
5297  
5298 4235 my $left_e = 0;
5299 4235 my $right_e = 0;
5300  
5301 # split regexp
5302 4235 my @char = $string =~ /\G((?>
5303 [^\\\$] |
5304 \\x\{ (?>[0-9A-Fa-f]+) \} |
5305 \\o\{ (?>[0-7]+) \} |
5306 \\N\{ (?>[^0-9\}][^\}]*) \} |
5307 \\ $q_char |
5308 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5309 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5310 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5311 \$ (?>\s* [0-9]+) |
5312 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5313 \$ \$ (?![\w\{]) |
5314 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5315 $q_char
5316 ))/oxmsg;
5317  
5318 4235 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 116503 4235 120738
5319  
5320 # "\L\u" --> "\u\L"
5321 116503 ▶ 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 116503 116503
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 116503 116503
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 116502 116503
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 116501 116502
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 116501 116501
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
11650300
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
5322 0 @char[$i,$i+1] = @char[$i+1,$i];
5323 }
5324  
5325 # "\U\l" --> "\l\U"
5326 ▶ 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
11650300
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
5327 0 @char[$i,$i+1] = @char[$i+1,$i];
5328 }
5329  
5330 # octal escape sequence
5331 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5332 1 $char[$i] = Ekoi8u::octchr($1);
5333 }
5334  
5335 # hexadecimal escape sequence
5336 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5337 1 $char[$i] = Ekoi8u::hexchr($1);
5338 }
5339  
5340 # \N{CHARNAME} --> N{CHARNAME}
5341 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5342 0 $char[$i] = $1;
5343 }
5344  
5345 116503 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 484 116019 116503
elsif ($char[$i] eq '\\u') { } 0 116019 116019
elsif ($char[$i] eq '\\l') { } 0 116019 116019
elsif ($char[$i] eq '\\U') { } 0 116019 116019
elsif ($char[$i] eq '\\L') { } 0 116019 116019
elsif ($char[$i] eq '\\F') { } 24 115995 116019
elsif ($char[$i] eq '\\Q') { } 0 115995 115995
elsif ($char[$i] eq '\\E') { } 24 115971 115995
elsif ($char[$i] eq '\\Q') { } 0 115971 115971
elsif ($char[$i] eq '\\E') { } 0 115971 115971
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 4 115967 115971
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 115967 115967
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 115967 115967
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 205 115762 115967
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 115762 115762
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 115762 115762
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 115762 115762
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 115762 115762
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 44 115718 115762
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 45 115673 115718
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 33 115640 115673
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 115640 115640
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 115640 115640
5346 }
5347  
5348 # \F
5349 #
5350 # P.69 Table 2-6. Translation escapes
5351 # in Chapter 2: Bits and Pieces
5352 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
5353 # (and so on)
5354  
5355 # \u \l \U \L \F \Q \E
5356 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5357 484 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 484 484
5358 0 $char[$i] = '\\' . $char[$i];
5359 }
5360 }
5361 elsif ($char[$i] eq '\u') {
5362  
5363 # "STRING @{[ LIST EXPR ]} MORE STRING"
5364  
5365 # P.257 Other Tricks You Can Do with Hard References
5366 # in Chapter 8: References
5367 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
5368  
5369 # P.353 Other Tricks You Can Do with Hard References
5370 # in Chapter 8: References
5371 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
5372  
5373 # (and so on)
5374  
5375 0 $char[$i] = '@{[Ekoi8u::ucfirst qq<';
5376 0 $left_e++;
5377 }
5378 elsif ($char[$i] eq '\l') {
5379 0 $char[$i] = '@{[Ekoi8u::lcfirst qq<';
5380 0 $left_e++;
5381 }
5382 elsif ($char[$i] eq '\U') {
5383 0 $char[$i] = '@{[Ekoi8u::uc qq<';
5384 0 $left_e++;
5385 }
5386 elsif ($char[$i] eq '\L') {
5387 0 $char[$i] = '@{[Ekoi8u::lc qq<';
5388 0 $left_e++;
5389 }
5390 elsif ($char[$i] eq '\F') {
5391 24 $char[$i] = '@{[Ekoi8u::fc qq<';
5392 24 $left_e++;
5393 }
5394 elsif ($char[$i] eq '\Q') {
5395 0 $char[$i] = '@{[CORE::quotemeta qq<';
5396 0 $left_e++;
5397 }
5398 elsif ($char[$i] eq '\E') {
5399 24 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 24 0 24
5400 24 $char[$i] = '>]}';
5401 24 $right_e++;
5402 }
5403 else {
5404 0 $char[$i] = '';
5405 }
5406 }
5407 elsif ($char[$i] eq '\Q') {
5408 0 while (1) {
5409 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5410 0 last;
5411 }
5412 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5413 0 last;
5414 }
5415 }
5416 }
5417 elsif ($char[$i] eq '\E') {
5418 }
5419  
5420 # $0 --> $0
5421 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5422 }
5423 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5424 }
5425  
5426 # $$ --> $$
5427 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5428 }
5429  
5430 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5431 # $1, $2, $3 --> $1, $2, $3 otherwise
5432 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5433 205 $char[$i] = e_capture($1);
5434 }
5435 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5436 0 $char[$i] = e_capture($1);
5437 }
5438  
5439 # $$foo[ ... ] --> $ $foo->[ ... ]
5440 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5441 0 $char[$i] = e_capture($1.'->'.$2);
5442 }
5443  
5444 # $$foo{ ... } --> $ $foo->{ ... }
5445 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5446 0 $char[$i] = e_capture($1.'->'.$2);
5447 }
5448  
5449 # $$foo
5450 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5451 0 $char[$i] = e_capture($1);
5452 }
5453  
5454 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
5455 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5456 44 $char[$i] = '@{[Ekoi8u::PREMATCH()]}';
5457 }
5458  
5459 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
5460 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5461 45 $char[$i] = '@{[Ekoi8u::MATCH()]}';
5462 }
5463  
5464 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
5465 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5466 33 $char[$i] = '@{[Ekoi8u::POSTMATCH()]}';
5467 }
5468  
5469 # ${ foo } --> ${ foo }
5470 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5471 }
5472  
5473 # ${ ... }
5474 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5475 0 $char[$i] = e_capture($1);
5476 }
5477 }
5478  
5479 # return string
5480 4235 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 4235 4235
5481 0 return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter;
5482 }
5483 4235 return join '', $ope, $delimiter, @char, $end_delimiter;
5484 }
5485  
5486 #
5487 # escape qw string (qw//)
5488 #
5489 16 ▶sub e_qw {
Subroutine e_qw: called CC=11 SCAR=43.1
Pod undocumented
5490 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
5491  
5492 16 $slash = 'div';
5493  
5494 # choice again delimiter
5495 16 my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg);
5496 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
5497 16 return join '', $ope, $delimiter, $string, $end_delimiter;
5498 }
5499 elsif (not $octet{')'}) {
5500 0 return join '', $ope, '(', $string, ')';
5501 }
5502 elsif (not $octet{'}'}) {
5503 0 return join '', $ope, '{', $string, '}';
5504 }
5505 elsif (not $octet{']'}) {
5506 0 return join '', $ope, '[', $string, ']';
5507 }
5508 elsif (not $octet{'>'}) {
5509 0 return join '', $ope, '<', $string, '>';
5510 }
5511 else {
5512 0 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5513 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5514 0 return join '', $ope, $char, $string, $char;
5515 }
5516 }
5517 }
5518  
5519 # qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC')
5520 0 my @string = CORE::split(/\s+/, $string);
5521 0 for my $string (@string) {
5522 0 my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5523 0 for my $octet (@octet) {
5524 0 ▶ if ($octet =~ /\A (['\\]) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet =~ /\A (['\\]) \z/mosx) 0 0 0
5525 0 $octet = '\\' . $1;
5526 }
5527 }
5528 0 $string = join '', @octet;
5529 }
5530 0 return join '', '(', (join ', ', map { "'$_'" } @string), ')';
5531 }
5532  
5533 #
5534 # escape here document (<<"HEREDOC", <<HEREDOC, <<`HEREDOC`, <<~"HEREDOC", <<~HEREDOC, <<~`HEREDOC`)
5535 #
5536 93 ▶sub e_heredoc {
Subroutine e_heredoc: called CC=37 SCAR=56.3
Pod undocumented
5537 93 my($string) = @_;
5538  
5539 93 $slash = 'm//';
5540  
5541 93 my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC`
5542  
5543 93 my $left_e = 0;
5544 93 my $right_e = 0;
5545  
5546 # split regexp
5547 93 my @char = $string =~ /\G((?>
5548 [^\\\$] |
5549 \\x\{ (?>[0-9A-Fa-f]+) \} |
5550 \\o\{ (?>[0-7]+) \} |
5551 \\N\{ (?>[^0-9\}][^\}]*) \} |
5552 \\ $q_char |
5553 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5554 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5555 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5556 \$ (?>\s* [0-9]+) |
5557 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5558 \$ \$ (?![\w\{]) |
5559 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5560 $q_char
5561 ))/oxmsg;
5562  
5563 93 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 3151 93 3244
5564  
5565 # "\L\u" --> "\u\L"
5566 3151 ▶ 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 3151 3151
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 3151 3151
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 3150 3151
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 3149 3150
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 3149 3149
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
315100
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
5567 0 @char[$i,$i+1] = @char[$i+1,$i];
5568 }
5569  
5570 # "\U\l" --> "\l\U"
5571 ▶ 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
315100
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
5572 0 @char[$i,$i+1] = @char[$i+1,$i];
5573 }
5574  
5575 # octal escape sequence
5576 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5577 1 $char[$i] = Ekoi8u::octchr($1);
5578 }
5579  
5580 # hexadecimal escape sequence
5581 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5582 1 $char[$i] = Ekoi8u::hexchr($1);
5583 }
5584  
5585 # \N{CHARNAME} --> N{CHARNAME}
5586 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5587 0 $char[$i] = $1;
5588 }
5589  
5590 3151 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 0 3151 3151
elsif ($char[$i] eq '\\u') { } 0 3151 3151
elsif ($char[$i] eq '\\l') { } 0 3151 3151
elsif ($char[$i] eq '\\U') { } 0 3151 3151
elsif ($char[$i] eq '\\L') { } 0 3151 3151
elsif ($char[$i] eq '\\F') { } 0 3151 3151
elsif ($char[$i] eq '\\Q') { } 0 3151 3151
elsif ($char[$i] eq '\\E') { } 0 3151 3151
elsif ($char[$i] eq '\\Q') { } 0 3151 3151
elsif ($char[$i] eq '\\E') { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 3151 3151
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 8 3143 3151
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 8 3135 3143
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 6 3129 3135
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 3129 3129
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 3129 3129
5591 }
5592  
5593 # \u \l \U \L \F \Q \E
5594 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5595 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
5596 0 $char[$i] = '\\' . $char[$i];
5597 }
5598 }
5599 elsif ($char[$i] eq '\u') {
5600 0 $char[$i] = '@{[Ekoi8u::ucfirst qq<';
5601 0 $left_e++;
5602 }
5603 elsif ($char[$i] eq '\l') {
5604 0 $char[$i] = '@{[Ekoi8u::lcfirst qq<';
5605 0 $left_e++;
5606 }
5607 elsif ($char[$i] eq '\U') {
5608 0 $char[$i] = '@{[Ekoi8u::uc qq<';
5609 0 $left_e++;
5610 }
5611 elsif ($char[$i] eq '\L') {
5612 0 $char[$i] = '@{[Ekoi8u::lc qq<';
5613 0 $left_e++;
5614 }
5615 elsif ($char[$i] eq '\F') {
5616 0 $char[$i] = '@{[Ekoi8u::fc qq<';
5617 0 $left_e++;
5618 }
5619 elsif ($char[$i] eq '\Q') {
5620 0 $char[$i] = '@{[CORE::quotemeta qq<';
5621 0 $left_e++;
5622 }
5623 elsif ($char[$i] eq '\E') {
5624 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
5625 0 $char[$i] = '>]}';
5626 0 $right_e++;
5627 }
5628 else {
5629 0 $char[$i] = '';
5630 }
5631 }
5632 elsif ($char[$i] eq '\Q') {
5633 0 while (1) {
5634 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5635 0 last;
5636 }
5637 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5638 0 last;
5639 }
5640 }
5641 }
5642 elsif ($char[$i] eq '\E') {
5643 }
5644  
5645 # $0 --> $0
5646 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5647 }
5648 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5649 }
5650  
5651 # $$ --> $$
5652 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5653 }
5654  
5655 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5656 # $1, $2, $3 --> $1, $2, $3 otherwise
5657 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5658 0 $char[$i] = e_capture($1);
5659 }
5660 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5661 0 $char[$i] = e_capture($1);
5662 }
5663  
5664 # $$foo[ ... ] --> $ $foo->[ ... ]
5665 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5666 0 $char[$i] = e_capture($1.'->'.$2);
5667 }
5668  
5669 # $$foo{ ... } --> $ $foo->{ ... }
5670 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5671 0 $char[$i] = e_capture($1.'->'.$2);
5672 }
5673  
5674 # $$foo
5675 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5676 0 $char[$i] = e_capture($1);
5677 }
5678  
5679 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
5680 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5681 8 $char[$i] = '@{[Ekoi8u::PREMATCH()]}';
5682 }
5683  
5684 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
5685 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5686 8 $char[$i] = '@{[Ekoi8u::MATCH()]}';
5687 }
5688  
5689 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
5690 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5691 6 $char[$i] = '@{[Ekoi8u::POSTMATCH()]}';
5692 }
5693  
5694 # ${ foo } --> ${ foo }
5695 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5696 }
5697  
5698 # ${ ... }
5699 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5700 0 $char[$i] = e_capture($1);
5701 }
5702 }
5703  
5704 # return string
5705 93 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 93 93
5706 0 return join '', @char, '>]}' x ($left_e - $right_e);
5707 }
5708 93 return join '', @char;
5709 }
5710  
5711 #
5712 # escape regexp (m//, qr//)
5713 #
5714 880 ▶sub e_qr {
Subroutine e_qr: called CC=110 SCAR=73.6
Pod undocumented
5715 880 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5716 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
5717  
5718 880 $modifier =~ tr/p//d;
5719 880 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 880 880
5720 0 my $line = 0;
5721 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5722 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5723 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5724 0 last;
5725 }
5726 }
5727 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5728 }
5729  
5730 880 $slash = 'div';
5731  
5732 # literal null string pattern
5733 880 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 872 880
elsif ($modifier =~ tr/Bb//d) { } 2 870 872
5734 8 $modifier =~ tr/bB//d;
5735 8 $modifier =~ tr/i//d;
5736 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5737 }
5738  
5739 # /b /B modifier
5740 elsif ($modifier =~ tr/bB//d) {
5741  
5742 # choice again delimiter
5743 2 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 2 2
5744 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5745 0 my %octet = map {$_ => 1} @char;
5746 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
5747 0 $delimiter = '(';
5748 0 $end_delimiter = ')';
5749 }
5750 elsif (not $octet{'}'}) {
5751 0 $delimiter = '{';
5752 0 $end_delimiter = '}';
5753 }
5754 elsif (not $octet{']'}) {
5755 0 $delimiter = '[';
5756 0 $end_delimiter = ']';
5757 }
5758 elsif (not $octet{'>'}) {
5759 0 $delimiter = '<';
5760 0 $end_delimiter = '>';
5761 }
5762 else {
5763 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5764 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5765 0 $delimiter = $char;
5766 0 $end_delimiter = $char;
5767 0 last;
5768 }
5769 }
5770 }
5771 }
5772  
5773 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
5774 0 return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier;
5775 }
5776 else {
5777 2 return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5778 }
5779 }
5780  
5781 870 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 312 558 870
5782 870 my $metachar = qr/[\@\\|[\]{^]/oxms;
5783  
5784 # split regexp
5785 870 my @char = $string =~ /\G((?>
5786 [^\\\$\@\[\(] |
5787 \\x (?>[0-9A-Fa-f]{1,2}) |
5788 \\ (?>[0-7]{2,3}) |
5789 \\c [\x40-\x5F] |
5790 \\x\{ (?>[0-9A-Fa-f]+) \} |
5791 \\o\{ (?>[0-7]+) \} |
5792 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5793 \\ $q_char |
5794 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5795 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5796 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5797 [\$\@] $qq_variable |
5798 \$ (?>\s* [0-9]+) |
5799 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5800 \$ \$ (?![\w\{]) |
5801 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5802 \[\^ |
5803 \[\: (?>[a-z]+) :\] |
5804 \[\:\^ (?>[a-z]+) :\] |
5805 \(\? |
5806 $q_char
5807 ))/oxmsg;
5808  
5809 # choice again delimiter
5810 870 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 870 870
5811 0 my %octet = map {$_ => 1} @char;
5812 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
5813 0 $delimiter = '(';
5814 0 $end_delimiter = ')';
5815 }
5816 elsif (not $octet{'}'}) {
5817 0 $delimiter = '{';
5818 0 $end_delimiter = '}';
5819 }
5820 elsif (not $octet{']'}) {
5821 0 $delimiter = '[';
5822 0 $end_delimiter = ']';
5823 }
5824 elsif (not $octet{'>'}) {
5825 0 $delimiter = '<';
5826 0 $end_delimiter = '>';
5827 }
5828 else {
5829 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5830 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5831 0 $delimiter = $char;
5832 0 $end_delimiter = $char;
5833 0 last;
5834 }
5835 }
5836 }
5837 }
5838  
5839 870 my $left_e = 0;
5840 870 my $right_e = 0;
5841 870 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2100 870 2970
5842  
5843 # "\L\u" --> "\u\L"
5844 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
5845 0 @char[$i,$i+1] = @char[$i+1,$i];
5846 }
5847  
5848 # "\U\l" --> "\l\U"
5849 ▶ 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
5850 0 @char[$i,$i+1] = @char[$i+1,$i];
5851 }
5852  
5853 # octal escape sequence
5854 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5855 1 $char[$i] = Ekoi8u::octchr($1);
5856 }
5857  
5858 # hexadecimal escape sequence
5859 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5860 1 $char[$i] = Ekoi8u::hexchr($1);
5861 }
5862  
5863 # \b{...} --> b\{...}
5864 # \B{...} --> B\{...}
5865 # \N{CHARNAME} --> N\{CHARNAME}
5866 # \p{PROPERTY} --> p\{PROPERTY}
5867 # \P{PROPERTY} --> P\{PROPERTY}
5868 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5869 6 $char[$i] = $1 . '\\' . $2;
5870 }
5871  
5872 # \p, \P, \X --> p, P, X
5873 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
5874 4 $char[$i] = $1;
5875 }
5876  
5877 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 &Ekoi8u::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
5878 }
5879  
5880 # join separated multiple-octet
5881 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
5882 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5883 0 $char[$i] .= join '', splice @char, $i+1, 3;
5884 }
5885 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5886 0 $char[$i] .= join '', splice @char, $i+1, 2;
5887 }
5888 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5889 0 $char[$i] .= join '', splice @char, $i+1, 1;
5890 }
5891 }
5892  
5893 # open character class [...]
5894 elsif ($char[$i] eq '[') {
5895 556 my $left = $i;
5896  
5897 # [] make die "Unmatched [] in regexp ...\n"
5898 # (and so on)
5899  
5900 556 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 3 553 556
5901 3 $i++;
5902 }
5903  
5904 556 while (1) {
5905 2063 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 2063 2063
5906 0 die __FILE__, ": Unmatched [] in regexp\n";
5907 }
5908 2063 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 556 1507 2063
5909 556 my $right = $i;
5910  
5911 # [...]
5912 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
5913 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5914 }
5915 else {
5916 526 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
5917 }
5918  
5919 556 $i = $left;
5920 556 last;
5921 }
5922 }
5923 }
5924  
5925 # open character class [^...]
5926 elsif ($char[$i] eq '[^') {
5927 74 my $left = $i;
5928  
5929 # [^] make die "Unmatched [] in regexp ...\n"
5930 # (and so on)
5931  
5932 74 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 4 70 74
5933 4 $i++;
5934 }
5935  
5936 74 while (1) {
5937 272 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 272 272
5938 0 die __FILE__, ": Unmatched [] in regexp\n";
5939 }
5940 272 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 74 198 272
5941 74 my $right = $i;
5942  
5943 # [^...]
5944 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
5945 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5946 }
5947 else {
5948 44 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5949 }
5950  
5951 74 $i = $left;
5952 74 last;
5953 }
5954 }
5955 }
5956  
5957 # rewrite character class or escape character
5958 elsif (my $char = character_class($char[$i],$modifier)) {
5959 139 $char[$i] = $char;
5960 }
5961  
5962 # /i modifier
5963 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition100%6/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5964 20 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 20 0 20
5965 20 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
5966 }
5967 else {
5968 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
5969 }
5970 }
5971  
5972 # \u \l \U \L \F \Q \E
5973 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
5974 1 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 1 1
5975 0 $char[$i] = '\\' . $char[$i];
5976 }
5977 }
5978 elsif ($char[$i] eq '\u') {
5979 0 $char[$i] = '@{[Ekoi8u::ucfirst qq<';
5980 0 $left_e++;
5981 }
5982 elsif ($char[$i] eq '\l') {
5983 0 $char[$i] = '@{[Ekoi8u::lcfirst qq<';
5984 0 $left_e++;
5985 }
5986 elsif ($char[$i] eq '\U') {
5987 1 $char[$i] = '@{[Ekoi8u::uc qq<';
5988 1 $left_e++;
5989 }
5990 elsif ($char[$i] eq '\L') {
5991 1 $char[$i] = '@{[Ekoi8u::lc qq<';
5992 1 $left_e++;
5993 }
5994 elsif ($char[$i] eq '\F') {
5995 18 $char[$i] = '@{[Ekoi8u::fc qq<';
5996 18 $left_e++;
5997 }
5998 elsif ($char[$i] eq '\Q') {
5999 1 $char[$i] = '@{[CORE::quotemeta qq<';
6000 1 $left_e++;
6001 }
6002 elsif ($char[$i] eq '\E') {
6003 21 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 21 0 21
6004 21 $char[$i] = '>]}';
6005 21 $right_e++;
6006 }
6007 else {
6008 0 $char[$i] = '';
6009 }
6010 }
6011 elsif ($char[$i] eq '\Q') {
6012 0 while (1) {
6013 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6014 0 last;
6015 }
6016 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6017 0 last;
6018 }
6019 }
6020 }
6021 elsif ($char[$i] eq '\E') {
6022 }
6023  
6024 # $0 --> $0
6025 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6026 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6027 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6028 }
6029 }
6030 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6031 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6032 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6033 }
6034 }
6035  
6036 # $$ --> $$
6037 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6038 }
6039  
6040 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6041 # $1, $2, $3 --> $1, $2, $3 otherwise
6042 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6043 0 $char[$i] = e_capture($1);
6044 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6045 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6046 }
6047 }
6048 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6049 0 $char[$i] = e_capture($1);
6050 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6051 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6052 }
6053 }
6054  
6055 # $$foo[ ... ] --> $ $foo->[ ... ]
6056 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6057 0 $char[$i] = e_capture($1.'->'.$2);
6058 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6059 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6060 }
6061 }
6062  
6063 # $$foo{ ... } --> $ $foo->{ ... }
6064 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6065 0 $char[$i] = e_capture($1.'->'.$2);
6066 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6067 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6068 }
6069 }
6070  
6071 # $$foo
6072 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6073 0 $char[$i] = e_capture($1);
6074 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6075 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6076 }
6077 }
6078  
6079 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
6080 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6081 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
6082 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::PREMATCH())]}';
6083 }
6084 else {
6085 8 $char[$i] = '@{[Ekoi8u::PREMATCH()]}';
6086 }
6087 }
6088  
6089 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
6090 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6091 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
6092 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::MATCH())]}';
6093 }
6094 else {
6095 8 $char[$i] = '@{[Ekoi8u::MATCH()]}';
6096 }
6097 }
6098  
6099 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
6100 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6101 6 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 6 6
6102 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::POSTMATCH())]}';
6103 }
6104 else {
6105 6 $char[$i] = '@{[Ekoi8u::POSTMATCH()]}';
6106 }
6107 }
6108  
6109 # ${ foo }
6110 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6111 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6112 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6113 }
6114 }
6115  
6116 # ${ ... }
6117 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6118 0 $char[$i] = e_capture($1);
6119 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6120 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6121 }
6122 }
6123  
6124 # $scalar or @array
6125 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6126 21 $char[$i] = e_string($char[$i]);
6127 21 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 11 10 21
6128 11 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6129 }
6130 }
6131  
6132 # quote character before ? + * {
6133 ▶ 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
6134 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
6135 }
6136 ▶ 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
6137 0 my $char = $char[$i-1];
6138 0 ▶ if ($char[$i] eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq '{') { } 0 0 0
6139 0 die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n};
6140 }
6141 else {
6142 0 die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n};
6143 }
6144 }
6145 else {
6146 127 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6147 }
6148 }
6149 }
6150  
6151 # make regexp string
6152 870 $modifier =~ tr/i//d;
6153 870 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 870 870
6154 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
6155 0 return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier;
6156 }
6157 else {
6158 0 return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6159 }
6160 }
6161 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
6162 0 return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier;
6163 }
6164 else {
6165 870 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6166 }
6167 }
6168  
6169 #
6170 # double quote stuff
6171 #
6172 180 ▶sub qq_stuff {
Subroutine qq_stuff: called CC=6 SCAR=18.5
Pod undocumented
6173 180 my($delimiter,$end_delimiter,$stuff) = @_;
6174  
6175 # scalar variable or array variable
6176 180 ▶ if ($stuff =~ /\A [\$\@] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff =~ /\A [\$\@] /mosx) 100 80 180
6177 100 return $stuff;
6178 }
6179  
6180 # quote by delimiter
6181 80 my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg);
6182 80 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6183 80 ▶ next if $char eq $delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $delimiter 0 80 80
6184 80 ▶ next if $char eq $end_delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $end_delimiter 0 80 80
6185 80 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 80 0 80
6186 80 return join '', 'qq', $char, $stuff, $char;
6187 }
6188 }
6189 0 return join '', 'qq', '<', $stuff, '>';
6190 }
6191  
6192 #
6193 # escape regexp (m'', qr'', and m''b, qr''b)
6194 #
6195 10 ▶sub e_qr_q {
Subroutine e_qr_q: called CC=7 SCAR=25.3
Pod undocumented
6196 10 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6197 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
6198  
6199 10 $modifier =~ tr/p//d;
6200 10 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 10 10
6201 0 my $line = 0;
6202 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6203 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6204 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6205 0 last;
6206 }
6207 }
6208 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6209 }
6210  
6211 10 $slash = 'div';
6212  
6213 # literal null string pattern
6214 10 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 2 10
elsif ($modifier =~ tr/Bb//d) { } 0 2 2
6215 8 $modifier =~ tr/bB//d;
6216 8 $modifier =~ tr/i//d;
6217 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6218 }
6219  
6220 # with /b /B modifier
6221 elsif ($modifier =~ tr/bB//d) {
6222 0 return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6223 }
6224  
6225 # without /b /B modifier
6226 else {
6227 2 return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6228 }
6229 }
6230  
6231 #
6232 # escape regexp (m'', qr'')
6233 #
6234 2 ▶sub e_qr_qt {
Subroutine e_qr_qt: called CC=20 SCAR=51.8
Pod undocumented
6235 2 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6236  
6237 2 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 2 2
6238  
6239 # split regexp
6240 2 my @char = $string =~ /\G((?>
6241 [^\\\[\$\@\/] |
6242 [\x00-\xFF] |
6243 \[\^ |
6244 \[\: (?>[a-z]+) \:\] |
6245 \[\:\^ (?>[a-z]+) \:\] |
6246 [\$\@\/] |
6247 \\ (?:$q_char) |
6248 (?:$q_char)
6249 ))/oxmsg;
6250  
6251 # unescape character
6252 2 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2 2 4
6253 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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])) { } 0 2 2
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 4 4
6254 }
6255  
6256 # open character class [...]
6257 elsif ($char[$i] eq '[') {
6258 0 my $left = $i;
6259 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6260 0 $i++;
6261 }
6262 0 while (1) {
6263 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6264 0 die __FILE__, ": Unmatched [] in regexp\n";
6265 }
6266 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6267 0 my $right = $i;
6268  
6269 # [...]
6270 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
6271  
6272 0 $i = $left;
6273 0 last;
6274 }
6275 }
6276 }
6277  
6278 # open character class [^...]
6279 elsif ($char[$i] eq '[^') {
6280 0 my $left = $i;
6281 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6282 0 $i++;
6283 }
6284 0 while (1) {
6285 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6286 0 die __FILE__, ": Unmatched [] in regexp\n";
6287 }
6288 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6289 0 my $right = $i;
6290  
6291 # [^...]
6292 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6293  
6294 0 $i = $left;
6295 0 last;
6296 }
6297 }
6298 }
6299  
6300 # escape $ @ / and \
6301 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6302 0 $char[$i] = '\\' . $char[$i];
6303 }
6304  
6305 # rewrite character class or escape character
6306 elsif (my $char = character_class($char[$i],$modifier)) {
6307 0 $char[$i] = $char;
6308 }
6309  
6310 # /i modifier
6311 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6312 0 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6313 0 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
6314 }
6315 else {
6316 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
6317 }
6318 }
6319  
6320 # quote character before ? + * {
6321 ▶ 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
6322 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
6323 }
6324 else {
6325 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6326 }
6327 }
6328 }
6329  
6330 2 $delimiter = '/';
6331 2 $end_delimiter = '/';
6332  
6333 2 $modifier =~ tr/i//d;
6334 2 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6335 }
6336  
6337 #
6338 # escape regexp (m''b, qr''b)
6339 #
6340 0 ▶sub e_qr_qb {
Subroutine e_qr_qb: not called CC=4 SCAR=30.0
Pod undocumented
6341 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6342  
6343 # split regexp
6344 0 my @char = $string =~ /\G ((?>[^\\]|\\\\)) /oxmsg;
6345  
6346 # unescape character
6347 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6348 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
6349 }
6350  
6351 # remain \\
6352 elsif ($char[$i] eq '\\\\') {
6353 }
6354  
6355 # escape $ @ / and \
6356 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6357 0 $char[$i] = '\\' . $char[$i];
6358 }
6359 }
6360  
6361 0 $delimiter = '/';
6362 0 $end_delimiter = '/';
6363 0 return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6364 }
6365  
6366 #
6367 # escape regexp (s/here//)
6368 #
6369 80 ▶sub e_s1 {
Subroutine e_s1: called CC=106 SCAR=81.1
Pod undocumented
6370 80 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6371 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
6372  
6373 80 $modifier =~ tr/p//d;
6374 80 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 80 80
6375 0 my $line = 0;
6376 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6377 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6378 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6379 0 last;
6380 }
6381 }
6382 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6383 }
6384  
6385 80 $slash = 'div';
6386  
6387 # literal null string pattern
6388 80 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 72 80
elsif ($modifier =~ tr/Bb//d) { } 0 72 72
6389 8 $modifier =~ tr/bB//d;
6390 8 $modifier =~ tr/i//d;
6391 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6392 }
6393  
6394 # /b /B modifier
6395 elsif ($modifier =~ tr/bB//d) {
6396  
6397 # choice again delimiter
6398 0 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 0 0
6399 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
6400 0 my %octet = map {$_ => 1} @char;
6401 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
6402 0 $delimiter = '(';
6403 0 $end_delimiter = ')';
6404 }
6405 elsif (not $octet{'}'}) {
6406 0 $delimiter = '{';
6407 0 $end_delimiter = '}';
6408 }
6409 elsif (not $octet{']'}) {
6410 0 $delimiter = '[';
6411 0 $end_delimiter = ']';
6412 }
6413 elsif (not $octet{'>'}) {
6414 0 $delimiter = '<';
6415 0 $end_delimiter = '>';
6416 }
6417 else {
6418 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6419 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
6420 0 $delimiter = $char;
6421 0 $end_delimiter = $char;
6422 0 last;
6423 }
6424 }
6425 }
6426 }
6427  
6428 0 my $prematch = '';
6429 0 return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
6430 }
6431  
6432 72 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 1 71 72
6433 72 my $metachar = qr/[\@\\|[\]{^]/oxms;
6434  
6435 # split regexp
6436 72 my @char = $string =~ /\G((?>
6437 [^\\\$\@\[\(] |
6438 \\ (?>[1-9][0-9]*) |
6439 \\g (?>\s*) (?>[1-9][0-9]*) |
6440 \\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
6441 \\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
6442 \\x (?>[0-9A-Fa-f]{1,2}) |
6443 \\ (?>[0-7]{2,3}) |
6444 \\c [\x40-\x5F] |
6445 \\x\{ (?>[0-9A-Fa-f]+) \} |
6446 \\o\{ (?>[0-7]+) \} |
6447 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
6448 \\ $q_char |
6449 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
6450 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
6451 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
6452 [\$\@] $qq_variable |
6453 \$ (?>\s* [0-9]+) |
6454 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
6455 \$ \$ (?![\w\{]) |
6456 \$ (?>\s*) \$ (?>\s*) $qq_variable |
6457 \[\^ |
6458 \[\: (?>[a-z]+) :\] |
6459 \[\:\^ (?>[a-z]+) :\] |
6460 \(\? |
6461 $q_char
6462 ))/oxmsg;
6463  
6464 # choice again delimiter
6465 72 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 72 72
6466 0 my %octet = map {$_ => 1} @char;
6467 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
6468 0 $delimiter = '(';
6469 0 $end_delimiter = ')';
6470 }
6471 elsif (not $octet{'}'}) {
6472 0 $delimiter = '{';
6473 0 $end_delimiter = '}';
6474 }
6475 elsif (not $octet{']'}) {
6476 0 $delimiter = '[';
6477 0 $end_delimiter = ']';
6478 }
6479 elsif (not $octet{'>'}) {
6480 0 $delimiter = '<';
6481 0 $end_delimiter = '>';
6482 }
6483 else {
6484 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6485 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
6486 0 $delimiter = $char;
6487 0 $end_delimiter = $char;
6488 0 last;
6489 }
6490 }
6491 }
6492 }
6493  
6494 # count '('
6495 72 my $parens = grep { $_ eq '(' } @char;
6496  
6497 72 my $left_e = 0;
6498 72 my $right_e = 0;
6499 72 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 200 72 272
6500  
6501 # "\L\u" --> "\u\L"
6502 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
6503 0 @char[$i,$i+1] = @char[$i+1,$i];
6504 }
6505  
6506 # "\U\l" --> "\l\U"
6507 ▶ 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
6508 0 @char[$i,$i+1] = @char[$i+1,$i];
6509 }
6510  
6511 # octal escape sequence
6512 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6513 1 $char[$i] = Ekoi8u::octchr($1);
6514 }
6515  
6516 # hexadecimal escape sequence
6517 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6518 1 $char[$i] = Ekoi8u::hexchr($1);
6519 }
6520  
6521 # \b{...} --> b\{...}
6522 # \B{...} --> B\{...}
6523 # \N{CHARNAME} --> N\{CHARNAME}
6524 # \p{PROPERTY} --> p\{PROPERTY}
6525 # \P{PROPERTY} --> P\{PROPERTY}
6526 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6527 0 $char[$i] = $1 . '\\' . $2;
6528 }
6529  
6530 # \p, \P, \X --> p, P, X
6531 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6532 0 $char[$i] = $1;
6533 }
6534  
6535 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 &Ekoi8u::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
6536 }
6537  
6538 # join separated multiple-octet
6539 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6540 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6541 0 $char[$i] .= join '', splice @char, $i+1, 3;
6542 }
6543 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6544 0 $char[$i] .= join '', splice @char, $i+1, 2;
6545 }
6546 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6547 0 $char[$i] .= join '', splice @char, $i+1, 1;
6548 }
6549 }
6550  
6551 # open character class [...]
6552 elsif ($char[$i] eq '[') {
6553 17 my $left = $i;
6554 17 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 17 17
6555 0 $i++;
6556 }
6557 17 while (1) {
6558 74 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 74 74
6559 0 die __FILE__, ": Unmatched [] in regexp\n";
6560 }
6561 74 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 17 57 74
6562 17 my $right = $i;
6563  
6564 # [...]
6565 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
6566 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6567 }
6568 else {
6569 17 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
6570 }
6571  
6572 17 $i = $left;
6573 17 last;
6574 }
6575 }
6576 }
6577  
6578 # open character class [^...]
6579 elsif ($char[$i] eq '[^') {
6580 0 my $left = $i;
6581 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6582 0 $i++;
6583 }
6584 0 while (1) {
6585 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6586 0 die __FILE__, ": Unmatched [] in regexp\n";
6587 }
6588 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6589 0 my $right = $i;
6590  
6591 # [^...]
6592 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
6593 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6594 }
6595 else {
6596 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6597 }
6598  
6599 0 $i = $left;
6600 0 last;
6601 }
6602 }
6603 }
6604  
6605 # rewrite character class or escape character
6606 elsif (my $char = character_class($char[$i],$modifier)) {
6607 7 $char[$i] = $char;
6608 }
6609  
6610 # /i modifier
6611 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition66%4/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6612 3 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 3 0 3
6613 3 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
6614 }
6615 else {
6616 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
6617 }
6618 }
6619  
6620 # \u \l \U \L \F \Q \E
6621 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
6622 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6623 0 $char[$i] = '\\' . $char[$i];
6624 }
6625 }
6626 elsif ($char[$i] eq '\u') {
6627 0 $char[$i] = '@{[Ekoi8u::ucfirst qq<';
6628 0 $left_e++;
6629 }
6630 elsif ($char[$i] eq '\l') {
6631 0 $char[$i] = '@{[Ekoi8u::lcfirst qq<';
6632 0 $left_e++;
6633 }
6634 elsif ($char[$i] eq '\U') {
6635 0 $char[$i] = '@{[Ekoi8u::uc qq<';
6636 0 $left_e++;
6637 }
6638 elsif ($char[$i] eq '\L') {
6639 0 $char[$i] = '@{[Ekoi8u::lc qq<';
6640 0 $left_e++;
6641 }
6642 elsif ($char[$i] eq '\F') {
6643 0 $char[$i] = '@{[Ekoi8u::fc qq<';
6644 0 $left_e++;
6645 }
6646 elsif ($char[$i] eq '\Q') {
6647 0 $char[$i] = '@{[CORE::quotemeta qq<';
6648 0 $left_e++;
6649 }
6650 elsif ($char[$i] eq '\E') {
6651 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6652 0 $char[$i] = '>]}';
6653 0 $right_e++;
6654 }
6655 else {
6656 0 $char[$i] = '';
6657 }
6658 }
6659 elsif ($char[$i] eq '\Q') {
6660 0 while (1) {
6661 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6662 0 last;
6663 }
6664 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6665 0 last;
6666 }
6667 }
6668 }
6669 elsif ($char[$i] eq '\E') {
6670 }
6671  
6672 # \0 --> \0
6673 elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) {
6674 }
6675  
6676 # \g{N}, \g{-N}
6677  
6678 # P.108 Using Simple Patterns
6679 # in Chapter 7: In the World of Regular Expressions
6680 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
6681  
6682 # P.221 Capturing
6683 # in Chapter 5: Pattern Matching
6684 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6685  
6686 # \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3}
6687 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6688 }
6689  
6690 # \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable)
6691 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6692 }
6693  
6694 # \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable)
6695 elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6696 }
6697  
6698 # \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable)
6699 elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6700 }
6701  
6702 # $0 --> $0
6703 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6704 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6705 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6706 }
6707 }
6708 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6709 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6710 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6711 }
6712 }
6713  
6714 # $$ --> $$
6715 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6716 }
6717  
6718 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6719 # $1, $2, $3 --> $1, $2, $3 otherwise
6720 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6721 0 $char[$i] = e_capture($1);
6722 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6723 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6724 }
6725 }
6726 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6727 0 $char[$i] = e_capture($1);
6728 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6729 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6730 }
6731 }
6732  
6733 # $$foo[ ... ] --> $ $foo->[ ... ]
6734 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6735 0 $char[$i] = e_capture($1.'->'.$2);
6736 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6737 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6738 }
6739 }
6740  
6741 # $$foo{ ... } --> $ $foo->{ ... }
6742 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6743 0 $char[$i] = e_capture($1.'->'.$2);
6744 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6745 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6746 }
6747 }
6748  
6749 # $$foo
6750 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6751 0 $char[$i] = e_capture($1);
6752 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6753 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6754 }
6755 }
6756  
6757 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
6758 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6759 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6760 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::PREMATCH())]}';
6761 }
6762 else {
6763 4 $char[$i] = '@{[Ekoi8u::PREMATCH()]}';
6764 }
6765 }
6766  
6767 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
6768 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6769 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6770 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::MATCH())]}';
6771 }
6772 else {
6773 4 $char[$i] = '@{[Ekoi8u::MATCH()]}';
6774 }
6775 }
6776  
6777 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
6778 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6779 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 3 3
6780 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::POSTMATCH())]}';
6781 }
6782 else {
6783 3 $char[$i] = '@{[Ekoi8u::POSTMATCH()]}';
6784 }
6785 }
6786  
6787 # ${ foo }
6788 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6789 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6790 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6791 }
6792 }
6793  
6794 # ${ ... }
6795 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6796 0 $char[$i] = e_capture($1);
6797 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6798 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6799 }
6800 }
6801  
6802 # $scalar or @array
6803 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6804 4 $char[$i] = e_string($char[$i]);
6805 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 4 4
6806 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
6807 }
6808 }
6809  
6810 # quote character before ? + * {
6811 ▶ 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
6812 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
6813 }
6814 else {
6815 14 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6816 }
6817 }
6818 }
6819  
6820 # make regexp string
6821 72 my $prematch = '';
6822 72 $modifier =~ tr/i//d;
6823 72 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 72 72
6824 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6825 }
6826 72 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6827 }
6828  
6829 #
6830 # escape regexp (s'here'' or s'here''b)
6831 #
6832 21 ▶sub e_s1_q {
Subroutine e_s1_q: called CC=7 SCAR=24.3
Pod undocumented
6833 21 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6834 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
6835  
6836 21 $modifier =~ tr/p//d;
6837 21 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 21 21
6838 0 my $line = 0;
6839 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6840 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6841 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6842 0 last;
6843 }
6844 }
6845 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6846 }
6847  
6848 21 $slash = 'div';
6849  
6850 # literal null string pattern
6851 21 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 13 21
elsif ($modifier =~ tr/Bb//d) { } 0 13 13
6852 8 $modifier =~ tr/bB//d;
6853 8 $modifier =~ tr/i//d;
6854 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6855 }
6856  
6857 # with /b /B modifier
6858 elsif ($modifier =~ tr/bB//d) {
6859 0 return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6860 }
6861  
6862 # without /b /B modifier
6863 else {
6864 13 return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6865 }
6866 }
6867  
6868 #
6869 # escape regexp (s'here'')
6870 #
6871 13 ▶sub e_s1_qt {
Subroutine e_s1_qt: called CC=20 SCAR=50.1
Pod undocumented
6872 13 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6873  
6874 13 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 13 13
6875  
6876 # split regexp
6877 13 my @char = $string =~ /\G((?>
6878 [^\\\[\$\@\/] |
6879 [\x00-\xFF] |
6880 \[\^ |
6881 \[\: (?>[a-z]+) \:\] |
6882 \[\:\^ (?>[a-z]+) \:\] |
6883 [\$\@\/] |
6884 \\ (?:$q_char) |
6885 (?:$q_char)
6886 ))/oxmsg;
6887  
6888 # unescape character
6889 13 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 25 13 38
6890 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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])) { } 0 19 19
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 32 32
6891 }
6892  
6893 # open character class [...]
6894 elsif ($char[$i] eq '[') {
6895 0 my $left = $i;
6896 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6897 0 $i++;
6898 }
6899 0 while (1) {
6900 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6901 0 die __FILE__, ": Unmatched [] in regexp\n";
6902 }
6903 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6904 0 my $right = $i;
6905  
6906 # [...]
6907 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
6908  
6909 0 $i = $left;
6910 0 last;
6911 }
6912 }
6913 }
6914  
6915 # open character class [^...]
6916 elsif ($char[$i] eq '[^') {
6917 0 my $left = $i;
6918 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6919 0 $i++;
6920 }
6921 0 while (1) {
6922 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6923 0 die __FILE__, ": Unmatched [] in regexp\n";
6924 }
6925 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6926 0 my $right = $i;
6927  
6928 # [^...]
6929 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6930  
6931 0 $i = $left;
6932 0 last;
6933 }
6934 }
6935 }
6936  
6937 # escape $ @ / and \
6938 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6939 0 $char[$i] = '\\' . $char[$i];
6940 }
6941  
6942 # rewrite character class or escape character
6943 elsif (my $char = character_class($char[$i],$modifier)) {
6944 6 $char[$i] = $char;
6945 }
6946  
6947 # /i modifier
6948 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6949 0 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6950 0 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
6951 }
6952 else {
6953 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
6954 }
6955 }
6956  
6957 # quote character before ? + * {
6958 ▶ 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
6959 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
6960 }
6961 else {
6962 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6963 }
6964 }
6965 }
6966  
6967 13 $modifier =~ tr/i//d;
6968 13 $delimiter = '/';
6969 13 $end_delimiter = '/';
6970 13 my $prematch = '';
6971 13 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6972 }
6973  
6974 #
6975 # escape regexp (s'here''b)
6976 #
6977 0 ▶sub e_s1_qb {
Subroutine e_s1_qb: not called CC=4 SCAR=30.0
Pod undocumented
6978 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6979  
6980 # split regexp
6981 0 my @char = $string =~ /\G (?>[^\\]|\\\\) /oxmsg;
6982  
6983 # unescape character
6984 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6985 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
6986 }
6987  
6988 # remain \\
6989 elsif ($char[$i] eq '\\\\') {
6990 }
6991  
6992 # escape $ @ / and \
6993 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6994 0 $char[$i] = '\\' . $char[$i];
6995 }
6996 }
6997  
6998 0 $delimiter = '/';
6999 0 $end_delimiter = '/';
7000 0 my $prematch = '';
7001 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
7002 }
7003  
7004 #
7005 # escape regexp (s''here')
7006 #
7007 16 ▶sub e_s2_q {
Subroutine e_s2_q: called CC=4 SCAR=13.9
Pod undocumented
7008 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
7009  
7010 16 $slash = 'div';
7011  
7012 16 my @char = $string =~ / \G (?>[^\\]|\\\\|$q_char) /oxmsg;
7013 16 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 9 16 25
7014 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
7015 }
7016  
7017 # not escape \\
7018 elsif ($char[$i] =~ /\A \\\\ \z/oxms) {
7019 }
7020  
7021 # escape $ @ / and \
7022 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
7023 5 $char[$i] = '\\' . $char[$i];
7024 }
7025 }
7026  
7027 16 return join '', $ope, $delimiter, @char, $end_delimiter;
7028 }
7029  
7030 #
7031 # escape regexp (s/here/and here/modifier)
7032 #
7033 101 ▶sub e_sub {
Subroutine e_sub: called CC=20 SCAR=32.6
Pod undocumented
7034 101 my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_;
7035 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
7036  
7037 101 $modifier =~ tr/p//d;
7038 101 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 101 101
7039 0 my $line = 0;
7040 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7041 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7042 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7043 0 last;
7044 }
7045 }
7046 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7047 }
7048  
7049 101 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq "") 36 65 101
7050 36 $variable = '$_';
7051 36 $bind_operator = ' =~ ';
7052 }
7053  
7054 101 $slash = 'div';
7055  
7056 # P.128 Start of match (or end of previous match): \G
7057 # P.130 Advanced Use of \G with Perl
7058 # in Chapter 3: Overview of Regular Expression Features and Flavors
7059 # P.312 Iterative Matching: Scalar Context, with /g
7060 # in Chapter 7: Perl
7061 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
7062  
7063 # P.181 Where You Left Off: The \G Assertion
7064 # in Chapter 5: Pattern Matching
7065 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
7066  
7067 # P.220 Where You Left Off: The \G Assertion
7068 # in Chapter 5: Pattern Matching
7069 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
7070  
7071 101 my $e_modifier = $modifier =~ tr/e//d;
7072 101 my $r_modifier = $modifier =~ tr/r//d;
7073  
7074 101 my $my = '';
7075 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
7076 0 $my = $variable;
7077 0 $variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms;
7078 0 $variable =~ s/ = .+ \z//oxms;
7079 }
7080  
7081 101 (my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms;
7082 101 $variable_basename =~ s/ \s+ \z//oxms;
7083  
7084 # quote replacement string
7085 101 my $e_replacement = '';
7086 101 ▶ if ($e_modifier >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e_modifier >= 1) { } 17 84 101
7087 17 $e_replacement = e_qq('', '', '', $replacement);
7088 17 $e_modifier--;
7089 }
7090 else {
7091 84 ▶ if ($delimiter2 eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter2 eq q[']) { } 16 68 84
7092 16 $e_replacement = e_s2_q('qq', '/', '/', $replacement);
7093 }
7094 else {
7095 68 $e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement);
7096 }
7097 }
7098  
7099 101 my $sub = '';
7100  
7101 # with /r
7102 101 ▶ if ($r_modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r_modifier) { } 10 91 101
7103 10 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 5 5 10
7104 }
7105  
7106 # s///gr without multibyte anchoring
7107 elsif ($modifier =~ /g/oxms) {
7108 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
7109 # 1 2 3 4 5
7110 q<CORE::eval{local $Ekoi8u::re_t=%s; while($Ekoi8u::re_t =~ %s){%s local $^W=0; local $Ekoi8u::re_r=%s; %s$Ekoi8u::re_t="$`$Ekoi8u::re_r$'"; pos($Ekoi8u::re_t)=length "$`$Ekoi8u::re_r"; } return $Ekoi8u::re_t}>,
7111  
7112 $variable, # 1
7113 ($delimiter1 eq "'") ? # 2
7114 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7115 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7116 $s_matched, # 3
7117 $e_replacement, # 4
7118 '$Ekoi8u::re_r=CORE::eval $Ekoi8u::re_r; ' x $e_modifier, # 5
7119 );
7120 }
7121  
7122 # s///r
7123 else {
7124  
7125 5 my $prematch = q{$`};
7126  
7127 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
7128 # 1 2 3 4 5 6 7
7129 q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Ekoi8u::re_r=%s; %s"%s$Ekoi8u::re_r$'" } : %s>,
7130  
7131 $variable, # 1
7132 ($delimiter1 eq "'") ? # 2
7133 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7134 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7135 $s_matched, # 3
7136 $e_replacement, # 4
7137 '$Ekoi8u::re_r=CORE::eval $Ekoi8u::re_r; ' x $e_modifier, # 5
7138 $prematch, # 6
7139 $variable, # 7
7140 );
7141 }
7142  
7143 # $var !~ s///r doesn't make sense
7144 10 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 10 10
7145 0 $sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub;
7146 }
7147 }
7148  
7149 # without /r
7150 else {
7151 91 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 23 68 91
7152 }
7153  
7154 # s///g without multibyte anchoring
7155 elsif ($modifier =~ /g/oxms) {
7156 23 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 3 20 23
$bind_operator =~ / !~ /mosx ? : 3 20 23
7157 # 1 2 3 4 5 6 7 8
7158 q<CORE::eval{local $Ekoi8u::re_n=0; while(%s =~ %s){%s local $^W=0; local $Ekoi8u::re_r=%s; %s%s="$`$Ekoi8u::re_r$'"; pos(%s)=length "$`$Ekoi8u::re_r"; $Ekoi8u::re_n++} return %s$Ekoi8u::re_n}>,
7159  
7160 $variable, # 1
7161 ($delimiter1 eq "'") ? # 2
7162 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7163 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7164 $s_matched, # 3
7165 $e_replacement, # 4
7166 '$Ekoi8u::re_r=CORE::eval $Ekoi8u::re_r; ' x $e_modifier, # 5
7167 $variable, # 6
7168 $variable, # 7
7169 ($bind_operator =~ / !~ /oxms) ? '!' : '', # 8
7170 );
7171 }
7172  
7173 # s///
7174 else {
7175  
7176 68 my $prematch = q{$`};
7177  
7178 68 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$bind_operator =~ / =~ /mosx ? : 65 3 68
$delimiter1 eq q['] ? : 18 50 68
7179  
7180 ($bind_operator =~ / =~ /oxms) ?
7181  
7182 # 1 2 3 4 5 6 7 8
7183 q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Ekoi8u::re_r=%s; %s%s="%s$Ekoi8u::re_r$'"; 1 } : undef> :
7184  
7185 # 1 2 3 4 5 6 7 8
7186 q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Ekoi8u::re_r=%s; %s%s="%s$Ekoi8u::re_r$'"; undef }>,
7187  
7188 $variable, # 1
7189 $bind_operator, # 2
7190 ($delimiter1 eq "'") ? # 3
7191 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7192 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7193 $s_matched, # 4
7194 $e_replacement, # 5
7195 '$Ekoi8u::re_r=CORE::eval $Ekoi8u::re_r; ' x $e_modifier, # 6
7196 $variable, # 7
7197 $prematch, # 8
7198 );
7199 }
7200 }
7201  
7202 # (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1]
7203 101 ▶ if ($my ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($my ne "") 0 101 101
7204 0 $sub = "($my, $sub)[1]";
7205 }
7206  
7207 # clear s/// variable
7208 101 $sub_variable = '';
7209 101 $bind_operator = '';
7210  
7211 101 return $sub;
7212 }
7213  
7214 #
7215 # escape regexp of split qr//
7216 #
7217 74 ▶sub e_split {
Subroutine e_split: called CC=88 SCAR=76.4
Pod undocumented
7218 74 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7219 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
7220  
7221 74 $modifier =~ tr/p//d;
7222 74 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 74 74
7223 0 my $line = 0;
7224 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7225 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7226 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7227 0 last;
7228 }
7229 }
7230 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7231 }
7232  
7233 74 $slash = 'div';
7234  
7235 # /b /B modifier
7236 74 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 74 74
7237 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7238 }
7239  
7240 74 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 74 74
7241 74 my $metachar = qr/[\@\\|[\]{^]/oxms;
7242  
7243 # split regexp
7244 74 my @char = $string =~ /\G((?>
7245 [^\\\$\@\[\(] |
7246 \\x (?>[0-9A-Fa-f]{1,2}) |
7247 \\ (?>[0-7]{2,3}) |
7248 \\c [\x40-\x5F] |
7249 \\x\{ (?>[0-9A-Fa-f]+) \} |
7250 \\o\{ (?>[0-7]+) \} |
7251 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
7252 \\ $q_char |
7253 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
7254 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
7255 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
7256 [\$\@] $qq_variable |
7257 \$ (?>\s* [0-9]+) |
7258 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
7259 \$ \$ (?![\w\{]) |
7260 \$ (?>\s*) \$ (?>\s*) $qq_variable |
7261 \[\^ |
7262 \[\: (?>[a-z]+) :\] |
7263 \[\:\^ (?>[a-z]+) :\] |
7264 \(\? |
7265 $q_char
7266 ))/oxmsg;
7267  
7268 74 my $left_e = 0;
7269 74 my $right_e = 0;
7270 74 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 249 74 323
7271  
7272 # "\L\u" --> "\u\L"
7273 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
7274 0 @char[$i,$i+1] = @char[$i+1,$i];
7275 }
7276  
7277 # "\U\l" --> "\l\U"
7278 ▶ 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
7279 0 @char[$i,$i+1] = @char[$i+1,$i];
7280 }
7281  
7282 # octal escape sequence
7283 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
7284 1 $char[$i] = Ekoi8u::octchr($1);
7285 }
7286  
7287 # hexadecimal escape sequence
7288 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
7289 1 $char[$i] = Ekoi8u::hexchr($1);
7290 }
7291  
7292 # \b{...} --> b\{...}
7293 # \B{...} --> B\{...}
7294 # \N{CHARNAME} --> N\{CHARNAME}
7295 # \p{PROPERTY} --> p\{PROPERTY}
7296 # \P{PROPERTY} --> P\{PROPERTY}
7297 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
7298 0 $char[$i] = $1 . '\\' . $2;
7299 }
7300  
7301 # \p, \P, \X --> p, P, X
7302 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
7303 0 $char[$i] = $1;
7304 }
7305  
7306 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 &Ekoi8u::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
7307 }
7308  
7309 # join separated multiple-octet
7310 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
7311 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7312 0 $char[$i] .= join '', splice @char, $i+1, 3;
7313 }
7314 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7315 0 $char[$i] .= join '', splice @char, $i+1, 2;
7316 }
7317 ▶ 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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::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 $Ekoi8u::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7318 0 $char[$i] .= join '', splice @char, $i+1, 1;
7319 }
7320 }
7321  
7322 # open character class [...]
7323 elsif ($char[$i] eq '[') {
7324 3 my $left = $i;
7325 3 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 3 3
7326 0 $i++;
7327 }
7328 3 while (1) {
7329 7 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 7 7
7330 0 die __FILE__, ": Unmatched [] in regexp\n";
7331 }
7332 7 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 3 4 7
7333 3 my $right = $i;
7334  
7335 # [...]
7336 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
7337 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
7338 }
7339 else {
7340 3 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
7341 }
7342  
7343 3 $i = $left;
7344 3 last;
7345 }
7346 }
7347 }
7348  
7349 # open character class [^...]
7350 elsif ($char[$i] eq '[^') {
7351 0 my $left = $i;
7352 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7353 0 $i++;
7354 }
7355 0 while (1) {
7356 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7357 0 die __FILE__, ": Unmatched [] in regexp\n";
7358 }
7359 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7360 0 my $right = $i;
7361  
7362 # [^...]
7363 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
7364 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8u::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
7365 }
7366 else {
7367 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7368 }
7369  
7370 0 $i = $left;
7371 0 last;
7372 }
7373 }
7374 }
7375  
7376 # rewrite character class or escape character
7377 elsif (my $char = character_class($char[$i],$modifier)) {
7378 1 $char[$i] = $char;
7379 }
7380  
7381 # P.794 29.2.161. split
7382 # in Chapter 29: Functions
7383 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
7384  
7385 # P.951 split
7386 # in Chapter 27: Functions
7387 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
7388  
7389 # said "The //m modifier is assumed when you split on the pattern /^/",
7390 # but perl5.008 is not so. Therefore, this software adds //m.
7391 # (and so on)
7392  
7393 # split(m/^/) --> split(m/^/m)
7394 ▶ 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
7395 7 $modifier .= 'm';
7396 }
7397  
7398 # /i modifier
7399 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7400 0 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7401 0 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
7402 }
7403 else {
7404 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
7405 }
7406 }
7407  
7408 # \u \l \U \L \F \Q \E
7409 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
7410 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
7411 0 $char[$i] = '\\' . $char[$i];
7412 }
7413 }
7414 elsif ($char[$i] eq '\u') {
7415 0 $char[$i] = '@{[Ekoi8u::ucfirst qq<';
7416 0 $left_e++;
7417 }
7418 elsif ($char[$i] eq '\l') {
7419 0 $char[$i] = '@{[Ekoi8u::lcfirst qq<';
7420 0 $left_e++;
7421 }
7422 elsif ($char[$i] eq '\U') {
7423 0 $char[$i] = '@{[Ekoi8u::uc qq<';
7424 0 $left_e++;
7425 }
7426 elsif ($char[$i] eq '\L') {
7427 0 $char[$i] = '@{[Ekoi8u::lc qq<';
7428 0 $left_e++;
7429 }
7430 elsif ($char[$i] eq '\F') {
7431 0 $char[$i] = '@{[Ekoi8u::fc qq<';
7432 0 $left_e++;
7433 }
7434 elsif ($char[$i] eq '\Q') {
7435 0 $char[$i] = '@{[CORE::quotemeta qq<';
7436 0 $left_e++;
7437 }
7438 elsif ($char[$i] eq '\E') {
7439 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
7440 0 $char[$i] = '>]}';
7441 0 $right_e++;
7442 }
7443 else {
7444 0 $char[$i] = '';
7445 }
7446 }
7447 elsif ($char[$i] eq '\Q') {
7448 0 while (1) {
7449 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7450 0 last;
7451 }
7452 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
7453 0 last;
7454 }
7455 }
7456 }
7457 elsif ($char[$i] eq '\E') {
7458 }
7459  
7460 # $0 --> $0
7461 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
7462 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7463 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7464 }
7465 }
7466 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
7467 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7468 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7469 }
7470 }
7471  
7472 # $$ --> $$
7473 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
7474 }
7475  
7476 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
7477 # $1, $2, $3 --> $1, $2, $3 otherwise
7478 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
7479 0 $char[$i] = e_capture($1);
7480 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7481 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7482 }
7483 }
7484 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
7485 0 $char[$i] = e_capture($1);
7486 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7487 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7488 }
7489 }
7490  
7491 # $$foo[ ... ] --> $ $foo->[ ... ]
7492 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
7493 0 $char[$i] = e_capture($1.'->'.$2);
7494 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7495 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7496 }
7497 }
7498  
7499 # $$foo{ ... } --> $ $foo->{ ... }
7500 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
7501 0 $char[$i] = e_capture($1.'->'.$2);
7502 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7503 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7504 }
7505 }
7506  
7507 # $$foo
7508 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
7509 0 $char[$i] = e_capture($1);
7510 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7511 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7512 }
7513 }
7514  
7515 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8u::PREMATCH()
7516 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
7517 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7518 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::PREMATCH())]}';
7519 }
7520 else {
7521 12 $char[$i] = '@{[Ekoi8u::PREMATCH()]}';
7522 }
7523 }
7524  
7525 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8u::MATCH()
7526 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
7527 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7528 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::MATCH())]}';
7529 }
7530 else {
7531 12 $char[$i] = '@{[Ekoi8u::MATCH()]}';
7532 }
7533 }
7534  
7535 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8u::POSTMATCH()
7536 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
7537 9 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 9 9
7538 0 $char[$i] = '@{[Ekoi8u::ignorecase(Ekoi8u::POSTMATCH())]}';
7539 }
7540 else {
7541 9 $char[$i] = '@{[Ekoi8u::POSTMATCH()]}';
7542 }
7543 }
7544  
7545 # ${ foo }
7546 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
7547 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7548 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $1 . ')]}';
7549 }
7550 }
7551  
7552 # ${ ... }
7553 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
7554 0 $char[$i] = e_capture($1);
7555 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7556 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7557 }
7558 }
7559  
7560 # $scalar or @array
7561 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
7562 3 $char[$i] = e_string($char[$i]);
7563 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 3 3
7564 0 $char[$i] = '@{[Ekoi8u::ignorecase(' . $char[$i] . ')]}';
7565 }
7566 }
7567  
7568 # quote character before ? + * {
7569 ▶ 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
7570 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
7571 }
7572 else {
7573 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7574 }
7575 }
7576 }
7577  
7578 # make regexp string
7579 74 $modifier =~ tr/i//d;
7580 74 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 74 74
7581 0 return join '', 'Ekoi8u::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier;
7582 }
7583 74 return join '', 'Ekoi8u::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7584 }
7585  
7586 #
7587 # escape regexp of split qr''
7588 #
7589 0 ▶sub e_split_q {
Subroutine e_split_q: not called CC=26 SCAR=65.5
Pod undocumented
7590 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7591 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
7592  
7593 0 $modifier =~ tr/p//d;
7594 0 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 0 0
7595 0 my $line = 0;
7596 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7597 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7598 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7599 0 last;
7600 }
7601 }
7602 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7603 }
7604  
7605 0 $slash = 'div';
7606  
7607 # /b /B modifier
7608 0 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 0 0
7609 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7610 }
7611  
7612 0 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 0 0
7613  
7614 # split regexp
7615 0 my @char = $string =~ /\G((?>
7616 [^\\\[] |
7617 [\x00-\xFF] |
7618 \[\^ |
7619 \[\: (?>[a-z]+) \:\] |
7620 \[\:\^ (?>[a-z]+) \:\] |
7621 \\ (?:$q_char) |
7622 (?:$q_char)
7623 ))/oxmsg;
7624  
7625 # unescape character
7626 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
7627 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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])) { } 0 0 0
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 0 0
7628 }
7629  
7630 # open character class [...]
7631 elsif ($char[$i] eq '[') {
7632 0 my $left = $i;
7633 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7634 0 $i++;
7635 }
7636 0 while (1) {
7637 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7638 0 die __FILE__, ": Unmatched [] in regexp\n";
7639 }
7640 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7641 0 my $right = $i;
7642  
7643 # [...]
7644 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_qr(@char[$left+1..$right-1], $modifier);
7645  
7646 0 $i = $left;
7647 0 last;
7648 }
7649 }
7650 }
7651  
7652 # open character class [^...]
7653 elsif ($char[$i] eq '[^') {
7654 0 my $left = $i;
7655 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7656 0 $i++;
7657 }
7658 0 while (1) {
7659 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7660 0 die __FILE__, ": Unmatched [] in regexp\n";
7661 }
7662 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7663 0 my $right = $i;
7664  
7665 # [^...]
7666 0 splice @char, $left, $right-$left+1, Ekoi8u::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7667  
7668 0 $i = $left;
7669 0 last;
7670 }
7671 }
7672 }
7673  
7674 # rewrite character class or escape character
7675 elsif (my $char = character_class($char[$i],$modifier)) {
7676 0 $char[$i] = $char;
7677 }
7678  
7679 # split(m/^/) --> split(m/^/m)
7680 ▶ 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
7681 0 $modifier .= 'm';
7682 }
7683  
7684 # /i modifier
7685 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8u::uc($char[$i]) ne Ekoi8u::fc($char[$i]))) {
Condition0%0/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8u::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 &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8u::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= &Ekoi8u::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7686 0 ▶ if (CORE::length(Ekoi8u::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7687 0 $char[$i] = '[' . Ekoi8u::uc($char[$i]) . Ekoi8u::fc($char[$i]) . ']';
7688 }
7689 else {
7690 0 $char[$i] = '(?:' . Ekoi8u::uc($char[$i]) . '|' . Ekoi8u::fc($char[$i]) . ')';
7691 }
7692 }
7693  
7694 # quote character before ? + * {
7695 ▶ 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
7696 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
7697 }
7698 else {
7699 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7700 }
7701 }
7702 }
7703  
7704 0 $modifier =~ tr/i//d;
7705 0 return join '', 'Ekoi8u::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7706 }
7707  
7708 #
7709 # instead of Carp::carp
7710 #
7711 0 ▶sub carp {
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
7712 0 my($package,$filename,$line) = caller(1);
7713 0 print STDERR "@_ at $filename line $line.\n";
7714 }
7715  
7716 #
7717 # instead of Carp::croak
7718 #
7719 0 ▶sub croak {
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
7720 0 my($package,$filename,$line) = caller(1);
7721 0 print STDERR "@_ at $filename line $line.\n";
7722 0 die "\n";
7723 }
7724  
7725 #
7726 # instead of Carp::cluck
7727 #
7728 0 ▶sub cluck {
Subroutine cluck: not called CC=2 SCAR=17.9
Pod undocumented
7729 0 my $i = 0;
7730 0 my @cluck = ();
7731 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7732 0 push @cluck, "[$i] $filename($line) $package::$subroutine\n";
7733 0 $i++;
7734 }
7735 0 print STDERR CORE::reverse @cluck;
7736 0 print STDERR "\n";
7737 0 print STDERR @_;
7738 }
7739  
7740 #
7741 # instead of Carp::confess
7742 #
7743 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
7744 0 my $i = 0;
7745 0 my @confess = ();
7746 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7747 0 push @confess, "[$i] $filename($line) $package::$subroutine\n";
7748 0 $i++;
7749 }
7750 0 print STDERR CORE::reverse @confess;
7751 0 print STDERR "\n";
7752 0 print STDERR @_;
7753 0 die "\n";
7754 }
7755  
7756 422 1;
7757  
7758 __END__
↑ Summary blib/lib/KOI8U.pm »