blib/lib/Ekoi8r.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/KOI8R.pm »
1 package Ekoi8r;
2 422 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 ######################################################################
4 #
5 # Ekoi8r - Run-time routines for KOI8R.pm
6 #
7 # http://search.cpan.org/dist/Char-KOI8R/
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 (&Ekoi8r::index($name, '::') >= 0) { } 0 15 15
elsif (&Ekoi8r::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 (Ekoi8r::index($name,'::') >= 0) {
83 0 return $name;
84 }
85 elsif (Ekoi8r::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-R character range per length
158 #
159 422 my %range_tr = ();
160  
161 #
162 # KOI8-R 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 Ekoi8r \z/mosx }) { } 422 0 422
175 }
176  
177 elsif (__PACKAGE__ =~ / \b Ekoi8r \z/oxms) {
178 422 %range_tr = (
179 1 => [ [0x00..0xFF],
180 ],
181 );
182  
183 422 %lc = (%lc,
184 "\xB3" => "\xA3", # CYRILLIC LETTER IO
185 "\xE0" => "\xC0", # CYRILLIC LETTER IU
186 "\xE1" => "\xC1", # CYRILLIC LETTER A
187 "\xE2" => "\xC2", # CYRILLIC LETTER BE
188 "\xE3" => "\xC3", # CYRILLIC LETTER TSE
189 "\xE4" => "\xC4", # CYRILLIC LETTER DE
190 "\xE5" => "\xC5", # CYRILLIC LETTER IE
191 "\xE6" => "\xC6", # CYRILLIC LETTER EF
192 "\xE7" => "\xC7", # CYRILLIC LETTER GE
193 "\xE8" => "\xC8", # CYRILLIC LETTER KHA
194 "\xE9" => "\xC9", # CYRILLIC LETTER II
195 "\xEA" => "\xCA", # CYRILLIC LETTER SHORT II
196 "\xEB" => "\xCB", # CYRILLIC LETTER KA
197 "\xEC" => "\xCC", # CYRILLIC LETTER EL
198 "\xED" => "\xCD", # CYRILLIC LETTER EM
199 "\xEE" => "\xCE", # CYRILLIC LETTER EN
200 "\xEF" => "\xCF", # CYRILLIC LETTER O
201 "\xF0" => "\xD0", # CYRILLIC LETTER PE
202 "\xF1" => "\xD1", # CYRILLIC LETTER IA
203 "\xF2" => "\xD2", # CYRILLIC LETTER ER
204 "\xF3" => "\xD3", # CYRILLIC LETTER ES
205 "\xF4" => "\xD4", # CYRILLIC LETTER TE
206 "\xF5" => "\xD5", # CYRILLIC LETTER U
207 "\xF6" => "\xD6", # CYRILLIC LETTER ZHE
208 "\xF7" => "\xD7", # CYRILLIC LETTER VE
209 "\xF8" => "\xD8", # CYRILLIC LETTER SOFT SIGN
210 "\xF9" => "\xD9", # CYRILLIC LETTER YERI
211 "\xFA" => "\xDA", # CYRILLIC LETTER ZE
212 "\xFB" => "\xDB", # CYRILLIC LETTER SHA
213 "\xFC" => "\xDC", # CYRILLIC LETTER REVERSED E
214 "\xFD" => "\xDD", # CYRILLIC LETTER SHCHA
215 "\xFE" => "\xDE", # CYRILLIC LETTER CHE
216 "\xFF" => "\xDF", # CYRILLIC LETTER HARD SIGN
217 );
218  
219 422 %uc = (%uc,
220 "\xA3" => "\xB3", # CYRILLIC LETTER IO
221 "\xC0" => "\xE0", # CYRILLIC LETTER IU
222 "\xC1" => "\xE1", # CYRILLIC LETTER A
223 "\xC2" => "\xE2", # CYRILLIC LETTER BE
224 "\xC3" => "\xE3", # CYRILLIC LETTER TSE
225 "\xC4" => "\xE4", # CYRILLIC LETTER DE
226 "\xC5" => "\xE5", # CYRILLIC LETTER IE
227 "\xC6" => "\xE6", # CYRILLIC LETTER EF
228 "\xC7" => "\xE7", # CYRILLIC LETTER GE
229 "\xC8" => "\xE8", # CYRILLIC LETTER KHA
230 "\xC9" => "\xE9", # CYRILLIC LETTER II
231 "\xCA" => "\xEA", # CYRILLIC LETTER SHORT II
232 "\xCB" => "\xEB", # CYRILLIC LETTER KA
233 "\xCC" => "\xEC", # CYRILLIC LETTER EL
234 "\xCD" => "\xED", # CYRILLIC LETTER EM
235 "\xCE" => "\xEE", # CYRILLIC LETTER EN
236 "\xCF" => "\xEF", # CYRILLIC LETTER O
237 "\xD0" => "\xF0", # CYRILLIC LETTER PE
238 "\xD1" => "\xF1", # CYRILLIC LETTER IA
239 "\xD2" => "\xF2", # CYRILLIC LETTER ER
240 "\xD3" => "\xF3", # CYRILLIC LETTER ES
241 "\xD4" => "\xF4", # CYRILLIC LETTER TE
242 "\xD5" => "\xF5", # CYRILLIC LETTER U
243 "\xD6" => "\xF6", # CYRILLIC LETTER ZHE
244 "\xD7" => "\xF7", # CYRILLIC LETTER VE
245 "\xD8" => "\xF8", # CYRILLIC LETTER SOFT SIGN
246 "\xD9" => "\xF9", # CYRILLIC LETTER YERI
247 "\xDA" => "\xFA", # CYRILLIC LETTER ZE
248 "\xDB" => "\xFB", # CYRILLIC LETTER SHA
249 "\xDC" => "\xFC", # CYRILLIC LETTER REVERSED E
250 "\xDD" => "\xFD", # CYRILLIC LETTER SHCHA
251 "\xDE" => "\xFE", # CYRILLIC LETTER CHE
252 "\xDF" => "\xFF", # CYRILLIC LETTER HARD SIGN
253 );
254  
255 422 %fc = (%fc,
256 "\xB3" => "\xA3", # CYRILLIC CAPITAL LETTER IO --> CYRILLIC SMALL LETTER IO
257 "\xE0" => "\xC0", # CYRILLIC CAPITAL LETTER YU --> CYRILLIC SMALL LETTER YU
258 "\xE1" => "\xC1", # CYRILLIC CAPITAL LETTER A --> CYRILLIC SMALL LETTER A
259 "\xE2" => "\xC2", # CYRILLIC CAPITAL LETTER BE --> CYRILLIC SMALL LETTER BE
260 "\xE3" => "\xC3", # CYRILLIC CAPITAL LETTER TSE --> CYRILLIC SMALL LETTER TSE
261 "\xE4" => "\xC4", # CYRILLIC CAPITAL LETTER DE --> CYRILLIC SMALL LETTER DE
262 "\xE5" => "\xC5", # CYRILLIC CAPITAL LETTER IE --> CYRILLIC SMALL LETTER IE
263 "\xE6" => "\xC6", # CYRILLIC CAPITAL LETTER EF --> CYRILLIC SMALL LETTER EF
264 "\xE7" => "\xC7", # CYRILLIC CAPITAL LETTER GHE --> CYRILLIC SMALL LETTER GHE
265 "\xE8" => "\xC8", # CYRILLIC CAPITAL LETTER HA --> CYRILLIC SMALL LETTER HA
266 "\xE9" => "\xC9", # CYRILLIC CAPITAL LETTER I --> CYRILLIC SMALL LETTER I
267 "\xEA" => "\xCA", # CYRILLIC CAPITAL LETTER SHORT I --> CYRILLIC SMALL LETTER SHORT I
268 "\xEB" => "\xCB", # CYRILLIC CAPITAL LETTER KA --> CYRILLIC SMALL LETTER KA
269 "\xEC" => "\xCC", # CYRILLIC CAPITAL LETTER EL --> CYRILLIC SMALL LETTER EL
270 "\xED" => "\xCD", # CYRILLIC CAPITAL LETTER EM --> CYRILLIC SMALL LETTER EM
271 "\xEE" => "\xCE", # CYRILLIC CAPITAL LETTER EN --> CYRILLIC SMALL LETTER EN
272 "\xEF" => "\xCF", # CYRILLIC CAPITAL LETTER O --> CYRILLIC SMALL LETTER O
273 "\xF0" => "\xD0", # CYRILLIC CAPITAL LETTER PE --> CYRILLIC SMALL LETTER PE
274 "\xF1" => "\xD1", # CYRILLIC CAPITAL LETTER YA --> CYRILLIC SMALL LETTER YA
275 "\xF2" => "\xD2", # CYRILLIC CAPITAL LETTER ER --> CYRILLIC SMALL LETTER ER
276 "\xF3" => "\xD3", # CYRILLIC CAPITAL LETTER ES --> CYRILLIC SMALL LETTER ES
277 "\xF4" => "\xD4", # CYRILLIC CAPITAL LETTER TE --> CYRILLIC SMALL LETTER TE
278 "\xF5" => "\xD5", # CYRILLIC CAPITAL LETTER U --> CYRILLIC SMALL LETTER U
279 "\xF6" => "\xD6", # CYRILLIC CAPITAL LETTER ZHE --> CYRILLIC SMALL LETTER ZHE
280 "\xF7" => "\xD7", # CYRILLIC CAPITAL LETTER VE --> CYRILLIC SMALL LETTER VE
281 "\xF8" => "\xD8", # CYRILLIC CAPITAL LETTER SOFT SIGN --> CYRILLIC SMALL LETTER SOFT SIGN
282 "\xF9" => "\xD9", # CYRILLIC CAPITAL LETTER YERU --> CYRILLIC SMALL LETTER YERU
283 "\xFA" => "\xDA", # CYRILLIC CAPITAL LETTER ZE --> CYRILLIC SMALL LETTER ZE
284 "\xFB" => "\xDB", # CYRILLIC CAPITAL LETTER SHA --> CYRILLIC SMALL LETTER SHA
285 "\xFC" => "\xDC", # CYRILLIC CAPITAL LETTER E --> CYRILLIC SMALL LETTER E
286 "\xFD" => "\xDD", # CYRILLIC CAPITAL LETTER SHCHA --> CYRILLIC SMALL LETTER SHCHA
287 "\xFE" => "\xDE", # CYRILLIC CAPITAL LETTER CHE --> CYRILLIC SMALL LETTER CHE
288 "\xFF" => "\xDF", # CYRILLIC CAPITAL LETTER HARD SIGN --> CYRILLIC SMALL LETTER HARD SIGN
289 );
290 }
291  
292 else {
293 0 croak "Don't know my package name '@{[__PACKAGE__]}'";
294 }
295  
296 #
297 # @ARGV wildcard globbing
298 #
299 211 ▶sub import {
Subroutine import: called CC=7 SCAR=28.3
300  
301 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
302 0 my @argv = ();
303 0 for (@ARGV) {
304  
305 # has space
306 0 ▶ if (/\A (?:$q_char)*? [ ] /oxms) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\A (?:$Ekoi8r::q_char)*? [ ] /mosx) { } 0 0 0
elsif (/\A (?:$Ekoi8r::q_char)*? [*?] /mosx) { } 0 0 0
307 0 ▶ if (my @glob = Ekoi8r::glob(qq{"$_"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8r::glob(qq["$_"])) { } 0 0 0
308 0 push @argv, @glob;
309 }
310 else {
311 0 push @argv, $_;
312 }
313 }
314  
315 # has wildcard metachar
316 elsif (/\A (?:$q_char)*? [*?] /oxms) {
317 0 ▶ if (my @glob = Ekoi8r::glob($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8r::glob($_)) { } 0 0 0
318 0 push @argv, @glob;
319 }
320 else {
321 0 push @argv, $_;
322 }
323 }
324  
325 # no wildcard globbing
326 else {
327 0 push @argv, $_;
328 }
329 }
330 0 @ARGV = @argv;
331 }
332  
333 211 *Char::ord = \&KOI8R::ord;
334 211 *Char::ord_ = \&KOI8R::ord_;
335 211 *Char::reverse = \&KOI8R::reverse;
336 211 *Char::getc = \&KOI8R::getc;
337 211 *Char::length = \&KOI8R::length;
338 211 *Char::substr = \&KOI8R::substr;
339 211 *Char::index = \&KOI8R::index;
340 211 *Char::rindex = \&KOI8R::rindex;
341 211 *Char::eval = \&KOI8R::eval;
342 211 *Char::escape = \&KOI8R::escape;
343 211 *Char::escape_token = \&KOI8R::escape_token;
344 211 *Char::escape_script = \&KOI8R::escape_script;
345 }
346  
347 # P.230 Care with Prototypes
348 # in Chapter 6: Subroutines
349 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
350 #
351 # If you aren't careful, you can get yourself into trouble with prototypes.
352 # But if you are careful, you can do a lot of neat things with them. This is
353 # all very powerful, of course, and should only be used in moderation to make
354 # the world a better place.
355  
356 # P.332 Care with Prototypes
357 # in Chapter 7: Subroutines
358 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
359 #
360 # If you aren't careful, you can get yourself into trouble with prototypes.
361 # But if you are careful, you can do a lot of neat things with them. This is
362 # all very powerful, of course, and should only be used in moderation to make
363 # the world a better place.
364  
365 #
366 # Prototypes of subroutines
367 #
368 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
369 sub Ekoi8r::split(;$$$);
370 sub Ekoi8r::tr($$$$;$);
371 sub Ekoi8r::chop(@);
372 sub Ekoi8r::index($$;$);
373 sub Ekoi8r::rindex($$;$);
374 sub Ekoi8r::lcfirst(@);
375 sub Ekoi8r::lcfirst_();
376 sub Ekoi8r::lc(@);
377 sub Ekoi8r::lc_();
378 sub Ekoi8r::ucfirst(@);
379 sub Ekoi8r::ucfirst_();
380 sub Ekoi8r::uc(@);
381 sub Ekoi8r::uc_();
382 sub Ekoi8r::fc(@);
383 sub Ekoi8r::fc_();
384 sub Ekoi8r::ignorecase;
385 sub Ekoi8r::classic_character_class;
386 sub Ekoi8r::capture;
387 sub Ekoi8r::chr(;$);
388 sub Ekoi8r::chr_();
389 sub Ekoi8r::glob($);
390 sub Ekoi8r::glob_();
391  
392 sub KOI8R::ord(;$);
393 sub KOI8R::ord_();
394 sub KOI8R::reverse(@);
395 sub KOI8R::getc(;*@);
396 sub KOI8R::length(;$);
397 sub KOI8R::substr($$;$$);
398 sub KOI8R::index($$;$);
399 sub KOI8R::rindex($$;$);
400 sub KOI8R::escape(;$);
401  
402 #
403 # Regexp work
404 #
405 422 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
406 $re_a
407 $re_t
408 $re_n
409 $re_r
410 422 );
411  
412 #
413 # Character class
414 #
415 422 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
416 $dot
417 $dot_s
418 $eD
419 $eS
420 $eW
421 $eH
422 $eV
423 $eR
424 $eN
425 $not_alnum
426 $not_alpha
427 $not_ascii
428 $not_blank
429 $not_cntrl
430 $not_digit
431 $not_graph
432 $not_lower
433 $not_lower_i
434 $not_print
435 $not_punct
436 $not_space
437 $not_upper
438 $not_upper_i
439 $not_word
440 $not_xdigit
441 $eb
442 $eB
443 422 );
444  
445 422 ${Ekoi8r::dot} = qr{(?>[^\x0A])};
446 422 ${Ekoi8r::dot_s} = qr{(?>[\x00-\xFF])};
447 422 ${Ekoi8r::eD} = qr{(?>[^0-9])};
448  
449 # Vertical tabs are now whitespace
450 # \s in a regex now matches a vertical tab in all circumstances.
451 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
452 # ${Ekoi8r::eS} = qr{(?>[^\x09\x0A \x0C\x0D\x20])};
453 # ${Ekoi8r::eS} = qr{(?>[^\x09\x0A\x0B\x0C\x0D\x20])};
454 422 ${Ekoi8r::eS} = qr{(?>[^\s])};
455  
456 422 ${Ekoi8r::eW} = qr{(?>[^0-9A-Z_a-z])};
457 422 ${Ekoi8r::eH} = qr{(?>[^\x09\x20])};
458 422 ${Ekoi8r::eV} = qr{(?>[^\x0A\x0B\x0C\x0D])};
459 422 ${Ekoi8r::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])};
460 422 ${Ekoi8r::eN} = qr{(?>[^\x0A])};
461 422 ${Ekoi8r::not_alnum} = qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
462 422 ${Ekoi8r::not_alpha} = qr{(?>[^\x41-\x5A\x61-\x7A])};
463 422 ${Ekoi8r::not_ascii} = qr{(?>[^\x00-\x7F])};
464 422 ${Ekoi8r::not_blank} = qr{(?>[^\x09\x20])};
465 422 ${Ekoi8r::not_cntrl} = qr{(?>[^\x00-\x1F\x7F])};
466 422 ${Ekoi8r::not_digit} = qr{(?>[^\x30-\x39])};
467 422 ${Ekoi8r::not_graph} = qr{(?>[^\x21-\x7F])};
468 422 ${Ekoi8r::not_lower} = qr{(?>[^\x61-\x7A])};
469 422 ${Ekoi8r::not_lower_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
470 # ${Ekoi8r::not_lower_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
471 422 ${Ekoi8r::not_print} = qr{(?>[^\x20-\x7F])};
472 422 ${Ekoi8r::not_punct} = qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
473 422 ${Ekoi8r::not_space} = qr{(?>[^\s\x0B])};
474 422 ${Ekoi8r::not_upper} = qr{(?>[^\x41-\x5A])};
475 422 ${Ekoi8r::not_upper_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
476 # ${Ekoi8r::not_upper_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
477 422 ${Ekoi8r::not_word} = qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
478 422 ${Ekoi8r::not_xdigit} = qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
479 422 ${Ekoi8r::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))};
480 422 ${Ekoi8r::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]))};
481  
482 # avoid: Name "Ekoi8r::foo" used only once: possible typo at here.
483 422 ${Ekoi8r::dot} = ${Ekoi8r::dot};
484 422 ${Ekoi8r::dot_s} = ${Ekoi8r::dot_s};
485 422 ${Ekoi8r::eD} = ${Ekoi8r::eD};
486 422 ${Ekoi8r::eS} = ${Ekoi8r::eS};
487 422 ${Ekoi8r::eW} = ${Ekoi8r::eW};
488 422 ${Ekoi8r::eH} = ${Ekoi8r::eH};
489 422 ${Ekoi8r::eV} = ${Ekoi8r::eV};
490 422 ${Ekoi8r::eR} = ${Ekoi8r::eR};
491 422 ${Ekoi8r::eN} = ${Ekoi8r::eN};
492 422 ${Ekoi8r::not_alnum} = ${Ekoi8r::not_alnum};
493 422 ${Ekoi8r::not_alpha} = ${Ekoi8r::not_alpha};
494 422 ${Ekoi8r::not_ascii} = ${Ekoi8r::not_ascii};
495 422 ${Ekoi8r::not_blank} = ${Ekoi8r::not_blank};
496 422 ${Ekoi8r::not_cntrl} = ${Ekoi8r::not_cntrl};
497 422 ${Ekoi8r::not_digit} = ${Ekoi8r::not_digit};
498 422 ${Ekoi8r::not_graph} = ${Ekoi8r::not_graph};
499 422 ${Ekoi8r::not_lower} = ${Ekoi8r::not_lower};
500 422 ${Ekoi8r::not_lower_i} = ${Ekoi8r::not_lower_i};
501 422 ${Ekoi8r::not_print} = ${Ekoi8r::not_print};
502 422 ${Ekoi8r::not_punct} = ${Ekoi8r::not_punct};
503 422 ${Ekoi8r::not_space} = ${Ekoi8r::not_space};
504 422 ${Ekoi8r::not_upper} = ${Ekoi8r::not_upper};
505 422 ${Ekoi8r::not_upper_i} = ${Ekoi8r::not_upper_i};
506 422 ${Ekoi8r::not_word} = ${Ekoi8r::not_word};
507 422 ${Ekoi8r::not_xdigit} = ${Ekoi8r::not_xdigit};
508 422 ${Ekoi8r::eb} = ${Ekoi8r::eb};
509 422 ${Ekoi8r::eB} = ${Ekoi8r::eB};
510  
511 #
512 # KOI8-R split
513 #
514 72 ▶sub Ekoi8r::split(;$$$) {
Subroutine split: called CC=34 SCAR=46.9
Pod undocumented
515  
516 # P.794 29.2.161. split
517 # in Chapter 29: Functions
518 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
519  
520 # P.951 split
521 # in Chapter 27: Functions
522 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
523  
524 72 my $pattern = $_[0];
525 72 my $string = $_[1];
526 72 my $limit = $_[2];
527  
528 # if $pattern is also omitted or is the literal space, " "
529 72 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 2 70 72
530 2 $pattern = ' ';
531 }
532  
533 # if $string is omitted, the function splits the $_ string
534 72 ▶ if (not defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 6 66 72
535 6 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 6 6
536 0 $string = $_;
537 }
538 else {
539 6 $string = '';
540 }
541 }
542  
543 72 my @split = ();
544  
545 # when string is empty
546 72 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 10 62 72
elsif ($pattern eq ' ') { } 2 60 62
547  
548 # resulting list value in list context
549 10 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 5 5 10
550 5 return @split;
551 }
552  
553 # count of substrings in scalar context
554 else {
555 5 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 5 5
556 5 @_ = @split;
557 5 return scalar @_;
558 }
559 }
560  
561 # split's first argument is more consistently interpreted
562 #
563 # After some changes earlier in v5.17, split's behavior has been simplified:
564 # if the PATTERN argument evaluates to a string containing one space, it is
565 # treated the way that a literal string containing one space once was.
566 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
567  
568 # if $pattern is also omitted or is the literal space, " ", the function splits
569 # on whitespace, /\s+/, after skipping any leading whitespace
570 # (and so on)
571  
572 elsif ($pattern eq ' ') {
573 2 ▶ if (not defined $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit) { } 2 0 2
574 2 return CORE::split(' ', $string);
575 }
576 else {
577 0 return CORE::split(' ', $string, $limit);
578 }
579 }
580  
581 # if $limit is negative, it is treated as if an arbitrarily large $limit has been specified
582 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
583  
584 # a pattern capable of matching either the null string or something longer than the
585 # null string will split the value of $string into separate characters wherever it
586 # matches the null string between characters
587 # (and so on)
588  
589 60 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 2 58 60
590 2 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
591 2 my $limit = scalar(() = $string =~ /($pattern)/oxmsg);
592  
593 # P.1024 Appendix W.10 Multibyte Processing
594 # of ISBN 1-56592-224-7 CJKV Information Processing
595 # (and so on)
596  
597 # the //m modifier is assumed when you split on the pattern /^/
598 # (and so on)
599  
600 # V
601 2 ▶ while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and $string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m) 9 2 11
Condition100%3/3
--$limit > 0 and $string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m
!ll&&!rl&&r
119
MC/DC100%2/2
--$limit > 0 and $string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m
--$limit > 0 $string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m
Truth table100%3/3
A and B
A= --$limit > 0B= $string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m
ABresult
0X0
100
111
602  
603 # if the $pattern contains parentheses, then the substring matched by each pair of parentheses
604 # is included in the resulting list, interspersed with the fields that are ordinarily returned
605 # (and so on)
606  
607 9 local $@;
608 9 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 9 9 18
609 9 push @split, CORE::eval('$' . $digit);
610 }
611 }
612 }
613  
614 else {
615 58 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
616  
617 # V
618 58 ▶ while ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8r::q_char)*?)$pattern//m) 163 58 221
619 163 local $@;
620 163 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 230 163 393
621 230 push @split, CORE::eval('$' . $digit);
622 }
623 }
624 }
625 }
626  
627 elsif ($limit > 0) {
628 0 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 0 0 0
629 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
630 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
631  
632 # V
633 0 ▶ if ($string =~ s/\A((?:$q_char)+?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8r::q_char)+?)$pattern//m) 0 0 0
634 0 local $@;
635 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
636 0 push @split, CORE::eval('$' . $digit);
637 }
638 }
639 }
640 }
641 else {
642 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
643 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
644  
645 # V
646 0 ▶ if ($string =~ s/\A((?:$q_char)*?)$pattern//m) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$Ekoi8r::q_char)*?)$pattern//m) 0 0 0
647 0 local $@;
648 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
649 0 push @split, CORE::eval('$' . $digit);
650 }
651 }
652 }
653 }
654 }
655  
656 60 ▶ if (CORE::length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 58 2 60
657 58 push @split, $string;
658 }
659  
660 # if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result
661 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
662 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
663 0 pop @split;
664 }
665 }
666  
667 # resulting list value in list context
668 60 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 58 2 60
669 58 return @split;
670 }
671  
672 # count of substrings in scalar context
673 else {
674 2 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 2 2
675 2 @_ = @split;
676 2 return scalar @_;
677 }
678 }
679  
680 #
681 # get last subexpression offsets
682 #
683 60 ▶sub _last_subexpression_offsets {
Subroutine _last_subexpression_offsets: called CC=3 SCAR=11.0
684 60 my $pattern = $_[0];
685  
686 # remove comment
687 60 $pattern =~ s/\(\?\# .*? \)//oxmsg;
688  
689 60 my $modifier = '';
690 60 ▶ if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/mosx) 11 49 60
691 11 $modifier = $1;
692 11 $modifier =~ s/-[A-Za-z]*//;
693 }
694  
695 # with /x modifier
696 60 my @char = ();
697 60 ▶ if ($modifier =~ /x/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /x/mosx) { } 5 55 60
698 5 @char = $pattern =~ /\G((?>
699 [^\\\#\[\(] |
700 \\ $q_char |
701 \# (?>[^\n]*) $ |
702 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
703 \(\? |
704 $q_char
705 ))/oxmsg;
706 }
707  
708 # without /x modifier
709 else {
710 55 @char = $pattern =~ /\G((?>
711 [^\\\[\(] |
712 \\ $q_char |
713 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
714 \(\? |
715 $q_char
716 ))/oxmsg;
717 }
718  
719 60 return scalar grep { $_ eq '(' } @char;
720 }
721  
722 #
723 # KOI8-R transliteration (tr///)
724 #
725 6 ▶sub Ekoi8r::tr($$$$;$) {
Subroutine tr: called CC=26 SCAR=48.6
Pod undocumented
726  
727 6 my $bind_operator = $_[1];
728 6 my $searchlist = $_[2];
729 6 my $replacementlist = $_[3];
730 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
731  
732 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) 5 1 6
733 5 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 5 5
734 0 croak "Using !~ with tr///r doesn't make sense";
735 }
736 }
737  
738 6 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
739 6 my @searchlist = _charlist_tr($searchlist);
740 6 my @replacementlist = _charlist_tr($replacementlist);
741  
742 6 my %tr = ();
743 6 ▶ for (my $i=0; $i <= $#searchlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#searchlist) 19 6 25
744 19 ▶ if (not exists $tr{$searchlist[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$searchlist[$i]}) 19 0 19
745 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
746 19 $tr{$searchlist[$i]} = $replacementlist[$i];
747 }
748 elsif ($modifier =~ /d/oxms) {
749 0 $tr{$searchlist[$i]} = '';
750 }
751 ▶ 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
752 0 $tr{$searchlist[$i]} = $replacementlist[-1];
753 }
754 else {
755 0 $tr{$searchlist[$i]} = $searchlist[$i];
756 }
757 }
758 }
759  
760 6 my $tr = 0;
761 6 my $replaced = '';
762 6 ▶ if ($modifier =~ /c/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /c/mosx) { } 0 6 6
763 0 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 0 0 0
764 0 ▶ if (not exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $tr{$char}) { } 0 0 0
765 0 ▶ if (defined $replacementlist[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $replacementlist[0]) 0 0 0
766 0 $replaced .= $replacementlist[0];
767 }
768 0 $tr++;
769 0 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 0 0
770 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
771 0 shift @char;
772 0 $tr++;
773 }
774 }
775 }
776 else {
777 0 $replaced .= $char;
778 }
779 }
780 }
781 else {
782 6 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 36 6 42
783 36 ▶ if (exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$char}) { } 19 17 36
784 19 $replaced .= $tr{$char};
785 19 $tr++;
786 19 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 19 19
787 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
788 0 shift @char;
789 0 $tr++;
790 }
791 }
792 }
793 else {
794 17 $replaced .= $char;
795 }
796 }
797 }
798  
799 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) { } 5 1 6
800 5 return $replaced;
801 }
802 else {
803 1 $_[0] = $replaced;
804 1 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) { } 0 1 1
805 0 return not $tr;
806 }
807 else {
808 1 return $tr;
809 }
810 }
811 }
812  
813 #
814 # KOI8-R chop
815 #
816 0 ▶sub Ekoi8r::chop(@) {
Subroutine chop: not called CC=3 SCAR=24.8
Pod undocumented
817  
818 0 my $chop;
819 0 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
820 0 my @char = /\G (?>$q_char) /oxmsg;
821 0 $chop = pop @char;
822 0 $_ = join '', @char;
823 }
824 else {
825 0 for (@_) {
826 0 my @char = /\G (?>$q_char) /oxmsg;
827 0 $chop = pop @char;
828 0 $_ = join '', @char;
829 }
830 }
831 0 return $chop;
832 }
833  
834 #
835 # KOI8-R index by octet
836 #
837 30 ▶sub Ekoi8r::index($$;$) {
Subroutine index: called CC=6 SCAR=20.8
Pod documented
838  
839 30 my($str,$substr,$position) = @_;
840 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
841 30 my $pos = 0;
842  
843 30 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str) 130 30 160
844 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
845 0 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 0 0 0
846 0 return $pos;
847 }
848 }
849 130 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Ekoi8r::q_char) /mosx) { } 130 0 130
850 130 $pos += CORE::length($1);
851 }
852 else {
853 0 $pos += 1;
854 }
855 }
856 30 return -1;
857 }
858  
859 #
860 # KOI8-R reverse index
861 #
862 0 ▶sub Ekoi8r::rindex($$;$) {
Subroutine rindex: not called CC=6 SCAR=37.4
Pod undocumented
863  
864 0 my($str,$substr,$position) = @_;
865 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
866 0 my $pos = 0;
867 0 my $rindex = -1;
868  
869 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
870 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
871 0 $rindex = $pos;
872 }
873 0 ▶ if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($str, $pos) =~ /\A ($Ekoi8r::q_char) /mosx) { } 0 0 0
874 0 $pos += CORE::length($1);
875 }
876 else {
877 0 $pos += 1;
878 }
879 }
880 0 return $rindex;
881 }
882  
883 #
884 # KOI8-R lower case first with parameter
885 #
886 0 ▶sub Ekoi8r::lcfirst(@) {
Subroutine lcfirst: not called CC=4 SCAR=30.0
Pod undocumented
887 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
888 0 my $s = shift @_;
889 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
890 0 return Ekoi8r::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
891 }
892 else {
893 0 return Ekoi8r::lc(CORE::substr($s,0,1)) . CORE::substr($s,1);
894 }
895 }
896 else {
897 0 return Ekoi8r::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
898 }
899 }
900  
901 #
902 # KOI8-R lower case first without parameter
903 #
904 0 ▶sub Ekoi8r::lcfirst_() {
Subroutine lcfirst_: not called CC=1 SCAR=6.9
Pod undocumented
905 0 return Ekoi8r::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
906 }
907  
908 #
909 # KOI8-R lower case with parameter
910 #
911 60 ▶sub Ekoi8r::lc(@) {
Subroutine lc: called CC=6 SCAR=24.2
Pod undocumented
912 60 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 60 0 60
913 60 my $s = shift @_;
914 60 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 60 60
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
6000
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
915 0 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
916 }
917 else {
918 60 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 62 0 62
919 }
920 }
921 else {
922 0 return Ekoi8r::lc_();
923 }
924 }
925  
926 #
927 # KOI8-R lower case without parameter
928 #
929 0 ▶sub Ekoi8r::lc_() {
Subroutine lc_: not called CC=2 SCAR=17.9
Pod undocumented
930 0 my $s = $_;
931 0 ▶ return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
932 }
933  
934 #
935 # KOI8-R upper case first with parameter
936 #
937 0 ▶sub Ekoi8r::ucfirst(@) {
Subroutine ucfirst: not called CC=4 SCAR=30.0
Pod undocumented
938 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
939 0 my $s = shift @_;
940 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
941 0 return Ekoi8r::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
942 }
943 else {
944 0 return Ekoi8r::uc(CORE::substr($s,0,1)) . CORE::substr($s,1);
945 }
946 }
947 else {
948 0 return Ekoi8r::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
949 }
950 }
951  
952 #
953 # KOI8-R upper case first without parameter
954 #
955 0 ▶sub Ekoi8r::ucfirst_() {
Subroutine ucfirst_: not called CC=1 SCAR=6.9
Pod undocumented
956 0 return Ekoi8r::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
957 }
958  
959 #
960 # KOI8-R upper case with parameter
961 #
962 2415 ▶sub Ekoi8r::uc(@) {
Subroutine uc: called CC=6 SCAR=22.9
Pod undocumented
963 2415 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2415 0 2415
964 2415 my $s = shift @_;
965 2415 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2415 2415
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
241500
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
966 0 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
967 }
968 else {
969 2415 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 621 1796 2417
970 }
971 }
972 else {
973 0 return Ekoi8r::uc_();
974 }
975 }
976  
977 #
978 # KOI8-R upper case without parameter
979 #
980 0 ▶sub Ekoi8r::uc_() {
Subroutine uc_: not called CC=2 SCAR=17.9
Pod undocumented
981 0 my $s = $_;
982 0 ▶ return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
983 }
984  
985 #
986 # KOI8-R fold case with parameter
987 #
988 2426 ▶sub Ekoi8r::fc(@) {
Subroutine fc: called CC=6 SCAR=22.9
Pod undocumented
989 2426 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2426 0 2426
990 2426 my $s = shift @_;
991 2426 ▶ if (@_ and wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and wantarray) { } 0 2426 2426
Condition33%1/3
@_ and wantarray
!ll&&!rl&&r
242600
MC/DC0%0/2
@_ and wantarray
@_ wantarray
Truth table33%1/3
A and B
A= @_B= wantarray
ABresult
0X0
100
111
992 0 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
993 }
994 else {
995 2426 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 2040 5312 7352
996 }
997 }
998 else {
999 0 return Ekoi8r::fc_();
1000 }
1001 }
1002  
1003 #
1004 # KOI8-R fold case without parameter
1005 #
1006 0 ▶sub Ekoi8r::fc_() {
Subroutine fc_: not called CC=2 SCAR=17.9
Pod undocumented
1007 0 my $s = $_;
1008 0 ▶ return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1009 }
1010  
1011 #
1012 # KOI8-R regexp capture
1013 #
1014 {
1015 0 ▶ sub Ekoi8r::capture {
Subroutine capture: not called CC=1 SCAR=6.9
Pod documented
1016 0 return $_[0];
1017 }
1018 }
1019  
1020 #
1021 # KOI8-R regexp ignore case modifier
1022 #
1023 422 ▶sub Ekoi8r::ignorecase {
Subroutine ignorecase: called CC=25 SCAR=52.9
Pod undocumented
1024  
1025 11 my @string = @_;
1026 11 my $metachar = qr/[\@\\|[\]{]/oxms;
1027  
1028 # ignore case of $scalar or @array
1029 11 for my $string (@string) {
1030  
1031 # split regexp
1032 11 my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg;
1033  
1034 # unescape character
1035 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 951 11 962
1036 951 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 951 951
1037  
1038 # open character class [...]
1039 951 ▶ if ($char[$i] eq '[') {
Branch: 4 branches
BranchTrueFalseTotal
if ($char[$i] eq '[') { } 0 951 951
elsif ($char[$i] eq '[^') { } 0 951 951
elsif (my $char = classic_character_class($char[$i])) { } 0 951 951
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/mosx) { } 951 0 951
1040 0 my $left = $i;
1041  
1042 # [] make die "unmatched [] in regexp ...\n"
1043  
1044 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1045 0 $i++;
1046 }
1047  
1048 0 while (1) {
1049 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1050 0 croak "Unmatched [] in regexp";
1051 }
1052 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1053 0 my $right = $i;
1054 0 my @charlist = charlist_qr(@char[$left+1..$right-1], 'i');
1055  
1056 # escape character
1057 0 for my $char (@charlist) {
1058 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1059 }
1060  
1061 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1062 0 $char = '\\' . $char;
1063 }
1064 }
1065  
1066 # [...]
1067 0 splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')';
1068  
1069 0 $i = $left;
1070 0 last;
1071 }
1072 }
1073 }
1074  
1075 # open character class [^...]
1076 elsif ($char[$i] eq '[^') {
1077 0 my $left = $i;
1078  
1079 # [^] make die "unmatched [] in regexp ...\n"
1080  
1081 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1082 0 $i++;
1083 }
1084  
1085 0 while (1) {
1086 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1087 0 croak "Unmatched [] in regexp";
1088 }
1089 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1090 0 my $right = $i;
1091 0 my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i');
1092  
1093 # escape character
1094 0 for my $char (@charlist) {
1095 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1096 }
1097  
1098 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1099 0 $char = '\\' . $char;
1100 }
1101 }
1102  
1103 # [^...]
1104 0 splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)";
1105  
1106 0 $i = $left;
1107 0 last;
1108 }
1109 }
1110 }
1111  
1112 # rewrite classic character class or escape character
1113 elsif (my $char = classic_character_class($char[$i])) {
1114 0 $char[$i] = $char;
1115 }
1116  
1117 # with /i modifier
1118 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1119 951 my $uc = Ekoi8r::uc($char[$i]);
1120 951 my $fc = Ekoi8r::fc($char[$i]);
1121 951 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) 487 464 951
1122 487 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 487 0 487
1123 487 $char[$i] = '[' . $uc . $fc . ']';
1124 }
1125 else {
1126 0 $char[$i] = '(?:' . $uc . '|' . $fc . ')';
1127 }
1128 }
1129 }
1130 }
1131  
1132 # characterize
1133 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 951 11 962
1134 951 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 951 951
1135  
1136 951 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx }) 0 962 962
1137 }
1138  
1139 # quote character before ? + * {
1140 0 ▶ elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) {
Condition66%2/3
$i >= 1 && $char[$i] =~ /\A [\?\+\*\{] \z/mosx
!ll&&!rl&&r
119400
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
1141 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
1142 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
1143 }
1144 }
1145 }
1146  
1147 11 $string = join '', @char;
1148 }
1149  
1150 # make regexp string
1151 11 return @string;
1152 }
1153  
1154 #
1155 # classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B )
1156 #
1157 2819 ▶sub Ekoi8r::classic_character_class {
Subroutine classic_character_class: called CC=2 SCAR=6.9
Pod undocumented
1158 2819 my($char) = @_;
1159  
1160 return {
1161 '\D' => '${Ekoi8r::eD}',
1162 '\S' => '${Ekoi8r::eS}',
1163 '\W' => '${Ekoi8r::eW}',
1164 '\d' => '[0-9]',
1165  
1166 # Before Perl 5.6, \s only matched the five whitespace characters
1167 # tab, newline, form-feed, carriage return, and the space character
1168 # itself, which, taken together, is the character class [\t\n\f\r ].
1169  
1170 # Vertical tabs are now whitespace
1171 # \s in a regex now matches a vertical tab in all circumstances.
1172 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1173 # \t \n \v \f \r space
1174 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1175 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1176 '\s' => '\s',
1177  
1178 '\w' => '[0-9A-Z_a-z]',
1179 '\C' => '[\x00-\xFF]',
1180 '\X' => 'X',
1181  
1182 # \h \v \H \V
1183  
1184 # P.114 Character Class Shortcuts
1185 # in Chapter 7: In the World of Regular Expressions
1186 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
1187  
1188 # P.357 13.2.3 Whitespace
1189 # in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes
1190 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1191 #
1192 # 0x00009 CHARACTER TABULATION h s
1193 # 0x0000a LINE FEED (LF) vs
1194 # 0x0000b LINE TABULATION v
1195 # 0x0000c FORM FEED (FF) vs
1196 # 0x0000d CARRIAGE RETURN (CR) vs
1197 # 0x00020 SPACE h s
1198  
1199 # P.196 Table 5-9. Alphanumeric regex metasymbols
1200 # in Chapter 5. Pattern Matching
1201 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1202  
1203 # (and so on)
1204  
1205 '\H' => '${Ekoi8r::eH}',
1206 '\V' => '${Ekoi8r::eV}',
1207 '\h' => '[\x09\x20]',
1208 '\v' => '[\x0A\x0B\x0C\x0D]',
1209 '\R' => '${Ekoi8r::eR}',
1210  
1211 # \N
1212 #
1213 # http://perldoc.perl.org/perlre.html
1214 # Character Classes and other Special Escapes
1215 # Any character but \n (experimental). Not affected by /s modifier
1216  
1217 '\N' => '${Ekoi8r::eN}',
1218  
1219 # \b \B
1220  
1221 # P.180 Boundaries: The \b and \B Assertions
1222 # in Chapter 5: Pattern Matching
1223 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1224  
1225 # P.219 Boundaries: The \b and \B Assertions
1226 # in Chapter 5: Pattern Matching
1227 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1228  
1229 # \b really means (?:(?<=\w)(?!\w)|(?<!\w)(?=\w))
1230 # or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z))
1231 '\b' => '${Ekoi8r::eb}',
1232  
1233 # \B really means (?:(?<=\w)(?=\w)|(?<!\w)(?!\w))
1234 # or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W))
1235 '\B' => '${Ekoi8r::eB}',
1236  
1237 2819 ▶ }->{$char} || '';
Condition100%2/2
{'\\D', '${Ekoi8r::eD}', '\\S', '${Ekoi8r::eS}', '\\W', '${Ekoi8r::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8r::eH}', '\\V', '${Ekoi8r::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8r::eR}', '\\N', '${Ekoi8r::eN}', '\\b', '${Ekoi8r::eb}', '\\B', '${Ekoi8r::eB}'}->{$char} || ''
l!l
1012718
MC/DC100%1/1
{'\\D', '${Ekoi8r::eD}', '\\S', '${Ekoi8r::eS}', '\\W', '${Ekoi8r::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8r::eH}', '\\V', '${Ekoi8r::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8r::eR}', '\\N', '${Ekoi8r::eN}', '\\b', '${Ekoi8r::eb}', '\\B', '${Ekoi8r::eB}'}->{$char} || ''
{'\\D', '${Ekoi8r::eD}', '\\S', '${Ekoi8r::eS}', '\\W', '${Ekoi8r::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8r::eH}', '\\V', '${Ekoi8r::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8r::eR}', '\\N', '${Ekoi8r::eN}', '\\b', '${Ekoi8r::eb}', '\\B', '${Ekoi8r::eB}'}->{$char}
Truth table100%2/2
A
A= {'\\D', '${Ekoi8r::eD}', '\\S', '${Ekoi8r::eS}', '\\W', '${Ekoi8r::eW}', '\\d', '[0-9]', '\\s', '\\s', '\\w', '[0-9A-Z_a-z]', '\\C', '[\\x00-\\xFF]', '\\X', 'X', '\\H', '${Ekoi8r::eH}', '\\V', '${Ekoi8r::eV}', '\\h', '[\\x09\\x20]', '\\v', '[\\x0A\\x0B\\x0C\\x0D]', '\\R', '${Ekoi8r::eR}', '\\N', '${Ekoi8r::eN}', '\\b', '${Ekoi8r::eb}', '\\B', '${Ekoi8r::eB}'}->{$char}
Aresult
11
00
1238 }
1239  
1240 #
1241 # prepare KOI8-R characters per length
1242 #
1243  
1244 # 1 octet characters
1245 422 my @chars1 = ();
1246 0 ▶sub chars1 {
Subroutine chars1: not called CC=5 SCAR=34.0
Pod undocumented
1247 0 ▶ if (@chars1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars1) 0 0 0
1248 0 return @chars1;
1249 }
1250 0 ▶ if (exists $range_tr{1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{1}) 0 0 0
1251 0 my @ranges = @{ $range_tr{1} };
1252 0 ▶ while (my @range = splice(@ranges,0,1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 1)) 0 0 0
1253 0 for my $oct0 (@{$range[0]}) {
1254 0 push @chars1, pack 'C', $oct0;
1255 }
1256 }
1257 }
1258 0 return @chars1;
1259 }
1260  
1261 # 2 octets characters
1262 422 my @chars2 = ();
1263 0 ▶sub chars2 {
Subroutine chars2: not called CC=6 SCAR=37.4
Pod undocumented
1264 0 ▶ if (@chars2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars2) 0 0 0
1265 0 return @chars2;
1266 }
1267 0 ▶ if (exists $range_tr{2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{2}) 0 0 0
1268 0 my @ranges = @{ $range_tr{2} };
1269 0 ▶ while (my @range = splice(@ranges,0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 2)) 0 0 0
1270 0 for my $oct0 (@{$range[0]}) {
1271 0 for my $oct1 (@{$range[1]}) {
1272 0 push @chars2, pack 'CC', $oct0,$oct1;
1273 }
1274 }
1275 }
1276 }
1277 0 return @chars2;
1278 }
1279  
1280 # 3 octets characters
1281 422 my @chars3 = ();
1282 0 ▶sub chars3 {
Subroutine chars3: not called CC=7 SCAR=40.3
Pod undocumented
1283 0 ▶ if (@chars3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars3) 0 0 0
1284 0 return @chars3;
1285 }
1286 0 ▶ if (exists $range_tr{3}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{3}) 0 0 0
1287 0 my @ranges = @{ $range_tr{3} };
1288 0 ▶ while (my @range = splice(@ranges,0,3)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 3)) 0 0 0
1289 0 for my $oct0 (@{$range[0]}) {
1290 0 for my $oct1 (@{$range[1]}) {
1291 0 for my $oct2 (@{$range[2]}) {
1292 0 push @chars3, pack 'CCC', $oct0,$oct1,$oct2;
1293 }
1294 }
1295 }
1296 }
1297 }
1298 0 return @chars3;
1299 }
1300  
1301 # 4 octets characters
1302 422 my @chars4 = ();
1303 0 ▶sub chars4 {
Subroutine chars4: not called CC=8 SCAR=42.8
Pod undocumented
1304 0 ▶ if (@chars4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars4) 0 0 0
1305 0 return @chars4;
1306 }
1307 0 ▶ if (exists $range_tr{4}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{4}) 0 0 0
1308 0 my @ranges = @{ $range_tr{4} };
1309 0 ▶ while (my @range = splice(@ranges,0,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 4)) 0 0 0
1310 0 for my $oct0 (@{$range[0]}) {
1311 0 for my $oct1 (@{$range[1]}) {
1312 0 for my $oct2 (@{$range[2]}) {
1313 0 for my $oct3 (@{$range[3]}) {
1314 0 push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3;
1315 }
1316 }
1317 }
1318 }
1319 }
1320 }
1321 0 return @chars4;
1322 }
1323  
1324 #
1325 # KOI8-R open character list for tr
1326 #
1327 12 ▶sub _charlist_tr {
Subroutine _charlist_tr: called CC=35 SCAR=66.4
1328  
1329 12 local $_ = shift @_;
1330  
1331 # unescape character
1332 12 my @char = ();
1333 12 ▶ while (not /\G \z/oxmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgmosx) 38 12 50
1334 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 \\ ($Ekoi8r::q_char) /cgmosx) { } 0 38 38
elsif (/\G ($Ekoi8r::q_char) /cgmosx) { } 38 0 38
1335 0 push @char, '\-';
1336 }
1337 elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) {
1338 0 push @char, CORE::chr(oct $1);
1339 }
1340 elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) {
1341 0 push @char, CORE::chr(hex $1);
1342 }
1343 elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) {
1344 0 push @char, CORE::chr(CORE::ord($1) & 0x1F);
1345 }
1346 elsif (/\G (\\ [0nrtfbae]) /oxmsgc) {
1347 push @char, {
1348 '\0' => "\0",
1349 '\n' => "\n",
1350 '\r' => "\r",
1351 '\t' => "\t",
1352 '\f' => "\f",
1353 '\b' => "\x08", # \b means backspace in character class
1354 '\a' => "\a",
1355 '\e' => "\e",
1356 0 }->{$1};
1357 }
1358 elsif (/\G \\ ($q_char) /oxmsgc) {
1359 0 push @char, $1;
1360 }
1361 elsif (/\G ($q_char) /oxmsgc) {
1362 38 push @char, $1;
1363 }
1364 }
1365  
1366 # join separated multiple-octet
1367 12 @char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg;
1368  
1369 # unescape '-'
1370 12 my @i = ();
1371 12 for my $i (0 .. $#char) {
1372 38 ▶ if ($char[$i] eq '\-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\-') { } 0 38 38
elsif ($char[$i] eq '-') { } 0 38 38
1373 0 $char[$i] = '-';
1374 }
1375 elsif ($char[$i] eq '-') {
1376 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
1377 0 push @i, $i;
1378 }
1379 }
1380 }
1381  
1382 # open character list (reverse for splice)
1383 12 for my $i (CORE::reverse @i) {
1384 0 my @range = ();
1385  
1386 # range error
1387 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
1388 0 croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1389 }
1390  
1391 # range of multiple-octet code
1392 0 ▶ if (CORE::length($char[$i-1]) == 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (length $char[$i - 1] == 1) { } 0 0 0
elsif (length $char[$i - 1] == 2) { } 0 0 0
elsif (length $char[$i - 1] == 3) { } 0 0 0
elsif (length $char[$i - 1] == 4) { } 0 0 0
1393 0 ▶ 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
1394 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
1395 }
1396 elsif (CORE::length($char[$i+1]) == 2) {
1397 0 push @range, grep {$char[$i-1] le $_} chars1();
1398 0 push @range, grep {$_ le $char[$i+1]} chars2();
1399 }
1400 elsif (CORE::length($char[$i+1]) == 3) {
1401 0 push @range, grep {$char[$i-1] le $_} chars1();
1402 0 push @range, chars2();
1403 0 push @range, grep {$_ le $char[$i+1]} chars3();
1404 }
1405 elsif (CORE::length($char[$i+1]) == 4) {
1406 0 push @range, grep {$char[$i-1] le $_} chars1();
1407 0 push @range, chars2();
1408 0 push @range, chars3();
1409 0 push @range, grep {$_ le $char[$i+1]} chars4();
1410 }
1411 else {
1412 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1413 }
1414 }
1415 elsif (CORE::length($char[$i-1]) == 2) {
1416 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
1417 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
1418 }
1419 elsif (CORE::length($char[$i+1]) == 3) {
1420 0 push @range, grep {$char[$i-1] le $_} chars2();
1421 0 push @range, grep {$_ le $char[$i+1]} chars3();
1422 }
1423 elsif (CORE::length($char[$i+1]) == 4) {
1424 0 push @range, grep {$char[$i-1] le $_} chars2();
1425 0 push @range, chars3();
1426 0 push @range, grep {$_ le $char[$i+1]} chars4();
1427 }
1428 else {
1429 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1430 }
1431 }
1432 elsif (CORE::length($char[$i-1]) == 3) {
1433 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
1434 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
1435 }
1436 elsif (CORE::length($char[$i+1]) == 4) {
1437 0 push @range, grep {$char[$i-1] le $_} 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]) == 4) {
1445 0 ▶ if (CORE::length($char[$i+1]) == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i + 1] == 4) { } 0 0 0
1446 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
1447 }
1448 else {
1449 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1450 }
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 0 splice @char, $i-1, 3, @range;
1457 }
1458  
1459 12 return @char;
1460 }
1461  
1462 #
1463 # KOI8-R open character class
1464 #
1465 0 ▶sub _cc {
Subroutine _cc: not called CC=7 SCAR=40.3
1466 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
1467 0 die __FILE__, ": subroutine cc got no parameter.\n";
1468 }
1469 elsif (scalar(@_) == 1) {
1470 0 return sprintf('\x%02X',$_[0]);
1471 }
1472 elsif (scalar(@_) == 2) {
1473 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
1474 0 die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n";
1475 }
1476 elsif ($_[0] == $_[1]) {
1477 0 return sprintf('\x%02X',$_[0]);
1478 }
1479 elsif (($_[0]+1) == $_[1]) {
1480 0 return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]);
1481 }
1482 else {
1483 0 return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]);
1484 }
1485 }
1486 else {
1487 0 die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n";
1488 }
1489 }
1490  
1491 #
1492 # KOI8-R octet range
1493 #
1494 246 ▶sub _octets {
Subroutine _octets: called CC=5 SCAR=19.3
1495 246 my $length = shift @_;
1496  
1497 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1498 246 my($a1) = unpack 'C', $_[0];
1499 246 my($z1) = unpack 'C', $_[1];
1500  
1501 246 ▶ if ($a1 > $z1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1 > $z1) 0 246 246
1502 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1);
1503 }
1504  
1505 246 ▶ if ($a1 == $z1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($a1 == $z1) { } 0 246 246
elsif ($a1 + 1 == $z1) { } 0 246 246
1506 0 return sprintf('\x%02X',$a1);
1507 }
1508 elsif (($a1+1) == $z1) {
1509 0 return sprintf('\x%02X\x%02X',$a1,$z1);
1510 }
1511 else {
1512 246 return sprintf('\x%02X-\x%02X',$a1,$z1);
1513 }
1514 }
1515 else {
1516 0 die __FILE__, ": subroutine _octets got invalid length ($length).\n";
1517 }
1518 }
1519  
1520 #
1521 # KOI8-R range regexp
1522 #
1523 246 ▶sub _range_regexp {
Subroutine _range_regexp: called CC=18 SCAR=41.7
1524 246 my($length,$first,$last) = @_;
1525  
1526 246 my @range_regexp = ();
1527 246 ▶ if (not exists $range_tr{$length}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $range_tr{$length}) 0 246 246
1528 0 return @range_regexp;
1529 }
1530  
1531 246 my @ranges = @{ $range_tr{$length} };
1532 246 ▶ while (my @range = splice(@ranges,0,$length)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, $length)) 246 246 492
1533 246 my $min = '';
1534 246 my $max = '';
1535 246 ▶ for (my $i=0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 246 246 492
1536 246 $min .= pack 'C', $range[$i][0];
1537 246 $max .= pack 'C', $range[$i][-1];
1538 }
1539  
1540 # min___max
1541 # FIRST_____________LAST
1542 # (nothing)
1543  
1544 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
1545 }
1546  
1547 # **********
1548 # min_________max
1549 # FIRST_____________LAST
1550 # **********
1551  
1552 ▶ 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
1553 0 push @range_regexp, _octets($length,$first,$max,$min,$max);
1554 }
1555  
1556 # **********************
1557 # min________________max
1558 # FIRST_____________LAST
1559 # **********************
1560  
1561 ▶ 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
1562 0 push @range_regexp, _octets($length,$first,$last,$min,$max);
1563 }
1564  
1565 # *********
1566 # min___max
1567 # FIRST_____________LAST
1568 # *********
1569  
1570 ▶ 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
1571 0 push @range_regexp, _octets($length,$min,$max,$min,$max);
1572 }
1573  
1574 # **********************
1575 # min__________________________max
1576 # FIRST_____________LAST
1577 # **********************
1578  
1579 ▶ 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
1580 246 push @range_regexp, _octets($length,$first,$last,$min,$max);
1581 }
1582  
1583 # *********
1584 # min________max
1585 # FIRST_____________LAST
1586 # *********
1587  
1588 ▶ 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
1589 0 push @range_regexp, _octets($length,$min,$last,$min,$max);
1590 }
1591  
1592 # min___max
1593 # FIRST_____________LAST
1594 # (nothing)
1595  
1596 elsif ($last lt $min) {
1597 }
1598  
1599 else {
1600 0 die __FILE__, ": subroutine _range_regexp panic.\n";
1601 }
1602 }
1603  
1604 246 return @range_regexp;
1605 }
1606  
1607 #
1608 # KOI8-R open character list for qr and not qr
1609 #
1610 650 ▶sub _charlist {
Subroutine _charlist: called CC=46 SCAR=45.9
1611  
1612 650 my $modifier = pop @_;
1613 650 my @char = @_;
1614  
1615 650 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 298 352 650
1616  
1617 # unescape character
1618 650 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1773 650 2423
1619  
1620 # escape - to ...
1621 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 \\ ($Ekoi8r::q_char) \z/mosx) { } 7 1371 1378
1622 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
1623 246 $char[$i] = '...';
1624 }
1625 }
1626  
1627 # octal escape sequence
1628 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
1629 0 $char[$i] = octchr($1);
1630 }
1631  
1632 # hexadecimal escape sequence
1633 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
1634 0 $char[$i] = hexchr($1);
1635 }
1636  
1637 # \b{...} --> b\{...}
1638 # \B{...} --> B\{...}
1639 # \N{CHARNAME} --> N\{CHARNAME}
1640 # \p{PROPERTY} --> p\{PROPERTY}
1641 # \P{PROPERTY} --> P\{PROPERTY}
1642 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
1643 0 $char[$i] = $1 . '\\' . $2;
1644 }
1645  
1646 # \p, \P, \X --> p, P, X
1647 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
1648 0 $char[$i] = $1;
1649 }
1650  
1651 elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) {
1652 0 $char[$i] = CORE::chr oct $1;
1653 }
1654 elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) {
1655 22 $char[$i] = CORE::chr hex $1;
1656 }
1657 elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) {
1658 0 $char[$i] = CORE::chr(CORE::ord($1) & 0x1F);
1659 }
1660 elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) {
1661 $char[$i] = {
1662 '\0' => "\0",
1663 '\n' => "\n",
1664 '\r' => "\r",
1665 '\t' => "\t",
1666 '\f' => "\f",
1667 '\b' => "\x08", # \b means backspace in character class
1668 '\a' => "\a",
1669 '\e' => "\e",
1670 '\d' => '[0-9]',
1671  
1672 # Vertical tabs are now whitespace
1673 # \s in a regex now matches a vertical tab in all circumstances.
1674 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1675 # \t \n \v \f \r space
1676 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1677 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1678 '\s' => '\s',
1679  
1680 '\w' => '[0-9A-Z_a-z]',
1681 '\D' => '${Ekoi8r::eD}',
1682 '\S' => '${Ekoi8r::eS}',
1683 '\W' => '${Ekoi8r::eW}',
1684  
1685 '\H' => '${Ekoi8r::eH}',
1686 '\V' => '${Ekoi8r::eV}',
1687 '\h' => '[\x09\x20]',
1688 '\v' => '[\x0A\x0B\x0C\x0D]',
1689 '\R' => '${Ekoi8r::eR}',
1690  
1691 25 }->{$1};
1692 }
1693  
1694 # POSIX-style character classes
1695 ▶ 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
1696 $char[$i] = {
1697  
1698 '[:lower:]' => '[\x41-\x5A\x61-\x7A]',
1699 '[:upper:]' => '[\x41-\x5A\x61-\x7A]',
1700 '[:^lower:]' => '${Ekoi8r::not_lower_i}',
1701 '[:^upper:]' => '${Ekoi8r::not_upper_i}',
1702  
1703 8 }->{$1};
1704 }
1705 elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) {
1706 $char[$i] = {
1707  
1708 '[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]',
1709 '[:alpha:]' => '[\x41-\x5A\x61-\x7A]',
1710 '[:ascii:]' => '[\x00-\x7F]',
1711 '[:blank:]' => '[\x09\x20]',
1712 '[:cntrl:]' => '[\x00-\x1F\x7F]',
1713 '[:digit:]' => '[\x30-\x39]',
1714 '[:graph:]' => '[\x21-\x7F]',
1715 '[:lower:]' => '[\x61-\x7A]',
1716 '[:print:]' => '[\x20-\x7F]',
1717 '[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]',
1718  
1719 # P.174 POSIX-Style Character Classes
1720 # in Chapter 5: Pattern Matching
1721 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1722  
1723 # P.311 11.2.4 Character Classes and other Special Escapes
1724 # in Chapter 11: perlre: Perl regular expressions
1725 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1726  
1727 # P.210 POSIX-Style Character Classes
1728 # in Chapter 5: Pattern Matching
1729 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1730  
1731 '[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK")
1732  
1733 '[:upper:]' => '[\x41-\x5A]',
1734 '[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]',
1735 '[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]',
1736 '[:^alnum:]' => '${Ekoi8r::not_alnum}',
1737 '[:^alpha:]' => '${Ekoi8r::not_alpha}',
1738 '[:^ascii:]' => '${Ekoi8r::not_ascii}',
1739 '[:^blank:]' => '${Ekoi8r::not_blank}',
1740 '[:^cntrl:]' => '${Ekoi8r::not_cntrl}',
1741 '[:^digit:]' => '${Ekoi8r::not_digit}',
1742 '[:^graph:]' => '${Ekoi8r::not_graph}',
1743 '[:^lower:]' => '${Ekoi8r::not_lower}',
1744 '[:^print:]' => '${Ekoi8r::not_print}',
1745 '[:^punct:]' => '${Ekoi8r::not_punct}',
1746 '[:^space:]' => '${Ekoi8r::not_space}',
1747 '[:^upper:]' => '${Ekoi8r::not_upper}',
1748 '[:^word:]' => '${Ekoi8r::not_word}',
1749 '[:^xdigit:]' => '${Ekoi8r::not_xdigit}',
1750  
1751 70 }->{$1};
1752 }
1753 elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) {
1754 7 $char[$i] = $1;
1755 }
1756 }
1757  
1758 # open character list
1759 650 my @singleoctet = ();
1760 650 my @multipleoctet = ();
1761 650 ▶ for (my $i=0; $i <= $#char; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1527 650 2177
1762  
1763 # escaped -
1764 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
1765 246 $i += 1;
1766 246 next;
1767 }
1768  
1769 # make range regexp
1770 elsif ($char[$i] eq '...') {
1771  
1772 # range error
1773 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
1774 0 croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1775 }
1776 elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) {
1777 246 ▶ if ($char[$i-1] gt $char[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] gt $char[$i + 1]) 0 246 246
1778 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1779 }
1780 }
1781  
1782 # make range regexp per length
1783 246 for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) {
1784 246 my @regexp = ();
1785  
1786 # is first and last
1787 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
1788 246 push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]);
1789 }
1790  
1791 # is first
1792 elsif ($length == CORE::length($char[$i-1])) {
1793 0 push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length);
1794 }
1795  
1796 # is inside in first and last
1797 ▶ 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
1798 0 push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length);
1799 }
1800  
1801 # is last
1802 elsif ($length == CORE::length($char[$i+1])) {
1803 0 push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]);
1804 }
1805  
1806 else {
1807 0 die __FILE__, ": subroutine make_regexp panic.\n";
1808 }
1809  
1810 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1811 246 push @singleoctet, @regexp;
1812 }
1813 else {
1814 0 push @multipleoctet, @regexp;
1815 }
1816 }
1817  
1818 246 $i += 2;
1819 }
1820  
1821 # with /i modifier
1822 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1823 949 ▶ if ($modifier =~ /i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) { } 480 469 949
1824 480 my $uc = Ekoi8r::uc($char[$i]);
1825 480 my $fc = Ekoi8r::fc($char[$i]);
1826 480 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) { } 240 240 480
1827 240 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 240 0 240
1828 240 push @singleoctet, $uc, $fc;
1829 }
1830 else {
1831 0 push @singleoctet, $uc;
1832 0 push @multipleoctet, $fc;
1833 }
1834 }
1835 else {
1836 240 push @singleoctet, $char[$i];
1837 }
1838 }
1839 else {
1840 469 push @singleoctet, $char[$i];
1841 }
1842 949 $i += 1;
1843 }
1844  
1845 # single character of single octet code
1846 elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) {
1847 0 push @singleoctet, "\t", "\x20";
1848 0 $i += 1;
1849 }
1850 elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) {
1851 0 push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D";
1852 0 $i += 1;
1853 }
1854 elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) {
1855 2 push @singleoctet, $char[$i];
1856 2 $i += 1;
1857 }
1858  
1859 # single character of multiple-octet code
1860 else {
1861 84 push @multipleoctet, $char[$i];
1862 84 $i += 1;
1863 }
1864 }
1865  
1866 # quote metachar
1867 650 for (@singleoctet) {
1868 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
1869 0 $_ = '-';
1870 }
1871 elsif (/\A \n \z/oxms) {
1872 8 $_ = '\n';
1873 }
1874 elsif (/\A \r \z/oxms) {
1875 8 $_ = '\r';
1876 }
1877 elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) {
1878 744 $_ = sprintf('\x%02X', CORE::ord $1);
1879 }
1880 elsif (/\A [\x00-\xFF] \z/oxms) {
1881 429 $_ = quotemeta $_;
1882 }
1883 }
1884  
1885 # return character list
1886 650 return \@singleoctet, \@multipleoctet;
1887 }
1888  
1889 #
1890 # KOI8-R octal escape sequence
1891 #
1892 5 ▶sub octchr {
Subroutine octchr: called CC=2 SCAR=6.9
Pod undocumented
1893 5 my($octdigit) = @_;
1894  
1895 5 my @binary = ();
1896 5 for my $octal (split(//,$octdigit)) {
1897 push @binary, {
1898 '0' => '000',
1899 '1' => '001',
1900 '2' => '010',
1901 '3' => '011',
1902 '4' => '100',
1903 '5' => '101',
1904 '6' => '110',
1905 '7' => '111',
1906 50 }->{$octal};
1907 }
1908 5 my $binary = join '', @binary;
1909  
1910 my $octchr = {
1911 # 1234567
1912 1 => pack('B*', "0000000$binary"),
1913 2 => pack('B*', "000000$binary"),
1914 3 => pack('B*', "00000$binary"),
1915 4 => pack('B*', "0000$binary"),
1916 5 => pack('B*', "000$binary"),
1917 6 => pack('B*', "00$binary"),
1918 7 => pack('B*', "0$binary"),
1919 0 => pack('B*', "$binary"),
1920  
1921 5 }->{CORE::length($binary) % 8};
1922  
1923 5 return $octchr;
1924 }
1925  
1926 #
1927 # KOI8-R hexadecimal escape sequence
1928 #
1929 5 ▶sub hexchr {
Subroutine hexchr: called CC=1 SCAR=0.0
Pod undocumented
1930 5 my($hexdigit) = @_;
1931  
1932 my $hexchr = {
1933 1 => pack('H*', "0$hexdigit"),
1934 0 => pack('H*', "$hexdigit"),
1935  
1936 5 }->{CORE::length($_[0]) % 2};
1937  
1938 5 return $hexchr;
1939 }
1940  
1941 #
1942 # KOI8-R open character list for qr
1943 #
1944 576 ▶sub charlist_qr {
Subroutine charlist_qr: called CC=17 SCAR=28.7
Pod undocumented
1945  
1946 576 my $modifier = pop @_;
1947 576 my @char = @_;
1948  
1949 576 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
1950 576 my @singleoctet = @$singleoctet;
1951 576 my @multipleoctet = @$multipleoctet;
1952  
1953 # return character list
1954 576 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) 498 78 576
1955  
1956 # with /i modifier
1957 498 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 265 233 498
1958 265 my %singleoctet_ignorecase = ();
1959 265 for (@singleoctet) {
1960 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
1961 745 for my $ord (hex($1) .. hex($2)) {
1962 795 my $char = CORE::chr($ord);
1963 795 my $uc = Ekoi8r::uc($char);
1964 795 my $fc = Ekoi8r::fc($char);
1965 795 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 240 555 795
1966 240 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
1967 }
1968 else {
1969 555 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 555 0 555
1970 555 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1971 555 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
1972 }
1973 else {
1974 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1975 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
1976 }
1977 }
1978 }
1979 }
1980 745 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 745 745
1981 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
1982 }
1983 }
1984 265 my $i = 0;
1985 265 my @singleoctet_ignorecase = ();
1986 265 for my $ord (0 .. 255) {
1987 67840 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 870 66970 67840
1988 870 push @{$singleoctet_ignorecase[$i]}, $ord;
1989 }
1990 else {
1991 66970 $i++;
1992 }
1993 }
1994 265 @singleoctet = ();
1995 265 for my $range (@singleoctet_ignorecase) {
1996 56160 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 770 55390 56160
1997 770 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 720 50 770
elsif (scalar @{$range;} == 2) { } 0 50 50
1998 720 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
1999 }
2000 50 elsif (scalar(@{$range}) == 2) {
2001 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2002 }
2003 else {
2004 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2005 }
2006 }
2007 }
2008 }
2009  
2010 498 my $not_anchor = '';
2011  
2012 498 push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' );
2013 }
2014 576 ▶ if (scalar(@multipleoctet) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 2) { } 6 570 576
2015 6 return '(?:' . join('|', @multipleoctet) . ')';
2016 }
2017 else {
2018 570 return $multipleoctet[0];
2019 }
2020 }
2021  
2022 #
2023 # KOI8-R open character list for not qr
2024 #
2025 74 ▶sub charlist_not_qr {
Subroutine charlist_not_qr: called CC=18 SCAR=33.1
Pod undocumented
2026  
2027 74 my $modifier = pop @_;
2028 74 my @char = @_;
2029  
2030 74 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
2031 74 my @singleoctet = @$singleoctet;
2032 74 my @multipleoctet = @$multipleoctet;
2033  
2034 # with /i modifier
2035 74 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 25 49 74
2036 25 my %singleoctet_ignorecase = ();
2037 25 for (@singleoctet) {
2038 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
2039 25 for my $ord (hex($1) .. hex($2)) {
2040 75 my $char = CORE::chr($ord);
2041 75 my $uc = Ekoi8r::uc($char);
2042 75 my $fc = Ekoi8r::fc($char);
2043 75 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 0 75 75
2044 0 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
2045 }
2046 else {
2047 75 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 75 0 75
2048 75 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2049 75 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
2050 }
2051 else {
2052 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2053 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
2054 }
2055 }
2056 }
2057 }
2058 25 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 25 25
2059 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
2060 }
2061 }
2062 25 my $i = 0;
2063 25 my @singleoctet_ignorecase = ();
2064 25 for my $ord (0 .. 255) {
2065 6400 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 150 6250 6400
2066 150 push @{$singleoctet_ignorecase[$i]}, $ord;
2067 }
2068 else {
2069 6250 $i++;
2070 }
2071 }
2072 25 @singleoctet = ();
2073 25 for my $range (@singleoctet_ignorecase) {
2074 2400 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 50 2350 2400
2075 50 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 0 50 50
elsif (scalar @{$range;} == 2) { } 0 50 50
2076 0 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2077 }
2078 50 elsif (scalar(@{$range}) == 2) {
2079 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2080 }
2081 else {
2082 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2083 }
2084 }
2085 }
2086 }
2087  
2088 # return character list
2089 74 ▶ if (scalar(@multipleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 1) { } 0 74 74
2090 0 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 0 0 0
2091  
2092 # any character other than multiple-octet and single octet character class
2093 0 return '(?!' . join('|', @multipleoctet) . ')(?:[^' . join('', @singleoctet) . '])';
2094 }
2095 else {
2096  
2097 # any character other than multiple-octet character class
2098 0 return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)";
2099 }
2100 }
2101 else {
2102 74 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 74 0 74
2103  
2104 # any character other than single octet character class
2105 74 return '(?:[^' . join('', @singleoctet) . '])';
2106 }
2107 else {
2108  
2109 # any character
2110 0 return "(?:$your_char)";
2111 }
2112 }
2113 }
2114  
2115 #
2116 # open file in read mode
2117 #
2118 422 ▶sub _open_r {
Subroutine _open_r: called CC=1 SCAR=0.0
2119 422 my(undef,$file) = @_;
2120 422 ▶ use Fcntl qw(O_RDONLY);
Subroutine BEGIN: called CC=1 SCAR=0.0
2121 422 return CORE::sysopen($_[0], $file, &O_RDONLY);
2122 }
2123  
2124 #
2125 # open file in append mode
2126 #
2127 211 ▶sub _open_a {
Subroutine _open_a: called CC=1 SCAR=0.0
2128 211 my(undef,$file) = @_;
2129 422 ▶ use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
2130 211 return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT);
2131 }
2132  
2133 #
2134 # safe system
2135 #
2136 211 ▶sub _systemx {
Subroutine _systemx: called CC=1 SCAR=0.0
2137  
2138 # P.707 29.2.33. exec
2139 # in Chapter 29: Functions
2140 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2141 #
2142 # Be aware that in older releases of Perl, exec (and system) did not flush
2143 # your output buffer, so you needed to enable command buffering by setting $|
2144 # on one or more filehandles to avoid lost output in the case of exec, or
2145 # misordererd output in the case of system. This situation was largely remedied
2146 # in the 5.6 release of Perl. (So, 5.005 release not yet.)
2147  
2148 # P.855 exec
2149 # in Chapter 27: Functions
2150 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2151 #
2152 # In very old release of Perl (before v5.6), exec (and system) did not flush
2153 # your output buffer, so you needed to enable command buffering by setting $|
2154 # on one or more filehandles to avoid lost output with exec or misordered
2155 # output with system.
2156  
2157 211 $| = 1;
2158  
2159 # P.565 23.1.2. Cleaning Up Your Environment
2160 # in Chapter 23: Security
2161 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2162  
2163 # P.656 Cleaning Up Your Environment
2164 # in Chapter 20: Security
2165 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2166  
2167 # local $ENV{'PATH'} = '.';
2168 211 local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
2169  
2170 # P.707 29.2.33. exec
2171 # in Chapter 29: Functions
2172 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2173 #
2174 # As we mentioned earlier, exec treats a discrete list of arguments as an
2175 # indication that it should bypass shell processing. However, there is one
2176 # place where you might still get tripped up. The exec call (and system, too)
2177 # will not distinguish between a single scalar argument and an array containing
2178 # only one element.
2179 #
2180 # @args = ("echo surprise"); # just one element in list
2181 # exec @args # still subject to shell escapes
2182 # or die "exec: $!"; # because @args == 1
2183 #
2184 # To avoid this, you can use the PATHNAME syntax, explicitly duplicating the
2185 # first argument as the pathname, which forces the rest of the arguments to be
2186 # interpreted as a list, even if there is only one of them:
2187 #
2188 # exec { $args[0] } @args # safe even with one-argument list
2189 # or die "can't exec @args: $!";
2190  
2191 # P.855 exec
2192 # in Chapter 27: Functions
2193 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2194 #
2195 # As we mentioned earlier, exec treats a discrete list of arguments as a
2196 # directive to bypass shell processing. However, there is one place where
2197 # you might still get tripped up. The exec call (and system, too) cannot
2198 # distinguish between a single scalar argument and an array containing
2199 # only one element.
2200 #
2201 # @args = ("echo surprise"); # just one element in list
2202 # exec @args # still subject to shell escapes
2203 # || die "exec: $!"; # because @args == 1
2204 #
2205 # To avoid this, use the PATHNAME syntax, explicitly duplicating the first
2206 # argument as the pathname, which forces the rest of the arguments to be
2207 # interpreted as a list, even if there is only one of them:
2208 #
2209 # exec { $args[0] } @args # safe even with one-argument list
2210 # || die "can't exec @args: $!";
2211  
2212 211 return CORE::system { $_[0] } @_; # safe even with one-argument list
2213 }
2214  
2215 #
2216 # KOI8-R order to character (with parameter)
2217 #
2218 3469 ▶sub Ekoi8r::chr(;$) {
Subroutine chr: called CC=4 SCAR=13.9
Pod undocumented
2219  
2220 3469 ▶ my $c = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3469 0 3469
2221  
2222 3469 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 24 3445 3469
2223 24 return "\x00";
2224 }
2225 else {
2226 3445 my @chr = ();
2227 3445 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 3445 3445 6890
2228 3445 unshift @chr, ($c % 0x100);
2229 3445 $c = int($c / 0x100);
2230 }
2231 3445 return pack 'C*', @chr;
2232 }
2233 }
2234  
2235 #
2236 # KOI8-R order to character (without parameter)
2237 #
2238 0 ▶sub Ekoi8r::chr_() {
Subroutine chr_: not called CC=3 SCAR=24.8
Pod undocumented
2239  
2240 0 my $c = $_;
2241  
2242 0 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 0 0 0
2243 0 return "\x00";
2244 }
2245 else {
2246 0 my @chr = ();
2247 0 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 0 0 0
2248 0 unshift @chr, ($c % 0x100);
2249 0 $c = int($c / 0x100);
2250 }
2251 0 return pack 'C*', @chr;
2252 }
2253 }
2254  
2255 #
2256 # KOI8-R path globbing (with parameter)
2257 #
2258 0 ▶sub Ekoi8r::glob($) {
Subroutine glob: not called CC=3 SCAR=24.8
Pod undocumented
2259  
2260 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2261 0 my @glob = _DOS_like_glob(@_);
2262 0 for my $glob (@glob) {
2263 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2264 }
2265 0 return @glob;
2266 }
2267 else {
2268 0 my $glob = _DOS_like_glob(@_);
2269 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2270 0 return $glob;
2271 }
2272 }
2273  
2274 #
2275 # KOI8-R path globbing (without parameter)
2276 #
2277 0 ▶sub Ekoi8r::glob_() {
Subroutine glob_: not called CC=3 SCAR=24.8
Pod undocumented
2278  
2279 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2280 0 my @glob = _DOS_like_glob();
2281 0 for my $glob (@glob) {
2282 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2283 }
2284 0 return @glob;
2285 }
2286 else {
2287 0 my $glob = _DOS_like_glob();
2288 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2289 0 return $glob;
2290 }
2291 }
2292  
2293 #
2294 # KOI8-R path globbing via File::DosGlob 1.10
2295 #
2296 # Often I confuse "_dosglob" and "_doglob".
2297 # So, I renamed "_dosglob" to "_DOS_like_glob".
2298 #
2299 422 my %iter;
2300 my %entries;
2301 0 ▶sub _DOS_like_glob {
Subroutine _DOS_like_glob: not called CC=10 SCAR=47.0
2302  
2303 # context (keyed by second cxix argument provided by core)
2304 0 my($expr,$cxix) = @_;
2305  
2306 # glob without args defaults to $_
2307 0 ▶ $expr = $_ if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2308  
2309 # represents the current user's home directory
2310 #
2311 # 7.3. Expanding Tildes in Filenames
2312 # in Chapter 7. File Access
2313 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2314 #
2315 # and File::HomeDir, File::HomeDir::Windows module
2316  
2317 # DOS-like system
2318 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
2319 0 $expr =~ s{ \A ~ (?= [^/\\] ) }
2320 0 { my_home_MSWin32() }oxmse;
2321 }
2322  
2323 # UNIX-like system
2324 else {
2325 0 $expr =~ s{ \A ~ ( (?:[^/])* ) }
2326 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
2327 }
2328  
2329 # assume global context if not provided one
2330 0 ▶ $cxix = '_G_' if not defined $cxix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cxix 0 0 0
2331 0 ▶ $iter{$cxix} = 0 if not exists $iter{$cxix};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $iter{$cxix} 0 0 0
2332  
2333 # if we're just beginning, do it all first
2334 0 ▶ if ($iter{$cxix} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} == 0) 0 0 0
2335 0 $entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ];
2336 }
2337  
2338 # chuck it all out, quick or slow
2339 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2340 0 delete $iter{$cxix};
2341 0 return @{delete $entries{$cxix}};
2342 }
2343 else {
2344 0 ▶ if ($iter{$cxix} = scalar @{$entries{$cxix}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} = scalar @{$entries{$cxix};}) { } 0 0 0
2345 0 return shift @{$entries{$cxix}};
2346 }
2347 else {
2348 # return undef for EOL
2349 0 delete $iter{$cxix};
2350 0 delete $entries{$cxix};
2351 0 return undef;
2352 }
2353 }
2354 }
2355  
2356 #
2357 # KOI8-R path globbing subroutine
2358 #
2359 0 ▶sub _do_glob {
Subroutine _do_glob: not called CC=44 SCAR=75.9
2360  
2361 0 my($cond,@expr) = @_;
2362 0 my @glob = ();
2363 0 my $fix_drive_relative_paths = 0;
2364  
2365 OUTER:
2366 0 for my $expr (@expr) {
2367 0 ▶ next OUTER if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2368 0 ▶ next OUTER if $expr eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $expr eq "" 0 0 0
2369  
2370 0 my @matched = ();
2371 0 my @globdir = ();
2372 0 my $head = '.';
2373 0 my $pathsep = '/';
2374 0 my $tail;
2375  
2376 # if argument is within quotes strip em and do no globbing
2377 0 ▶ if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ /\A " ((?:$Ekoi8r::q_char)*?) " \z/mosx) 0 0 0
2378 0 $expr = $1;
2379 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2380 0 ▶ if (-d $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $expr) 0 0 0
2381 0 push @glob, $expr;
2382 }
2383 }
2384 else {
2385 0 ▶ if (-e $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $expr) 0 0 0
2386 0 push @glob, $expr;
2387 }
2388 }
2389 0 next OUTER;
2390 }
2391  
2392 # wildcards with a drive prefix such as h:*.pm must be changed
2393 # to h:./*.pm to expand correctly
2394 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
2395 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
2396 0 $fix_drive_relative_paths = 1;
2397 }
2398 }
2399  
2400 0 ▶ if (($head, $tail) = _parse_path($expr,$pathsep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($head, $tail) = _parse_path($expr, $pathsep)) 0 0 0
2401 0 ▶ if ($tail eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail eq "") 0 0 0
2402 0 push @glob, $expr;
2403 0 next OUTER;
2404 }
2405 0 ▶ if ($head =~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ / \A (?:$Ekoi8r::q_char)*? [*?] /mosx) 0 0 0
2406 0 ▶ if (@globdir = _do_glob('d', $head)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@globdir = _do_glob("d", $head)) 0 0 0
2407 0 push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir);
2408 0 next OUTER;
2409 }
2410 }
2411 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
2412 0 $head .= $pathsep;
2413 }
2414 0 $expr = $tail;
2415 }
2416  
2417 # If file component has no wildcards, we can avoid opendir
2418 0 ▶ if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expr =~ / \A (?:$Ekoi8r::q_char)*? [*?] /mosx) 0 0 0
2419 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2420 0 $head = '';
2421 }
2422 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2423 0 $head .= $pathsep;
2424 }
2425 0 $head .= $expr;
2426 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2427 0 ▶ if (-d $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $head) 0 0 0
2428 0 push @glob, $head;
2429 }
2430 }
2431 else {
2432 0 ▶ if (-e $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $head) 0 0 0
2433 0 push @glob, $head;
2434 }
2435 }
2436 0 next OUTER;
2437 }
2438 0 ▶ opendir(*DIR, $head) or next OUTER;
Branch: 1 branch
BranchTrueFalseTotal
opendir *DIR, $head or next OUTER 0 0 0
2439 0 my @leaf = readdir DIR;
2440 0 closedir DIR;
2441  
2442 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2443 0 $head = '';
2444 }
2445 0 ▶ if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep) 0 0 0
Condition0%0/3
$head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
!ll&&!rl&&r
000
MC/DC0%0/2
$head ne "" and ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
$head ne "" ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
Truth table0%0/3
A and B
A= $head ne ""B= ($head =~ / \G ($Ekoi8r::q_char) /gmosx)[-1] ne $pathsep
ABresult
0X0
100
111
2446 0 $head .= $pathsep;
2447 }
2448  
2449 0 my $pattern = '';
2450 0 ▶ while ($expr =~ / \G ($q_char) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ / \G ($Ekoi8r::q_char) /cgox) 0 0 0
2451 0 my $char = $1;
2452  
2453 # 6.9. Matching Shell Globs as Regular Expressions
2454 # in Chapter 6. Pattern Matching
2455 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2456 # (and so on)
2457  
2458 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
2459 0 $pattern .= "(?:$your_char)*",
2460 }
2461 elsif ($char eq '?') {
2462 0 $pattern .= "(?:$your_char)?", # DOS style
2463 # $pattern .= "(?:$your_char)", # UNIX style
2464 }
2465 elsif ((my $fc = Ekoi8r::fc($char)) ne $char) {
2466 0 $pattern .= $fc;
2467 }
2468 else {
2469 0 $pattern .= quotemeta $char;
2470 }
2471 }
2472 0 ▶ my $matchsub = sub { Ekoi8r::fc($_[0]) =~ /\A $pattern \z/xms };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2473  
2474 # if ($@) {
2475 # print STDERR "$0: $@\n";
2476 # next OUTER;
2477 # }
2478  
2479 INNER:
2480 0 for my $leaf (@leaf) {
2481 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
2482 0 next INNER;
2483 }
2484 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
2485 0 next INNER;
2486 }
2487  
2488 0 ▶ if (&$matchsub($leaf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub($leaf)) 0 0 0
2489 0 push @matched, "$head$leaf";
2490 0 next INNER;
2491 }
2492  
2493 # [DOS compatibility special case]
2494 # Failed, add a trailing dot and try again, but only...
2495  
2496 0 ▶ if (Ekoi8r::index($leaf,'.') == -1 and # if name does not have a dot in it *and*
Branch: 1 branch
BranchTrueFalseTotal
if (&Ekoi8r::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8r::index($pattern, "\\.") != -1) 0 0 0
Condition0%0/6
&Ekoi8r::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8r::index($pattern, "\\.") != -1
!ll&&!rl&&r
000
&Ekoi8r::index($leaf, ".") == -1 and length $leaf <= 8
!ll&&!rl&&r
000
MC/DC0%0/3
&Ekoi8r::index($leaf, ".") == -1 and length $leaf <= 8 and &Ekoi8r::index($pattern, "\\.") != -1
&Ekoi8r::index($leaf, ".") == -1 length $leaf <= 8 &Ekoi8r::index($pattern, "\\.") != -1
Truth table0%0/4
A and B and C
A= &Ekoi8r::index($leaf, ".") == -1B= length $leaf <= 8C= &Ekoi8r::index($pattern, "\\.") != -1
ABCresult
0XX0
10X0
1100
1111
2497 CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and*
2498 Ekoi8r::index($pattern,'\\.') != -1 # pattern has a dot.
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 }
2506 0 ▶ if (@matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matched) 0 0 0
2507 0 push @glob, @matched;
2508 }
2509 }
2510 0 ▶ if ($fix_drive_relative_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fix_drive_relative_paths) 0 0 0
2511 0 for my $glob (@glob) {
2512 0 $glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms;
2513 }
2514 }
2515 0 return @glob;
2516 }
2517  
2518 #
2519 # KOI8-R parse line
2520 #
2521 0 ▶sub _parse_line {
Subroutine _parse_line: not called CC=3 SCAR=24.8
2522  
2523 0 my($line) = @_;
2524  
2525 0 $line .= ' ';
2526 0 my @piece = ();
2527 0 ▶ while ($line =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / " ( (?>(?: [^"] )* ) ) " (?>\s+) | ( (?>(?: [^"\s] )* ) ) (?>\s+) /gmosx) 0 0 0
2528 " ( (?>(?: [^"] )* ) ) " (?>\s+) |
2529 ( (?>(?: [^"\s] )* ) ) (?>\s+)
2530 /oxmsg
2531 ) {
2532 0 ▶ push @piece, defined($1) ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
2533 }
2534 0 return @piece;
2535 }
2536  
2537 #
2538 # KOI8-R parse path
2539 #
2540 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=2 SCAR=17.9
2541  
2542 0 my($path,$pathsep) = @_;
2543  
2544 0 $path .= '/';
2545 0 my @subpath = ();
2546 0 ▶ while ($path =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m( ((?: [^/\\] )+?) [/\\] )gmosx) 0 0 0
2547 ((?: [^\/\\] )+?) [\/\\]
2548 /oxmsg
2549 ) {
2550 0 push @subpath, $1;
2551 }
2552  
2553 0 my $tail = pop @subpath;
2554 0 my $head = join $pathsep, @subpath;
2555 0 return $head, $tail;
2556 }
2557  
2558 #
2559 # via File::HomeDir::Windows 1.00
2560 #
2561 0 ▶sub my_home_MSWin32 {
Subroutine my_home_MSWin32: not called CC=9 SCAR=45.0
Pod undocumented
2562  
2563 # A lot of unix people and unix-derived tools rely on
2564 # the ability to overload HOME. We will support it too
2565 # so that they can replace raw HOME calls with File::HomeDir.
2566 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
2567 0 return $ENV{'HOME'};
2568 }
2569  
2570 # Do we have a user profile?
2571 ▶ 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
2572 0 return $ENV{'USERPROFILE'};
2573 }
2574  
2575 # Some Windows use something like $ENV{'HOME'}
2576 ▶ 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
2577 0 return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
2578 }
2579  
2580 0 return undef;
2581 }
2582  
2583 #
2584 # via File::HomeDir::Unix 1.00
2585 #
2586 0 ▶sub my_home {
Subroutine my_home: not called CC=7 SCAR=40.3
Pod undocumented
2587 0 my $home;
2588  
2589 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
2590 0 $home = $ENV{'HOME'};
2591 }
2592  
2593 # This is from the original code, but I'm guessing
2594 # it means "login directory" and exists on some Unixes.
2595 ▶ 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
2596 0 $home = $ENV{'LOGDIR'};
2597 }
2598  
2599 ### More-desperate methods
2600  
2601 # Light desperation on any (Unixish) platform
2602 else {
2603 0 $home = CORE::eval q{ (getpwuid($<))[7] };
2604 }
2605  
2606 # On Unix in general, a non-existant home means "no home"
2607 # For example, "nobody"-like users might use /nonexistant
2608 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
2609 0 $home = undef;
2610 }
2611 0 return $home;
2612 }
2613  
2614 #
2615 # ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched
2616 #
2617 56 ▶sub Ekoi8r::PREMATCH {
Subroutine PREMATCH: called CC=1 SCAR=0.0
Pod undocumented
2618 56 return $`;
2619 }
2620  
2621 #
2622 # ${^MATCH}, $MATCH, $& the string that matched
2623 #
2624 81 ▶sub Ekoi8r::MATCH {
Subroutine MATCH: called CC=1 SCAR=0.0
Pod undocumented
2625 81 return $&;
2626 }
2627  
2628 #
2629 # ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched
2630 #
2631 42 ▶sub Ekoi8r::POSTMATCH {
Subroutine POSTMATCH: called CC=1 SCAR=0.0
Pod undocumented
2632 42 return $';
2633 }
2634  
2635 #
2636 # KOI8-R character to order (with parameter)
2637 #
2638 0 ▶sub KOI8R::ord(;$) {
Subroutine ord: not called CC=4 SCAR=30.0
2639  
2640 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2641  
2642 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8r::q_char) /mosx) { } 0 0 0
2643 0 my @ord = unpack 'C*', $1;
2644 0 my $ord = 0;
2645 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2646 0 $ord = $ord * 0x100 + $o;
2647 }
2648 0 return $ord;
2649 }
2650 else {
2651 0 return CORE::ord $_;
2652 }
2653 }
2654  
2655 #
2656 # KOI8-R character to order (without parameter)
2657 #
2658 0 ▶sub KOI8R::ord_() {
Subroutine ord_: not called CC=3 SCAR=24.8
2659  
2660 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8r::q_char) /mosx) { } 0 0 0
2661 0 my @ord = unpack 'C*', $1;
2662 0 my $ord = 0;
2663 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2664 0 $ord = $ord * 0x100 + $o;
2665 }
2666 0 return $ord;
2667 }
2668 else {
2669 0 return CORE::ord $_;
2670 }
2671 }
2672  
2673 #
2674 # KOI8-R reverse
2675 #
2676 0 ▶sub KOI8R::reverse(@) {
Subroutine reverse: not called CC=2 SCAR=17.9
2677  
2678 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2679 0 return CORE::reverse @_;
2680 }
2681 else {
2682  
2683 # One of us once cornered Larry in an elevator and asked him what
2684 # problem he was solving with this, but he looked as far off into
2685 # the distance as he could in an elevator and said, "It seemed like
2686 # a good idea at the time."
2687  
2688 0 return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg);
2689 }
2690 }
2691  
2692 #
2693 # KOI8-R getc (with parameter, without parameter)
2694 #
2695 20 ▶sub KOI8R::getc(;*@) {
Subroutine getc: called CC=9 SCAR=26.7
2696  
2697 20 my($package) = caller;
2698 20 ▶ my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 20 0 20
2699 20 ▶ croak 'Too many arguments for KOI8R::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
2700  
2701 0 my @length = sort { $a <=> $b } keys %range_tr;
2702 20 my $getc = '';
2703 20 for my $length ($length[0] .. $length[-1]) {
2704 20 $getc .= CORE::getc($fh);
2705 20 ▶ if (exists $range_tr{CORE::length($getc)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{length $getc}) 20 0 20
2706 20 ▶ if ($getc =~ /\A ${Ekoi8r::dot_s} \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A $Ekoi8r::dot_s \z/mosx) 20 0 20
2707 20 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 20 20
2708 }
2709 }
2710 }
2711 0 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2712 }
2713  
2714 #
2715 # KOI8-R length by character
2716 #
2717 0 ▶sub KOI8R::length(;$) {
Subroutine length: not called CC=2 SCAR=17.9
2718  
2719 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2720  
2721 0 local @_ = /\G ($q_char) /oxmsg;
2722 0 return scalar @_;
2723 }
2724  
2725 #
2726 # KOI8-R substr by character
2727 #
2728 422 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
2729  
2730 # P.232 The lvalue Attribute
2731 # in Chapter 6: Subroutines
2732 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2733  
2734 # P.336 The lvalue Attribute
2735 # in Chapter 7: Subroutines
2736 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2737  
2738 # P.144 8.4 Lvalue subroutines
2739 # in Chapter 8: perlsub: Perl subroutines
2740 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
2741  
2742 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
2743 # vv----------------------*******
2744 sub KOI8R::substr($$;$$) %s {
2745  
2746 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
2747  
2748 # If the substring is beyond either end of the string, substr() returns the undefined
2749 # value and produces a warning. When used as an lvalue, specifying a substring that
2750 # is entirely outside the string raises an exception.
2751 # http://perldoc.perl.org/functions/substr.html
2752  
2753 # A return with no argument returns the scalar value undef in scalar context,
2754 # an empty list () in list context, and (naturally) nothing at all in void
2755 # context.
2756  
2757 my $offset = $_[1];
2758 if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) {
2759 return;
2760 }
2761  
2762 # substr($string,$offset,$length,$replacement)
2763 if (@_ == 4) {
2764 my(undef,undef,$length,$replacement) = @_;
2765 my $substr = join '', splice(@char, $offset, $length, $replacement);
2766 $_[0] = join '', @char;
2767  
2768 # return $substr; this doesn't work, don't say "return"
2769 $substr;
2770 }
2771  
2772 # substr($string,$offset,$length)
2773 elsif (@_ == 3) {
2774 my(undef,undef,$length) = @_;
2775 my $octet_offset = 0;
2776 my $octet_length = 0;
2777 if ($offset == 0) {
2778 $octet_offset = 0;
2779 }
2780 elsif ($offset > 0) {
2781 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2782 }
2783 else {
2784 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2785 }
2786 if ($length == 0) {
2787 $octet_length = 0;
2788 }
2789 elsif ($length > 0) {
2790 $octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]);
2791 }
2792 else {
2793 $octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]);
2794 }
2795 CORE::substr($_[0], $octet_offset, $octet_length);
2796 }
2797  
2798 # substr($string,$offset)
2799 else {
2800 my $octet_offset = 0;
2801 if ($offset == 0) {
2802 $octet_offset = 0;
2803 }
2804 elsif ($offset > 0) {
2805 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2806 }
2807 else {
2808 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2809 }
2810 CORE::substr($_[0], $octet_offset);
2811 }
2812 }
2813 END
2814 }
2815  
2816 #
2817 # KOI8-R index by character
2818 #
2819 0 ▶sub KOI8R::index($$;$) {
Subroutine index: not called CC=3 SCAR=24.8
2820  
2821 0 my $index;
2822 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2823 0 $index = Ekoi8r::index($_[0], $_[1], CORE::length(KOI8R::substr($_[0], 0, $_[2])));
2824 }
2825 else {
2826 0 $index = Ekoi8r::index($_[0], $_[1]);
2827 }
2828  
2829 0 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 0 0 0
2830 0 return -1;
2831 }
2832 else {
2833 0 return KOI8R::length(CORE::substr $_[0], 0, $index);
2834 }
2835 }
2836  
2837 #
2838 # KOI8-R rindex by character
2839 #
2840 0 ▶sub KOI8R::rindex($$;$) {
Subroutine rindex: not called CC=3 SCAR=24.8
2841  
2842 0 my $rindex;
2843 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2844 0 $rindex = Ekoi8r::rindex($_[0], $_[1], CORE::length(KOI8R::substr($_[0], 0, $_[2])));
2845 }
2846 else {
2847 0 $rindex = Ekoi8r::rindex($_[0], $_[1]);
2848 }
2849  
2850 0 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 0 0 0
2851 0 return -1;
2852 }
2853 else {
2854 0 return KOI8R::length(CORE::substr $_[0], 0, $rindex);
2855 }
2856 }
2857  
2858 # when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??'
2859 # when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else)
2860 422 ▶use vars qw($slash); $slash = 'm//';
Subroutine BEGIN: called CC=1 SCAR=0.0
2861  
2862 # ord() to ord() or KOI8R::ord()
2863 422 my $function_ord = 'ord';
2864  
2865 # ord to ord or KOI8R::ord_
2866 422 my $function_ord_ = 'ord';
2867  
2868 # reverse to reverse or KOI8R::reverse
2869 422 my $function_reverse = 'reverse';
2870  
2871 # getc to getc or KOI8R::getc
2872 422 my $function_getc = 'getc';
2873  
2874 # P.1023 Appendix W.9 Multibyte Anchoring
2875 # of ISBN 1-56592-224-7 CJKV Information Processing
2876  
2877 422 my $anchor = '';
2878  
2879 422 ▶use vars qw($nest);
Subroutine BEGIN: called CC=1 SCAR=0.0
2880  
2881 # regexp of nested parens in qqXX
2882  
2883 # P.340 Matching Nested Constructs with Embedded Code
2884 # in Chapter 7: Perl
2885 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2886  
2887 my $qq_paren = qr{(?{local $nest=0}) (?>(?:
2888 [^\\()] |
2889 \( (?{$nest++}) |
2890 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2891 \\ [^c] |
2892 \\c[\x40-\x5F] |
2893 [\x00-\xFF]
2894 422 }xms;
2895  
2896 my $qq_brace = qr{(?{local $nest=0}) (?>(?:
2897 [^\\{}] |
2898 \{ (?{$nest++}) |
2899 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2900 \\ [^c] |
2901 \\c[\x40-\x5F] |
2902 [\x00-\xFF]
2903 422 }xms;
2904  
2905 my $qq_bracket = qr{(?{local $nest=0}) (?>(?:
2906 [^\\\[\]] |
2907 \[ (?{$nest++}) |
2908 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2909 \\ [^c] |
2910 \\c[\x40-\x5F] |
2911 [\x00-\xFF]
2912 422 }xms;
2913  
2914 my $qq_angle = qr{(?{local $nest=0}) (?>(?:
2915 [^\\<>] |
2916 \< (?{$nest++}) |
2917 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2918 \\ [^c] |
2919 \\c[\x40-\x5F] |
2920 [\x00-\xFF]
2921 422 }xms;
2922  
2923 422 my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} |
2924 (?: ::)? (?:
2925 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2926 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2927 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2928 ))
2929 }xms;
2930  
2931 422 my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} |
2932 (?: ::)? (?:
2933 (?>[0-9]+) |
2934 [^a-zA-Z_0-9\[\]] |
2935 ^[A-Z] |
2936 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2937 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2938 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2939 ))
2940 }xms;
2941  
2942 422 my $qq_substr = qr{(?> Char::substr | KOI8R::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \)
2943 }xms;
2944  
2945 # regexp of nested parens in qXX
2946 my $q_paren = qr{(?{local $nest=0}) (?>(?:
2947 [^()] |
2948 \( (?{$nest++}) |
2949 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2950 [\x00-\xFF]
2951 422 }xms;
2952  
2953 my $q_brace = qr{(?{local $nest=0}) (?>(?:
2954 [^\{\}] |
2955 \{ (?{$nest++}) |
2956 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2957 [\x00-\xFF]
2958 422 }xms;
2959  
2960 my $q_bracket = qr{(?{local $nest=0}) (?>(?:
2961 [^\[\]] |
2962 \[ (?{$nest++}) |
2963 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2964 [\x00-\xFF]
2965 422 }xms;
2966  
2967 my $q_angle = qr{(?{local $nest=0}) (?>(?:
2968 [^<>] |
2969 \< (?{$nest++}) |
2970 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2971 [\x00-\xFF]
2972 422 }xms;
2973  
2974 422 my $matched = '';
2975 422 my $s_matched = '';
2976  
2977 422 my $tr_variable = ''; # variable of tr///
2978 422 my $sub_variable = ''; # variable of s///
2979 422 my $bind_operator = ''; # =~ or !~
2980  
2981 422 my @heredoc = (); # here document
2982 422 my @heredoc_delimiter = ();
2983 422 my $here_script = ''; # here script
2984  
2985 #
2986 # escape KOI8-R script
2987 #
2988 547 ▶sub KOI8R::escape(;$) {
Subroutine escape: called CC=3 SCAR=11.0
2989 547 ▶ local($_) = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 292 255 547
2990  
2991 # P.359 The Study Function
2992 # in Chapter 7: Perl
2993 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2994  
2995 547 study $_; # Yes, I studied study yesterday.
2996  
2997 # while all script
2998  
2999 # 6.14. Matching from Where the Last Pattern Left Off
3000 # in Chapter 6. Pattern Matching
3001 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
3002 # (and so on)
3003  
3004 # one member of Tag-team
3005 #
3006 # P.128 Start of match (or end of previous match): \G
3007 # P.130 Advanced Use of \G with Perl
3008 # in Chapter 3: Overview of Regular Expression Features and Flavors
3009 # P.255 Use leading anchors
3010 # P.256 Expose ^ and \G at the front expressions
3011 # in Chapter 6: Crafting an Efficient Expression
3012 # P.315 "Tag-team" matching with /gc
3013 # in Chapter 7: Perl
3014 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3015  
3016 547 my $e_script = '';
3017 547 ▶ while (not /\G \z/oxgc) { # member
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 86150 547 86697
3018 86150 $e_script .= KOI8R::escape_token();
3019 }
3020  
3021 547 return $e_script;
3022 }
3023  
3024 #
3025 # escape KOI8-R token of script
3026 #
3027 86150 ▶sub KOI8R::escape_token {
Subroutine escape_token: called CC=504 SCAR=109.3
3028  
3029 # \n output here document
3030  
3031 86150 my $ignore_modules = join('|', qw(
3032 utf8
3033 bytes
3034 charnames
3035 I18N::Japanese
3036 I18N::Collate
3037 I18N::JExt
3038 File::DosGlob
3039 Wild
3040 Wildcard
3041 Japanese
3042 ));
3043  
3044 # another member of Tag-team
3045 #
3046 # P.315 "Tag-team" matching with /gc
3047 # in Chapter 7: Perl
3048 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3049  
3050 86150 ▶ if (/\G ( \n ) /oxgc) { # another member (and so on)
Branch: 139 branches
BranchTrueFalseTotal
if (/\G ( \n ) /cgox) { } 12799 73351 86150
elsif (/\G ((?>\s+)|\#.*) /cgox) { } 21263 52088 73351
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /cgox) { } 1644 50444 52088
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /cgox) { } 90 50354 50444
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx) { } 4 50350 50354
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 28 50322 50350
elsif (/\G ( \$' | \$\{'\} ) /cgmosx) { } 1 50321 50322
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 3 50318 50321
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /cgox) { } 1752 48566 50318
elsif (/\G ( [,;] ) /cgox) { } 5058 43508 48566
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 43508 43508
elsif (/\G ( \$ 0 ) /cgmosx) { } 2 43506 43508
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 43506 43506
elsif (/\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 1 43505 43506
elsif (/\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 4 43501 43505
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 43501 43501
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 43501 43501
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 43501 43501
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 43501 43501
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /cgmosx) { } 0 43501 43501
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 0 43501 43501
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 43459 43501
elsif (m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 63 43396 43459
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /cgox) { } 0 43396 43396
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /cgox) { } 0 43396 43396
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /cgox) { } 0 43396 43396
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /cgox) { } 0 43396 43396
elsif (/\G \b ( if | unless | while | until | for | when ) \b /cgox) { } 251 43145 43396
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 19 43126 43145
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 43126 43126
elsif (/\G \b KOI8R::eval (?= (?>\s*) \{ ) /cgox) { } 22 43104 43126
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /cgox) { } 0 43104 43104
elsif (/\G \b KOI8R::eval \b (?! (?>\s*) => ) /cgox) { } 168 42936 43104
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /cgox) { } 2 42934 42936
elsif (/\G \b chop \b (?! (?>\s*) => ) /cgox) { } 0 42934 42934
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /cgox) { } 2 42932 42934
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /cgox) { } 0 42932 42932
elsif (/\G \b KOI8R::index \b (?! (?>\s*) => ) /cgox) { } 0 42932 42932
elsif (/\G \b index \b (?! (?>\s*) => ) /cgox) { } 0 42932 42932
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /cgox) { } 2 42930 42932
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42930 42930
elsif (/\G \b KOI8R::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42930 42930
elsif (/\G \b rindex \b (?! (?>\s*) => ) /cgox) { } 0 42930 42930
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42929 42930
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42929 42929
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42928 42929
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42928 42928
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 6 42922 42928
elsif (/\G -s (?>\s*) (\") ((?:$Ekoi8r::qq_char)+?) (\") /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Ekoi8r::qq_char)+?) (\#) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Ekoi8r::qq_char)+?) (\1) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Ekoi8r::q_char)+?) (\') /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)+?) (\#) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Ekoi8r::q_char)+?) (\1) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 42922 42922
elsif (/\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 42922 42922
elsif (/\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 42922 42922
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42920 42922
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42918 42920
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 36 42882 42918
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42880 42882
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 8 42872 42880
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42872 42872
elsif (/\G \b lc \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b uc \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b fc \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G -s \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b chr \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b ord \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b glob \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b reverse \b (?! (?>\s*) => ) /cgox) { } 0 42872 42872
elsif (/\G \b getc \b (?! (?>\s*) => ) /cgox) { } 8 42864 42872
elsif (/\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 87 42777 42864
elsif (/\G \b ( tr | y ) \b /cgox) { } 4 42773 42777
elsif (/\G \b (qq) \b /cgox) { } 2252 40521 42773
elsif (/\G \b (qr) \b /cgox) { } 0 40521 40521
elsif (/\G \b (qw) \b /cgox) { } 16 40505 40521
elsif (/\G \b (qx) \b /cgox) { } 0 40505 40505
elsif (/\G \b (q) \b /cgox) { } 473 40032 40505
elsif (/\G \b (m) \b /cgox) { } 209 39823 40032
elsif (/\G \b (s) \b /cgox) { } 101 39722 39823
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39722 39722
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39722 39722
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39722 39722
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /cgmosx) { } 37 39685 39722
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39685 39685
elsif (/\G \b use ((?>\s+) strict) \b /cgmosx) { } 0 39685 39685
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 2 39683 39685
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 0 39683 39683
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 2 39681 39683
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39681 39681
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39681 39681
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39681 39681
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39681 39681
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39681 39681
elsif (/\G \b use \b /cgmosx) { } 0 39681 39681
elsif (/\G \b no \b /cgmosx) { } 2 39679 39681
elsif (/\G (?<![\w\$\@\%\&\*]) (\') /cgox) { } 1142 38537 39679
elsif (/\G (\") /cgox) { } 1873 36664 38537
elsif (/\G (\`) /cgox) { } 1 36663 36664
elsif ($Ekoi8r::slash eq 'm//' and m[\G (/) ]cgox) { } 681 35982 36663
elsif ($Ekoi8r::slash eq 'm//' and /\G (\?) /cgox) { } 0 35982 35982
elsif (/\G ( <<>> ) /cgox) { } 0 35982 35982
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 35982 35982
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 6 35976 35982
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 3 35973 35976
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 6 35967 35973
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 3 35964 35967
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 6 35958 35964
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 72 35886 35958
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 35886 35886
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 36 35850 35886
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 42 35808 35850
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 35808 35808
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 12 35796 35808
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 35796 35796
elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /cgox) { } 0 35796 35796
elsif (/\G ^ ( __DATA__ \n .*) \z /cgmosx) { } 0 35796 35796
elsif (/\G ^ ( __END__ \n .*) \z /cgmosx) { } 210 35586 35796
elsif (/\G ( \cD .*) \z /cgmosx) { } 0 35586 35586
elsif (/\G ( \cZ .*) \z /cgmosx) { } 0 35586 35586
elsif (/\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 5837 29749 35586
elsif (/\G ( \.\.\. ) /cgox) { } 7 29742 29749
elsif (m"\G ((?> !~~ | !~ | != | ! | %= | % | &&= | && | &= | &\.= | &\. | & | -= | -> | - | :(?>\s*)= | : | <<>> | <<= | <=> | <= | < | == | => | =~ | = | >>= | >> | >= | > | \*\*= | \*\* | \*= | \* | \+= | \+ | \.\. | \.= | \. | //= | // | /= | / | \? | \\ | \^= | \^\.= | \^\. | \^ | \b x= | \|\|= | \|\| | \|= | \|\.= | \|\. | \| | ~~ | ~\. | ~ | \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | \b(?: print )\b | [,;\(\{\[] )) "cgox) { } 9766 19976 29742
elsif (/\G ($Ekoi8r::q_char) /cgox) { } 19976 0 19976
3051 12799 my $heredoc = '';
3052 12799 ▶ if (scalar(@heredoc_delimiter) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @heredoc_delimiter >= 1) 174 12625 12799
3053 174 $slash = 'm//';
3054  
3055 174 $heredoc = join '', @heredoc;
3056 174 @heredoc = ();
3057  
3058 # skip here document
3059 174 for my $heredoc_delimiter (@heredoc_delimiter) {
3060 174 /\G .*? \n $heredoc_delimiter \n/xmsgc;
3061 }
3062 174 @heredoc_delimiter = ();
3063  
3064 174 $here_script = '';
3065 }
3066 12799 return "\n" . $heredoc;
3067 }
3068  
3069 # ignore space, comment
3070 21263 elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; }
3071  
3072 # if (, elsif (, unless (, while (, until (, given (, and when (
3073  
3074 # given, when
3075  
3076 # P.225 The given Statement
3077 # in Chapter 15: Smart Matching and given-when
3078 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3079  
3080 # P.133 The given Statement
3081 # in Chapter 4: Statements and Declarations
3082 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3083  
3084 elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) {
3085 1644 $slash = 'm//';
3086 1644 return $1;
3087 }
3088  
3089 # scalar variable ($scalar = ...) =~ tr///;
3090 # scalar variable ($scalar = ...) =~ s///;
3091  
3092 # state
3093  
3094 # P.68 Persistent, Private Variables
3095 # in Chapter 4: Subroutines
3096 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3097  
3098 # P.160 Persistent Lexically Scoped Variables: state
3099 # in Chapter 4: Statements and Declarations
3100 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3101  
3102 # (and so on)
3103  
3104 elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) {
3105 90 my $e_string = e_string($1);
3106  
3107 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
3108 0 $tr_variable = $e_string . e_string($1);
3109 0 $bind_operator = $2;
3110 0 $slash = 'm//';
3111 0 return '';
3112 }
3113 elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3114 0 $sub_variable = $e_string . e_string($1);
3115 0 $bind_operator = $2;
3116 0 $slash = 'm//';
3117 0 return '';
3118 }
3119 else {
3120 90 $slash = 'div';
3121 90 return $e_string;
3122 }
3123 }
3124  
3125 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
3126 elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
3127 4 $slash = 'div';
3128 4 return q{Ekoi8r::PREMATCH()};
3129 }
3130  
3131 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
3132 elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
3133 28 $slash = 'div';
3134 28 return q{Ekoi8r::MATCH()};
3135 }
3136  
3137 # $', ${'} --> $', ${'}
3138 elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) {
3139 1 $slash = 'div';
3140 1 return $1;
3141 }
3142  
3143 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
3144 elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
3145 3 $slash = 'div';
3146 3 return q{Ekoi8r::POSTMATCH()};
3147 }
3148  
3149 # scalar variable $scalar =~ tr///;
3150 # scalar variable $scalar =~ s///;
3151 # substr() =~ tr///;
3152 # substr() =~ s///;
3153 elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) {
3154 1752 my $scalar = e_string($1);
3155  
3156 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
3157 2 $tr_variable = $scalar;
3158 2 $bind_operator = $1;
3159 2 $slash = 'm//';
3160 2 return '';
3161 }
3162 elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3163 65 $sub_variable = $scalar;
3164 65 $bind_operator = $1;
3165 65 $slash = 'm//';
3166 65 return '';
3167 }
3168 else {
3169 1685 $slash = 'div';
3170 1685 return $scalar;
3171 }
3172 }
3173  
3174 # end of statement
3175 elsif (/\G ( [,;] ) /oxgc) {
3176 5058 $slash = 'm//';
3177  
3178 # clear tr/// variable
3179 5058 $tr_variable = '';
3180  
3181 # clear s/// variable
3182 5058 $sub_variable = '';
3183  
3184 5058 $bind_operator = '';
3185  
3186 5058 return $1;
3187 }
3188  
3189 # bareword
3190 elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
3191 0 return $1;
3192 }
3193  
3194 # $0 --> $0
3195 elsif (/\G ( \$ 0 ) /oxmsgc) {
3196 2 $slash = 'div';
3197 2 return $1;
3198 }
3199 elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
3200 0 $slash = 'div';
3201 0 return $1;
3202 }
3203  
3204 # $$ --> $$
3205 elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
3206 1 $slash = 'div';
3207 1 return $1;
3208 }
3209  
3210 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
3211 # $1, $2, $3 --> $1, $2, $3 otherwise
3212 elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
3213 4 $slash = 'div';
3214 4 return e_capture($1);
3215 }
3216 elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
3217 0 $slash = 'div';
3218 0 return e_capture($1);
3219 }
3220  
3221 # $$foo[ ... ] --> $ $foo->[ ... ]
3222 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
3223 0 $slash = 'div';
3224 0 return e_capture($1.'->'.$2);
3225 }
3226  
3227 # $$foo{ ... } --> $ $foo->{ ... }
3228 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
3229 0 $slash = 'div';
3230 0 return e_capture($1.'->'.$2);
3231 }
3232  
3233 # $$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);
3237 }
3238  
3239 # ${ foo }
3240 elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) {
3241 0 $slash = 'div';
3242 0 return '${' . $1 . '}';
3243 }
3244  
3245 # ${ ... }
3246 elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
3247 0 $slash = 'div';
3248 0 return e_capture($1);
3249 }
3250  
3251 # variable or function
3252 # $ @ % & * $ #
3253 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) {
3254 42 $slash = 'div';
3255 42 return $1;
3256 }
3257 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
3258 # $ @ # \ ' " / ? ( ) [ ] < >
3259 elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
3260 63 $slash = 'div';
3261 63 return $1;
3262 }
3263  
3264 # while (<FILEHANDLE>)
3265 elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) {
3266 0 return $1;
3267 }
3268  
3269 # while (<WILDCARD>) --- glob
3270  
3271 # avoid "Error: Runtime exception" of perl version 5.005_03
3272  
3273 elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /oxgc) {
3274 0 return 'while ($_ = Ekoi8r::glob("' . $1 . '"))';
3275 }
3276  
3277 # while (glob)
3278 elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) {
3279 0 return 'while ($_ = Ekoi8r::glob_)';
3280 }
3281  
3282 # while (glob(WILDCARD))
3283 elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) {
3284 0 return 'while ($_ = Ekoi8r::glob';
3285 }
3286  
3287 # doit if, doit unless, doit while, doit until, doit for, doit when
3288 251 elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; }
3289  
3290 # subroutines of package Ekoi8r
3291 19 elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; }
3292 0 elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3293 22 elsif (/\G \b KOI8R::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3294 0 elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; }
3295 168 elsif (/\G \b KOI8R::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval KOI8R::escape'; }
3296 2 elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; }
3297 0 elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chop'; }
3298 2 elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; }
3299 0 elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; }
3300 0 elsif (/\G \b KOI8R::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8R::index'; }
3301 0 elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::index'; }
3302 2 elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; }
3303 0 elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; }
3304 0 elsif (/\G \b KOI8R::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8R::rindex'; }
3305 0 elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::rindex'; }
3306 1 elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lc'; }
3307 0 elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lcfirst'; }
3308 1 elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::uc'; }
3309 0 elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::ucfirst'; }
3310 6 elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::fc'; }
3311  
3312 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
3313 0 elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); }
3314 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3315 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3316 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3317 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3318 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3319 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3320  
3321 0 elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); }
3322 0 elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3323 0 elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3324 0 elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3325 0 elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3326 0 elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3327 0 elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3328  
3329 elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc)
3330 0 { $slash = 'm//'; return "-s $1"; }
3331 0 elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; }
3332 0 elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; }
3333 0 elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; }
3334  
3335 2 elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; }
3336 2 elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; }
3337 36 elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chr'; }
3338 2 elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; }
3339 8 elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; }
3340 0 elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::glob'; }
3341 0 elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lc_'; }
3342 0 elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lcfirst_'; }
3343 0 elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::uc_'; }
3344 0 elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::ucfirst_'; }
3345 0 elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::fc_'; }
3346 0 elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; }
3347  
3348 0 elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; }
3349 0 elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; }
3350 0 elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chr_'; }
3351 0 elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; }
3352 0 elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; }
3353 0 elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::glob_'; }
3354 0 elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; }
3355 8 elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; }
3356 # split
3357 elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
3358 87 $slash = 'm//';
3359  
3360 87 my $e = '';
3361 87 ▶ while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( (?>\s+) | \( | \#.* ) /cgox) 85 87 172
3362 85 $e .= $1;
3363 }
3364  
3365 # end of split
3366 87 ▶ if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Ekoi8r::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
3367  
3368 # split scalar value
3369 1 elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Ekoi8r::split' . $e . e_string($1); }
3370  
3371 # split literal space
3372 0 elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Ekoi8r::split' . $e . qq {qq$1 $2}; }
3373 0 elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3374 0 elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3375 0 elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3376 0 elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3377 0 elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3378 0 elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Ekoi8r::split' . $e . qq {q$1 $2}; }
3379 0 elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3380 0 elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3381 0 elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3382 0 elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3383 0 elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3384 10 elsif (/\G ' [ ] ' /oxgc) { return 'Ekoi8r::split' . $e . qq {' '}; }
3385 0 elsif (/\G " [ ] " /oxgc) { return 'Ekoi8r::split' . $e . qq {" "}; }
3386  
3387 # split qq//
3388 elsif (/\G \b (qq) \b /oxgc) {
3389 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
3390 else {
3391 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3392 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 ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
3393 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( )
3394 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { }
3395 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ]
3396 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < >
3397 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { }
3398 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * *
3399 }
3400 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3401 }
3402 }
3403  
3404 # split qr//
3405 elsif (/\G \b (qr) \b /oxgc) {
3406 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 12 12
3407 else {
3408 12 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 12 0 12
3409 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 12 12
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 12 0 12
3410 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( )
3411 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { }
3412 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ]
3413 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < >
3414 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' '
3415 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { }
3416 12 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * *
3417 }
3418 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3419 }
3420 }
3421  
3422 # split q//
3423 elsif (/\G \b (q) \b /oxgc) {
3424 0 ▶ if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)*?) (\#) /cgox) { } 0 0 0
3425 else {
3426 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3427 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 ([*\-:?\\^|]) ((?:$Ekoi8r::q_char)*?) (\1) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:\\\\|\\\1| $Ekoi8r::q_char)*?) (\1) /cgox) { } 0 0 0
3428 0 elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( )
3429 0 elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { }
3430 0 elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ]
3431 0 elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < >
3432 0 elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { }
3433 0 elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * *
3434 }
3435 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3436 }
3437 }
3438  
3439 # split m//
3440 elsif (/\G \b (m) \b /oxgc) {
3441 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
3442 else {
3443 18 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 18 0 18
3444 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 18 18
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 18 0 18
3445 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( )
3446 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { }
3447 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ]
3448 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < >
3449 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' '
3450 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { }
3451 18 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * *
3452 }
3453 0 die __FILE__, ": Search pattern not terminated\n";
3454 }
3455 }
3456  
3457 # split ''
3458 elsif (/\G (\') /oxgc) {
3459 0 my $q_string = '';
3460 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3461 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
3462 0 elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
3463 0 elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' '
3464 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3465 }
3466 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3467 }
3468  
3469 # split ""
3470 elsif (/\G (\") /oxgc) {
3471 0 my $qq_string = '';
3472 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3473 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
3474 0 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
3475 0 elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " "
3476 0 elsif (/\G ($q_char) /oxgc) { $qq_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 44 my $regexp = '';
3484 44 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 381 0 381
3485 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 ($Ekoi8r::q_char) /cgox) { } 337 0 337
3486 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
3487 44 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / /
3488 337 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
3489 }
3490 0 die __FILE__, ": Search pattern not terminated\n";
3491 }
3492 }
3493  
3494 # tr/// or y///
3495  
3496 # about [cdsrbB]* (/B modifier)
3497 #
3498 # P.559 appendix C
3499 # of ISBN 4-89052-384-7 Programming perl
3500 # (Japanese title is: Perl puroguramingu)
3501  
3502 elsif (/\G \b ( tr | y ) \b /oxgc) {
3503 4 my $ope = $1;
3504  
3505 # $1 $2 $3 $4 $5 $6
3506 4 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cdsrbB]*) /cgox) { } 0 4 4
3507 0 my @tr = ($tr_variable,$2);
3508 0 return e_tr(@tr,'',$4,$6);
3509 }
3510 else {
3511 4 my $e = '';
3512 4 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 4 0 4
3513 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) ((?:$Ekoi8r::qq_char)*?) (\1) ((?:$Ekoi8r::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 4 0 4
3514 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3515 0 my @tr = ($tr_variable,$2);
3516 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3517 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) ((?:$Ekoi8r::qq_char)*?) (\1) ([cdsrbB]*) /cgox) { } 0 0 0
3518 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( )
3519 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { }
3520 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ]
3521 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < >
3522 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * *
3523 }
3524 0 die __FILE__, ": Transliteration replacement not terminated\n";
3525 }
3526 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /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) ((?:$Ekoi8r::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_bracket)*?) (\]) /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) ((?:$Ekoi8r::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_angle)*?) (\>) /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) ((?:$Ekoi8r::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 # $1 $2 $3 $4 $5 $6
3563 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * *
3564 4 my @tr = ($tr_variable,$2);
3565 4 return e_tr(@tr,'',$4,$6);
3566 }
3567 }
3568 0 die __FILE__, ": Transliteration pattern not terminated\n";
3569 }
3570 }
3571  
3572 # qq//
3573 elsif (/\G \b (qq) \b /oxgc) {
3574 2252 my $ope = $1;
3575  
3576 # if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# #
3577 2252 ▶ if (/\G (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 2252 2252
3578 0 my $qq_string = '';
3579 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3580 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 ($Ekoi8r::qq_char) /cgox) { } 0 0 0
3581 0 elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; }
3582 0 elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); }
3583 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3584 }
3585 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3586 }
3587  
3588 else {
3589 2252 my $e = '';
3590 2252 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 2252 0 2252
3591 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
3592  
3593 # elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( )
3594 elsif (/\G (\() /oxgc) { # qq ( )
3595 0 my $qq_string = '';
3596 0 local $nest = 1;
3597 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3598 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 ($Ekoi8r::qq_char) /cgox) { } 0 0 0
3599 0 elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; }
3600 0 elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; }
3601 elsif (/\G (\)) /oxgc) {
3602 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3603 0 else { $qq_string .= $1; }
3604 }
3605 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3606 }
3607 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3608 }
3609  
3610 # elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { }
3611 elsif (/\G (\{) /oxgc) { # qq { }
3612 2222 my $qq_string = '';
3613 2222 local $nest = 1;
3614 2222 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 85091 0 85091
3615 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 ($Ekoi8r::qq_char) /cgox) { } 79769 0 79769
3616 0 elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; }
3617 1189 elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; }
3618 elsif (/\G (\}) /oxgc) {
3619 3411 ▶ if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 2222 1189 3411
3620 1189 else { $qq_string .= $1; }
3621 }
3622 79769 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3623 }
3624 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3625 }
3626  
3627 # elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ]
3628 elsif (/\G (\[) /oxgc) { # qq [ ]
3629 0 my $qq_string = '';
3630 0 local $nest = 1;
3631 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3632 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 ($Ekoi8r::qq_char) /cgox) { } 0 0 0
3633 0 elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; }
3634 0 elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; }
3635 elsif (/\G (\]) /oxgc) {
3636 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3637 0 else { $qq_string .= $1; }
3638 }
3639 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3640 }
3641 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3642 }
3643  
3644 # elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < >
3645 elsif (/\G (\<) /oxgc) { # qq < >
3646 30 my $qq_string = '';
3647 30 local $nest = 1;
3648 30 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 1166 0 1166
3649 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 ($Ekoi8r::qq_char) /cgox) { } 1114 0 1114
3650 0 elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; }
3651 0 elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; }
3652 elsif (/\G (\>) /oxgc) {
3653 30 ▶ if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 30 0 30
3654 0 else { $qq_string .= $1; }
3655 }
3656 1114 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3657 }
3658 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3659 }
3660  
3661 # elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * *
3662 elsif (/\G (\S) /oxgc) { # qq * *
3663 0 my $delimiter = $1;
3664 0 my $qq_string = '';
3665 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3666 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 ($Ekoi8r::qq_char) /cgox) { } 0 0 0
3667 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; }
3668 0 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); }
3669 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3670 }
3671 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3672 }
3673 }
3674 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3675 }
3676 }
3677  
3678 # qr//
3679 elsif (/\G \b (qr) \b /oxgc) {
3680 0 my $ope = $1;
3681 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3682 0 return e_qr($ope,$1,$3,$2,$4);
3683 }
3684 else {
3685 0 my $e = '';
3686 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3687 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3688 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( )
3689 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { }
3690 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ]
3691 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < >
3692 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' '
3693 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { }
3694 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * *
3695 }
3696 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3697 }
3698 }
3699  
3700 # qw//
3701 elsif (/\G \b (qw) \b /oxgc) {
3702 16 my $ope = $1;
3703 16 ▶ if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) (.*?) (\#) /cgmosx) { } 0 16 16
3704 0 return e_qw($ope,$1,$3,$2);
3705 }
3706 else {
3707 16 my $e = '';
3708 16 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 16 0 16
3709 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) ((?:$Ekoi8r::q_char)*?) (\1) /cgmosx) { } 0 0 0
3710  
3711 16 elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3712 0 elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3713  
3714 0 elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3715 0 elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3716  
3717 0 elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3718 0 elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3719  
3720 0 elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3721 0 elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3722  
3723 0 elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3724 0 elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3725 }
3726 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3727 }
3728 }
3729  
3730 # qx//
3731 elsif (/\G \b (qx) \b /oxgc) {
3732 0 my $ope = $1;
3733 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
3734 0 return e_qq($ope,$1,$3,$2);
3735 }
3736 else {
3737 0 my $e = '';
3738 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3739 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
3740 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( )
3741 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { }
3742 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ]
3743 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < >
3744 0 elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' '
3745 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * *
3746 }
3747 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3748 }
3749 }
3750  
3751 # q//
3752 elsif (/\G \b (q) \b /oxgc) {
3753 473 my $ope = $1;
3754  
3755 # if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# #
3756  
3757 # avoid "Error: Runtime exception" of perl version 5.005_03
3758 # (and so on)
3759  
3760 473 ▶ if (/\G (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 473 473
3761 0 my $q_string = '';
3762 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3763 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
3764 0 elsif (/\G (\\\#) /oxgc) { $q_string .= $1; }
3765 0 elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); }
3766 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3767 }
3768 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3769 }
3770  
3771 else {
3772 473 my $e = '';
3773 473 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 473 0 473
3774 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
3775  
3776 # elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( )
3777 elsif (/\G (\() /oxgc) { # q ( )
3778 0 my $q_string = '';
3779 0 local $nest = 1;
3780 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3781 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
3782 0 elsif (/\G (\\\)) /oxgc) { $q_string .= $1; }
3783 0 elsif (/\G (\\\() /oxgc) { $q_string .= $1; }
3784 0 elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; }
3785 elsif (/\G (\)) /oxgc) {
3786 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3787 0 else { $q_string .= $1; }
3788 }
3789 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3790 }
3791 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3792 }
3793  
3794 # elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { }
3795 elsif (/\G (\{) /oxgc) { # q { }
3796 467 my $q_string = '';
3797 467 local $nest = 1;
3798 467 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 8236 0 8236
3799 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 ($Ekoi8r::q_char) /cgox) { } 7451 0 7451
3800 0 elsif (/\G (\\\}) /oxgc) { $q_string .= $1; }
3801 0 elsif (/\G (\\\{) /oxgc) { $q_string .= $1; }
3802 159 elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; }
3803 elsif (/\G (\}) /oxgc) {
3804 626 ▶ if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 467 159 626
3805 159 else { $q_string .= $1; }
3806 }
3807 7451 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3808 }
3809 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3810 }
3811  
3812 # elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ]
3813 elsif (/\G (\[) /oxgc) { # q [ ]
3814 0 my $q_string = '';
3815 0 local $nest = 1;
3816 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3817 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
3818 0 elsif (/\G (\\\]) /oxgc) { $q_string .= $1; }
3819 0 elsif (/\G (\\\[) /oxgc) { $q_string .= $1; }
3820 0 elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; }
3821 elsif (/\G (\]) /oxgc) {
3822 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3823 0 else { $q_string .= $1; }
3824 }
3825 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3826 }
3827 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3828 }
3829  
3830 # elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < >
3831 elsif (/\G (\<) /oxgc) { # q < >
3832 5 my $q_string = '';
3833 5 local $nest = 1;
3834 5 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 88 0 88
3835 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 ($Ekoi8r::q_char) /cgox) { } 83 0 83
3836 0 elsif (/\G (\\\>) /oxgc) { $q_string .= $1; }
3837 0 elsif (/\G (\\\<) /oxgc) { $q_string .= $1; }
3838 0 elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; }
3839 elsif (/\G (\>) /oxgc) {
3840 5 ▶ if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 5 0 5
3841 0 else { $q_string .= $1; }
3842 }
3843 83 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3844 }
3845 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3846 }
3847  
3848 # elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * *
3849 elsif (/\G (\S) /oxgc) { # q * *
3850 1 my $delimiter = $1;
3851 1 my $q_string = '';
3852 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 14 0 14
3853 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 ($Ekoi8r::q_char) /cgox) { } 13 0 13
3854 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; }
3855 1 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); }
3856 13 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3857 }
3858 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3859 }
3860 }
3861 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3862 }
3863 }
3864  
3865 # m//
3866 elsif (/\G \b (m) \b /oxgc) {
3867 209 my $ope = $1;
3868 209 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
3869 0 return e_qr($ope,$1,$3,$2,$4);
3870 }
3871 else {
3872 209 my $e = '';
3873 209 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 209 0 209
3874 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 (\?) ((?:$Ekoi8r::qq_char)*?) (\?) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
elsif (/\G (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 10 199 209
elsif (/\G ([*\-:\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 199 199
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 199 0 199
3875 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( )
3876 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { }
3877 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ]
3878 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < >
3879 0 elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ?
3880 10 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' '
3881 0 elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { }
3882 199 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * *
3883 }
3884 0 die __FILE__, ": Search pattern not terminated\n";
3885 }
3886 }
3887  
3888 # s///
3889  
3890 # about [cegimosxpradlunbB]* (/cg modifier)
3891 #
3892 # P.67 Pattern-Matching Operators
3893 # of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition.
3894  
3895 elsif (/\G \b (s) \b /oxgc) {
3896 101 my $ope = $1;
3897  
3898 # $1 $2 $3 $4 $5 $6
3899 101 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cegimosxpradlunbB]*) /cgox) { } 1 100 101
3900 1 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3901 }
3902 else {
3903 100 my $e = '';
3904 100 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 100 0 100
3905 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 21 79 100
elsif (/\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\$) ((?:$Ekoi8r::qq_char)*?) (\1) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 79 79
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 79 0 79
3906 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3907 0 my @s = ($1,$2,$3);
3908 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3909 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8r::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8r::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8r::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3910 # $1 $2 $3 $4
3911 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3912 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3913 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3914 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3915 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3916 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3917 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3918 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3919 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3920 }
3921 0 die __FILE__, ": Substitution replacement not terminated\n";
3922 }
3923 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3924 0 my @s = ($1,$2,$3);
3925 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3926 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8r::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8r::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8r::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3927 # $1 $2 $3 $4
3928 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3929 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3930 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3931 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3932 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3933 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3934 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3935 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3936 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3937 }
3938 0 die __FILE__, ": Substitution replacement not terminated\n";
3939 }
3940 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3941 0 my @s = ($1,$2,$3);
3942 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3943 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8r::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3944 # $1 $2 $3 $4
3945 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3946 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3947 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3948 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3949 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3950 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3951 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3952 }
3953 0 die __FILE__, ": Substitution replacement not terminated\n";
3954 }
3955 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3956 0 my @s = ($1,$2,$3);
3957 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3958 0 ▶ if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; }
Branch: 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\$) ((?:$Ekoi8r::qq_char)*?) (\$) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\:) ((?:$Ekoi8r::qq_char)*?) (\:) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\@) ((?:$Ekoi8r::qq_char)*?) (\@) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
elsif (/\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cegimosxpradlunbB]*) /cgox) { } 0 0 0
3959 # $1 $2 $3 $4
3960 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3961 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3962 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3963 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3964 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3965 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3966 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3967 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3968 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3969 }
3970 0 die __FILE__, ": Substitution replacement not terminated\n";
3971 }
3972 # $1 $2 $3 $4 $5 $6
3973 elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) {
3974 21 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3975 }
3976 # $1 $2 $3 $4 $5 $6
3977 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3978 0 return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { }
3979 }
3980 # $1 $2 $3 $4 $5 $6
3981 elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3982 0 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3983 }
3984 # $1 $2 $3 $4 $5 $6
3985 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3986 79 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3987 }
3988 }
3989 0 die __FILE__, ": Substitution pattern not terminated\n";
3990 }
3991 }
3992  
3993 # require ignore module
3994 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; }
3995 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# require$1\n$2"; }
3996 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; }
3997  
3998 # use strict; --> use strict; no strict qw(refs);
3999 37 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; }
4000 0 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; }
4001 0 elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; }
4002  
4003 # use 5.12.0; --> use 5.12.0; no strict qw(refs);
4004 elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4005 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
4006 0 return "use $1; no strict qw(refs);";
4007 }
4008 else {
4009 2 return "use $1;";
4010 }
4011 }
4012 elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4013 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
4014 0 return "use $1; no strict qw(refs);";
4015 }
4016 else {
4017 0 return "use $1;";
4018 }
4019 }
4020  
4021 # ignore use module
4022 2 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; }
4023 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# use$1\n$2"; }
4024 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; }
4025  
4026 # ignore no module
4027 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; }
4028 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# no$1\n$2"; }
4029 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; }
4030  
4031 # use else
4032 0 elsif (/\G \b use \b /oxmsgc) { return "use"; }
4033  
4034 # use else
4035 2 elsif (/\G \b no \b /oxmsgc) { return "no"; }
4036  
4037 # ''
4038 elsif (/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
4039 1142 my $q_string = '';
4040 1142 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 10162 0 10162
4041 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 ($Ekoi8r::q_char) /cgox) { } 8968 0 8968
4042 48 elsif (/\G (\\\') /oxgc) { $q_string .= $1; }
4043 1142 elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); }
4044 8968 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
4045 }
4046 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4047 }
4048  
4049 # ""
4050 elsif (/\G (\") /oxgc) {
4051 1873 my $qq_string = '';
4052 1873 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 36840 0 36840
4053 36840 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 67 36773 36840
elsif (/\G (\\\") /cgox) { } 12 36761 36773
elsif (/\G \" /cgox) { } 1873 34888 36761
elsif (/\G ($Ekoi8r::q_char) /cgox) { } 34888 0 34888
4054 12 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; }
4055 1873 elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); }
4056 34888 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
4057 }
4058 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4059 }
4060  
4061 # ``
4062 elsif (/\G (\`) /oxgc) {
4063 1 my $qx_string = '';
4064 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 19 0 19
4065 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 ($Ekoi8r::q_char) /cgox) { } 18 0 18
4066 0 elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; }
4067 1 elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); }
4068 18 elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; }
4069 }
4070 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4071 }
4072  
4073 # // --- not divide operator (num / num), not defined-or
4074 ▶ elsif (($slash eq 'm//') and /\G (\/) /oxgc) {
Condition100%3/3
$Ekoi8r::slash eq "m//" and m[\G (/) ]cgox
!ll&&!rl&&r
271468836681
MC/DC100%2/2
$Ekoi8r::slash eq "m//" and m[\G (/) ]cgox
$Ekoi8r::slash eq "m//" m[\G (/) ]cgox
Truth table100%3/3
A and B
A= $Ekoi8r::slash eq "m//"B= m[\G (/) ]cgox
ABresult
0X0
100
111
4075 681 my $regexp = '';
4076 681 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 5636 0 5636
4077 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 ($Ekoi8r::q_char) /cgox) { } 4955 0 4955
4078 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; }
4079 681 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); }
4080 4955 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4081 }
4082 0 die __FILE__, ": Search pattern not terminated\n";
4083 }
4084  
4085 # ?? --- not conditional operator (condition ? then : else)
4086 ▶ elsif (($slash eq 'm//') and /\G (\?) /oxgc) {
Condition66%2/3
$Ekoi8r::slash eq "m//" and /\G (\?) /cgox
!ll&&!rl&&r
2714688360
MC/DC0%0/2
$Ekoi8r::slash eq "m//" and /\G (\?) /cgox
$Ekoi8r::slash eq "m//" /\G (\?) /cgox
Truth table66%2/3
A and B
A= $Ekoi8r::slash eq "m//"B= /\G (\?) /cgox
ABresult
0X0
100
111
4087 0 my $regexp = '';
4088 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
4089 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
4090 0 elsif (/\G (\\\?) /oxgc) { $regexp .= $1; }
4091 0 elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); }
4092 0 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4093 }
4094 0 die __FILE__, ": Search pattern not terminated\n";
4095 }
4096  
4097 # <<>> (a safer ARGV)
4098 0 elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; }
4099  
4100 # << (bit shift) --- not here document
4101 0 elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; }
4102  
4103 # <<~'HEREDOC'
4104 elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4105 6 $slash = 'm//';
4106 6 my $here_quote = $1;
4107 6 my $delimiter = $2;
4108  
4109 # get here document
4110 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4111 6 $here_script = CORE::substr $_, pos $_;
4112 6 $here_script =~ s/.*?\n//oxm;
4113 }
4114 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
4115 6 my $heredoc = $1;
4116 6 my $indent = $2;
4117 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4118 6 push @heredoc, $heredoc . qq{\n$delimiter\n};
4119 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4120 }
4121 else {
4122 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4123 }
4124 6 return qq{<<'$delimiter'};
4125 }
4126  
4127 # <<~\HEREDOC
4128  
4129 # P.66 2.6.6. "Here" Documents
4130 # in Chapter 2: Bits and Pieces
4131 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4132  
4133 # P.73 "Here" Documents
4134 # in Chapter 2: Bits and Pieces
4135 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4136  
4137 elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4138 3 $slash = 'm//';
4139 3 my $here_quote = $1;
4140 3 my $delimiter = $2;
4141  
4142 # get here document
4143 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4144 3 $here_script = CORE::substr $_, pos $_;
4145 3 $here_script =~ s/.*?\n//oxm;
4146 }
4147 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
4148 3 my $heredoc = $1;
4149 3 my $indent = $2;
4150 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4151 3 push @heredoc, $heredoc . qq{\n$delimiter\n};
4152 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4153 }
4154 else {
4155 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4156 }
4157 3 return qq{<<\\$delimiter};
4158 }
4159  
4160 # <<~"HEREDOC"
4161 elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4162 6 $slash = 'm//';
4163 6 my $here_quote = $1;
4164 6 my $delimiter = $2;
4165  
4166 # get here document
4167 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4168 6 $here_script = CORE::substr $_, pos $_;
4169 6 $here_script =~ s/.*?\n//oxm;
4170 }
4171 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
4172 6 my $heredoc = $1;
4173 6 my $indent = $2;
4174 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4175 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4176 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4177 }
4178 else {
4179 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4180 }
4181 6 return qq{<<"$delimiter"};
4182 }
4183  
4184 # <<~HEREDOC
4185 elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4186 3 $slash = 'm//';
4187 3 my $here_quote = $1;
4188 3 my $delimiter = $2;
4189  
4190 # get here document
4191 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4192 3 $here_script = CORE::substr $_, pos $_;
4193 3 $here_script =~ s/.*?\n//oxm;
4194 }
4195 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
4196 3 my $heredoc = $1;
4197 3 my $indent = $2;
4198 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4199 3 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4200 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4201 }
4202 else {
4203 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4204 }
4205 3 return qq{<<$delimiter};
4206 }
4207  
4208 # <<~`HEREDOC`
4209 elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4210 6 $slash = 'm//';
4211 6 my $here_quote = $1;
4212 6 my $delimiter = $2;
4213  
4214 # get here document
4215 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4216 6 $here_script = CORE::substr $_, pos $_;
4217 6 $here_script =~ s/.*?\n//oxm;
4218 }
4219 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
4220 6 my $heredoc = $1;
4221 6 my $indent = $2;
4222 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4223 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4224 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4225 }
4226 else {
4227 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4228 }
4229 6 return qq{<<`$delimiter`};
4230 }
4231  
4232 # <<'HEREDOC'
4233 elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
4234 72 $slash = 'm//';
4235 72 my $here_quote = $1;
4236 72 my $delimiter = $2;
4237  
4238 # get here document
4239 72 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 72 0 72
4240 72 $here_script = CORE::substr $_, pos $_;
4241 72 $here_script =~ s/.*?\n//oxm;
4242 }
4243 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
4244 72 push @heredoc, $1 . qq{\n$delimiter\n};
4245 72 push @heredoc_delimiter, $delimiter;
4246 }
4247 else {
4248 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4249 }
4250 72 return $here_quote;
4251 }
4252  
4253 # <<\HEREDOC
4254  
4255 # P.66 2.6.6. "Here" Documents
4256 # in Chapter 2: Bits and Pieces
4257 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4258  
4259 # P.73 "Here" Documents
4260 # in Chapter 2: Bits and Pieces
4261 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4262  
4263 elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
4264 0 $slash = 'm//';
4265 0 my $here_quote = $1;
4266 0 my $delimiter = $2;
4267  
4268 # get here document
4269 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4270 0 $here_script = CORE::substr $_, pos $_;
4271 0 $here_script =~ s/.*?\n//oxm;
4272 }
4273 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
4274 0 push @heredoc, $1 . qq{\n$delimiter\n};
4275 0 push @heredoc_delimiter, $delimiter;
4276 }
4277 else {
4278 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4279 }
4280 0 return $here_quote;
4281 }
4282  
4283 # <<"HEREDOC"
4284 elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
4285 36 $slash = 'm//';
4286 36 my $here_quote = $1;
4287 36 my $delimiter = $2;
4288  
4289 # get here document
4290 36 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 36 0 36
4291 36 $here_script = CORE::substr $_, pos $_;
4292 36 $here_script =~ s/.*?\n//oxm;
4293 }
4294 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
4295 36 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4296 36 push @heredoc_delimiter, $delimiter;
4297 }
4298 else {
4299 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4300 }
4301 36 return $here_quote;
4302 }
4303  
4304 # <<HEREDOC
4305 elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
4306 42 $slash = 'm//';
4307 42 my $here_quote = $1;
4308 42 my $delimiter = $2;
4309  
4310 # get here document
4311 42 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 42 0 42
4312 42 $here_script = CORE::substr $_, pos $_;
4313 42 $here_script =~ s/.*?\n//oxm;
4314 }
4315 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
4316 42 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4317 42 push @heredoc_delimiter, $delimiter;
4318 }
4319 else {
4320 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4321 }
4322 42 return $here_quote;
4323 }
4324  
4325 # <<`HEREDOC`
4326 elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
4327 0 $slash = 'm//';
4328 0 my $here_quote = $1;
4329 0 my $delimiter = $2;
4330  
4331 # get here document
4332 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4333 0 $here_script = CORE::substr $_, pos $_;
4334 0 $here_script =~ s/.*?\n//oxm;
4335 }
4336 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
4337 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4338 0 push @heredoc_delimiter, $delimiter;
4339 }
4340 else {
4341 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4342 }
4343 0 return $here_quote;
4344 }
4345  
4346 # <<= <=> <= < operator
4347 elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
4348 12 return $1;
4349 }
4350  
4351 # <FILEHANDLE>
4352 elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
4353 0 return $1;
4354 }
4355  
4356 # <WILDCARD> --- glob
4357  
4358 # avoid "Error: Runtime exception" of perl version 5.005_03
4359  
4360 elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /oxgc) {
4361 0 return 'Ekoi8r::glob("' . $1 . '")';
4362 }
4363  
4364 # __DATA__
4365 0 elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; }
4366  
4367 # __END__
4368 210 elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; }
4369  
4370 # \cD Control-D
4371  
4372 # P.68 2.6.8. Other Literal Tokens
4373 # in Chapter 2: Bits and Pieces
4374 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4375  
4376 # P.76 Other Literal Tokens
4377 # in Chapter 2: Bits and Pieces
4378 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4379  
4380 0 elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; }
4381  
4382 # \cZ Control-Z
4383 0 elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; }
4384  
4385 # any operator before div
4386 elsif (/\G (
4387 -- | \+\+ |
4388 [\)\}\]]
4389  
4390 5837 ) /oxgc) { $slash = 'div'; return $1; }
4391  
4392 # yada-yada or triple-dot operator
4393 elsif (/\G (
4394 \.\.\.
4395  
4396 7 ) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; }
4397  
4398 # any operator before m//
4399  
4400 # //, //= (defined-or)
4401  
4402 # P.164 Logical Operators
4403 # in Chapter 10: More Control Structures
4404 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4405  
4406 # P.119 C-Style Logical (Short-Circuit) Operators
4407 # in Chapter 3: Unary and Binary Operators
4408 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4409  
4410 # (and so on)
4411  
4412 # ~~
4413  
4414 # P.221 The Smart Match Operator
4415 # in Chapter 15: Smart Matching and given-when
4416 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4417  
4418 # P.112 Smartmatch Operator
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 elsif (/\G ((?>
4425  
4426 !~~ | !~ | != | ! |
4427 %= | % |
4428 &&= | && | &= | &\.= | &\. | & |
4429 -= | -> | - |
4430 :(?>\s*)= |
4431 : |
4432 <<>> |
4433 <<= | <=> | <= | < |
4434 == | => | =~ | = |
4435 >>= | >> | >= | > |
4436 \*\*= | \*\* | \*= | \* |
4437 \+= | \+ |
4438 \.\. | \.= | \. |
4439 \/\/= | \/\/ |
4440 \/= | \/ |
4441 \? |
4442 \\ |
4443 \^= | \^\.= | \^\. | \^ |
4444 \b x= |
4445 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
4446 ~~ | ~\. | ~ |
4447 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
4448 \b(?: print )\b |
4449  
4450 [,;\(\{\[]
4451  
4452 9766 )) /oxgc) { $slash = 'm//'; return $1; }
4453  
4454 # other any character
4455 19976 elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; }
4456  
4457 # system error
4458 else {
4459 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4460 }
4461 }
4462  
4463 # escape KOI8-R string
4464 1871 ▶sub e_string {
Subroutine e_string: called CC=228 SCAR=104.2
Pod documented
4465 1871 my($string) = @_;
4466 1871 my $e_string = '';
4467  
4468 1871 local $slash = 'm//';
4469  
4470 # P.1024 Appendix W.10 Multibyte Processing
4471 # of ISBN 1-56592-224-7 CJKV Information Processing
4472 # (and so on)
4473  
4474 1871 my @char = $string =~ / \G (?>[^\\]|\\$q_char|$q_char) /oxmsg;
4475  
4476 # without { ... }
4477 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
4478 1854 ▶ if ($string !~ /<</oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /<</mosx) 1854 0 1854
4479 1854 return $string;
4480 }
4481 }
4482  
4483 E_STRING_LOOP:
4484 17 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 190 17 207
4485 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 KOI8R::eval (?= (?>\s*) \{ ) /cgox) { } 0 180 180
elsif ($string =~ /\G \b Char::eval \b /cgox) { } 0 180 180
elsif ($string =~ /\G \b KOI8R::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 KOI8R::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 KOI8R::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*) (\") ((?:$Ekoi8r::qq_char)+?) (\") /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Ekoi8r::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) ((?:$Ekoi8r::qq_char)+?) (\1) /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Ekoi8r::q_char)+?) (\') /cgox) { } 0 180 180
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Ekoi8r::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|\\\\|$Ekoi8r::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\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$Ekoi8r::q_char)*?) (\') /cgox) { } 0 180 180
elsif ($string =~ /\G (\") ((?:$Ekoi8r::qq_char)*?) (\") /cgox) { } 0 180 180
elsif ($string =~ /\G (\`) ((?:$Ekoi8r::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 < ((?:$Ekoi8r::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 ($Ekoi8r::q_char) /cgox) { } 131 0 131
4486 }
4487  
4488 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Ekoi8r::PREMATCH()]}
4489 elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
4490 0 $e_string .= q{Ekoi8r::PREMATCH()};
4491 0 $slash = 'div';
4492 }
4493  
4494 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Ekoi8r::MATCH()]}
4495 elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
4496 0 $e_string .= q{Ekoi8r::MATCH()};
4497 0 $slash = 'div';
4498 }
4499  
4500 # $', ${'} --> $', ${'}
4501 elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) {
4502 0 $e_string .= $1;
4503 0 $slash = 'div';
4504 }
4505  
4506 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Ekoi8r::POSTMATCH()]}
4507 elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
4508 0 $e_string .= q{Ekoi8r::POSTMATCH()};
4509 0 $slash = 'div';
4510 }
4511  
4512 # bareword
4513 elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
4514 0 $e_string .= $1;
4515 0 $slash = 'div';
4516 }
4517  
4518 # $0 --> $0
4519 elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) {
4520 0 $e_string .= $1;
4521 0 $slash = 'div';
4522 }
4523 elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
4524 0 $e_string .= $1;
4525 0 $slash = 'div';
4526 }
4527  
4528 # $$ --> $$
4529 elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
4530 0 $e_string .= $1;
4531 0 $slash = 'div';
4532 }
4533  
4534 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4535 # $1, $2, $3 --> $1, $2, $3 otherwise
4536 elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
4537 0 $e_string .= e_capture($1);
4538 0 $slash = 'div';
4539 }
4540 elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
4541 0 $e_string .= e_capture($1);
4542 0 $slash = 'div';
4543 }
4544  
4545 # $$foo[ ... ] --> $ $foo->[ ... ]
4546 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
4547 0 $e_string .= e_capture($1.'->'.$2);
4548 0 $slash = 'div';
4549 }
4550  
4551 # $$foo{ ... } --> $ $foo->{ ... }
4552 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
4553 0 $e_string .= e_capture($1.'->'.$2);
4554 0 $slash = 'div';
4555 }
4556  
4557 # $$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);
4560 0 $slash = 'div';
4561 }
4562  
4563 # ${ foo }
4564 elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) {
4565 0 $e_string .= '${' . $1 . '}';
4566 0 $slash = 'div';
4567 }
4568  
4569 # ${ ... }
4570 elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
4571 3 $e_string .= e_capture($1);
4572 3 $slash = 'div';
4573 }
4574  
4575 # variable or function
4576 # $ @ % & * $ #
4577 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) {
4578 7 $e_string .= $1;
4579 7 $slash = 'div';
4580 }
4581 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
4582 # $ @ # \ ' " / ? ( ) [ ] < >
4583 elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
4584 0 $e_string .= $1;
4585 0 $slash = 'div';
4586 }
4587  
4588 # subroutines of package Ekoi8r
4589 0 elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; }
4590 0 elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; }
4591 0 elsif ($string =~ /\G \b KOI8R::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; }
4592 0 elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; }
4593 0 elsif ($string =~ /\G \b KOI8R::eval \b /oxgc) { $e_string .= 'eval KOI8R::escape'; $slash = 'm//'; }
4594 0 elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; }
4595 0 elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Ekoi8r::chop'; $slash = 'm//'; }
4596 0 elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; }
4597 0 elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; }
4598 0 elsif ($string =~ /\G \b KOI8R::index \b /oxgc) { $e_string .= 'KOI8R::index'; $slash = 'm//'; }
4599 0 elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Ekoi8r::index'; $slash = 'm//'; }
4600 0 elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; }
4601 0 elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; }
4602 0 elsif ($string =~ /\G \b KOI8R::rindex \b /oxgc) { $e_string .= 'KOI8R::rindex'; $slash = 'm//'; }
4603 0 elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Ekoi8r::rindex'; $slash = 'm//'; }
4604 0 elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::lc'; $slash = 'm//'; }
4605 0 elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::lcfirst'; $slash = 'm//'; }
4606 0 elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::uc'; $slash = 'm//'; }
4607 0 elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::ucfirst'; $slash = 'm//'; }
4608 0 elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::fc'; $slash = 'm//'; }
4609  
4610 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
4611 0 elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; }
4612 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4613 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4614 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4615 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4616 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4617 0 elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; }
4618  
4619 0 elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; }
4620 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4621 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4622 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4623 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4624 0 elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; }
4625 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//'; }
4626  
4627 elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc)
4628 0 { $e_string .= "-s $1"; $slash = 'm//'; }
4629 0 elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; }
4630 0 elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; }
4631 0 elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; }
4632  
4633 0 elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; }
4634 0 elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; }
4635 0 elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::chr'; $slash = 'm//'; }
4636 0 elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; }
4637 0 elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; }
4638 0 elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ekoi8r::glob'; $slash = 'm//'; }
4639 0 elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Ekoi8r::lc_'; $slash = 'm//'; }
4640 0 elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Ekoi8r::lcfirst_'; $slash = 'm//'; }
4641 0 elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Ekoi8r::uc_'; $slash = 'm//'; }
4642 0 elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Ekoi8r::ucfirst_'; $slash = 'm//'; }
4643 0 elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Ekoi8r::fc_'; $slash = 'm//'; }
4644 0 elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; }
4645  
4646 0 elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; }
4647 0 elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; }
4648 0 elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Ekoi8r::chr_'; $slash = 'm//'; }
4649 0 elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; }
4650 0 elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; }
4651 0 elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Ekoi8r::glob_'; $slash = 'm//'; }
4652 0 elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; }
4653 0 elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; }
4654 # split
4655 elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
4656 0 $slash = 'm//';
4657  
4658 0 my $e = '';
4659 0 ▶ while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G ( (?>\s+) | \( | \#.* ) /cgox) 0 0 0
4660 0 $e .= $1;
4661 }
4662  
4663 # end of split
4664 0 ▶ if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Ekoi8r::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
4665  
4666 # split scalar value
4667 0 elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . e_string($1); next E_STRING_LOOP; }
4668  
4669 # split literal space
4670 0 elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; }
4671 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4672 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4673 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4674 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4675 0 elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; }
4676 0 elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; }
4677 0 elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4678 0 elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4679 0 elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4680 0 elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4681 0 elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; }
4682 0 elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {' '}; next E_STRING_LOOP; }
4683 0 elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Ekoi8r::split' . $e . qq {" "}; next E_STRING_LOOP; }
4684  
4685 # split qq//
4686 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4687 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 (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
4688 else {
4689 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4690 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 ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
4691 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq ( ) --> qr ( )
4692 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq { } --> qr { }
4693 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq [ ] --> qr [ ]
4694 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < >
4695 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { }
4696 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * *
4697 }
4698 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4699 }
4700 }
4701  
4702 # split qr//
4703 elsif ($string =~ /\G \b (qr) \b /oxgc) {
4704 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 (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
4705 else {
4706 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4707 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([imosxpadlunbB]*) /cgox) { } 0 0 0
4708 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ( )
4709 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr { }
4710 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr [ ]
4711 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr < >
4712 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' '
4713 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { }
4714 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 * *
4715 }
4716 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4717 }
4718 }
4719  
4720 # split q//
4721 elsif ($string =~ /\G \b (q) \b /oxgc) {
4722 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 (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)*?) (\#) /cgox) { } 0 0 0
4723 else {
4724 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4725 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 ([*\-:?\\^|]) ((?:$Ekoi8r::q_char)*?) (\1) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $Ekoi8r::q_char)*?) (\1) /cgox) { } 0 0 0
4726 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q ( ) --> qr ( )
4727 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q { } --> qr { }
4728 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q [ ] --> qr [ ]
4729 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < >
4730 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { }
4731 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 * *
4732 }
4733 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4734 }
4735 }
4736  
4737 # split m//
4738 elsif ($string =~ /\G \b (m) \b /oxgc) {
4739 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 (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
4740 else {
4741 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4742 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) ([cgimosxpadlunbB]*) /cgox) { } 0 0 0
4743 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ( ) --> qr ( )
4744 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m { } --> qr { }
4745 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m [ ] --> qr [ ]
4746 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m < > --> qr < >
4747 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 ' '
4748 0 elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { }
4749 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 * *
4750 }
4751 0 die __FILE__, ": Search pattern not terminated\n";
4752 }
4753 }
4754  
4755 # split ''
4756 elsif ($string =~ /\G (\') /oxgc) {
4757 0 my $q_string = '';
4758 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4759 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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
4760 0 elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
4761 0 elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' '
4762 0 elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; }
4763 }
4764 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4765 }
4766  
4767 # split ""
4768 elsif ($string =~ /\G (\") /oxgc) {
4769 0 my $qq_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) { $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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
4772 0 elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
4773 0 elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " "
4774 0 elsif ($string =~ /\G ($q_char) /oxgc) { $qq_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 $regexp = '';
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) { $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 ($Ekoi8r::q_char) /cgox) { } 0 0 0
4784 0 elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
4785 0 elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / /
4786 0 elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; }
4787 }
4788 0 die __FILE__, ": Search pattern not terminated\n";
4789 }
4790 }
4791  
4792 # qq//
4793 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4794 0 my $ope = $1;
4795 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
4796 0 $e_string .= e_qq($ope,$1,$3,$2);
4797 }
4798 else {
4799 0 my $e = '';
4800 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4801 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) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
4802 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( )
4803 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { }
4804 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ]
4805 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < >
4806 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * *
4807 }
4808 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4809 }
4810 }
4811  
4812 # qx//
4813 elsif ($string =~ /\G \b (qx) \b /oxgc) {
4814 0 my $ope = $1;
4815 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
4816 0 $e_string .= e_qq($ope,$1,$3,$2);
4817 }
4818 else {
4819 0 my $e = '';
4820 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4821 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 (\') ((?:$Ekoi8r::qq_char)*?) (\') /cgox) { } 0 0 0
elsif ($string =~ /\G (\S) ((?:$Ekoi8r::qq_char)*?) (\1) /cgox) { } 0 0 0
4822 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( )
4823 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { }
4824 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ]
4825 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < >
4826 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' '
4827 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * *
4828 }
4829 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4830 }
4831 }
4832  
4833 # q//
4834 elsif ($string =~ /\G \b (q) \b /oxgc) {
4835 0 my $ope = $1;
4836 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)*?) (\#) /cgox) { } 0 0 0
4837 0 $e_string .= e_q($ope,$1,$3,$2);
4838 }
4839 else {
4840 0 my $e = '';
4841 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4842 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| $Ekoi8r::q_char)*?) (\1) /cgox) { } 0 0 0
4843 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( )
4844 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { }
4845 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ]
4846 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < >
4847 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * *
4848 }
4849 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4850 }
4851 }
4852  
4853 # ''
4854 0 elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('',$1,$3,$2); }
4855  
4856 # ""
4857 0 elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4858  
4859 # ``
4860 0 elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4861  
4862 # <<>> (a safer ARGV)
4863 0 elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; }
4864  
4865 # <<= <=> <= < operator
4866 0 elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; }
4867  
4868 # <FILEHANDLE>
4869 0 elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; }
4870  
4871 # <WILDCARD> --- glob
4872 elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) {
4873 0 $e_string .= 'Ekoi8r::glob("' . $1 . '")';
4874 }
4875  
4876 # << (bit shift) --- not here document
4877 elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) {
4878 0 $slash = 'm//';
4879 0 $e_string .= $1;
4880 }
4881  
4882 # <<~'HEREDOC'
4883 elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4884 0 $slash = 'm//';
4885 0 my $here_quote = $1;
4886 0 my $delimiter = $2;
4887  
4888 # get here document
4889 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4890 0 $here_script = CORE::substr $_, pos $_;
4891 0 $here_script =~ s/.*?\n//oxm;
4892 }
4893 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
4894 0 my $heredoc = $1;
4895 0 my $indent = $2;
4896 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4897 0 push @heredoc, $heredoc . qq{\n$delimiter\n};
4898 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4899 }
4900 else {
4901 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4902 }
4903 0 $e_string .= qq{<<'$delimiter'};
4904 }
4905  
4906 # <<~\HEREDOC
4907 elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4908 0 $slash = 'm//';
4909 0 my $here_quote = $1;
4910 0 my $delimiter = $2;
4911  
4912 # get here document
4913 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4914 0 $here_script = CORE::substr $_, pos $_;
4915 0 $here_script =~ s/.*?\n//oxm;
4916 }
4917 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
4918 0 my $heredoc = $1;
4919 0 my $indent = $2;
4920 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4921 0 push @heredoc, $heredoc . qq{\n$delimiter\n};
4922 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4923 }
4924 else {
4925 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4926 }
4927 0 $e_string .= qq{<<\\$delimiter};
4928 }
4929  
4930 # <<~"HEREDOC"
4931 elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4932 0 $slash = 'm//';
4933 0 my $here_quote = $1;
4934 0 my $delimiter = $2;
4935  
4936 # get here document
4937 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4938 0 $here_script = CORE::substr $_, pos $_;
4939 0 $here_script =~ s/.*?\n//oxm;
4940 }
4941 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
4942 0 my $heredoc = $1;
4943 0 my $indent = $2;
4944 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4945 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4946 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4947 }
4948 else {
4949 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4950 }
4951 0 $e_string .= qq{<<"$delimiter"};
4952 }
4953  
4954 # <<~HEREDOC
4955 elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4956 0 $slash = 'm//';
4957 0 my $here_quote = $1;
4958 0 my $delimiter = $2;
4959  
4960 # get here document
4961 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4962 0 $here_script = CORE::substr $_, pos $_;
4963 0 $here_script =~ s/.*?\n//oxm;
4964 }
4965 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
4966 0 my $heredoc = $1;
4967 0 my $indent = $2;
4968 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4969 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4970 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4971 }
4972 else {
4973 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4974 }
4975 0 $e_string .= qq{<<$delimiter};
4976 }
4977  
4978 # <<~`HEREDOC`
4979 elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4980 0 $slash = 'm//';
4981 0 my $here_quote = $1;
4982 0 my $delimiter = $2;
4983  
4984 # get here document
4985 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4986 0 $here_script = CORE::substr $_, pos $_;
4987 0 $here_script =~ s/.*?\n//oxm;
4988 }
4989 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
4990 0 my $heredoc = $1;
4991 0 my $indent = $2;
4992 0 $heredoc =~ s{^$indent}{}msg; # no /ox
4993 0 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4994 0 push @heredoc_delimiter, qq{\\s*$delimiter};
4995 }
4996 else {
4997 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4998 }
4999 0 $e_string .= qq{<<`$delimiter`};
5000 }
5001  
5002 # <<'HEREDOC'
5003 elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
5004 0 $slash = 'm//';
5005 0 my $here_quote = $1;
5006 0 my $delimiter = $2;
5007  
5008 # get here document
5009 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5010 0 $here_script = CORE::substr $_, pos $_;
5011 0 $here_script =~ s/.*?\n//oxm;
5012 }
5013 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
5014 0 push @heredoc, $1 . qq{\n$delimiter\n};
5015 0 push @heredoc_delimiter, $delimiter;
5016 }
5017 else {
5018 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5019 }
5020 0 $e_string .= $here_quote;
5021 }
5022  
5023 # <<\HEREDOC
5024 elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
5025 0 $slash = 'm//';
5026 0 my $here_quote = $1;
5027 0 my $delimiter = $2;
5028  
5029 # get here document
5030 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5031 0 $here_script = CORE::substr $_, pos $_;
5032 0 $here_script =~ s/.*?\n//oxm;
5033 }
5034 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
5035 0 push @heredoc, $1 . qq{\n$delimiter\n};
5036 0 push @heredoc_delimiter, $delimiter;
5037 }
5038 else {
5039 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5040 }
5041 0 $e_string .= $here_quote;
5042 }
5043  
5044 # <<"HEREDOC"
5045 elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
5046 0 $slash = 'm//';
5047 0 my $here_quote = $1;
5048 0 my $delimiter = $2;
5049  
5050 # get here document
5051 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5052 0 $here_script = CORE::substr $_, pos $_;
5053 0 $here_script =~ s/.*?\n//oxm;
5054 }
5055 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
5056 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5057 0 push @heredoc_delimiter, $delimiter;
5058 }
5059 else {
5060 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5061 }
5062 0 $e_string .= $here_quote;
5063 }
5064  
5065 # <<HEREDOC
5066 elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
5067 0 $slash = 'm//';
5068 0 my $here_quote = $1;
5069 0 my $delimiter = $2;
5070  
5071 # get here document
5072 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5073 0 $here_script = CORE::substr $_, pos $_;
5074 0 $here_script =~ s/.*?\n//oxm;
5075 }
5076 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
5077 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5078 0 push @heredoc_delimiter, $delimiter;
5079 }
5080 else {
5081 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5082 }
5083 0 $e_string .= $here_quote;
5084 }
5085  
5086 # <<`HEREDOC`
5087 elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
5088 0 $slash = 'm//';
5089 0 my $here_quote = $1;
5090 0 my $delimiter = $2;
5091  
5092 # get here document
5093 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
5094 0 $here_script = CORE::substr $_, pos $_;
5095 0 $here_script =~ s/.*?\n//oxm;
5096 }
5097 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
5098 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
5099 0 push @heredoc_delimiter, $delimiter;
5100 }
5101 else {
5102 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
5103 }
5104 0 $e_string .= $here_quote;
5105 }
5106  
5107 # any operator before div
5108 elsif ($string =~ /\G (
5109 -- | \+\+ |
5110 [\)\}\]]
5111  
5112 18 ) /oxgc) { $slash = 'div'; $e_string .= $1; }
5113  
5114 # yada-yada or triple-dot operator
5115 elsif ($string =~ /\G (
5116 \.\.\.
5117  
5118 0 ) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; }
5119  
5120 # any operator before m//
5121 elsif ($string =~ /\G ((?>
5122  
5123 !~~ | !~ | != | ! |
5124 %= | % |
5125 &&= | && | &= | &\.= | &\. | & |
5126 -= | -> | - |
5127 :(?>\s*)= |
5128 : |
5129 <<>> |
5130 <<= | <=> | <= | < |
5131 == | => | =~ | = |
5132 >>= | >> | >= | > |
5133 \*\*= | \*\* | \*= | \* |
5134 \+= | \+ |
5135 \.\. | \.= | \. |
5136 \/\/= | \/\/ |
5137 \/= | \/ |
5138 \? |
5139 \\ |
5140 \^= | \^\.= | \^\. | \^ |
5141 \b x= |
5142 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
5143 ~~ | ~\. | ~ |
5144 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
5145 \b(?: print )\b |
5146  
5147 [,;\(\{\[]
5148  
5149 31 )) /oxgc) { $slash = 'm//'; $e_string .= $1; }
5150  
5151 # other any character
5152 131 elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; }
5153  
5154 # system error
5155 else {
5156 0 die __FILE__, ": Oops, this shouldn't happen!\n";
5157 }
5158 }
5159  
5160 17 return $e_string;
5161 }
5162  
5163 #
5164 # character class
5165 #
5166 1920 ▶sub character_class {
Subroutine character_class: called CC=3 SCAR=11.0
Pod undocumented
5167 1920 my($char,$modifier) = @_;
5168  
5169 1920 ▶ if ($char eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '.') { } 52 1868 1920
5170 52 ▶ if ($modifier =~ /s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/) { } 17 35 52
5171 17 return '${Ekoi8r::dot_s}';
5172 }
5173 else {
5174 35 return '${Ekoi8r::dot}';
5175 }
5176 }
5177 else {
5178 1868 return Ekoi8r::classic_character_class($char);
5179 }
5180 }
5181  
5182 #
5183 # escape capture ($1, $2, $3, ...)
5184 #
5185 212 ▶sub e_capture {
Subroutine e_capture: called CC=1 SCAR=0.0
Pod undocumented
5186  
5187 212 return join '', '${', $_[0], '}';
5188 }
5189  
5190 #
5191 # escape transliteration (tr/// or y///)
5192 #
5193 4 ▶sub e_tr {
Subroutine e_tr: called CC=5 SCAR=16.8
Pod undocumented
5194 4 my($variable,$charclass,$e,$charclass2,$modifier) = @_;
5195 4 my $e_tr = '';
5196 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
5197  
5198 4 $slash = 'div';
5199  
5200 # quote character class 1
5201 4 $charclass = q_tr($charclass);
5202  
5203 # quote character class 2
5204 4 $charclass2 = q_tr($charclass2);
5205  
5206 # /b /B modifier
5207 4 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) { } 0 4 4
5208 0 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 0 0 0
5209 0 $e_tr = qq{tr$charclass$e$charclass2$modifier};
5210 }
5211 else {
5212 0 $e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier};
5213 }
5214 }
5215 else {
5216 4 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 2 2 4
5217 2 $e_tr = qq{Ekoi8r::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')};
5218 }
5219 else {
5220 2 $e_tr = qq{Ekoi8r::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')};
5221 }
5222 }
5223  
5224 # clear tr/// variable
5225 4 $tr_variable = '';
5226 4 $bind_operator = '';
5227  
5228 4 return $e_tr;
5229 }
5230  
5231 #
5232 # quote for escape transliteration (tr/// or y///)
5233 #
5234 8 ▶sub q_tr {
Subroutine q_tr: called CC=9 SCAR=40.6
Pod undocumented
5235 8 my($charclass) = @_;
5236  
5237 # quote character class
5238 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
5239 8 return e_q('', "'", "'", $charclass); # --> q' '
5240 }
5241 elsif ($charclass !~ /\//oxms) {
5242 0 return e_q('q', '/', '/', $charclass); # --> q/ /
5243 }
5244 elsif ($charclass !~ /\#/oxms) {
5245 0 return e_q('q', '#', '#', $charclass); # --> q# #
5246 }
5247 elsif ($charclass !~ /[\<\>]/oxms) {
5248 0 return e_q('q', '<', '>', $charclass); # --> q< >
5249 }
5250 elsif ($charclass !~ /[\(\)]/oxms) {
5251 0 return e_q('q', '(', ')', $charclass); # --> q( )
5252 }
5253 elsif ($charclass !~ /[\{\}]/oxms) {
5254 0 return e_q('q', '{', '}', $charclass); # --> q{ }
5255 }
5256 else {
5257 0 for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5258 0 ▶ if ($charclass !~ /\Q$char\E/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($charclass =~ /\Q$char\E/msx) 0 0 0
5259 0 return e_q('q', $char, $char, $charclass);
5260 }
5261 }
5262 }
5263  
5264 0 return e_q('q', '{', '}', $charclass);
5265 }
5266  
5267 #
5268 # escape q string (q//, '')
5269 #
5270 1623 ▶sub e_q {
Subroutine e_q: called CC=1 SCAR=0.0
Pod undocumented
5271 1623 my($ope,$delimiter,$end_delimiter,$string) = @_;
5272  
5273 1623 $slash = 'div';
5274  
5275 1623 return join '', $ope, $delimiter, $string, $end_delimiter;
5276 }
5277  
5278 #
5279 # escape qq string (qq//, "", qx//, ``)
5280 #
5281 4211 ▶sub e_qq {
Subroutine e_qq: called CC=37 SCAR=50.9
Pod undocumented
5282 4211 my($ope,$delimiter,$end_delimiter,$string) = @_;
5283  
5284 4211 $slash = 'div';
5285  
5286 4211 my $left_e = 0;
5287 4211 my $right_e = 0;
5288  
5289 # split regexp
5290 4211 my @char = $string =~ /\G((?>
5291 [^\\\$] |
5292 \\x\{ (?>[0-9A-Fa-f]+) \} |
5293 \\o\{ (?>[0-7]+) \} |
5294 \\N\{ (?>[^0-9\}][^\}]*) \} |
5295 \\ $q_char |
5296 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5297 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5298 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5299 \$ (?>\s* [0-9]+) |
5300 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5301 \$ \$ (?![\w\{]) |
5302 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5303 $q_char
5304 ))/oxmsg;
5305  
5306 4211 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 116431 4211 120642
5307  
5308 # "\L\u" --> "\u\L"
5309 116431 ▶ 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 116431 116431
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 116431 116431
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 116430 116431
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 116429 116430
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 116429 116429
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
11643100
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
5310 0 @char[$i,$i+1] = @char[$i+1,$i];
5311 }
5312  
5313 # "\U\l" --> "\l\U"
5314 ▶ 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
11643100
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
5315 0 @char[$i,$i+1] = @char[$i+1,$i];
5316 }
5317  
5318 # octal escape sequence
5319 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5320 1 $char[$i] = Ekoi8r::octchr($1);
5321 }
5322  
5323 # hexadecimal escape sequence
5324 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5325 1 $char[$i] = Ekoi8r::hexchr($1);
5326 }
5327  
5328 # \N{CHARNAME} --> N{CHARNAME}
5329 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5330 0 $char[$i] = $1;
5331 }
5332  
5333 116431 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 484 115947 116431
elsif ($char[$i] eq '\\u') { } 0 115947 115947
elsif ($char[$i] eq '\\l') { } 0 115947 115947
elsif ($char[$i] eq '\\U') { } 0 115947 115947
elsif ($char[$i] eq '\\L') { } 0 115947 115947
elsif ($char[$i] eq '\\F') { } 24 115923 115947
elsif ($char[$i] eq '\\Q') { } 0 115923 115923
elsif ($char[$i] eq '\\E') { } 24 115899 115923
elsif ($char[$i] eq '\\Q') { } 0 115899 115899
elsif ($char[$i] eq '\\E') { } 0 115899 115899
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 4 115895 115899
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 115895 115895
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 115895 115895
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 205 115690 115895
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 115690 115690
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 115690 115690
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 115690 115690
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 115690 115690
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 44 115646 115690
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 45 115601 115646
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 33 115568 115601
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 115568 115568
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 115568 115568
5334 }
5335  
5336 # \F
5337 #
5338 # P.69 Table 2-6. Translation escapes
5339 # in Chapter 2: Bits and Pieces
5340 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
5341 # (and so on)
5342  
5343 # \u \l \U \L \F \Q \E
5344 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5345 484 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 484 484
5346 0 $char[$i] = '\\' . $char[$i];
5347 }
5348 }
5349 elsif ($char[$i] eq '\u') {
5350  
5351 # "STRING @{[ LIST EXPR ]} MORE STRING"
5352  
5353 # P.257 Other Tricks You Can Do with Hard References
5354 # in Chapter 8: References
5355 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
5356  
5357 # P.353 Other Tricks You Can Do with Hard References
5358 # in Chapter 8: References
5359 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
5360  
5361 # (and so on)
5362  
5363 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
5364 0 $left_e++;
5365 }
5366 elsif ($char[$i] eq '\l') {
5367 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
5368 0 $left_e++;
5369 }
5370 elsif ($char[$i] eq '\U') {
5371 0 $char[$i] = '@{[Ekoi8r::uc qq<';
5372 0 $left_e++;
5373 }
5374 elsif ($char[$i] eq '\L') {
5375 0 $char[$i] = '@{[Ekoi8r::lc qq<';
5376 0 $left_e++;
5377 }
5378 elsif ($char[$i] eq '\F') {
5379 24 $char[$i] = '@{[Ekoi8r::fc qq<';
5380 24 $left_e++;
5381 }
5382 elsif ($char[$i] eq '\Q') {
5383 0 $char[$i] = '@{[CORE::quotemeta qq<';
5384 0 $left_e++;
5385 }
5386 elsif ($char[$i] eq '\E') {
5387 24 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 24 0 24
5388 24 $char[$i] = '>]}';
5389 24 $right_e++;
5390 }
5391 else {
5392 0 $char[$i] = '';
5393 }
5394 }
5395 elsif ($char[$i] eq '\Q') {
5396 0 while (1) {
5397 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5398 0 last;
5399 }
5400 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5401 0 last;
5402 }
5403 }
5404 }
5405 elsif ($char[$i] eq '\E') {
5406 }
5407  
5408 # $0 --> $0
5409 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5410 }
5411 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5412 }
5413  
5414 # $$ --> $$
5415 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5416 }
5417  
5418 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5419 # $1, $2, $3 --> $1, $2, $3 otherwise
5420 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5421 205 $char[$i] = e_capture($1);
5422 }
5423 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5424 0 $char[$i] = e_capture($1);
5425 }
5426  
5427 # $$foo[ ... ] --> $ $foo->[ ... ]
5428 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5429 0 $char[$i] = e_capture($1.'->'.$2);
5430 }
5431  
5432 # $$foo{ ... } --> $ $foo->{ ... }
5433 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5434 0 $char[$i] = e_capture($1.'->'.$2);
5435 }
5436  
5437 # $$foo
5438 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5439 0 $char[$i] = e_capture($1);
5440 }
5441  
5442 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
5443 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5444 44 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
5445 }
5446  
5447 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
5448 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5449 45 $char[$i] = '@{[Ekoi8r::MATCH()]}';
5450 }
5451  
5452 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
5453 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5454 33 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
5455 }
5456  
5457 # ${ foo } --> ${ foo }
5458 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5459 }
5460  
5461 # ${ ... }
5462 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5463 0 $char[$i] = e_capture($1);
5464 }
5465 }
5466  
5467 # return string
5468 4211 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 4211 4211
5469 0 return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter;
5470 }
5471 4211 return join '', $ope, $delimiter, @char, $end_delimiter;
5472 }
5473  
5474 #
5475 # escape qw string (qw//)
5476 #
5477 16 ▶sub e_qw {
Subroutine e_qw: called CC=11 SCAR=43.1
Pod undocumented
5478 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
5479  
5480 16 $slash = 'div';
5481  
5482 # choice again delimiter
5483 16 my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg);
5484 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
5485 16 return join '', $ope, $delimiter, $string, $end_delimiter;
5486 }
5487 elsif (not $octet{')'}) {
5488 0 return join '', $ope, '(', $string, ')';
5489 }
5490 elsif (not $octet{'}'}) {
5491 0 return join '', $ope, '{', $string, '}';
5492 }
5493 elsif (not $octet{']'}) {
5494 0 return join '', $ope, '[', $string, ']';
5495 }
5496 elsif (not $octet{'>'}) {
5497 0 return join '', $ope, '<', $string, '>';
5498 }
5499 else {
5500 0 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5501 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5502 0 return join '', $ope, $char, $string, $char;
5503 }
5504 }
5505 }
5506  
5507 # qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC')
5508 0 my @string = CORE::split(/\s+/, $string);
5509 0 for my $string (@string) {
5510 0 my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5511 0 for my $octet (@octet) {
5512 0 ▶ if ($octet =~ /\A (['\\]) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet =~ /\A (['\\]) \z/mosx) 0 0 0
5513 0 $octet = '\\' . $1;
5514 }
5515 }
5516 0 $string = join '', @octet;
5517 }
5518 0 return join '', '(', (join ', ', map { "'$_'" } @string), ')';
5519 }
5520  
5521 #
5522 # escape here document (<<"HEREDOC", <<HEREDOC, <<`HEREDOC`, <<~"HEREDOC", <<~HEREDOC, <<~`HEREDOC`)
5523 #
5524 93 ▶sub e_heredoc {
Subroutine e_heredoc: called CC=37 SCAR=56.3
Pod undocumented
5525 93 my($string) = @_;
5526  
5527 93 $slash = 'm//';
5528  
5529 93 my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC`
5530  
5531 93 my $left_e = 0;
5532 93 my $right_e = 0;
5533  
5534 # split regexp
5535 93 my @char = $string =~ /\G((?>
5536 [^\\\$] |
5537 \\x\{ (?>[0-9A-Fa-f]+) \} |
5538 \\o\{ (?>[0-7]+) \} |
5539 \\N\{ (?>[^0-9\}][^\}]*) \} |
5540 \\ $q_char |
5541 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5542 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5543 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5544 \$ (?>\s* [0-9]+) |
5545 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5546 \$ \$ (?![\w\{]) |
5547 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5548 $q_char
5549 ))/oxmsg;
5550  
5551 93 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 3151 93 3244
5552  
5553 # "\L\u" --> "\u\L"
5554 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
5555 0 @char[$i,$i+1] = @char[$i+1,$i];
5556 }
5557  
5558 # "\U\l" --> "\l\U"
5559 ▶ 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
5560 0 @char[$i,$i+1] = @char[$i+1,$i];
5561 }
5562  
5563 # octal escape sequence
5564 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5565 1 $char[$i] = Ekoi8r::octchr($1);
5566 }
5567  
5568 # hexadecimal escape sequence
5569 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5570 1 $char[$i] = Ekoi8r::hexchr($1);
5571 }
5572  
5573 # \N{CHARNAME} --> N{CHARNAME}
5574 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5575 0 $char[$i] = $1;
5576 }
5577  
5578 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
5579 }
5580  
5581 # \u \l \U \L \F \Q \E
5582 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5583 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
5584 0 $char[$i] = '\\' . $char[$i];
5585 }
5586 }
5587 elsif ($char[$i] eq '\u') {
5588 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
5589 0 $left_e++;
5590 }
5591 elsif ($char[$i] eq '\l') {
5592 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
5593 0 $left_e++;
5594 }
5595 elsif ($char[$i] eq '\U') {
5596 0 $char[$i] = '@{[Ekoi8r::uc qq<';
5597 0 $left_e++;
5598 }
5599 elsif ($char[$i] eq '\L') {
5600 0 $char[$i] = '@{[Ekoi8r::lc qq<';
5601 0 $left_e++;
5602 }
5603 elsif ($char[$i] eq '\F') {
5604 0 $char[$i] = '@{[Ekoi8r::fc qq<';
5605 0 $left_e++;
5606 }
5607 elsif ($char[$i] eq '\Q') {
5608 0 $char[$i] = '@{[CORE::quotemeta qq<';
5609 0 $left_e++;
5610 }
5611 elsif ($char[$i] eq '\E') {
5612 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
5613 0 $char[$i] = '>]}';
5614 0 $right_e++;
5615 }
5616 else {
5617 0 $char[$i] = '';
5618 }
5619 }
5620 elsif ($char[$i] eq '\Q') {
5621 0 while (1) {
5622 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5623 0 last;
5624 }
5625 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5626 0 last;
5627 }
5628 }
5629 }
5630 elsif ($char[$i] eq '\E') {
5631 }
5632  
5633 # $0 --> $0
5634 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5635 }
5636 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5637 }
5638  
5639 # $$ --> $$
5640 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5641 }
5642  
5643 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5644 # $1, $2, $3 --> $1, $2, $3 otherwise
5645 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5646 0 $char[$i] = e_capture($1);
5647 }
5648 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5649 0 $char[$i] = e_capture($1);
5650 }
5651  
5652 # $$foo[ ... ] --> $ $foo->[ ... ]
5653 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5654 0 $char[$i] = e_capture($1.'->'.$2);
5655 }
5656  
5657 # $$foo{ ... } --> $ $foo->{ ... }
5658 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5659 0 $char[$i] = e_capture($1.'->'.$2);
5660 }
5661  
5662 # $$foo
5663 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5664 0 $char[$i] = e_capture($1);
5665 }
5666  
5667 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
5668 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5669 8 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
5670 }
5671  
5672 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
5673 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5674 8 $char[$i] = '@{[Ekoi8r::MATCH()]}';
5675 }
5676  
5677 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
5678 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5679 6 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
5680 }
5681  
5682 # ${ foo } --> ${ foo }
5683 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5684 }
5685  
5686 # ${ ... }
5687 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5688 0 $char[$i] = e_capture($1);
5689 }
5690 }
5691  
5692 # return string
5693 93 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 93 93
5694 0 return join '', @char, '>]}' x ($left_e - $right_e);
5695 }
5696 93 return join '', @char;
5697 }
5698  
5699 #
5700 # escape regexp (m//, qr//)
5701 #
5702 880 ▶sub e_qr {
Subroutine e_qr: called CC=110 SCAR=73.6
Pod undocumented
5703 880 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5704 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
5705  
5706 880 $modifier =~ tr/p//d;
5707 880 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 880 880
5708 0 my $line = 0;
5709 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5710 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5711 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5712 0 last;
5713 }
5714 }
5715 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5716 }
5717  
5718 880 $slash = 'div';
5719  
5720 # literal null string pattern
5721 880 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 872 880
elsif ($modifier =~ tr/Bb//d) { } 2 870 872
5722 8 $modifier =~ tr/bB//d;
5723 8 $modifier =~ tr/i//d;
5724 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5725 }
5726  
5727 # /b /B modifier
5728 elsif ($modifier =~ tr/bB//d) {
5729  
5730 # choice again delimiter
5731 2 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 2 2
5732 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5733 0 my %octet = map {$_ => 1} @char;
5734 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
5735 0 $delimiter = '(';
5736 0 $end_delimiter = ')';
5737 }
5738 elsif (not $octet{'}'}) {
5739 0 $delimiter = '{';
5740 0 $end_delimiter = '}';
5741 }
5742 elsif (not $octet{']'}) {
5743 0 $delimiter = '[';
5744 0 $end_delimiter = ']';
5745 }
5746 elsif (not $octet{'>'}) {
5747 0 $delimiter = '<';
5748 0 $end_delimiter = '>';
5749 }
5750 else {
5751 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5752 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5753 0 $delimiter = $char;
5754 0 $end_delimiter = $char;
5755 0 last;
5756 }
5757 }
5758 }
5759 }
5760  
5761 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
5762 0 return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier;
5763 }
5764 else {
5765 2 return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5766 }
5767 }
5768  
5769 870 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 312 558 870
5770 870 my $metachar = qr/[\@\\|[\]{^]/oxms;
5771  
5772 # split regexp
5773 870 my @char = $string =~ /\G((?>
5774 [^\\\$\@\[\(] |
5775 \\x (?>[0-9A-Fa-f]{1,2}) |
5776 \\ (?>[0-7]{2,3}) |
5777 \\c [\x40-\x5F] |
5778 \\x\{ (?>[0-9A-Fa-f]+) \} |
5779 \\o\{ (?>[0-7]+) \} |
5780 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5781 \\ $q_char |
5782 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5783 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5784 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5785 [\$\@] $qq_variable |
5786 \$ (?>\s* [0-9]+) |
5787 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5788 \$ \$ (?![\w\{]) |
5789 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5790 \[\^ |
5791 \[\: (?>[a-z]+) :\] |
5792 \[\:\^ (?>[a-z]+) :\] |
5793 \(\? |
5794 $q_char
5795 ))/oxmsg;
5796  
5797 # choice again delimiter
5798 870 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 870 870
5799 0 my %octet = map {$_ => 1} @char;
5800 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
5801 0 $delimiter = '(';
5802 0 $end_delimiter = ')';
5803 }
5804 elsif (not $octet{'}'}) {
5805 0 $delimiter = '{';
5806 0 $end_delimiter = '}';
5807 }
5808 elsif (not $octet{']'}) {
5809 0 $delimiter = '[';
5810 0 $end_delimiter = ']';
5811 }
5812 elsif (not $octet{'>'}) {
5813 0 $delimiter = '<';
5814 0 $end_delimiter = '>';
5815 }
5816 else {
5817 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5818 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5819 0 $delimiter = $char;
5820 0 $end_delimiter = $char;
5821 0 last;
5822 }
5823 }
5824 }
5825 }
5826  
5827 870 my $left_e = 0;
5828 870 my $right_e = 0;
5829 870 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2100 870 2970
5830  
5831 # "\L\u" --> "\u\L"
5832 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
5833 0 @char[$i,$i+1] = @char[$i+1,$i];
5834 }
5835  
5836 # "\U\l" --> "\l\U"
5837 ▶ 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
5838 0 @char[$i,$i+1] = @char[$i+1,$i];
5839 }
5840  
5841 # octal escape sequence
5842 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5843 1 $char[$i] = Ekoi8r::octchr($1);
5844 }
5845  
5846 # hexadecimal escape sequence
5847 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5848 1 $char[$i] = Ekoi8r::hexchr($1);
5849 }
5850  
5851 # \b{...} --> b\{...}
5852 # \B{...} --> B\{...}
5853 # \N{CHARNAME} --> N\{CHARNAME}
5854 # \p{PROPERTY} --> p\{PROPERTY}
5855 # \P{PROPERTY} --> P\{PROPERTY}
5856 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5857 6 $char[$i] = $1 . '\\' . $2;
5858 }
5859  
5860 # \p, \P, \X --> p, P, X
5861 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
5862 4 $char[$i] = $1;
5863 }
5864  
5865 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 &Ekoi8r::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
5866 }
5867  
5868 # join separated multiple-octet
5869 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
5870 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5871 0 $char[$i] .= join '', splice @char, $i+1, 3;
5872 }
5873 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5874 0 $char[$i] .= join '', splice @char, $i+1, 2;
5875 }
5876 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
5877 0 $char[$i] .= join '', splice @char, $i+1, 1;
5878 }
5879 }
5880  
5881 # open character class [...]
5882 elsif ($char[$i] eq '[') {
5883 556 my $left = $i;
5884  
5885 # [] make die "Unmatched [] in regexp ...\n"
5886 # (and so on)
5887  
5888 556 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 3 553 556
5889 3 $i++;
5890 }
5891  
5892 556 while (1) {
5893 2063 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 2063 2063
5894 0 die __FILE__, ": Unmatched [] in regexp\n";
5895 }
5896 2063 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 556 1507 2063
5897 556 my $right = $i;
5898  
5899 # [...]
5900 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
5901 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5902 }
5903 else {
5904 526 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
5905 }
5906  
5907 556 $i = $left;
5908 556 last;
5909 }
5910 }
5911 }
5912  
5913 # open character class [^...]
5914 elsif ($char[$i] eq '[^') {
5915 74 my $left = $i;
5916  
5917 # [^] make die "Unmatched [] in regexp ...\n"
5918 # (and so on)
5919  
5920 74 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 4 70 74
5921 4 $i++;
5922 }
5923  
5924 74 while (1) {
5925 272 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 272 272
5926 0 die __FILE__, ": Unmatched [] in regexp\n";
5927 }
5928 272 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 74 198 272
5929 74 my $right = $i;
5930  
5931 # [^...]
5932 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
5933 30 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
5934 }
5935 else {
5936 44 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5937 }
5938  
5939 74 $i = $left;
5940 74 last;
5941 }
5942 }
5943 }
5944  
5945 # rewrite character class or escape character
5946 elsif (my $char = character_class($char[$i],$modifier)) {
5947 139 $char[$i] = $char;
5948 }
5949  
5950 # /i modifier
5951 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition100%6/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
5952 20 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 20 0 20
5953 20 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
5954 }
5955 else {
5956 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
5957 }
5958 }
5959  
5960 # \u \l \U \L \F \Q \E
5961 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
5962 1 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 1 1
5963 0 $char[$i] = '\\' . $char[$i];
5964 }
5965 }
5966 elsif ($char[$i] eq '\u') {
5967 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
5968 0 $left_e++;
5969 }
5970 elsif ($char[$i] eq '\l') {
5971 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
5972 0 $left_e++;
5973 }
5974 elsif ($char[$i] eq '\U') {
5975 1 $char[$i] = '@{[Ekoi8r::uc qq<';
5976 1 $left_e++;
5977 }
5978 elsif ($char[$i] eq '\L') {
5979 1 $char[$i] = '@{[Ekoi8r::lc qq<';
5980 1 $left_e++;
5981 }
5982 elsif ($char[$i] eq '\F') {
5983 18 $char[$i] = '@{[Ekoi8r::fc qq<';
5984 18 $left_e++;
5985 }
5986 elsif ($char[$i] eq '\Q') {
5987 1 $char[$i] = '@{[CORE::quotemeta qq<';
5988 1 $left_e++;
5989 }
5990 elsif ($char[$i] eq '\E') {
5991 21 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 21 0 21
5992 21 $char[$i] = '>]}';
5993 21 $right_e++;
5994 }
5995 else {
5996 0 $char[$i] = '';
5997 }
5998 }
5999 elsif ($char[$i] eq '\Q') {
6000 0 while (1) {
6001 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6002 0 last;
6003 }
6004 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6005 0 last;
6006 }
6007 }
6008 }
6009 elsif ($char[$i] eq '\E') {
6010 }
6011  
6012 # $0 --> $0
6013 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6014 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6015 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6016 }
6017 }
6018 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6019 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6020 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6021 }
6022 }
6023  
6024 # $$ --> $$
6025 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6026 }
6027  
6028 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6029 # $1, $2, $3 --> $1, $2, $3 otherwise
6030 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6031 0 $char[$i] = e_capture($1);
6032 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6033 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6034 }
6035 }
6036 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6037 0 $char[$i] = e_capture($1);
6038 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6039 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6040 }
6041 }
6042  
6043 # $$foo[ ... ] --> $ $foo->[ ... ]
6044 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6045 0 $char[$i] = e_capture($1.'->'.$2);
6046 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6047 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6048 }
6049 }
6050  
6051 # $$foo{ ... } --> $ $foo->{ ... }
6052 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6053 0 $char[$i] = e_capture($1.'->'.$2);
6054 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6055 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6056 }
6057 }
6058  
6059 # $$foo
6060 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6061 0 $char[$i] = e_capture($1);
6062 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6063 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6064 }
6065 }
6066  
6067 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
6068 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6069 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
6070 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
6071 }
6072 else {
6073 8 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
6074 }
6075 }
6076  
6077 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
6078 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6079 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
6080 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
6081 }
6082 else {
6083 8 $char[$i] = '@{[Ekoi8r::MATCH()]}';
6084 }
6085 }
6086  
6087 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
6088 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6089 6 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 6 6
6090 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
6091 }
6092 else {
6093 6 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
6094 }
6095 }
6096  
6097 # ${ foo }
6098 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6099 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6100 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6101 }
6102 }
6103  
6104 # ${ ... }
6105 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6106 0 $char[$i] = e_capture($1);
6107 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6108 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6109 }
6110 }
6111  
6112 # $scalar or @array
6113 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6114 21 $char[$i] = e_string($char[$i]);
6115 21 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 11 10 21
6116 11 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6117 }
6118 }
6119  
6120 # quote character before ? + * {
6121 ▶ 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
6122 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
6123 }
6124 ▶ 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
6125 0 my $char = $char[$i-1];
6126 0 ▶ if ($char[$i] eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq '{') { } 0 0 0
6127 0 die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n};
6128 }
6129 else {
6130 0 die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n};
6131 }
6132 }
6133 else {
6134 127 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6135 }
6136 }
6137 }
6138  
6139 # make regexp string
6140 870 $modifier =~ tr/i//d;
6141 870 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 870 870
6142 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
6143 0 return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier;
6144 }
6145 else {
6146 0 return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6147 }
6148 }
6149 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
6150 0 return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier;
6151 }
6152 else {
6153 870 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6154 }
6155 }
6156  
6157 #
6158 # double quote stuff
6159 #
6160 180 ▶sub qq_stuff {
Subroutine qq_stuff: called CC=6 SCAR=18.5
Pod undocumented
6161 180 my($delimiter,$end_delimiter,$stuff) = @_;
6162  
6163 # scalar variable or array variable
6164 180 ▶ if ($stuff =~ /\A [\$\@] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff =~ /\A [\$\@] /mosx) 100 80 180
6165 100 return $stuff;
6166 }
6167  
6168 # quote by delimiter
6169 80 my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg);
6170 80 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6171 80 ▶ next if $char eq $delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $delimiter 0 80 80
6172 80 ▶ next if $char eq $end_delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $end_delimiter 0 80 80
6173 80 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 80 0 80
6174 80 return join '', 'qq', $char, $stuff, $char;
6175 }
6176 }
6177 0 return join '', 'qq', '<', $stuff, '>';
6178 }
6179  
6180 #
6181 # escape regexp (m'', qr'', and m''b, qr''b)
6182 #
6183 10 ▶sub e_qr_q {
Subroutine e_qr_q: called CC=7 SCAR=25.3
Pod undocumented
6184 10 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6185 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
6186  
6187 10 $modifier =~ tr/p//d;
6188 10 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 10 10
6189 0 my $line = 0;
6190 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6191 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6192 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6193 0 last;
6194 }
6195 }
6196 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6197 }
6198  
6199 10 $slash = 'div';
6200  
6201 # literal null string pattern
6202 10 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 2 10
elsif ($modifier =~ tr/Bb//d) { } 0 2 2
6203 8 $modifier =~ tr/bB//d;
6204 8 $modifier =~ tr/i//d;
6205 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6206 }
6207  
6208 # with /b /B modifier
6209 elsif ($modifier =~ tr/bB//d) {
6210 0 return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6211 }
6212  
6213 # without /b /B modifier
6214 else {
6215 2 return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6216 }
6217 }
6218  
6219 #
6220 # escape regexp (m'', qr'')
6221 #
6222 2 ▶sub e_qr_qt {
Subroutine e_qr_qt: called CC=20 SCAR=51.8
Pod undocumented
6223 2 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6224  
6225 2 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 2 2
6226  
6227 # split regexp
6228 2 my @char = $string =~ /\G((?>
6229 [^\\\[\$\@\/] |
6230 [\x00-\xFF] |
6231 \[\^ |
6232 \[\: (?>[a-z]+) \:\] |
6233 \[\:\^ (?>[a-z]+) \:\] |
6234 [\$\@\/] |
6235 \\ (?:$q_char) |
6236 (?:$q_char)
6237 ))/oxmsg;
6238  
6239 # unescape character
6240 2 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2 2 4
6241 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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])) { } 0 2 2
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 4 4
6242 }
6243  
6244 # open character class [...]
6245 elsif ($char[$i] eq '[') {
6246 0 my $left = $i;
6247 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6248 0 $i++;
6249 }
6250 0 while (1) {
6251 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6252 0 die __FILE__, ": Unmatched [] in regexp\n";
6253 }
6254 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6255 0 my $right = $i;
6256  
6257 # [...]
6258 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6259  
6260 0 $i = $left;
6261 0 last;
6262 }
6263 }
6264 }
6265  
6266 # open character class [^...]
6267 elsif ($char[$i] eq '[^') {
6268 0 my $left = $i;
6269 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6270 0 $i++;
6271 }
6272 0 while (1) {
6273 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6274 0 die __FILE__, ": Unmatched [] in regexp\n";
6275 }
6276 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6277 0 my $right = $i;
6278  
6279 # [^...]
6280 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6281  
6282 0 $i = $left;
6283 0 last;
6284 }
6285 }
6286 }
6287  
6288 # escape $ @ / and \
6289 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6290 0 $char[$i] = '\\' . $char[$i];
6291 }
6292  
6293 # rewrite character class or escape character
6294 elsif (my $char = character_class($char[$i],$modifier)) {
6295 0 $char[$i] = $char;
6296 }
6297  
6298 # /i modifier
6299 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6300 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6301 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6302 }
6303 else {
6304 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6305 }
6306 }
6307  
6308 # quote character before ? + * {
6309 ▶ 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
6310 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
6311 }
6312 else {
6313 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6314 }
6315 }
6316 }
6317  
6318 2 $delimiter = '/';
6319 2 $end_delimiter = '/';
6320  
6321 2 $modifier =~ tr/i//d;
6322 2 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6323 }
6324  
6325 #
6326 # escape regexp (m''b, qr''b)
6327 #
6328 0 ▶sub e_qr_qb {
Subroutine e_qr_qb: not called CC=4 SCAR=30.0
Pod undocumented
6329 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6330  
6331 # split regexp
6332 0 my @char = $string =~ /\G ((?>[^\\]|\\\\)) /oxmsg;
6333  
6334 # unescape character
6335 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6336 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
6337 }
6338  
6339 # remain \\
6340 elsif ($char[$i] eq '\\\\') {
6341 }
6342  
6343 # escape $ @ / and \
6344 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6345 0 $char[$i] = '\\' . $char[$i];
6346 }
6347 }
6348  
6349 0 $delimiter = '/';
6350 0 $end_delimiter = '/';
6351 0 return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6352 }
6353  
6354 #
6355 # escape regexp (s/here//)
6356 #
6357 80 ▶sub e_s1 {
Subroutine e_s1: called CC=106 SCAR=81.1
Pod undocumented
6358 80 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6359 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
6360  
6361 80 $modifier =~ tr/p//d;
6362 80 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 80 80
6363 0 my $line = 0;
6364 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6365 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6366 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6367 0 last;
6368 }
6369 }
6370 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6371 }
6372  
6373 80 $slash = 'div';
6374  
6375 # literal null string pattern
6376 80 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 72 80
elsif ($modifier =~ tr/Bb//d) { } 0 72 72
6377 8 $modifier =~ tr/bB//d;
6378 8 $modifier =~ tr/i//d;
6379 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6380 }
6381  
6382 # /b /B modifier
6383 elsif ($modifier =~ tr/bB//d) {
6384  
6385 # choice again delimiter
6386 0 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 0 0
6387 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
6388 0 my %octet = map {$_ => 1} @char;
6389 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
6390 0 $delimiter = '(';
6391 0 $end_delimiter = ')';
6392 }
6393 elsif (not $octet{'}'}) {
6394 0 $delimiter = '{';
6395 0 $end_delimiter = '}';
6396 }
6397 elsif (not $octet{']'}) {
6398 0 $delimiter = '[';
6399 0 $end_delimiter = ']';
6400 }
6401 elsif (not $octet{'>'}) {
6402 0 $delimiter = '<';
6403 0 $end_delimiter = '>';
6404 }
6405 else {
6406 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6407 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
6408 0 $delimiter = $char;
6409 0 $end_delimiter = $char;
6410 0 last;
6411 }
6412 }
6413 }
6414 }
6415  
6416 0 my $prematch = '';
6417 0 return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
6418 }
6419  
6420 72 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 1 71 72
6421 72 my $metachar = qr/[\@\\|[\]{^]/oxms;
6422  
6423 # split regexp
6424 72 my @char = $string =~ /\G((?>
6425 [^\\\$\@\[\(] |
6426 \\ (?>[1-9][0-9]*) |
6427 \\g (?>\s*) (?>[1-9][0-9]*) |
6428 \\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
6429 \\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
6430 \\x (?>[0-9A-Fa-f]{1,2}) |
6431 \\ (?>[0-7]{2,3}) |
6432 \\c [\x40-\x5F] |
6433 \\x\{ (?>[0-9A-Fa-f]+) \} |
6434 \\o\{ (?>[0-7]+) \} |
6435 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
6436 \\ $q_char |
6437 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
6438 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
6439 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
6440 [\$\@] $qq_variable |
6441 \$ (?>\s* [0-9]+) |
6442 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
6443 \$ \$ (?![\w\{]) |
6444 \$ (?>\s*) \$ (?>\s*) $qq_variable |
6445 \[\^ |
6446 \[\: (?>[a-z]+) :\] |
6447 \[\:\^ (?>[a-z]+) :\] |
6448 \(\? |
6449 $q_char
6450 ))/oxmsg;
6451  
6452 # choice again delimiter
6453 72 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 72 72
6454 0 my %octet = map {$_ => 1} @char;
6455 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
6456 0 $delimiter = '(';
6457 0 $end_delimiter = ')';
6458 }
6459 elsif (not $octet{'}'}) {
6460 0 $delimiter = '{';
6461 0 $end_delimiter = '}';
6462 }
6463 elsif (not $octet{']'}) {
6464 0 $delimiter = '[';
6465 0 $end_delimiter = ']';
6466 }
6467 elsif (not $octet{'>'}) {
6468 0 $delimiter = '<';
6469 0 $end_delimiter = '>';
6470 }
6471 else {
6472 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
6473 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
6474 0 $delimiter = $char;
6475 0 $end_delimiter = $char;
6476 0 last;
6477 }
6478 }
6479 }
6480 }
6481  
6482 # count '('
6483 72 my $parens = grep { $_ eq '(' } @char;
6484  
6485 72 my $left_e = 0;
6486 72 my $right_e = 0;
6487 72 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 200 72 272
6488  
6489 # "\L\u" --> "\u\L"
6490 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
6491 0 @char[$i,$i+1] = @char[$i+1,$i];
6492 }
6493  
6494 # "\U\l" --> "\l\U"
6495 ▶ 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
6496 0 @char[$i,$i+1] = @char[$i+1,$i];
6497 }
6498  
6499 # octal escape sequence
6500 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6501 1 $char[$i] = Ekoi8r::octchr($1);
6502 }
6503  
6504 # hexadecimal escape sequence
6505 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6506 1 $char[$i] = Ekoi8r::hexchr($1);
6507 }
6508  
6509 # \b{...} --> b\{...}
6510 # \B{...} --> B\{...}
6511 # \N{CHARNAME} --> N\{CHARNAME}
6512 # \p{PROPERTY} --> p\{PROPERTY}
6513 # \P{PROPERTY} --> P\{PROPERTY}
6514 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6515 0 $char[$i] = $1 . '\\' . $2;
6516 }
6517  
6518 # \p, \P, \X --> p, P, X
6519 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6520 0 $char[$i] = $1;
6521 }
6522  
6523 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 &Ekoi8r::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
6524 }
6525  
6526 # join separated multiple-octet
6527 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6528 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6529 0 $char[$i] .= join '', splice @char, $i+1, 3;
6530 }
6531 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6532 0 $char[$i] .= join '', splice @char, $i+1, 2;
6533 }
6534 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
6535 0 $char[$i] .= join '', splice @char, $i+1, 1;
6536 }
6537 }
6538  
6539 # open character class [...]
6540 elsif ($char[$i] eq '[') {
6541 17 my $left = $i;
6542 17 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 17 17
6543 0 $i++;
6544 }
6545 17 while (1) {
6546 74 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 74 74
6547 0 die __FILE__, ": Unmatched [] in regexp\n";
6548 }
6549 74 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 17 57 74
6550 17 my $right = $i;
6551  
6552 # [...]
6553 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
6554 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6555 }
6556 else {
6557 17 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6558 }
6559  
6560 17 $i = $left;
6561 17 last;
6562 }
6563 }
6564 }
6565  
6566 # open character class [^...]
6567 elsif ($char[$i] eq '[^') {
6568 0 my $left = $i;
6569 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6570 0 $i++;
6571 }
6572 0 while (1) {
6573 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6574 0 die __FILE__, ": Unmatched [] in regexp\n";
6575 }
6576 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6577 0 my $right = $i;
6578  
6579 # [^...]
6580 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
6581 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
6582 }
6583 else {
6584 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6585 }
6586  
6587 0 $i = $left;
6588 0 last;
6589 }
6590 }
6591 }
6592  
6593 # rewrite character class or escape character
6594 elsif (my $char = character_class($char[$i],$modifier)) {
6595 7 $char[$i] = $char;
6596 }
6597  
6598 # /i modifier
6599 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition66%4/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6600 3 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 3 0 3
6601 3 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6602 }
6603 else {
6604 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6605 }
6606 }
6607  
6608 # \u \l \U \L \F \Q \E
6609 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
6610 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6611 0 $char[$i] = '\\' . $char[$i];
6612 }
6613 }
6614 elsif ($char[$i] eq '\u') {
6615 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
6616 0 $left_e++;
6617 }
6618 elsif ($char[$i] eq '\l') {
6619 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
6620 0 $left_e++;
6621 }
6622 elsif ($char[$i] eq '\U') {
6623 0 $char[$i] = '@{[Ekoi8r::uc qq<';
6624 0 $left_e++;
6625 }
6626 elsif ($char[$i] eq '\L') {
6627 0 $char[$i] = '@{[Ekoi8r::lc qq<';
6628 0 $left_e++;
6629 }
6630 elsif ($char[$i] eq '\F') {
6631 0 $char[$i] = '@{[Ekoi8r::fc qq<';
6632 0 $left_e++;
6633 }
6634 elsif ($char[$i] eq '\Q') {
6635 0 $char[$i] = '@{[CORE::quotemeta qq<';
6636 0 $left_e++;
6637 }
6638 elsif ($char[$i] eq '\E') {
6639 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6640 0 $char[$i] = '>]}';
6641 0 $right_e++;
6642 }
6643 else {
6644 0 $char[$i] = '';
6645 }
6646 }
6647 elsif ($char[$i] eq '\Q') {
6648 0 while (1) {
6649 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6650 0 last;
6651 }
6652 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6653 0 last;
6654 }
6655 }
6656 }
6657 elsif ($char[$i] eq '\E') {
6658 }
6659  
6660 # \0 --> \0
6661 elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) {
6662 }
6663  
6664 # \g{N}, \g{-N}
6665  
6666 # P.108 Using Simple Patterns
6667 # in Chapter 7: In the World of Regular Expressions
6668 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
6669  
6670 # P.221 Capturing
6671 # in Chapter 5: Pattern Matching
6672 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6673  
6674 # \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3}
6675 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6676 }
6677  
6678 # \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable)
6679 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6680 }
6681  
6682 # \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable)
6683 elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6684 }
6685  
6686 # \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable)
6687 elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6688 }
6689  
6690 # $0 --> $0
6691 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6692 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6693 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6694 }
6695 }
6696 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6697 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6698 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6699 }
6700 }
6701  
6702 # $$ --> $$
6703 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6704 }
6705  
6706 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6707 # $1, $2, $3 --> $1, $2, $3 otherwise
6708 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6709 0 $char[$i] = e_capture($1);
6710 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6711 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6712 }
6713 }
6714 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6715 0 $char[$i] = e_capture($1);
6716 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6717 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6718 }
6719 }
6720  
6721 # $$foo[ ... ] --> $ $foo->[ ... ]
6722 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6723 0 $char[$i] = e_capture($1.'->'.$2);
6724 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6725 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6726 }
6727 }
6728  
6729 # $$foo{ ... } --> $ $foo->{ ... }
6730 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6731 0 $char[$i] = e_capture($1.'->'.$2);
6732 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6733 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6734 }
6735 }
6736  
6737 # $$foo
6738 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6739 0 $char[$i] = e_capture($1);
6740 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6741 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6742 }
6743 }
6744  
6745 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
6746 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6747 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6748 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
6749 }
6750 else {
6751 4 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
6752 }
6753 }
6754  
6755 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
6756 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6757 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6758 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
6759 }
6760 else {
6761 4 $char[$i] = '@{[Ekoi8r::MATCH()]}';
6762 }
6763 }
6764  
6765 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
6766 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6767 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 3 3
6768 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
6769 }
6770 else {
6771 3 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
6772 }
6773 }
6774  
6775 # ${ foo }
6776 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6777 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6778 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6779 }
6780 }
6781  
6782 # ${ ... }
6783 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6784 0 $char[$i] = e_capture($1);
6785 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6786 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6787 }
6788 }
6789  
6790 # $scalar or @array
6791 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6792 4 $char[$i] = e_string($char[$i]);
6793 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 4 4
6794 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6795 }
6796 }
6797  
6798 # quote character before ? + * {
6799 ▶ 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
6800 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
6801 }
6802 else {
6803 14 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6804 }
6805 }
6806 }
6807  
6808 # make regexp string
6809 72 my $prematch = '';
6810 72 $modifier =~ tr/i//d;
6811 72 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 72 72
6812 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6813 }
6814 72 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6815 }
6816  
6817 #
6818 # escape regexp (s'here'' or s'here''b)
6819 #
6820 21 ▶sub e_s1_q {
Subroutine e_s1_q: called CC=7 SCAR=24.3
Pod undocumented
6821 21 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6822 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
6823  
6824 21 $modifier =~ tr/p//d;
6825 21 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 21 21
6826 0 my $line = 0;
6827 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6828 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6829 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6830 0 last;
6831 }
6832 }
6833 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6834 }
6835  
6836 21 $slash = 'div';
6837  
6838 # literal null string pattern
6839 21 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 13 21
elsif ($modifier =~ tr/Bb//d) { } 0 13 13
6840 8 $modifier =~ tr/bB//d;
6841 8 $modifier =~ tr/i//d;
6842 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6843 }
6844  
6845 # with /b /B modifier
6846 elsif ($modifier =~ tr/bB//d) {
6847 0 return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6848 }
6849  
6850 # without /b /B modifier
6851 else {
6852 13 return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6853 }
6854 }
6855  
6856 #
6857 # escape regexp (s'here'')
6858 #
6859 13 ▶sub e_s1_qt {
Subroutine e_s1_qt: called CC=20 SCAR=50.1
Pod undocumented
6860 13 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6861  
6862 13 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 13 13
6863  
6864 # split regexp
6865 13 my @char = $string =~ /\G((?>
6866 [^\\\[\$\@\/] |
6867 [\x00-\xFF] |
6868 \[\^ |
6869 \[\: (?>[a-z]+) \:\] |
6870 \[\:\^ (?>[a-z]+) \:\] |
6871 [\$\@\/] |
6872 \\ (?:$q_char) |
6873 (?:$q_char)
6874 ))/oxmsg;
6875  
6876 # unescape character
6877 13 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 25 13 38
6878 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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])) { } 0 19 19
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 32 32
6879 }
6880  
6881 # open character class [...]
6882 elsif ($char[$i] eq '[') {
6883 0 my $left = $i;
6884 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6885 0 $i++;
6886 }
6887 0 while (1) {
6888 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6889 0 die __FILE__, ": Unmatched [] in regexp\n";
6890 }
6891 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6892 0 my $right = $i;
6893  
6894 # [...]
6895 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6896  
6897 0 $i = $left;
6898 0 last;
6899 }
6900 }
6901 }
6902  
6903 # open character class [^...]
6904 elsif ($char[$i] eq '[^') {
6905 0 my $left = $i;
6906 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6907 0 $i++;
6908 }
6909 0 while (1) {
6910 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6911 0 die __FILE__, ": Unmatched [] in regexp\n";
6912 }
6913 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6914 0 my $right = $i;
6915  
6916 # [^...]
6917 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6918  
6919 0 $i = $left;
6920 0 last;
6921 }
6922 }
6923 }
6924  
6925 # escape $ @ / and \
6926 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6927 0 $char[$i] = '\\' . $char[$i];
6928 }
6929  
6930 # rewrite character class or escape character
6931 elsif (my $char = character_class($char[$i],$modifier)) {
6932 6 $char[$i] = $char;
6933 }
6934  
6935 # /i modifier
6936 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
6937 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6938 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6939 }
6940 else {
6941 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6942 }
6943 }
6944  
6945 # quote character before ? + * {
6946 ▶ 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
6947 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
6948 }
6949 else {
6950 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6951 }
6952 }
6953 }
6954  
6955 13 $modifier =~ tr/i//d;
6956 13 $delimiter = '/';
6957 13 $end_delimiter = '/';
6958 13 my $prematch = '';
6959 13 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6960 }
6961  
6962 #
6963 # escape regexp (s'here''b)
6964 #
6965 0 ▶sub e_s1_qb {
Subroutine e_s1_qb: not called CC=4 SCAR=30.0
Pod undocumented
6966 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6967  
6968 # split regexp
6969 0 my @char = $string =~ /\G (?>[^\\]|\\\\) /oxmsg;
6970  
6971 # unescape character
6972 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6973 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
6974 }
6975  
6976 # remain \\
6977 elsif ($char[$i] eq '\\\\') {
6978 }
6979  
6980 # escape $ @ / and \
6981 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6982 0 $char[$i] = '\\' . $char[$i];
6983 }
6984 }
6985  
6986 0 $delimiter = '/';
6987 0 $end_delimiter = '/';
6988 0 my $prematch = '';
6989 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6990 }
6991  
6992 #
6993 # escape regexp (s''here')
6994 #
6995 16 ▶sub e_s2_q {
Subroutine e_s2_q: called CC=4 SCAR=13.9
Pod undocumented
6996 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
6997  
6998 16 $slash = 'div';
6999  
7000 16 my @char = $string =~ / \G (?>[^\\]|\\\\|$q_char) /oxmsg;
7001 16 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 9 16 25
7002 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
7003 }
7004  
7005 # not escape \\
7006 elsif ($char[$i] =~ /\A \\\\ \z/oxms) {
7007 }
7008  
7009 # escape $ @ / and \
7010 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
7011 5 $char[$i] = '\\' . $char[$i];
7012 }
7013 }
7014  
7015 16 return join '', $ope, $delimiter, @char, $end_delimiter;
7016 }
7017  
7018 #
7019 # escape regexp (s/here/and here/modifier)
7020 #
7021 101 ▶sub e_sub {
Subroutine e_sub: called CC=20 SCAR=32.6
Pod undocumented
7022 101 my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_;
7023 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
7024  
7025 101 $modifier =~ tr/p//d;
7026 101 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 101 101
7027 0 my $line = 0;
7028 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7029 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7030 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7031 0 last;
7032 }
7033 }
7034 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7035 }
7036  
7037 101 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq "") 36 65 101
7038 36 $variable = '$_';
7039 36 $bind_operator = ' =~ ';
7040 }
7041  
7042 101 $slash = 'div';
7043  
7044 # P.128 Start of match (or end of previous match): \G
7045 # P.130 Advanced Use of \G with Perl
7046 # in Chapter 3: Overview of Regular Expression Features and Flavors
7047 # P.312 Iterative Matching: Scalar Context, with /g
7048 # in Chapter 7: Perl
7049 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
7050  
7051 # P.181 Where You Left Off: The \G Assertion
7052 # in Chapter 5: Pattern Matching
7053 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
7054  
7055 # P.220 Where You Left Off: The \G Assertion
7056 # in Chapter 5: Pattern Matching
7057 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
7058  
7059 101 my $e_modifier = $modifier =~ tr/e//d;
7060 101 my $r_modifier = $modifier =~ tr/r//d;
7061  
7062 101 my $my = '';
7063 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
7064 0 $my = $variable;
7065 0 $variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms;
7066 0 $variable =~ s/ = .+ \z//oxms;
7067 }
7068  
7069 101 (my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms;
7070 101 $variable_basename =~ s/ \s+ \z//oxms;
7071  
7072 # quote replacement string
7073 101 my $e_replacement = '';
7074 101 ▶ if ($e_modifier >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e_modifier >= 1) { } 17 84 101
7075 17 $e_replacement = e_qq('', '', '', $replacement);
7076 17 $e_modifier--;
7077 }
7078 else {
7079 84 ▶ if ($delimiter2 eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter2 eq q[']) { } 16 68 84
7080 16 $e_replacement = e_s2_q('qq', '/', '/', $replacement);
7081 }
7082 else {
7083 68 $e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement);
7084 }
7085 }
7086  
7087 101 my $sub = '';
7088  
7089 # with /r
7090 101 ▶ if ($r_modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r_modifier) { } 10 91 101
7091 10 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 5 5 10
7092 }
7093  
7094 # s///gr without multibyte anchoring
7095 elsif ($modifier =~ /g/oxms) {
7096 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
7097 # 1 2 3 4 5
7098 q<CORE::eval{local $Ekoi8r::re_t=%s; while($Ekoi8r::re_t =~ %s){%s local $^W=0; local $Ekoi8r::re_r=%s; %s$Ekoi8r::re_t="$`$Ekoi8r::re_r$'"; pos($Ekoi8r::re_t)=length "$`$Ekoi8r::re_r"; } return $Ekoi8r::re_t}>,
7099  
7100 $variable, # 1
7101 ($delimiter1 eq "'") ? # 2
7102 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7103 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7104 $s_matched, # 3
7105 $e_replacement, # 4
7106 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
7107 );
7108 }
7109  
7110 # s///r
7111 else {
7112  
7113 5 my $prematch = q{$`};
7114  
7115 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
7116 # 1 2 3 4 5 6 7
7117 q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s"%s$Ekoi8r::re_r$'" } : %s>,
7118  
7119 $variable, # 1
7120 ($delimiter1 eq "'") ? # 2
7121 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7122 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7123 $s_matched, # 3
7124 $e_replacement, # 4
7125 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
7126 $prematch, # 6
7127 $variable, # 7
7128 );
7129 }
7130  
7131 # $var !~ s///r doesn't make sense
7132 10 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 10 10
7133 0 $sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub;
7134 }
7135 }
7136  
7137 # without /r
7138 else {
7139 91 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 23 68 91
7140 }
7141  
7142 # s///g without multibyte anchoring
7143 elsif ($modifier =~ /g/oxms) {
7144 23 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 3 20 23
$bind_operator =~ / !~ /mosx ? : 3 20 23
7145 # 1 2 3 4 5 6 7 8
7146 q<CORE::eval{local $Ekoi8r::re_n=0; while(%s =~ %s){%s local $^W=0; local $Ekoi8r::re_r=%s; %s%s="$`$Ekoi8r::re_r$'"; pos(%s)=length "$`$Ekoi8r::re_r"; $Ekoi8r::re_n++} return %s$Ekoi8r::re_n}>,
7147  
7148 $variable, # 1
7149 ($delimiter1 eq "'") ? # 2
7150 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7151 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7152 $s_matched, # 3
7153 $e_replacement, # 4
7154 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
7155 $variable, # 6
7156 $variable, # 7
7157 ($bind_operator =~ / !~ /oxms) ? '!' : '', # 8
7158 );
7159 }
7160  
7161 # s///
7162 else {
7163  
7164 68 my $prematch = q{$`};
7165  
7166 68 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$bind_operator =~ / =~ /mosx ? : 65 3 68
$delimiter1 eq q['] ? : 18 50 68
7167  
7168 ($bind_operator =~ / =~ /oxms) ?
7169  
7170 # 1 2 3 4 5 6 7 8
7171 q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s%s="%s$Ekoi8r::re_r$'"; 1 } : undef> :
7172  
7173 # 1 2 3 4 5 6 7 8
7174 q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s%s="%s$Ekoi8r::re_r$'"; undef }>,
7175  
7176 $variable, # 1
7177 $bind_operator, # 2
7178 ($delimiter1 eq "'") ? # 3
7179 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
7180 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
7181 $s_matched, # 4
7182 $e_replacement, # 5
7183 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 6
7184 $variable, # 7
7185 $prematch, # 8
7186 );
7187 }
7188 }
7189  
7190 # (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1]
7191 101 ▶ if ($my ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($my ne "") 0 101 101
7192 0 $sub = "($my, $sub)[1]";
7193 }
7194  
7195 # clear s/// variable
7196 101 $sub_variable = '';
7197 101 $bind_operator = '';
7198  
7199 101 return $sub;
7200 }
7201  
7202 #
7203 # escape regexp of split qr//
7204 #
7205 74 ▶sub e_split {
Subroutine e_split: called CC=88 SCAR=76.4
Pod undocumented
7206 74 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7207 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
7208  
7209 74 $modifier =~ tr/p//d;
7210 74 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 74 74
7211 0 my $line = 0;
7212 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7213 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7214 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7215 0 last;
7216 }
7217 }
7218 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7219 }
7220  
7221 74 $slash = 'div';
7222  
7223 # /b /B modifier
7224 74 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 74 74
7225 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7226 }
7227  
7228 74 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 74 74
7229 74 my $metachar = qr/[\@\\|[\]{^]/oxms;
7230  
7231 # split regexp
7232 74 my @char = $string =~ /\G((?>
7233 [^\\\$\@\[\(] |
7234 \\x (?>[0-9A-Fa-f]{1,2}) |
7235 \\ (?>[0-7]{2,3}) |
7236 \\c [\x40-\x5F] |
7237 \\x\{ (?>[0-9A-Fa-f]+) \} |
7238 \\o\{ (?>[0-7]+) \} |
7239 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
7240 \\ $q_char |
7241 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
7242 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
7243 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
7244 [\$\@] $qq_variable |
7245 \$ (?>\s* [0-9]+) |
7246 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
7247 \$ \$ (?![\w\{]) |
7248 \$ (?>\s*) \$ (?>\s*) $qq_variable |
7249 \[\^ |
7250 \[\: (?>[a-z]+) :\] |
7251 \[\:\^ (?>[a-z]+) :\] |
7252 \(\? |
7253 $q_char
7254 ))/oxmsg;
7255  
7256 74 my $left_e = 0;
7257 74 my $right_e = 0;
7258 74 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 249 74 323
7259  
7260 # "\L\u" --> "\u\L"
7261 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
7262 0 @char[$i,$i+1] = @char[$i+1,$i];
7263 }
7264  
7265 # "\U\l" --> "\l\U"
7266 ▶ 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
7267 0 @char[$i,$i+1] = @char[$i+1,$i];
7268 }
7269  
7270 # octal escape sequence
7271 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
7272 1 $char[$i] = Ekoi8r::octchr($1);
7273 }
7274  
7275 # hexadecimal escape sequence
7276 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
7277 1 $char[$i] = Ekoi8r::hexchr($1);
7278 }
7279  
7280 # \b{...} --> b\{...}
7281 # \B{...} --> B\{...}
7282 # \N{CHARNAME} --> N\{CHARNAME}
7283 # \p{PROPERTY} --> p\{PROPERTY}
7284 # \P{PROPERTY} --> P\{PROPERTY}
7285 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
7286 0 $char[$i] = $1 . '\\' . $2;
7287 }
7288  
7289 # \p, \P, \X --> p, P, X
7290 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
7291 0 $char[$i] = $1;
7292 }
7293  
7294 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 &Ekoi8r::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
7295 }
7296  
7297 # join separated multiple-octet
7298 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
7299 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7300 0 $char[$i] .= join '', splice @char, $i+1, 3;
7301 }
7302 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7303 0 $char[$i] .= join '', splice @char, $i+1, 2;
7304 }
7305 ▶ 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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::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 $Ekoi8r::q_char \z/mosx
ABCresult
0XX0
10X0
1100
1111
7306 0 $char[$i] .= join '', splice @char, $i+1, 1;
7307 }
7308 }
7309  
7310 # open character class [...]
7311 elsif ($char[$i] eq '[') {
7312 3 my $left = $i;
7313 3 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 3 3
7314 0 $i++;
7315 }
7316 3 while (1) {
7317 7 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 7 7
7318 0 die __FILE__, ": Unmatched [] in regexp\n";
7319 }
7320 7 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 3 4 7
7321 3 my $right = $i;
7322  
7323 # [...]
7324 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
7325 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
7326 }
7327 else {
7328 3 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
7329 }
7330  
7331 3 $i = $left;
7332 3 last;
7333 }
7334 }
7335 }
7336  
7337 # open character class [^...]
7338 elsif ($char[$i] eq '[^') {
7339 0 my $left = $i;
7340 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7341 0 $i++;
7342 }
7343 0 while (1) {
7344 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7345 0 die __FILE__, ": Unmatched [] in regexp\n";
7346 }
7347 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7348 0 my $right = $i;
7349  
7350 # [^...]
7351 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
7352 0 splice @char, $left, $right-$left+1, sprintf(q{@{[Ekoi8r::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier);
7353 }
7354 else {
7355 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7356 }
7357  
7358 0 $i = $left;
7359 0 last;
7360 }
7361 }
7362 }
7363  
7364 # rewrite character class or escape character
7365 elsif (my $char = character_class($char[$i],$modifier)) {
7366 1 $char[$i] = $char;
7367 }
7368  
7369 # P.794 29.2.161. split
7370 # in Chapter 29: Functions
7371 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
7372  
7373 # P.951 split
7374 # in Chapter 27: Functions
7375 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
7376  
7377 # said "The //m modifier is assumed when you split on the pattern /^/",
7378 # but perl5.008 is not so. Therefore, this software adds //m.
7379 # (and so on)
7380  
7381 # split(m/^/) --> split(m/^/m)
7382 ▶ 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
7383 7 $modifier .= 'm';
7384 }
7385  
7386 # /i modifier
7387 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition33%2/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7388 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7389 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
7390 }
7391 else {
7392 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
7393 }
7394 }
7395  
7396 # \u \l \U \L \F \Q \E
7397 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
7398 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
7399 0 $char[$i] = '\\' . $char[$i];
7400 }
7401 }
7402 elsif ($char[$i] eq '\u') {
7403 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
7404 0 $left_e++;
7405 }
7406 elsif ($char[$i] eq '\l') {
7407 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
7408 0 $left_e++;
7409 }
7410 elsif ($char[$i] eq '\U') {
7411 0 $char[$i] = '@{[Ekoi8r::uc qq<';
7412 0 $left_e++;
7413 }
7414 elsif ($char[$i] eq '\L') {
7415 0 $char[$i] = '@{[Ekoi8r::lc qq<';
7416 0 $left_e++;
7417 }
7418 elsif ($char[$i] eq '\F') {
7419 0 $char[$i] = '@{[Ekoi8r::fc qq<';
7420 0 $left_e++;
7421 }
7422 elsif ($char[$i] eq '\Q') {
7423 0 $char[$i] = '@{[CORE::quotemeta qq<';
7424 0 $left_e++;
7425 }
7426 elsif ($char[$i] eq '\E') {
7427 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
7428 0 $char[$i] = '>]}';
7429 0 $right_e++;
7430 }
7431 else {
7432 0 $char[$i] = '';
7433 }
7434 }
7435 elsif ($char[$i] eq '\Q') {
7436 0 while (1) {
7437 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7438 0 last;
7439 }
7440 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
7441 0 last;
7442 }
7443 }
7444 }
7445 elsif ($char[$i] eq '\E') {
7446 }
7447  
7448 # $0 --> $0
7449 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
7450 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7451 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7452 }
7453 }
7454 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
7455 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7456 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7457 }
7458 }
7459  
7460 # $$ --> $$
7461 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
7462 }
7463  
7464 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
7465 # $1, $2, $3 --> $1, $2, $3 otherwise
7466 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
7467 0 $char[$i] = e_capture($1);
7468 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7469 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7470 }
7471 }
7472 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
7473 0 $char[$i] = e_capture($1);
7474 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7475 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7476 }
7477 }
7478  
7479 # $$foo[ ... ] --> $ $foo->[ ... ]
7480 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
7481 0 $char[$i] = e_capture($1.'->'.$2);
7482 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7483 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7484 }
7485 }
7486  
7487 # $$foo{ ... } --> $ $foo->{ ... }
7488 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
7489 0 $char[$i] = e_capture($1.'->'.$2);
7490 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7491 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7492 }
7493 }
7494  
7495 # $$foo
7496 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
7497 0 $char[$i] = e_capture($1);
7498 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7499 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7500 }
7501 }
7502  
7503 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
7504 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
7505 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7506 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
7507 }
7508 else {
7509 12 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
7510 }
7511 }
7512  
7513 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
7514 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
7515 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7516 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
7517 }
7518 else {
7519 12 $char[$i] = '@{[Ekoi8r::MATCH()]}';
7520 }
7521 }
7522  
7523 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
7524 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
7525 9 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 9 9
7526 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
7527 }
7528 else {
7529 9 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
7530 }
7531 }
7532  
7533 # ${ foo }
7534 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
7535 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7536 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $1 . ')]}';
7537 }
7538 }
7539  
7540 # ${ ... }
7541 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
7542 0 $char[$i] = e_capture($1);
7543 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7544 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7545 }
7546 }
7547  
7548 # $scalar or @array
7549 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
7550 3 $char[$i] = e_string($char[$i]);
7551 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 3 3
7552 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7553 }
7554 }
7555  
7556 # quote character before ? + * {
7557 ▶ 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
7558 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
7559 }
7560 else {
7561 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7562 }
7563 }
7564 }
7565  
7566 # make regexp string
7567 74 $modifier =~ tr/i//d;
7568 74 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 74 74
7569 0 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier;
7570 }
7571 74 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7572 }
7573  
7574 #
7575 # escape regexp of split qr''
7576 #
7577 0 ▶sub e_split_q {
Subroutine e_split_q: not called CC=26 SCAR=65.5
Pod undocumented
7578 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7579 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
7580  
7581 0 $modifier =~ tr/p//d;
7582 0 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 0 0
7583 0 my $line = 0;
7584 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7585 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7586 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7587 0 last;
7588 }
7589 }
7590 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7591 }
7592  
7593 0 $slash = 'div';
7594  
7595 # /b /B modifier
7596 0 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 0 0
7597 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7598 }
7599  
7600 0 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 0 0
7601  
7602 # split regexp
7603 0 my @char = $string =~ /\G((?>
7604 [^\\\[] |
7605 [\x00-\xFF] |
7606 \[\^ |
7607 \[\: (?>[a-z]+) \:\] |
7608 \[\:\^ (?>[a-z]+) \:\] |
7609 \\ (?:$q_char) |
7610 (?:$q_char)
7611 ))/oxmsg;
7612  
7613 # unescape character
7614 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
7615 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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])) { } 0 0 0
elsif ($i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx) { } 0 0 0
7616 }
7617  
7618 # open character class [...]
7619 elsif ($char[$i] eq '[') {
7620 0 my $left = $i;
7621 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7622 0 $i++;
7623 }
7624 0 while (1) {
7625 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7626 0 die __FILE__, ": Unmatched [] in regexp\n";
7627 }
7628 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7629 0 my $right = $i;
7630  
7631 # [...]
7632 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
7633  
7634 0 $i = $left;
7635 0 last;
7636 }
7637 }
7638 }
7639  
7640 # open character class [^...]
7641 elsif ($char[$i] eq '[^') {
7642 0 my $left = $i;
7643 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7644 0 $i++;
7645 }
7646 0 while (1) {
7647 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7648 0 die __FILE__, ": Unmatched [] in regexp\n";
7649 }
7650 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7651 0 my $right = $i;
7652  
7653 # [^...]
7654 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7655  
7656 0 $i = $left;
7657 0 last;
7658 }
7659 }
7660 }
7661  
7662 # rewrite character class or escape character
7663 elsif (my $char = character_class($char[$i],$modifier)) {
7664 0 $char[$i] = $char;
7665 }
7666  
7667 # split(m/^/) --> split(m/^/m)
7668 ▶ 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
7669 0 $modifier .= 'm';
7670 }
7671  
7672 # /i modifier
7673 ▶ elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ekoi8r::uc($char[$i]) ne Ekoi8r::fc($char[$i]))) {
Condition0%0/6
$ignorecase and $char[$i] =~ /\A [\x00-\xFF] \z/mosx and &Ekoi8r::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 &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
$ignorecase $char[$i] =~ /\A [\x00-\xFF] \z/mosx &Ekoi8r::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= &Ekoi8r::uc($char[$i]) ne &fc($char[$i])
ABCresult
0XX0
10X0
1100
1111
7674 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7675 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
7676 }
7677 else {
7678 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
7679 }
7680 }
7681  
7682 # quote character before ? + * {
7683 ▶ 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
7684 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
7685 }
7686 else {
7687 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7688 }
7689 }
7690 }
7691  
7692 0 $modifier =~ tr/i//d;
7693 0 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7694 }
7695  
7696 #
7697 # instead of Carp::carp
7698 #
7699 0 ▶sub carp {
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
7700 0 my($package,$filename,$line) = caller(1);
7701 0 print STDERR "@_ at $filename line $line.\n";
7702 }
7703  
7704 #
7705 # instead of Carp::croak
7706 #
7707 0 ▶sub croak {
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
7708 0 my($package,$filename,$line) = caller(1);
7709 0 print STDERR "@_ at $filename line $line.\n";
7710 0 die "\n";
7711 }
7712  
7713 #
7714 # instead of Carp::cluck
7715 #
7716 0 ▶sub cluck {
Subroutine cluck: not called CC=2 SCAR=17.9
Pod undocumented
7717 0 my $i = 0;
7718 0 my @cluck = ();
7719 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7720 0 push @cluck, "[$i] $filename($line) $package::$subroutine\n";
7721 0 $i++;
7722 }
7723 0 print STDERR CORE::reverse @cluck;
7724 0 print STDERR "\n";
7725 0 print STDERR @_;
7726 }
7727  
7728 #
7729 # instead of Carp::confess
7730 #
7731 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
7732 0 my $i = 0;
7733 0 my @confess = ();
7734 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7735 0 push @confess, "[$i] $filename($line) $package::$subroutine\n";
7736 0 $i++;
7737 }
7738 0 print STDERR CORE::reverse @confess;
7739 0 print STDERR "\n";
7740 0 print STDERR @_;
7741 0 die "\n";
7742 }
7743  
7744 422 1;
7745  
7746 __END__
↑ Summary blib/lib/KOI8R.pm »