Ekoi8r.pm

filter: Statementstmt 43.5% 1311 / 3009 Branchbran 40.7% 1062 / 2608 Conditioncond 31.0% 115 / 370 MC/DCmcdc 15.9% 35 / 220 Subroutinesub 68.9% 111 / 161 Podpod 4.6% 3 / 64 totaltotal 41.0% 2637 / 6432 CC 1475 SCAR 97.8
CC
1475
Cov
42%
escape_token
55669.4
e_s1
3320.4
e_split
2070.1
CRAP 17630.3
↑ Summary KOI8R.pm »
1 package Ekoi8r;
2 425 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 425 ▶BEGIN { $INC{'warnings.pm'} = '' if $] < 5.006 } use warnings;
Subroutine BEGIN: called CC=2 SCAR=7.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.006" 0 424 424
4 ######################################################################
5 #
6 # Ekoi8r - Run-time routines for KOI8R.pm
7 #
8 # http://search.cpan.org/dist/Char-KOI8R/
9 #
10 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi <ina@cpan.org>
11 ######################################################################
12  
13 425 ▶use 5.00503; # Galapagos Consensus 1998 for primetools
Subroutine BEGIN: called CC=1 SCAR=0.0
14 # use 5.008001; # Lancaster Consensus 2013 for toolchains
15  
16 # 12.3. Delaying use Until Runtime
17 # in Chapter 12. Packages, Libraries, and Modules
18 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
19 # (and so on)
20  
21 # Version numbers should be boring
22 # http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
23 # For the impatient, the disinterested or those who just want to follow
24 # a recipe, my advice for all modules is this:
25 # our $VERSION = "0.001"; # or "0.001_001" for a dev release
26 # $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1'
27  
28 425 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 424 $VERSION = '1.22';
30 424 $VERSION = $VERSION;
31  
32 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
33 425 ▶ if ($^X =~ / jperl /oxmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^X =~ / jperl /imosx) 0 424 424
34 1 die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n";
35 }
36 425 if (CORE::ord('A') == 193) {
37 die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n";
38 }
39 424 if (CORE::ord('A') != 0x41) {
40 die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n";
41 }
42 }
43  
44 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=9.5
45  
46 # instead of utf8.pm
47 424 ▶ CORE::eval q{
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
48 no warnings qw(redefine);
49 *utf8::upgrade = sub { CORE::length $_[0] };
50 *utf8::downgrade = sub { 1 };
51 *utf8::encode = sub { };
52 *utf8::decode = sub { 1 };
53 *utf8::is_utf8 = sub { };
54 *utf8::valid = sub { 1 };
55 };
56 424 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 424 424
57 0 ▶ *utf8::upgrade = sub { CORE::length $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 ▶ *utf8::downgrade = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 ▶ *utf8::encode = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ *utf8::decode = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ *utf8::is_utf8 = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 ▶ *utf8::valid = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 }
64 }
65  
66 # instead of Symbol.pm
67 BEGIN {
68 0 ▶ sub gensym () {
Subroutine gensym: not called CC=2 SCAR=17.9
Pod undocumented
69 0 ▶ if ($] < 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.006) { } 0 0 0
70 0 return \do { local *_ };
71 }
72 else {
73 0 return undef;
74 }
75 }
76  
77 20 ▶ sub qualify ($$) {
Subroutine qualify: called CC=8 SCAR=28.9
Pod undocumented
78 20 my($name) = @_;
79  
80 20 ▶ if (ref $name) {
Branch: 7 branches
BranchTrueFalseTotal
if (ref $name) { } 5 15 20
elsif (&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
81 5 return $name;
82 }
83 elsif (Ekoi8r::index($name,'::') >= 0) {
84 0 return $name;
85 }
86 elsif (Ekoi8r::index($name,"'") >= 0) {
87 0 return $name;
88 }
89  
90 # special character, "^xyz"
91 elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) {
92  
93 # RGS 2001-11-05 : translate leading ^X to control-char
94 0 $name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee;
95 0 return 'main::' . $name;
96 }
97  
98 # Global names
99 elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) {
100 0 return 'main::' . $name;
101 }
102  
103 # or other
104 elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) {
105 0 return 'main::' . $name;
106 }
107  
108 elsif (defined $_[1]) {
109 15 return $_[1] . '::' . $name;
110 }
111 else {
112 0 return (caller)[0] . '::' . $name;
113 }
114 }
115  
116 20 ▶ sub qualify_to_ref ($;$) {
Subroutine qualify_to_ref: called CC=2 SCAR=7.2
Pod undocumented
117 20 ▶ if (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) { } 20 0 20
118 424 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
119 20 return \*{ qualify $_[0], $_[1] };
120 }
121 else {
122 424 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
123 0 return \*{ qualify $_[0], (caller)[0] };
124 }
125 }
126 }
127  
128 # P.714 29.2.39. flock
129 # in Chapter 29: Functions
130 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
131  
132 # P.863 flock
133 # in Chapter 27: Functions
134 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
135  
136 sub LOCK_SH() {1}
137 sub LOCK_EX() {2}
138 sub LOCK_UN() {8}
139 sub LOCK_NB() {4}
140  
141 # instead of Carp.pm
142 sub carp;
143 sub croak;
144 sub cluck;
145 sub confess;
146  
147 # 6.18. Matching Multiple-Byte Characters
148 # in Chapter 6. Pattern Matching
149 # of ISBN 978-1-56592-243-3 Perl Perl Cookbook.
150 # (and so on)
151  
152 # regexp of character
153 424 my $your_char = q{[\x00-\xFF]};
154 424 ▶use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
155 424 ▶use vars qw($q_char); $q_char = qr/$your_char/oxms;
Subroutine BEGIN: called CC=1 SCAR=0.0
156  
157 #
158 # KOI8-R character range per length
159 #
160 424 my %range_tr = ();
161  
162 #
163 # KOI8-R case conversion
164 #
165 424 my %lc = ();
166 424 @lc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} =
167 qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);
168 424 my %uc = ();
169 424 @uc{qw(a b c d e f g h i j k l m n o p q r s t u v w x y z)} =
170 qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
171 424 my %fc = ();
172 424 @fc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} =
173 qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);
174  
175 424 ▶if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { __PACKAGE__ =~ / \b Ekoi8r \z/mosx }) { } 424 0 424
176 }
177  
178 elsif (__PACKAGE__ =~ / \b Ekoi8r \z/oxms) {
179 424 %range_tr = (
180 1 => [ [0x00..0xFF],
181 ],
182 );
183  
184 424 %lc = (%lc,
185 "\xB3" => "\xA3", # CYRILLIC LETTER IO
186 "\xE0" => "\xC0", # CYRILLIC LETTER IU
187 "\xE1" => "\xC1", # CYRILLIC LETTER A
188 "\xE2" => "\xC2", # CYRILLIC LETTER BE
189 "\xE3" => "\xC3", # CYRILLIC LETTER TSE
190 "\xE4" => "\xC4", # CYRILLIC LETTER DE
191 "\xE5" => "\xC5", # CYRILLIC LETTER IE
192 "\xE6" => "\xC6", # CYRILLIC LETTER EF
193 "\xE7" => "\xC7", # CYRILLIC LETTER GE
194 "\xE8" => "\xC8", # CYRILLIC LETTER KHA
195 "\xE9" => "\xC9", # CYRILLIC LETTER II
196 "\xEA" => "\xCA", # CYRILLIC LETTER SHORT II
197 "\xEB" => "\xCB", # CYRILLIC LETTER KA
198 "\xEC" => "\xCC", # CYRILLIC LETTER EL
199 "\xED" => "\xCD", # CYRILLIC LETTER EM
200 "\xEE" => "\xCE", # CYRILLIC LETTER EN
201 "\xEF" => "\xCF", # CYRILLIC LETTER O
202 "\xF0" => "\xD0", # CYRILLIC LETTER PE
203 "\xF1" => "\xD1", # CYRILLIC LETTER IA
204 "\xF2" => "\xD2", # CYRILLIC LETTER ER
205 "\xF3" => "\xD3", # CYRILLIC LETTER ES
206 "\xF4" => "\xD4", # CYRILLIC LETTER TE
207 "\xF5" => "\xD5", # CYRILLIC LETTER U
208 "\xF6" => "\xD6", # CYRILLIC LETTER ZHE
209 "\xF7" => "\xD7", # CYRILLIC LETTER VE
210 "\xF8" => "\xD8", # CYRILLIC LETTER SOFT SIGN
211 "\xF9" => "\xD9", # CYRILLIC LETTER YERI
212 "\xFA" => "\xDA", # CYRILLIC LETTER ZE
213 "\xFB" => "\xDB", # CYRILLIC LETTER SHA
214 "\xFC" => "\xDC", # CYRILLIC LETTER REVERSED E
215 "\xFD" => "\xDD", # CYRILLIC LETTER SHCHA
216 "\xFE" => "\xDE", # CYRILLIC LETTER CHE
217 "\xFF" => "\xDF", # CYRILLIC LETTER HARD SIGN
218 );
219  
220 424 %uc = (%uc,
221 "\xA3" => "\xB3", # CYRILLIC LETTER IO
222 "\xC0" => "\xE0", # CYRILLIC LETTER IU
223 "\xC1" => "\xE1", # CYRILLIC LETTER A
224 "\xC2" => "\xE2", # CYRILLIC LETTER BE
225 "\xC3" => "\xE3", # CYRILLIC LETTER TSE
226 "\xC4" => "\xE4", # CYRILLIC LETTER DE
227 "\xC5" => "\xE5", # CYRILLIC LETTER IE
228 "\xC6" => "\xE6", # CYRILLIC LETTER EF
229 "\xC7" => "\xE7", # CYRILLIC LETTER GE
230 "\xC8" => "\xE8", # CYRILLIC LETTER KHA
231 "\xC9" => "\xE9", # CYRILLIC LETTER II
232 "\xCA" => "\xEA", # CYRILLIC LETTER SHORT II
233 "\xCB" => "\xEB", # CYRILLIC LETTER KA
234 "\xCC" => "\xEC", # CYRILLIC LETTER EL
235 "\xCD" => "\xED", # CYRILLIC LETTER EM
236 "\xCE" => "\xEE", # CYRILLIC LETTER EN
237 "\xCF" => "\xEF", # CYRILLIC LETTER O
238 "\xD0" => "\xF0", # CYRILLIC LETTER PE
239 "\xD1" => "\xF1", # CYRILLIC LETTER IA
240 "\xD2" => "\xF2", # CYRILLIC LETTER ER
241 "\xD3" => "\xF3", # CYRILLIC LETTER ES
242 "\xD4" => "\xF4", # CYRILLIC LETTER TE
243 "\xD5" => "\xF5", # CYRILLIC LETTER U
244 "\xD6" => "\xF6", # CYRILLIC LETTER ZHE
245 "\xD7" => "\xF7", # CYRILLIC LETTER VE
246 "\xD8" => "\xF8", # CYRILLIC LETTER SOFT SIGN
247 "\xD9" => "\xF9", # CYRILLIC LETTER YERI
248 "\xDA" => "\xFA", # CYRILLIC LETTER ZE
249 "\xDB" => "\xFB", # CYRILLIC LETTER SHA
250 "\xDC" => "\xFC", # CYRILLIC LETTER REVERSED E
251 "\xDD" => "\xFD", # CYRILLIC LETTER SHCHA
252 "\xDE" => "\xFE", # CYRILLIC LETTER CHE
253 "\xDF" => "\xFF", # CYRILLIC LETTER HARD SIGN
254 );
255  
256 424 %fc = (%fc,
257 "\xB3" => "\xA3", # CYRILLIC CAPITAL LETTER IO --> CYRILLIC SMALL LETTER IO
258 "\xE0" => "\xC0", # CYRILLIC CAPITAL LETTER YU --> CYRILLIC SMALL LETTER YU
259 "\xE1" => "\xC1", # CYRILLIC CAPITAL LETTER A --> CYRILLIC SMALL LETTER A
260 "\xE2" => "\xC2", # CYRILLIC CAPITAL LETTER BE --> CYRILLIC SMALL LETTER BE
261 "\xE3" => "\xC3", # CYRILLIC CAPITAL LETTER TSE --> CYRILLIC SMALL LETTER TSE
262 "\xE4" => "\xC4", # CYRILLIC CAPITAL LETTER DE --> CYRILLIC SMALL LETTER DE
263 "\xE5" => "\xC5", # CYRILLIC CAPITAL LETTER IE --> CYRILLIC SMALL LETTER IE
264 "\xE6" => "\xC6", # CYRILLIC CAPITAL LETTER EF --> CYRILLIC SMALL LETTER EF
265 "\xE7" => "\xC7", # CYRILLIC CAPITAL LETTER GHE --> CYRILLIC SMALL LETTER GHE
266 "\xE8" => "\xC8", # CYRILLIC CAPITAL LETTER HA --> CYRILLIC SMALL LETTER HA
267 "\xE9" => "\xC9", # CYRILLIC CAPITAL LETTER I --> CYRILLIC SMALL LETTER I
268 "\xEA" => "\xCA", # CYRILLIC CAPITAL LETTER SHORT I --> CYRILLIC SMALL LETTER SHORT I
269 "\xEB" => "\xCB", # CYRILLIC CAPITAL LETTER KA --> CYRILLIC SMALL LETTER KA
270 "\xEC" => "\xCC", # CYRILLIC CAPITAL LETTER EL --> CYRILLIC SMALL LETTER EL
271 "\xED" => "\xCD", # CYRILLIC CAPITAL LETTER EM --> CYRILLIC SMALL LETTER EM
272 "\xEE" => "\xCE", # CYRILLIC CAPITAL LETTER EN --> CYRILLIC SMALL LETTER EN
273 "\xEF" => "\xCF", # CYRILLIC CAPITAL LETTER O --> CYRILLIC SMALL LETTER O
274 "\xF0" => "\xD0", # CYRILLIC CAPITAL LETTER PE --> CYRILLIC SMALL LETTER PE
275 "\xF1" => "\xD1", # CYRILLIC CAPITAL LETTER YA --> CYRILLIC SMALL LETTER YA
276 "\xF2" => "\xD2", # CYRILLIC CAPITAL LETTER ER --> CYRILLIC SMALL LETTER ER
277 "\xF3" => "\xD3", # CYRILLIC CAPITAL LETTER ES --> CYRILLIC SMALL LETTER ES
278 "\xF4" => "\xD4", # CYRILLIC CAPITAL LETTER TE --> CYRILLIC SMALL LETTER TE
279 "\xF5" => "\xD5", # CYRILLIC CAPITAL LETTER U --> CYRILLIC SMALL LETTER U
280 "\xF6" => "\xD6", # CYRILLIC CAPITAL LETTER ZHE --> CYRILLIC SMALL LETTER ZHE
281 "\xF7" => "\xD7", # CYRILLIC CAPITAL LETTER VE --> CYRILLIC SMALL LETTER VE
282 "\xF8" => "\xD8", # CYRILLIC CAPITAL LETTER SOFT SIGN --> CYRILLIC SMALL LETTER SOFT SIGN
283 "\xF9" => "\xD9", # CYRILLIC CAPITAL LETTER YERU --> CYRILLIC SMALL LETTER YERU
284 "\xFA" => "\xDA", # CYRILLIC CAPITAL LETTER ZE --> CYRILLIC SMALL LETTER ZE
285 "\xFB" => "\xDB", # CYRILLIC CAPITAL LETTER SHA --> CYRILLIC SMALL LETTER SHA
286 "\xFC" => "\xDC", # CYRILLIC CAPITAL LETTER E --> CYRILLIC SMALL LETTER E
287 "\xFD" => "\xDD", # CYRILLIC CAPITAL LETTER SHCHA --> CYRILLIC SMALL LETTER SHCHA
288 "\xFE" => "\xDE", # CYRILLIC CAPITAL LETTER CHE --> CYRILLIC SMALL LETTER CHE
289 "\xFF" => "\xDF", # CYRILLIC CAPITAL LETTER HARD SIGN --> CYRILLIC SMALL LETTER HARD SIGN
290 );
291 }
292  
293 else {
294 0 croak "Don't know my package name '@{[__PACKAGE__]}'";
295 }
296  
297 #
298 # @ARGV wildcard globbing
299 #
300 212 ▶sub import {
Subroutine import: called CC=7 SCAR=28.3
301  
302 212 ▶ if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/mosx) 0 212 212
303 0 my @argv = ();
304 0 for (@ARGV) {
305  
306 # has space
307 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
308 0 ▶ if (my @glob = Ekoi8r::glob(qq{"$_"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8r::glob(qq["$_"])) { } 0 0 0
309 0 push @argv, @glob;
310 }
311 else {
312 0 push @argv, $_;
313 }
314 }
315  
316 # has wildcard metachar
317 elsif (/\A (?:$q_char)*? [*?] /oxms) {
318 0 ▶ if (my @glob = Ekoi8r::glob($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@glob) = &Ekoi8r::glob($_)) { } 0 0 0
319 0 push @argv, @glob;
320 }
321 else {
322 0 push @argv, $_;
323 }
324 }
325  
326 # no wildcard globbing
327 else {
328 0 push @argv, $_;
329 }
330 }
331 0 @ARGV = @argv;
332 }
333  
334 212 *Char::ord = \&KOI8R::ord;
335 212 *Char::ord_ = \&KOI8R::ord_;
336 212 *Char::reverse = \&KOI8R::reverse;
337 212 *Char::getc = \&KOI8R::getc;
338 212 *Char::length = \&KOI8R::length;
339 212 *Char::substr = \&KOI8R::substr;
340 212 *Char::index = \&KOI8R::index;
341 212 *Char::rindex = \&KOI8R::rindex;
342 212 *Char::eval = \&KOI8R::eval;
343 212 *Char::escape = \&KOI8R::escape;
344 212 *Char::escape_token = \&KOI8R::escape_token;
345 212 *Char::escape_script = \&KOI8R::escape_script;
346 }
347  
348 # P.230 Care with Prototypes
349 # in Chapter 6: Subroutines
350 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
351 #
352 # If you aren't careful, you can get yourself into trouble with prototypes.
353 # But if you are careful, you can do a lot of neat things with them. This is
354 # all very powerful, of course, and should only be used in moderation to make
355 # the world a better place.
356  
357 # P.332 Care with Prototypes
358 # in Chapter 7: Subroutines
359 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
360 #
361 # If you aren't careful, you can get yourself into trouble with prototypes.
362 # But if you are careful, you can do a lot of neat things with them. This is
363 # all very powerful, of course, and should only be used in moderation to make
364 # the world a better place.
365  
366 #
367 # Prototypes of subroutines
368 #
369 0 ▶sub unimport {}
Subroutine unimport: not called CC=1 SCAR=0.0
370 sub Ekoi8r::split(;$$$);
371 sub Ekoi8r::tr($$$$;$);
372 sub Ekoi8r::chop(@);
373 sub Ekoi8r::index($$;$);
374 sub Ekoi8r::rindex($$;$);
375 sub Ekoi8r::lcfirst(@);
376 sub Ekoi8r::lcfirst_();
377 sub Ekoi8r::lc(@);
378 sub Ekoi8r::lc_();
379 sub Ekoi8r::ucfirst(@);
380 sub Ekoi8r::ucfirst_();
381 sub Ekoi8r::uc(@);
382 sub Ekoi8r::uc_();
383 sub Ekoi8r::fc(@);
384 sub Ekoi8r::fc_();
385 sub Ekoi8r::ignorecase;
386 sub Ekoi8r::classic_character_class;
387 sub Ekoi8r::capture;
388 sub Ekoi8r::chr(;$);
389 sub Ekoi8r::chr_();
390 sub Ekoi8r::glob($);
391 sub Ekoi8r::glob_();
392  
393 sub KOI8R::ord(;$);
394 sub KOI8R::ord_();
395 sub KOI8R::reverse(@);
396 sub KOI8R::getc(;*@);
397 sub KOI8R::length(;$);
398 sub KOI8R::substr($$;$$);
399 sub KOI8R::index($$;$);
400 sub KOI8R::rindex($$;$);
401 sub KOI8R::escape(;$);
402  
403 #
404 # Regexp work
405 #
406 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
407 $re_a
408 $re_t
409 $re_n
410 $re_r
411 424 );
412  
413 #
414 # Character class
415 #
416 424 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
417 $dot
418 $dot_s
419 $eD
420 $eS
421 $eW
422 $eH
423 $eV
424 $eR
425 $eN
426 $not_alnum
427 $not_alpha
428 $not_ascii
429 $not_blank
430 $not_cntrl
431 $not_digit
432 $not_graph
433 $not_lower
434 $not_lower_i
435 $not_print
436 $not_punct
437 $not_space
438 $not_upper
439 $not_upper_i
440 $not_word
441 $not_xdigit
442 $eb
443 $eB
444 424 );
445  
446 424 ${Ekoi8r::dot} = qr{(?>[^\x0A])};
447 424 ${Ekoi8r::dot_s} = qr{(?>[\x00-\xFF])};
448 424 ${Ekoi8r::eD} = qr{(?>[^0-9])};
449  
450 # Vertical tabs are now whitespace
451 # \s in a regex now matches a vertical tab in all circumstances.
452 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
453 # ${Ekoi8r::eS} = qr{(?>[^\x09\x0A \x0C\x0D\x20])};
454 # ${Ekoi8r::eS} = qr{(?>[^\x09\x0A\x0B\x0C\x0D\x20])};
455 424 ${Ekoi8r::eS} = qr{(?>[^\s])};
456  
457 424 ${Ekoi8r::eW} = qr{(?>[^0-9A-Z_a-z])};
458 424 ${Ekoi8r::eH} = qr{(?>[^\x09\x20])};
459 424 ${Ekoi8r::eV} = qr{(?>[^\x0A\x0B\x0C\x0D])};
460 424 ${Ekoi8r::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])};
461 424 ${Ekoi8r::eN} = qr{(?>[^\x0A])};
462 424 ${Ekoi8r::not_alnum} = qr{(?>[^\x30-\x39\x41-\x5A\x61-\x7A])};
463 424 ${Ekoi8r::not_alpha} = qr{(?>[^\x41-\x5A\x61-\x7A])};
464 424 ${Ekoi8r::not_ascii} = qr{(?>[^\x00-\x7F])};
465 424 ${Ekoi8r::not_blank} = qr{(?>[^\x09\x20])};
466 424 ${Ekoi8r::not_cntrl} = qr{(?>[^\x00-\x1F\x7F])};
467 424 ${Ekoi8r::not_digit} = qr{(?>[^\x30-\x39])};
468 424 ${Ekoi8r::not_graph} = qr{(?>[^\x21-\x7F])};
469 424 ${Ekoi8r::not_lower} = qr{(?>[^\x61-\x7A])};
470 424 ${Ekoi8r::not_lower_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
471 # ${Ekoi8r::not_lower_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
472 424 ${Ekoi8r::not_print} = qr{(?>[^\x20-\x7F])};
473 424 ${Ekoi8r::not_punct} = qr{(?>[^\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E])};
474 424 ${Ekoi8r::not_space} = qr{(?>[^\s\x0B])};
475 424 ${Ekoi8r::not_upper} = qr{(?>[^\x41-\x5A])};
476 424 ${Ekoi8r::not_upper_i} = qr{(?>[^\x41-\x5A\x61-\x7A])}; # Perl 5.16 compatible
477 # ${Ekoi8r::not_upper_i} = qr{(?>[\x00-\xFF])}; # older Perl compatible
478 424 ${Ekoi8r::not_word} = qr{(?>[^\x30-\x39\x41-\x5A\x5F\x61-\x7A])};
479 424 ${Ekoi8r::not_xdigit} = qr{(?>[^\x30-\x39\x41-\x46\x61-\x66])};
480 424 ${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))};
481 424 ${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]))};
482  
483 # avoid: Name "Ekoi8r::foo" used only once: possible typo at here.
484 424 ${Ekoi8r::dot} = ${Ekoi8r::dot};
485 424 ${Ekoi8r::dot_s} = ${Ekoi8r::dot_s};
486 424 ${Ekoi8r::eD} = ${Ekoi8r::eD};
487 424 ${Ekoi8r::eS} = ${Ekoi8r::eS};
488 424 ${Ekoi8r::eW} = ${Ekoi8r::eW};
489 424 ${Ekoi8r::eH} = ${Ekoi8r::eH};
490 424 ${Ekoi8r::eV} = ${Ekoi8r::eV};
491 424 ${Ekoi8r::eR} = ${Ekoi8r::eR};
492 424 ${Ekoi8r::eN} = ${Ekoi8r::eN};
493 424 ${Ekoi8r::not_alnum} = ${Ekoi8r::not_alnum};
494 424 ${Ekoi8r::not_alpha} = ${Ekoi8r::not_alpha};
495 424 ${Ekoi8r::not_ascii} = ${Ekoi8r::not_ascii};
496 424 ${Ekoi8r::not_blank} = ${Ekoi8r::not_blank};
497 424 ${Ekoi8r::not_cntrl} = ${Ekoi8r::not_cntrl};
498 424 ${Ekoi8r::not_digit} = ${Ekoi8r::not_digit};
499 424 ${Ekoi8r::not_graph} = ${Ekoi8r::not_graph};
500 424 ${Ekoi8r::not_lower} = ${Ekoi8r::not_lower};
501 424 ${Ekoi8r::not_lower_i} = ${Ekoi8r::not_lower_i};
502 424 ${Ekoi8r::not_print} = ${Ekoi8r::not_print};
503 424 ${Ekoi8r::not_punct} = ${Ekoi8r::not_punct};
504 424 ${Ekoi8r::not_space} = ${Ekoi8r::not_space};
505 424 ${Ekoi8r::not_upper} = ${Ekoi8r::not_upper};
506 424 ${Ekoi8r::not_upper_i} = ${Ekoi8r::not_upper_i};
507 424 ${Ekoi8r::not_word} = ${Ekoi8r::not_word};
508 424 ${Ekoi8r::not_xdigit} = ${Ekoi8r::not_xdigit};
509 424 ${Ekoi8r::eb} = ${Ekoi8r::eb};
510 424 ${Ekoi8r::eB} = ${Ekoi8r::eB};
511  
512 #
513 # KOI8-R split
514 #
515 72 ▶sub Ekoi8r::split(;$$$) {
Subroutine split: called CC=34 SCAR=38.5
Pod undocumented
516  
517 # P.794 29.2.161. split
518 # in Chapter 29: Functions
519 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
520  
521 # P.951 split
522 # in Chapter 27: Functions
523 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
524  
525 72 my $pattern = $_[0];
526 72 my $string = $_[1];
527 72 my $limit = $_[2];
528  
529 # if $pattern is also omitted or is the literal space, " "
530 72 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 2 70 72
531 2 $pattern = ' ';
532 }
533  
534 # if $string is omitted, the function splits the $_ string
535 72 ▶ if (not defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 6 66 72
536 6 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 6 6
537 0 $string = $_;
538 }
539 else {
540 6 $string = '';
541 }
542 }
543  
544 72 my @split = ();
545  
546 # when string is empty
547 72 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 10 62 72
elsif ($pattern eq ' ') { } 2 60 62
548  
549 # resulting list value in list context
550 10 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 5 5 10
551 5 return @split;
552 }
553  
554 # count of substrings in scalar context
555 else {
556 5 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 5 5
557 5 @_ = @split;
558 5 return scalar @_;
559 }
560 }
561  
562 # split's first argument is more consistently interpreted
563 #
564 # After some changes earlier in v5.17, split's behavior has been simplified:
565 # if the PATTERN argument evaluates to a string containing one space, it is
566 # treated the way that a literal string containing one space once was.
567 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
568  
569 # if $pattern is also omitted or is the literal space, " ", the function splits
570 # on whitespace, /\s+/, after skipping any leading whitespace
571 # (and so on)
572  
573 elsif ($pattern eq ' ') {
574 2 ▶ if (not defined $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit) { } 2 0 2
575 2 return CORE::split(' ', $string);
576 }
577 else {
578 0 return CORE::split(' ', $string, $limit);
579 }
580 }
581  
582 # if $limit is negative, it is treated as if an arbitrarily large $limit has been specified
583 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
584  
585 # a pattern capable of matching either the null string or something longer than the
586 # null string will split the value of $string into separate characters wherever it
587 # matches the null string between characters
588 # (and so on)
589  
590 60 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 2 58 60
591 2 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
592 2 my $limit = scalar(() = $string =~ /($pattern)/oxmsg);
593  
594 # P.1024 Appendix W.10 Multibyte Processing
595 # of ISBN 1-56592-224-7 CJKV Information Processing
596 # (and so on)
597  
598 # the //m modifier is assumed when you split on the pattern /^/
599 # (and so on)
600  
601 2 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
602 # V
603 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
604  
605 # if the $pattern contains parentheses, then the substring matched by each pair of parentheses
606 # is included in the resulting list, interspersed with the fields that are ordinarily returned
607 # (and so on)
608  
609 9 local $@;
610 9 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
611 9 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 9 9 18
612 9 push @split, CORE::eval('$' . $digit);
613 }
614 }
615 }
616  
617 else {
618 58 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
619  
620 58 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
621 # V
622 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
623 163 local $@;
624 163 ▶ eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
625 163 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 230 163 393
626 230 push @split, CORE::eval('$' . $digit);
627 }
628 }
629 }
630 }
631  
632 elsif ($limit > 0) {
633 0 ▶ if ('' =~ / \A $pattern \z /xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ('' =~ / \A $pattern \z /msx) { } 0 0 0
634 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
635 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
636  
637 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
638 # V
639 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
640 0 local $@;
641 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
642 0 push @split, CORE::eval('$' . $digit);
643 }
644 }
645 }
646 }
647 else {
648 0 my $last_subexpression_offsets = _last_subexpression_offsets($pattern);
649 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
650  
651 0 eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (32766) exceeded at ...
652 # V
653 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
654 0 local $@;
655 0 ▶ for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit <= $last_subexpression_offsets + 1) 0 0 0
656 0 push @split, CORE::eval('$' . $digit);
657 }
658 }
659 }
660 }
661 }
662  
663 60 ▶ if (CORE::length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 58 2 60
664 58 push @split, $string;
665 }
666  
667 # if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result
668 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
669 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
670 0 pop @split;
671 }
672 }
673  
674 # resulting list value in list context
675 60 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 58 2 60
676 58 return @split;
677 }
678  
679 # count of substrings in scalar context
680 else {
681 2 ▶ carp "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 2 2
682 2 @_ = @split;
683 2 return scalar @_;
684 }
685 }
686  
687 #
688 # get last subexpression offsets
689 #
690 60 ▶sub _last_subexpression_offsets {
Subroutine _last_subexpression_offsets: called CC=3 SCAR=11.0
691 60 my $pattern = $_[0];
692  
693 # remove comment
694 60 $pattern =~ s/\(\?\# .*? \)//oxmsg;
695  
696 60 my $modifier = '';
697 60 ▶ if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/mosx) 11 49 60
698 11 $modifier = $1;
699 11 $modifier =~ s/-[A-Za-z]*//;
700 }
701  
702 # with /x modifier
703 60 my @char = ();
704 60 ▶ if ($modifier =~ /x/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /x/mosx) { } 5 55 60
705 5 @char = $pattern =~ /\G((?>
706 [^\\\#\[\(] |
707 \\ $q_char |
708 \# (?>[^\n]*) $ |
709 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
710 \(\? |
711 $q_char
712 ))/oxmsg;
713 }
714  
715 # without /x modifier
716 else {
717 55 @char = $pattern =~ /\G((?>
718 [^\\\[\(] |
719 \\ $q_char |
720 \[ (?>(?:[^\\\]]|\\\\|\\\]|$q_char)+) \] |
721 \(\? |
722 $q_char
723 ))/oxmsg;
724 }
725  
726 60 return scalar grep { $_ eq '(' } @char;
727 }
728  
729 #
730 # KOI8-R transliteration (tr///)
731 #
732 6 ▶sub Ekoi8r::tr($$$$;$) {
Subroutine tr: called CC=26 SCAR=48.6
Pod undocumented
733  
734 6 my $bind_operator = $_[1];
735 6 my $searchlist = $_[2];
736 6 my $replacementlist = $_[3];
737 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
738  
739 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) 5 1 6
740 5 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 5 5
741 0 croak "Using !~ with tr///r doesn't make sense";
742 }
743 }
744  
745 6 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
746 6 my @searchlist = _charlist_tr($searchlist);
747 6 my @replacementlist = _charlist_tr($replacementlist);
748  
749 6 my %tr = ();
750 6 ▶ for (my $i=0; $i <= $#searchlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#searchlist) 19 6 25
751 19 ▶ if (not exists $tr{$searchlist[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$searchlist[$i]}) 19 0 19
752 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
753 19 $tr{$searchlist[$i]} = $replacementlist[$i];
754 }
755 elsif ($modifier =~ /d/oxms) {
756 0 $tr{$searchlist[$i]} = '';
757 }
758 ▶ 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
759 0 $tr{$searchlist[$i]} = $replacementlist[-1];
760 }
761 else {
762 0 $tr{$searchlist[$i]} = $searchlist[$i];
763 }
764 }
765 }
766  
767 6 my $tr = 0;
768 6 my $replaced = '';
769 6 ▶ if ($modifier =~ /c/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /c/mosx) { } 0 6 6
770 0 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 0 0 0
771 0 ▶ if (not exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $tr{$char}) { } 0 0 0
772 0 ▶ if (defined $replacementlist[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $replacementlist[-1]) 0 0 0
773 0 $replaced .= $replacementlist[-1];
774 }
775 0 $tr++;
776 0 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 0 0
777 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
778 0 shift @char;
779 0 $tr++;
780 }
781 }
782 }
783 else {
784 0 $replaced .= $char;
785 }
786 }
787 }
788 else {
789 6 ▶ while (defined(my $char = shift @char)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = shift @char)) 36 6 42
790 36 ▶ if (exists $tr{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$char}) { } 19 17 36
791 19 $replaced .= $tr{$char};
792 19 $tr++;
793 19 ▶ if ($modifier =~ /s/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/mosx) 0 19 19
794 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
795 0 shift @char;
796 0 $tr++;
797 }
798 }
799 }
800 else {
801 17 $replaced .= $char;
802 }
803 }
804 }
805  
806 6 ▶ if ($modifier =~ /r/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /r/mosx) { } 5 1 6
807 5 return $replaced;
808 }
809 else {
810 1 $_[0] = $replaced;
811 1 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) { } 0 1 1
812 0 return not $tr;
813 }
814 else {
815 1 return $tr;
816 }
817 }
818 }
819  
820 #
821 # KOI8-R chop
822 #
823 0 ▶sub Ekoi8r::chop(@) {
Subroutine chop: not called CC=3 SCAR=24.8
Pod undocumented
824  
825 0 my $chop;
826 0 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
827 0 my @char = /\G (?>$q_char) /oxmsg;
828 0 $chop = pop @char;
829 0 $_ = join '', @char;
830 }
831 else {
832 0 for (@_) {
833 0 my @char = /\G (?>$q_char) /oxmsg;
834 0 $chop = pop @char;
835 0 $_ = join '', @char;
836 }
837 }
838 0 return $chop;
839 }
840  
841 #
842 # KOI8-R index by octet
843 #
844 30 ▶sub Ekoi8r::index($$;$) {
Subroutine index: called CC=6 SCAR=20.8
Pod documented
845  
846 30 my($str,$substr,$position) = @_;
847 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
848 30 my $pos = 0;
849  
850 30 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < length $str) 130 30 160
851 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
852 0 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 0 0 0
853 0 return $pos;
854 }
855 }
856 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
857 130 $pos += CORE::length($1);
858 }
859 else {
860 0 $pos += 1;
861 }
862 }
863 30 return -1;
864 }
865  
866 #
867 # KOI8-R reverse index
868 #
869 0 ▶sub Ekoi8r::rindex($$;$) {
Subroutine rindex: not called CC=6 SCAR=37.4
Pod undocumented
870  
871 0 my($str,$substr,$position) = @_;
872 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
873 0 my $pos = 0;
874 0 my $rindex = -1;
875  
876 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
877 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
878 0 $rindex = $pos;
879 }
880 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
881 0 $pos += CORE::length($1);
882 }
883 else {
884 0 $pos += 1;
885 }
886 }
887 0 return $rindex;
888 }
889  
890 #
891 # KOI8-R lower case first with parameter
892 #
893 0 ▶sub Ekoi8r::lcfirst(@) {
Subroutine lcfirst: not called CC=4 SCAR=30.0
Pod undocumented
894 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
895 0 my $s = shift @_;
896 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
897 0 return Ekoi8r::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
898 }
899 else {
900 0 return Ekoi8r::lc(CORE::substr($s,0,1)) . CORE::substr($s,1);
901 }
902 }
903 else {
904 0 return Ekoi8r::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
905 }
906 }
907  
908 #
909 # KOI8-R lower case first without parameter
910 #
911 0 ▶sub Ekoi8r::lcfirst_() {
Subroutine lcfirst_: not called CC=1 SCAR=6.9
Pod undocumented
912 0 return Ekoi8r::lc(CORE::substr($_,0,1)) . CORE::substr($_,1);
913 }
914  
915 #
916 # KOI8-R lower case with parameter
917 #
918 60 ▶sub Ekoi8r::lc(@) {
Subroutine lc: called CC=6 SCAR=24.2
Pod undocumented
919 60 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 60 0 60
920 60 my $s = shift @_;
921 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
922 0 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
923 }
924 else {
925 60 ▶ return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 62 0 62
926 }
927 }
928 else {
929 0 return Ekoi8r::lc_();
930 }
931 }
932  
933 #
934 # KOI8-R lower case without parameter
935 #
936 0 ▶sub Ekoi8r::lc_() {
Subroutine lc_: not called CC=2 SCAR=17.9
Pod undocumented
937 0 my $s = $_;
938 0 ▶ return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $lc{$_} ? : 0 0 0
939 }
940  
941 #
942 # KOI8-R upper case first with parameter
943 #
944 0 ▶sub Ekoi8r::ucfirst(@) {
Subroutine ucfirst: not called CC=4 SCAR=30.0
Pod undocumented
945 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
946 0 my $s = shift @_;
947 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
948 0 return Ekoi8r::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_;
949 }
950 else {
951 0 return Ekoi8r::uc(CORE::substr($s,0,1)) . CORE::substr($s,1);
952 }
953 }
954 else {
955 0 return Ekoi8r::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
956 }
957 }
958  
959 #
960 # KOI8-R upper case first without parameter
961 #
962 0 ▶sub Ekoi8r::ucfirst_() {
Subroutine ucfirst_: not called CC=1 SCAR=6.9
Pod undocumented
963 0 return Ekoi8r::uc(CORE::substr($_,0,1)) . CORE::substr($_,1);
964 }
965  
966 #
967 # KOI8-R upper case with parameter
968 #
969 2415 ▶sub Ekoi8r::uc(@) {
Subroutine uc: called CC=6 SCAR=22.9
Pod undocumented
970 2415 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2415 0 2415
971 2415 my $s = shift @_;
972 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
973 0 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
974 }
975 else {
976 2415 ▶ return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 621 1796 2417
977 }
978 }
979 else {
980 0 return Ekoi8r::uc_();
981 }
982 }
983  
984 #
985 # KOI8-R upper case without parameter
986 #
987 0 ▶sub Ekoi8r::uc_() {
Subroutine uc_: not called CC=2 SCAR=17.9
Pod undocumented
988 0 my $s = $_;
989 0 ▶ return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $uc{$_} ? : 0 0 0
990 }
991  
992 #
993 # KOI8-R fold case with parameter
994 #
995 2426 ▶sub Ekoi8r::fc(@) {
Subroutine fc: called CC=6 SCAR=22.9
Pod undocumented
996 2426 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2426 0 2426
997 2426 my $s = shift @_;
998 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
999 0 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1000 }
1001 else {
1002 2426 ▶ return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg));
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 2040 5312 7352
1003 }
1004 }
1005 else {
1006 0 return Ekoi8r::fc_();
1007 }
1008 }
1009  
1010 #
1011 # KOI8-R fold case without parameter
1012 #
1013 0 ▶sub Ekoi8r::fc_() {
Subroutine fc_: not called CC=2 SCAR=17.9
Pod undocumented
1014 0 my $s = $_;
1015 0 ▶ return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg);
Branch: 1 branch
BranchTrueFalseTotal
defined $fc{$_} ? : 0 0 0
1016 }
1017  
1018 #
1019 # KOI8-R regexp capture
1020 #
1021 {
1022 0 ▶ sub Ekoi8r::capture {
Subroutine capture: not called CC=1 SCAR=6.9
Pod documented
1023 0 return $_[0];
1024 }
1025 }
1026  
1027 #
1028 # KOI8-R regexp ignore case modifier
1029 #
1030 424 ▶sub Ekoi8r::ignorecase {
Subroutine ignorecase: called CC=25 SCAR=52.9
Pod undocumented
1031  
1032 11 my @string = @_;
1033 11 my $metachar = qr/[\@\\|[\]{]/oxms;
1034  
1035 # ignore case of $scalar or @array
1036 11 for my $string (@string) {
1037  
1038 # split regexp
1039 11 my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg;
1040  
1041 # unescape character
1042 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 951 11 962
1043 951 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 951 951
1044  
1045 # open character class [...]
1046 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
1047 0 my $left = $i;
1048  
1049 # [] make die "unmatched [] in regexp ...\n"
1050  
1051 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1052 0 $i++;
1053 }
1054  
1055 0 while (1) {
1056 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1057 0 croak "Unmatched [] in regexp";
1058 }
1059 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1060 0 my $right = $i;
1061 0 my @charlist = charlist_qr(@char[$left+1..$right-1], 'i');
1062  
1063 # escape character
1064 0 for my $char (@charlist) {
1065 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1066 }
1067  
1068 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1069 0 $char = '\\' . $char;
1070 }
1071 }
1072  
1073 # [...]
1074 0 splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')';
1075  
1076 0 $i = $left;
1077 0 last;
1078 }
1079 }
1080 }
1081  
1082 # open character class [^...]
1083 elsif ($char[$i] eq '[^') {
1084 0 my $left = $i;
1085  
1086 # [^] make die "unmatched [] in regexp ...\n"
1087  
1088 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
1089 0 $i++;
1090 }
1091  
1092 0 while (1) {
1093 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
1094 0 croak "Unmatched [] in regexp";
1095 }
1096 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
1097 0 my $right = $i;
1098 0 my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i');
1099  
1100 # escape character
1101 0 for my $char (@charlist) {
1102 0 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $char =~ /\A [.|)] \z/mosx }) 0 0 0
1103 }
1104  
1105 0 elsif ($char =~ /\A [.|)] \z/oxms) {
1106 0 $char = '\\' . $char;
1107 }
1108 }
1109  
1110 # [^...]
1111 0 splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)";
1112  
1113 0 $i = $left;
1114 0 last;
1115 }
1116 }
1117 }
1118  
1119 # rewrite classic character class or escape character
1120 elsif (my $char = classic_character_class($char[$i])) {
1121 0 $char[$i] = $char;
1122 }
1123  
1124 # with /i modifier
1125 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1126 951 my $uc = Ekoi8r::uc($char[$i]);
1127 951 my $fc = Ekoi8r::fc($char[$i]);
1128 951 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) 487 464 951
1129 487 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 487 0 487
1130 487 $char[$i] = '[' . $uc . $fc . ']';
1131 }
1132 else {
1133 0 $char[$i] = '(?:' . $uc . '|' . $fc . ')';
1134 }
1135 }
1136 }
1137 }
1138  
1139 # characterize
1140 11 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 951 11 962
1141 951 ▶ next if not defined $char[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char[$i] 0 951 951
1142  
1143 951 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $i >= 1 and $char[$i] =~ /\A [\?\+\*\{] \z/mosx }) 0 962 962
1144 }
1145  
1146 # quote character before ? + * {
1147 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
1148 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
1149 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
1150 }
1151 }
1152 }
1153  
1154 11 $string = join '', @char;
1155 }
1156  
1157 # make regexp string
1158 11 return @string;
1159 }
1160  
1161 #
1162 # classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B )
1163 #
1164 2819 ▶sub Ekoi8r::classic_character_class {
Subroutine classic_character_class: called CC=2 SCAR=6.9
Pod undocumented
1165 2819 my($char) = @_;
1166  
1167 return {
1168 '\D' => '${Ekoi8r::eD}',
1169 '\S' => '${Ekoi8r::eS}',
1170 '\W' => '${Ekoi8r::eW}',
1171 '\d' => '[0-9]',
1172  
1173 # Before Perl 5.6, \s only matched the five whitespace characters
1174 # tab, newline, form-feed, carriage return, and the space character
1175 # itself, which, taken together, is the character class [\t\n\f\r ].
1176  
1177 # Vertical tabs are now whitespace
1178 # \s in a regex now matches a vertical tab in all circumstances.
1179 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1180 # \t \n \v \f \r space
1181 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1182 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1183 '\s' => '\s',
1184  
1185 '\w' => '[0-9A-Z_a-z]',
1186 '\C' => '[\x00-\xFF]',
1187 '\X' => 'X',
1188  
1189 # \h \v \H \V
1190  
1191 # P.114 Character Class Shortcuts
1192 # in Chapter 7: In the World of Regular Expressions
1193 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
1194  
1195 # P.357 13.2.3 Whitespace
1196 # in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes
1197 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1198 #
1199 # 0x00009 CHARACTER TABULATION h s
1200 # 0x0000a LINE FEED (LF) vs
1201 # 0x0000b LINE TABULATION v
1202 # 0x0000c FORM FEED (FF) vs
1203 # 0x0000d CARRIAGE RETURN (CR) vs
1204 # 0x00020 SPACE h s
1205  
1206 # P.196 Table 5-9. Alphanumeric regex metasymbols
1207 # in Chapter 5. Pattern Matching
1208 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1209  
1210 # (and so on)
1211  
1212 '\H' => '${Ekoi8r::eH}',
1213 '\V' => '${Ekoi8r::eV}',
1214 '\h' => '[\x09\x20]',
1215 '\v' => '[\x0A\x0B\x0C\x0D]',
1216 '\R' => '${Ekoi8r::eR}',
1217  
1218 # \N
1219 #
1220 # http://perldoc.perl.org/perlre.html
1221 # Character Classes and other Special Escapes
1222 # Any character but \n (experimental). Not affected by /s modifier
1223  
1224 '\N' => '${Ekoi8r::eN}',
1225  
1226 # \b \B
1227  
1228 # P.180 Boundaries: The \b and \B Assertions
1229 # in Chapter 5: Pattern Matching
1230 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1231  
1232 # P.219 Boundaries: The \b and \B Assertions
1233 # in Chapter 5: Pattern Matching
1234 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1235  
1236 # \b really means (?:(?<=\w)(?!\w)|(?<!\w)(?=\w))
1237 # or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z))
1238 '\b' => '${Ekoi8r::eb}',
1239  
1240 # \B really means (?:(?<=\w)(?=\w)|(?<!\w)(?!\w))
1241 # or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W))
1242 '\B' => '${Ekoi8r::eB}',
1243  
1244 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
1245 }
1246  
1247 #
1248 # prepare KOI8-R characters per length
1249 #
1250  
1251 # 1 octet characters
1252 424 my @chars1 = ();
1253 0 ▶sub chars1 {
Subroutine chars1: not called CC=5 SCAR=34.0
Pod undocumented
1254 0 ▶ if (@chars1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars1) 0 0 0
1255 0 return @chars1;
1256 }
1257 0 ▶ if (exists $range_tr{1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{1}) 0 0 0
1258 0 my @ranges = @{ $range_tr{1} };
1259 0 ▶ while (my @range = splice(@ranges,0,1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 1)) 0 0 0
1260 0 for my $oct0 (@{$range[0]}) {
1261 0 push @chars1, pack 'C', $oct0;
1262 }
1263 }
1264 }
1265 0 return @chars1;
1266 }
1267  
1268 # 2 octets characters
1269 424 my @chars2 = ();
1270 0 ▶sub chars2 {
Subroutine chars2: not called CC=6 SCAR=37.4
Pod undocumented
1271 0 ▶ if (@chars2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars2) 0 0 0
1272 0 return @chars2;
1273 }
1274 0 ▶ if (exists $range_tr{2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{2}) 0 0 0
1275 0 my @ranges = @{ $range_tr{2} };
1276 0 ▶ while (my @range = splice(@ranges,0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 2)) 0 0 0
1277 0 for my $oct0 (@{$range[0]}) {
1278 0 for my $oct1 (@{$range[1]}) {
1279 0 push @chars2, pack 'CC', $oct0,$oct1;
1280 }
1281 }
1282 }
1283 }
1284 0 return @chars2;
1285 }
1286  
1287 # 3 octets characters
1288 424 my @chars3 = ();
1289 0 ▶sub chars3 {
Subroutine chars3: not called CC=7 SCAR=40.3
Pod undocumented
1290 0 ▶ if (@chars3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars3) 0 0 0
1291 0 return @chars3;
1292 }
1293 0 ▶ if (exists $range_tr{3}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{3}) 0 0 0
1294 0 my @ranges = @{ $range_tr{3} };
1295 0 ▶ while (my @range = splice(@ranges,0,3)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 3)) 0 0 0
1296 0 for my $oct0 (@{$range[0]}) {
1297 0 for my $oct1 (@{$range[1]}) {
1298 0 for my $oct2 (@{$range[2]}) {
1299 0 push @chars3, pack 'CCC', $oct0,$oct1,$oct2;
1300 }
1301 }
1302 }
1303 }
1304 }
1305 0 return @chars3;
1306 }
1307  
1308 # 4 octets characters
1309 424 my @chars4 = ();
1310 0 ▶sub chars4 {
Subroutine chars4: not called CC=8 SCAR=42.8
Pod undocumented
1311 0 ▶ if (@chars4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chars4) 0 0 0
1312 0 return @chars4;
1313 }
1314 0 ▶ if (exists $range_tr{4}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{4}) 0 0 0
1315 0 my @ranges = @{ $range_tr{4} };
1316 0 ▶ while (my @range = splice(@ranges,0,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, 4)) 0 0 0
1317 0 for my $oct0 (@{$range[0]}) {
1318 0 for my $oct1 (@{$range[1]}) {
1319 0 for my $oct2 (@{$range[2]}) {
1320 0 for my $oct3 (@{$range[3]}) {
1321 0 push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3;
1322 }
1323 }
1324 }
1325 }
1326 }
1327 }
1328 0 return @chars4;
1329 }
1330  
1331 #
1332 # KOI8-R open character list for tr
1333 #
1334 12 ▶sub _charlist_tr {
Subroutine _charlist_tr: called CC=35 SCAR=66.4
1335  
1336 12 local $_ = shift @_;
1337  
1338 # unescape character
1339 12 my @char = ();
1340 12 ▶ while (not /\G \z/oxmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgmosx) 38 12 50
1341 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
1342 0 push @char, '\-';
1343 }
1344 elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) {
1345 0 push @char, CORE::chr(oct $1);
1346 }
1347 elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) {
1348 0 push @char, CORE::chr(hex $1);
1349 }
1350 elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) {
1351 0 push @char, CORE::chr(CORE::ord($1) & 0x1F);
1352 }
1353 elsif (/\G (\\ [0nrtfbae]) /oxmsgc) {
1354 push @char, {
1355 '\0' => "\0",
1356 '\n' => "\n",
1357 '\r' => "\r",
1358 '\t' => "\t",
1359 '\f' => "\f",
1360 '\b' => "\x08", # \b means backspace in character class
1361 '\a' => "\a",
1362 '\e' => "\e",
1363 0 }->{$1};
1364 }
1365 elsif (/\G \\ ($q_char) /oxmsgc) {
1366 0 push @char, $1;
1367 }
1368 elsif (/\G ($q_char) /oxmsgc) {
1369 38 push @char, $1;
1370 }
1371 }
1372  
1373 # join separated multiple-octet
1374 12 @char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg;
1375  
1376 # unescape '-'
1377 12 my @i = ();
1378 12 for my $i (0 .. $#char) {
1379 38 ▶ if ($char[$i] eq '\-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char[$i] eq '\\-') { } 0 38 38
elsif ($char[$i] eq '-') { } 0 38 38
1380 0 $char[$i] = '-';
1381 }
1382 elsif ($char[$i] eq '-') {
1383 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
1384 0 push @i, $i;
1385 }
1386 }
1387 }
1388  
1389 # open character list (reverse for splice)
1390 12 for my $i (CORE::reverse @i) {
1391 0 my @range = ();
1392  
1393 # range error
1394 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
1395 0 croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1396 }
1397  
1398 # range of multiple-octet code
1399 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
1400 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
1401 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
1402 }
1403 elsif (CORE::length($char[$i+1]) == 2) {
1404 0 push @range, grep {$char[$i-1] le $_} chars1();
1405 0 push @range, grep {$_ le $char[$i+1]} chars2();
1406 }
1407 elsif (CORE::length($char[$i+1]) == 3) {
1408 0 push @range, grep {$char[$i-1] le $_} chars1();
1409 0 push @range, chars2();
1410 0 push @range, grep {$_ le $char[$i+1]} chars3();
1411 }
1412 elsif (CORE::length($char[$i+1]) == 4) {
1413 0 push @range, grep {$char[$i-1] le $_} chars1();
1414 0 push @range, chars2();
1415 0 push @range, chars3();
1416 0 push @range, grep {$_ le $char[$i+1]} chars4();
1417 }
1418 else {
1419 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1420 }
1421 }
1422 elsif (CORE::length($char[$i-1]) == 2) {
1423 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
1424 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
1425 }
1426 elsif (CORE::length($char[$i+1]) == 3) {
1427 0 push @range, grep {$char[$i-1] le $_} chars2();
1428 0 push @range, grep {$_ le $char[$i+1]} chars3();
1429 }
1430 elsif (CORE::length($char[$i+1]) == 4) {
1431 0 push @range, grep {$char[$i-1] le $_} chars2();
1432 0 push @range, chars3();
1433 0 push @range, grep {$_ le $char[$i+1]} chars4();
1434 }
1435 else {
1436 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1437 }
1438 }
1439 elsif (CORE::length($char[$i-1]) == 3) {
1440 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
1441 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
1442 }
1443 elsif (CORE::length($char[$i+1]) == 4) {
1444 0 push @range, grep {$char[$i-1] le $_} chars3();
1445 0 push @range, grep {$_ le $char[$i+1]} chars4();
1446 }
1447 else {
1448 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1449 }
1450 }
1451 elsif (CORE::length($char[$i-1]) == 4) {
1452 0 ▶ if (CORE::length($char[$i+1]) == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $char[$i + 1] == 4) { } 0 0 0
1453 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
1454 }
1455 else {
1456 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1457 }
1458 }
1459 else {
1460 0 croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"';
1461 }
1462  
1463 0 splice @char, $i-1, 3, @range;
1464 }
1465  
1466 12 return @char;
1467 }
1468  
1469 #
1470 # KOI8-R open character class
1471 #
1472 0 ▶sub _cc {
Subroutine _cc: not called CC=7 SCAR=40.3
1473 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
1474 0 die __FILE__, ": subroutine cc got no parameter.\n";
1475 }
1476 elsif (scalar(@_) == 1) {
1477 0 return sprintf('\x%02X',$_[0]);
1478 }
1479 elsif (scalar(@_) == 2) {
1480 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
1481 0 die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n";
1482 }
1483 elsif ($_[0] == $_[1]) {
1484 0 return sprintf('\x%02X',$_[0]);
1485 }
1486 elsif (($_[0]+1) == $_[1]) {
1487 0 return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]);
1488 }
1489 else {
1490 0 return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]);
1491 }
1492 }
1493 else {
1494 0 die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n";
1495 }
1496 }
1497  
1498 #
1499 # KOI8-R octet range
1500 #
1501 246 ▶sub _octets {
Subroutine _octets: called CC=5 SCAR=19.3
1502 246 my $length = shift @_;
1503  
1504 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1505 246 my($a1) = unpack 'C', $_[0];
1506 246 my($z1) = unpack 'C', $_[1];
1507  
1508 246 ▶ if ($a1 > $z1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1 > $z1) 0 246 246
1509 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1);
1510 }
1511  
1512 246 ▶ if ($a1 == $z1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($a1 == $z1) { } 0 246 246
elsif ($a1 + 1 == $z1) { } 0 246 246
1513 0 return sprintf('\x%02X',$a1);
1514 }
1515 elsif (($a1+1) == $z1) {
1516 0 return sprintf('\x%02X\x%02X',$a1,$z1);
1517 }
1518 else {
1519 246 return sprintf('\x%02X-\x%02X',$a1,$z1);
1520 }
1521 }
1522 else {
1523 0 die __FILE__, ": subroutine _octets got invalid length ($length).\n";
1524 }
1525 }
1526  
1527 #
1528 # KOI8-R range regexp
1529 #
1530 246 ▶sub _range_regexp {
Subroutine _range_regexp: called CC=18 SCAR=41.7
1531 246 my($length,$first,$last) = @_;
1532  
1533 246 my @range_regexp = ();
1534 246 ▶ if (not exists $range_tr{$length}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $range_tr{$length}) 0 246 246
1535 0 return @range_regexp;
1536 }
1537  
1538 246 my @ranges = @{ $range_tr{$length} };
1539 246 ▶ while (my @range = splice(@ranges,0,$length)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@range) = splice(@ranges, 0, $length)) 246 246 492
1540 246 my $min = '';
1541 246 my $max = '';
1542 246 ▶ for (my $i=0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 246 246 492
1543 246 $min .= pack 'C', $range[$i][0];
1544 246 $max .= pack 'C', $range[$i][-1];
1545 }
1546  
1547 # min___max
1548 # FIRST_____________LAST
1549 # (nothing)
1550  
1551 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
1552 }
1553  
1554 # **********
1555 # min_________max
1556 # FIRST_____________LAST
1557 # **********
1558  
1559 ▶ 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
1560 0 push @range_regexp, _octets($length,$first,$max,$min,$max);
1561 }
1562  
1563 # **********************
1564 # min________________max
1565 # FIRST_____________LAST
1566 # **********************
1567  
1568 ▶ 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
1569 0 push @range_regexp, _octets($length,$first,$last,$min,$max);
1570 }
1571  
1572 # *********
1573 # min___max
1574 # FIRST_____________LAST
1575 # *********
1576  
1577 ▶ 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
1578 0 push @range_regexp, _octets($length,$min,$max,$min,$max);
1579 }
1580  
1581 # **********************
1582 # min__________________________max
1583 # FIRST_____________LAST
1584 # **********************
1585  
1586 ▶ 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
1587 246 push @range_regexp, _octets($length,$first,$last,$min,$max);
1588 }
1589  
1590 # *********
1591 # min________max
1592 # FIRST_____________LAST
1593 # *********
1594  
1595 ▶ 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
1596 0 push @range_regexp, _octets($length,$min,$last,$min,$max);
1597 }
1598  
1599 # min___max
1600 # FIRST_____________LAST
1601 # (nothing)
1602  
1603 elsif ($last lt $min) {
1604 }
1605  
1606 else {
1607 0 die __FILE__, ": subroutine _range_regexp panic.\n";
1608 }
1609 }
1610  
1611 246 return @range_regexp;
1612 }
1613  
1614 #
1615 # KOI8-R open character list for qr and not qr
1616 #
1617 650 ▶sub _charlist {
Subroutine _charlist: called CC=46 SCAR=45.9
1618  
1619 650 my $modifier = pop @_;
1620 650 my @char = @_;
1621  
1622 650 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 298 352 650
1623  
1624 # unescape character
1625 650 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1773 650 2423
1626  
1627 # escape - to ...
1628 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
1629 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
1630 246 $char[$i] = '...';
1631 }
1632 }
1633  
1634 # octal escape sequence
1635 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
1636 0 $char[$i] = octchr($1);
1637 }
1638  
1639 # hexadecimal escape sequence
1640 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
1641 0 $char[$i] = hexchr($1);
1642 }
1643  
1644 # \b{...} --> b\{...}
1645 # \B{...} --> B\{...}
1646 # \N{CHARNAME} --> N\{CHARNAME}
1647 # \p{PROPERTY} --> p\{PROPERTY}
1648 # \P{PROPERTY} --> P\{PROPERTY}
1649 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
1650 0 $char[$i] = $1 . '\\' . $2;
1651 }
1652  
1653 # \p, \P, \X --> p, P, X
1654 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
1655 0 $char[$i] = $1;
1656 }
1657  
1658 elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) {
1659 0 $char[$i] = CORE::chr oct $1;
1660 }
1661 elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) {
1662 22 $char[$i] = CORE::chr hex $1;
1663 }
1664 elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) {
1665 0 $char[$i] = CORE::chr(CORE::ord($1) & 0x1F);
1666 }
1667 elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) {
1668 $char[$i] = {
1669 '\0' => "\0",
1670 '\n' => "\n",
1671 '\r' => "\r",
1672 '\t' => "\t",
1673 '\f' => "\f",
1674 '\b' => "\x08", # \b means backspace in character class
1675 '\a' => "\a",
1676 '\e' => "\e",
1677 '\d' => '[0-9]',
1678  
1679 # Vertical tabs are now whitespace
1680 # \s in a regex now matches a vertical tab in all circumstances.
1681 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace
1682 # \t \n \v \f \r space
1683 # '\s' => '[\x09\x0A \x0C\x0D\x20]',
1684 # '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]',
1685 '\s' => '\s',
1686  
1687 '\w' => '[0-9A-Z_a-z]',
1688 '\D' => '${Ekoi8r::eD}',
1689 '\S' => '${Ekoi8r::eS}',
1690 '\W' => '${Ekoi8r::eW}',
1691  
1692 '\H' => '${Ekoi8r::eH}',
1693 '\V' => '${Ekoi8r::eV}',
1694 '\h' => '[\x09\x20]',
1695 '\v' => '[\x0A\x0B\x0C\x0D]',
1696 '\R' => '${Ekoi8r::eR}',
1697  
1698 25 }->{$1};
1699 }
1700  
1701 # POSIX-style character classes
1702 ▶ 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
1703 $char[$i] = {
1704  
1705 '[:lower:]' => '[\x41-\x5A\x61-\x7A]',
1706 '[:upper:]' => '[\x41-\x5A\x61-\x7A]',
1707 '[:^lower:]' => '${Ekoi8r::not_lower_i}',
1708 '[:^upper:]' => '${Ekoi8r::not_upper_i}',
1709  
1710 8 }->{$1};
1711 }
1712 elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) {
1713 $char[$i] = {
1714  
1715 '[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]',
1716 '[:alpha:]' => '[\x41-\x5A\x61-\x7A]',
1717 '[:ascii:]' => '[\x00-\x7F]',
1718 '[:blank:]' => '[\x09\x20]',
1719 '[:cntrl:]' => '[\x00-\x1F\x7F]',
1720 '[:digit:]' => '[\x30-\x39]',
1721 '[:graph:]' => '[\x21-\x7F]',
1722 '[:lower:]' => '[\x61-\x7A]',
1723 '[:print:]' => '[\x20-\x7F]',
1724 '[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]',
1725  
1726 # P.174 POSIX-Style Character Classes
1727 # in Chapter 5: Pattern Matching
1728 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
1729  
1730 # P.311 11.2.4 Character Classes and other Special Escapes
1731 # in Chapter 11: perlre: Perl regular expressions
1732 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
1733  
1734 # P.210 POSIX-Style Character Classes
1735 # in Chapter 5: Pattern Matching
1736 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
1737  
1738 '[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK")
1739  
1740 '[:upper:]' => '[\x41-\x5A]',
1741 '[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]',
1742 '[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]',
1743 '[:^alnum:]' => '${Ekoi8r::not_alnum}',
1744 '[:^alpha:]' => '${Ekoi8r::not_alpha}',
1745 '[:^ascii:]' => '${Ekoi8r::not_ascii}',
1746 '[:^blank:]' => '${Ekoi8r::not_blank}',
1747 '[:^cntrl:]' => '${Ekoi8r::not_cntrl}',
1748 '[:^digit:]' => '${Ekoi8r::not_digit}',
1749 '[:^graph:]' => '${Ekoi8r::not_graph}',
1750 '[:^lower:]' => '${Ekoi8r::not_lower}',
1751 '[:^print:]' => '${Ekoi8r::not_print}',
1752 '[:^punct:]' => '${Ekoi8r::not_punct}',
1753 '[:^space:]' => '${Ekoi8r::not_space}',
1754 '[:^upper:]' => '${Ekoi8r::not_upper}',
1755 '[:^word:]' => '${Ekoi8r::not_word}',
1756 '[:^xdigit:]' => '${Ekoi8r::not_xdigit}',
1757  
1758 70 }->{$1};
1759 }
1760 elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) {
1761 7 $char[$i] = $1;
1762 }
1763 }
1764  
1765 # open character list
1766 650 my @singleoctet = ();
1767 650 my @multipleoctet = ();
1768 650 ▶ for (my $i=0; $i <= $#char; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 1527 650 2177
1769  
1770 # escaped -
1771 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
1772 246 $i += 1;
1773 246 next;
1774 }
1775  
1776 # make range regexp
1777 elsif ($char[$i] eq '...') {
1778  
1779 # range error
1780 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
1781 0 croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1782 }
1783 elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) {
1784 246 ▶ if ($char[$i-1] gt $char[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i - 1] gt $char[$i + 1]) 0 246 246
1785 0 croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]);
1786 }
1787 }
1788  
1789 # make range regexp per length
1790 246 for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) {
1791 246 my @regexp = ();
1792  
1793 # is first and last
1794 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
1795 246 push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]);
1796 }
1797  
1798 # is first
1799 elsif ($length == CORE::length($char[$i-1])) {
1800 0 push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length);
1801 }
1802  
1803 # is inside in first and last
1804 ▶ 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
1805 0 push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length);
1806 }
1807  
1808 # is last
1809 elsif ($length == CORE::length($char[$i+1])) {
1810 0 push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]);
1811 }
1812  
1813 else {
1814 0 die __FILE__, ": subroutine make_regexp panic.\n";
1815 }
1816  
1817 246 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) { } 246 0 246
1818 246 push @singleoctet, @regexp;
1819 }
1820 else {
1821 0 push @multipleoctet, @regexp;
1822 }
1823 }
1824  
1825 246 $i += 2;
1826 }
1827  
1828 # with /i modifier
1829 elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) {
1830 949 ▶ if ($modifier =~ /i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) { } 480 469 949
1831 480 my $uc = Ekoi8r::uc($char[$i]);
1832 480 my $fc = Ekoi8r::fc($char[$i]);
1833 480 ▶ if ($uc ne $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc ne $fc) { } 240 240 480
1834 240 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 240 0 240
1835 240 push @singleoctet, $uc, $fc;
1836 }
1837 else {
1838 0 push @singleoctet, $uc;
1839 0 push @multipleoctet, $fc;
1840 }
1841 }
1842 else {
1843 240 push @singleoctet, $char[$i];
1844 }
1845 }
1846 else {
1847 469 push @singleoctet, $char[$i];
1848 }
1849 949 $i += 1;
1850 }
1851  
1852 # single character of single octet code
1853 elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) {
1854 0 push @singleoctet, "\t", "\x20";
1855 0 $i += 1;
1856 }
1857 elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) {
1858 0 push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D";
1859 0 $i += 1;
1860 }
1861 elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) {
1862 2 push @singleoctet, $char[$i];
1863 2 $i += 1;
1864 }
1865  
1866 # single character of multiple-octet code
1867 else {
1868 84 push @multipleoctet, $char[$i];
1869 84 $i += 1;
1870 }
1871 }
1872  
1873 # quote metachar
1874 650 for (@singleoctet) {
1875 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
1876 0 $_ = '-';
1877 }
1878 elsif (/\A \n \z/oxms) {
1879 8 $_ = '\n';
1880 }
1881 elsif (/\A \r \z/oxms) {
1882 8 $_ = '\r';
1883 }
1884 elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) {
1885 744 $_ = sprintf('\x%02X', CORE::ord $1);
1886 }
1887 elsif (/\A [\x00-\xFF] \z/oxms) {
1888 429 $_ = quotemeta $_;
1889 }
1890 }
1891  
1892 # return character list
1893 650 return \@singleoctet, \@multipleoctet;
1894 }
1895  
1896 #
1897 # KOI8-R octal escape sequence
1898 #
1899 5 ▶sub octchr {
Subroutine octchr: called CC=2 SCAR=6.9
Pod undocumented
1900 5 my($octdigit) = @_;
1901  
1902 5 my @binary = ();
1903 5 for my $octal (split(//,$octdigit)) {
1904 push @binary, {
1905 '0' => '000',
1906 '1' => '001',
1907 '2' => '010',
1908 '3' => '011',
1909 '4' => '100',
1910 '5' => '101',
1911 '6' => '110',
1912 '7' => '111',
1913 50 }->{$octal};
1914 }
1915 5 my $binary = join '', @binary;
1916  
1917 my $octchr = {
1918 # 1234567
1919 1 => pack('B*', "0000000$binary"),
1920 2 => pack('B*', "000000$binary"),
1921 3 => pack('B*', "00000$binary"),
1922 4 => pack('B*', "0000$binary"),
1923 5 => pack('B*', "000$binary"),
1924 6 => pack('B*', "00$binary"),
1925 7 => pack('B*', "0$binary"),
1926 0 => pack('B*', "$binary"),
1927  
1928 5 }->{CORE::length($binary) % 8};
1929  
1930 5 return $octchr;
1931 }
1932  
1933 #
1934 # KOI8-R hexadecimal escape sequence
1935 #
1936 5 ▶sub hexchr {
Subroutine hexchr: called CC=1 SCAR=0.0
Pod undocumented
1937 5 my($hexdigit) = @_;
1938  
1939 my $hexchr = {
1940 1 => pack('H*', "0$hexdigit"),
1941 0 => pack('H*', "$hexdigit"),
1942  
1943 5 }->{CORE::length($_[0]) % 2};
1944  
1945 5 return $hexchr;
1946 }
1947  
1948 #
1949 # KOI8-R open character list for qr
1950 #
1951 576 ▶sub charlist_qr {
Subroutine charlist_qr: called CC=17 SCAR=28.7
Pod undocumented
1952  
1953 576 my $modifier = pop @_;
1954 576 my @char = @_;
1955  
1956 576 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
1957 576 my @singleoctet = @$singleoctet;
1958 576 my @multipleoctet = @$multipleoctet;
1959  
1960 # return character list
1961 576 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) 498 78 576
1962  
1963 # with /i modifier
1964 498 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 265 233 498
1965 265 my %singleoctet_ignorecase = ();
1966 265 for (@singleoctet) {
1967 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
1968 745 for my $ord (hex($1) .. hex($2)) {
1969 795 my $char = CORE::chr($ord);
1970 795 my $uc = Ekoi8r::uc($char);
1971 795 my $fc = Ekoi8r::fc($char);
1972 795 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 240 555 795
1973 240 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
1974 }
1975 else {
1976 555 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 555 0 555
1977 555 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1978 555 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
1979 }
1980 else {
1981 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
1982 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
1983 }
1984 }
1985 }
1986 }
1987 745 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 745 745
1988 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
1989 }
1990 }
1991 265 my $i = 0;
1992 265 my @singleoctet_ignorecase = ();
1993 265 for my $ord (0 .. 255) {
1994 67840 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 870 66970 67840
1995 870 push @{$singleoctet_ignorecase[$i]}, $ord;
1996 }
1997 else {
1998 66970 $i++;
1999 }
2000 }
2001 265 @singleoctet = ();
2002 265 for my $range (@singleoctet_ignorecase) {
2003 56160 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 770 55390 56160
2004 770 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 720 50 770
elsif (scalar @{$range;} == 2) { } 0 50 50
2005 720 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2006 }
2007 50 elsif (scalar(@{$range}) == 2) {
2008 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2009 }
2010 else {
2011 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2012 }
2013 }
2014 }
2015 }
2016  
2017 498 my $not_anchor = '';
2018  
2019 498 push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' );
2020 }
2021 576 ▶ if (scalar(@multipleoctet) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 2) { } 6 570 576
2022 6 return '(?:' . join('|', @multipleoctet) . ')';
2023 }
2024 else {
2025 570 return $multipleoctet[0];
2026 }
2027 }
2028  
2029 #
2030 # KOI8-R open character list for not qr
2031 #
2032 74 ▶sub charlist_not_qr {
Subroutine charlist_not_qr: called CC=18 SCAR=33.1
Pod undocumented
2033  
2034 74 my $modifier = pop @_;
2035 74 my @char = @_;
2036  
2037 74 my($singleoctet, $multipleoctet) = _charlist(@char, $modifier);
2038 74 my @singleoctet = @$singleoctet;
2039 74 my @multipleoctet = @$multipleoctet;
2040  
2041 # with /i modifier
2042 74 ▶ if ($modifier =~ m/i/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /i/mosx) 25 49 74
2043 25 my %singleoctet_ignorecase = ();
2044 25 for (@singleoctet) {
2045 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
2046 25 for my $ord (hex($1) .. hex($2)) {
2047 75 my $char = CORE::chr($ord);
2048 75 my $uc = Ekoi8r::uc($char);
2049 75 my $fc = Ekoi8r::fc($char);
2050 75 ▶ if ($uc eq $fc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uc eq $fc) { } 0 75 75
2051 0 $singleoctet_ignorecase{unpack 'C*', $char} = 1;
2052 }
2053 else {
2054 75 ▶ if (CORE::length($fc) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $fc == 1) { } 75 0 75
2055 75 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2056 75 $singleoctet_ignorecase{unpack 'C*', $fc} = 1;
2057 }
2058 else {
2059 0 $singleoctet_ignorecase{unpack 'C*', $uc} = 1;
2060 0 push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc;
2061 }
2062 }
2063 }
2064 }
2065 25 ▶ if ($_ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne "") 0 25 25
2066 0 $singleoctet_ignorecase{unpack 'C*', $_} = 1;
2067 }
2068 }
2069 25 my $i = 0;
2070 25 my @singleoctet_ignorecase = ();
2071 25 for my $ord (0 .. 255) {
2072 6400 ▶ if (exists $singleoctet_ignorecase{$ord}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $singleoctet_ignorecase{$ord}) { } 150 6250 6400
2073 150 push @{$singleoctet_ignorecase[$i]}, $ord;
2074 }
2075 else {
2076 6250 $i++;
2077 }
2078 }
2079 25 @singleoctet = ();
2080 25 for my $range (@singleoctet_ignorecase) {
2081 2400 ▶ if (ref $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $range) 50 2350 2400
2082 50 ▶ if (scalar(@{$range}) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$range;} == 1) { } 0 50 50
elsif (scalar @{$range;} == 2) { } 0 50 50
2083 0 push @singleoctet, sprintf('\x%02X', @{$range}[0]);
2084 }
2085 50 elsif (scalar(@{$range}) == 2) {
2086 0 push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]);
2087 }
2088 else {
2089 50 push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]);
2090 }
2091 }
2092 }
2093 }
2094  
2095 # return character list
2096 74 ▶ if (scalar(@multipleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @multipleoctet >= 1) { } 0 74 74
2097 0 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 0 0 0
2098  
2099 # any character other than multiple-octet and single octet character class
2100 0 return '(?!' . join('|', @multipleoctet) . ')(?:[^' . join('', @singleoctet) . '])';
2101 }
2102 else {
2103  
2104 # any character other than multiple-octet character class
2105 0 return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)";
2106 }
2107 }
2108 else {
2109 74 ▶ if (scalar(@singleoctet) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @singleoctet >= 1) { } 74 0 74
2110  
2111 # any character other than single octet character class
2112 74 return '(?:[^' . join('', @singleoctet) . '])';
2113 }
2114 else {
2115  
2116 # any character
2117 0 return "(?:$your_char)";
2118 }
2119 }
2120 }
2121  
2122 #
2123 # open file in read mode
2124 #
2125 424 ▶sub _open_r {
Subroutine _open_r: called CC=1 SCAR=0.0
2126 424 my(undef,$file) = @_;
2127 424 ▶ use Fcntl qw(O_RDONLY);
Subroutine BEGIN: called CC=1 SCAR=0.0
2128 424 return CORE::sysopen($_[0], $file, &O_RDONLY);
2129 }
2130  
2131 #
2132 # open file in append mode
2133 #
2134 212 ▶sub _open_a {
Subroutine _open_a: called CC=1 SCAR=0.0
2135 212 my(undef,$file) = @_;
2136 424 ▶ use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
2137 212 return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT);
2138 }
2139  
2140 #
2141 # safe system
2142 #
2143 212 ▶sub _systemx {
Subroutine _systemx: called CC=1 SCAR=0.0
2144  
2145 # P.707 29.2.33. exec
2146 # in Chapter 29: Functions
2147 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2148 #
2149 # Be aware that in older releases of Perl, exec (and system) did not flush
2150 # your output buffer, so you needed to enable command buffering by setting $|
2151 # on one or more filehandles to avoid lost output in the case of exec, or
2152 # misordererd output in the case of system. This situation was largely remedied
2153 # in the 5.6 release of Perl. (So, 5.005 release not yet.)
2154  
2155 # P.855 exec
2156 # in Chapter 27: Functions
2157 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2158 #
2159 # In very old release of Perl (before v5.6), exec (and system) did not flush
2160 # your output buffer, so you needed to enable command buffering by setting $|
2161 # on one or more filehandles to avoid lost output with exec or misordered
2162 # output with system.
2163  
2164 212 $| = 1;
2165  
2166 # P.565 23.1.2. Cleaning Up Your Environment
2167 # in Chapter 23: Security
2168 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2169  
2170 # P.656 Cleaning Up Your Environment
2171 # in Chapter 20: Security
2172 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2173  
2174 # local $ENV{'PATH'} = '.';
2175 212 local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
2176  
2177 # P.707 29.2.33. exec
2178 # in Chapter 29: Functions
2179 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2180 #
2181 # As we mentioned earlier, exec treats a discrete list of arguments as an
2182 # indication that it should bypass shell processing. However, there is one
2183 # place where you might still get tripped up. The exec call (and system, too)
2184 # will not distinguish between a single scalar argument and an array containing
2185 # only one element.
2186 #
2187 # @args = ("echo surprise"); # just one element in list
2188 # exec @args # still subject to shell escapes
2189 # or die "exec: $!"; # because @args == 1
2190 #
2191 # To avoid this, you can use the PATHNAME syntax, explicitly duplicating the
2192 # first argument as the pathname, which forces the rest of the arguments to be
2193 # interpreted as a list, even if there is only one of them:
2194 #
2195 # exec { $args[0] } @args # safe even with one-argument list
2196 # or die "can't exec @args: $!";
2197  
2198 # P.855 exec
2199 # in Chapter 27: Functions
2200 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2201 #
2202 # As we mentioned earlier, exec treats a discrete list of arguments as a
2203 # directive to bypass shell processing. However, there is one place where
2204 # you might still get tripped up. The exec call (and system, too) cannot
2205 # distinguish between a single scalar argument and an array containing
2206 # only one element.
2207 #
2208 # @args = ("echo surprise"); # just one element in list
2209 # exec @args # still subject to shell escapes
2210 # || die "exec: $!"; # because @args == 1
2211 #
2212 # To avoid this, use the PATHNAME syntax, explicitly duplicating the first
2213 # argument as the pathname, which forces the rest of the arguments to be
2214 # interpreted as a list, even if there is only one of them:
2215 #
2216 # exec { $args[0] } @args # safe even with one-argument list
2217 # || die "can't exec @args: $!";
2218  
2219 212 return CORE::system { $_[0] } @_; # safe even with one-argument list
2220 }
2221  
2222 #
2223 # KOI8-R order to character (with parameter)
2224 #
2225 3469 ▶sub Ekoi8r::chr(;$) {
Subroutine chr: called CC=4 SCAR=13.9
Pod undocumented
2226  
2227 3469 ▶ my $c = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3469 0 3469
2228  
2229 3469 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 24 3445 3469
2230 24 return "\x00";
2231 }
2232 else {
2233 3445 my @chr = ();
2234 3445 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 3445 3445 6890
2235 3445 unshift @chr, ($c % 0x100);
2236 3445 $c = int($c / 0x100);
2237 }
2238 3445 return pack 'C*', @chr;
2239 }
2240 }
2241  
2242 #
2243 # KOI8-R order to character (without parameter)
2244 #
2245 0 ▶sub Ekoi8r::chr_() {
Subroutine chr_: not called CC=3 SCAR=24.8
Pod undocumented
2246  
2247 0 my $c = $_;
2248  
2249 0 ▶ if ($c == 0x00) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 0) { } 0 0 0
2250 0 return "\x00";
2251 }
2252 else {
2253 0 my @chr = ();
2254 0 ▶ while ($c > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > 0) 0 0 0
2255 0 unshift @chr, ($c % 0x100);
2256 0 $c = int($c / 0x100);
2257 }
2258 0 return pack 'C*', @chr;
2259 }
2260 }
2261  
2262 #
2263 # KOI8-R path globbing (with parameter)
2264 #
2265 0 ▶sub Ekoi8r::glob($) {
Subroutine glob: not called CC=3 SCAR=24.8
Pod undocumented
2266  
2267 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2268 0 my @glob = _DOS_like_glob(@_);
2269 0 for my $glob (@glob) {
2270 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2271 }
2272 0 return @glob;
2273 }
2274 else {
2275 0 my $glob = _DOS_like_glob(@_);
2276 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2277 0 return $glob;
2278 }
2279 }
2280  
2281 #
2282 # KOI8-R path globbing (without parameter)
2283 #
2284 0 ▶sub Ekoi8r::glob_() {
Subroutine glob_: not called CC=3 SCAR=24.8
Pod undocumented
2285  
2286 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2287 0 my @glob = _DOS_like_glob();
2288 0 for my $glob (@glob) {
2289 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2290 }
2291 0 return @glob;
2292 }
2293 else {
2294 0 my $glob = _DOS_like_glob();
2295 0 $glob =~ s{ \A (?:\./)+ }{}oxms;
2296 0 return $glob;
2297 }
2298 }
2299  
2300 #
2301 # KOI8-R path globbing via File::DosGlob 1.10
2302 #
2303 # Often I confuse "_dosglob" and "_doglob".
2304 # So, I renamed "_dosglob" to "_DOS_like_glob".
2305 #
2306 424 my %iter;
2307 my %entries;
2308 0 ▶sub _DOS_like_glob {
Subroutine _DOS_like_glob: not called CC=10 SCAR=47.0
2309  
2310 # context (keyed by second cxix argument provided by core)
2311 0 my($expr,$cxix) = @_;
2312  
2313 # glob without args defaults to $_
2314 0 ▶ $expr = $_ if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2315  
2316 # represents the current user's home directory
2317 #
2318 # 7.3. Expanding Tildes in Filenames
2319 # in Chapter 7. File Access
2320 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2321 #
2322 # and File::HomeDir, File::HomeDir::Windows module
2323  
2324 # DOS-like system
2325 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
2326 0 $expr =~ s{ \A ~ (?= [^/\\] ) }
2327 0 { my_home_MSWin32() }oxmse;
2328 }
2329  
2330 # UNIX-like system
2331 else {
2332 0 $expr =~ s{ \A ~ ( (?:[^/])* ) }
2333 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
2334 }
2335  
2336 # assume global context if not provided one
2337 0 ▶ $cxix = '_G_' if not defined $cxix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cxix 0 0 0
2338 0 ▶ $iter{$cxix} = 0 if not exists $iter{$cxix};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $iter{$cxix} 0 0 0
2339  
2340 # if we're just beginning, do it all first
2341 0 ▶ if ($iter{$cxix} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} == 0) 0 0 0
2342 0 $entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ];
2343 }
2344  
2345 # chuck it all out, quick or slow
2346 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2347 0 delete $iter{$cxix};
2348 0 return @{delete $entries{$cxix}};
2349 }
2350 else {
2351 0 ▶ if ($iter{$cxix} = scalar @{$entries{$cxix}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter{$cxix} = scalar @{$entries{$cxix};}) { } 0 0 0
2352 0 return shift @{$entries{$cxix}};
2353 }
2354 else {
2355 # return undef for EOL
2356 0 delete $iter{$cxix};
2357 0 delete $entries{$cxix};
2358 0 return undef;
2359 }
2360 }
2361 }
2362  
2363 #
2364 # KOI8-R path globbing subroutine
2365 #
2366 0 ▶sub _do_glob {
Subroutine _do_glob: not called CC=44 SCAR=75.9
2367  
2368 0 my($cond,@expr) = @_;
2369 0 my @glob = ();
2370 0 my $fix_drive_relative_paths = 0;
2371  
2372 OUTER:
2373 0 for my $expr (@expr) {
2374 0 ▶ next OUTER if not defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 0 0
2375 0 ▶ next OUTER if $expr eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $expr eq "" 0 0 0
2376  
2377 0 my @matched = ();
2378 0 my @globdir = ();
2379 0 my $head = '.';
2380 0 my $pathsep = '/';
2381 0 my $tail;
2382  
2383 # if argument is within quotes strip em and do no globbing
2384 0 ▶ if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ /\A " ((?:$Ekoi8r::q_char)*?) " \z/mosx) 0 0 0
2385 0 $expr = $1;
2386 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2387 0 ▶ if (-d $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $expr) 0 0 0
2388 0 push @glob, $expr;
2389 }
2390 }
2391 else {
2392 0 ▶ if (-e $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $expr) 0 0 0
2393 0 push @glob, $expr;
2394 }
2395 }
2396 0 next OUTER;
2397 }
2398  
2399 # wildcards with a drive prefix such as h:*.pm must be changed
2400 # to h:./*.pm to expand correctly
2401 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
2402 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
2403 0 $fix_drive_relative_paths = 1;
2404 }
2405 }
2406  
2407 0 ▶ if (($head, $tail) = _parse_path($expr,$pathsep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($head, $tail) = _parse_path($expr, $pathsep)) 0 0 0
2408 0 ▶ if ($tail eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail eq "") 0 0 0
2409 0 push @glob, $expr;
2410 0 next OUTER;
2411 }
2412 0 ▶ if ($head =~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head =~ / \A (?:$Ekoi8r::q_char)*? [*?] /mosx) 0 0 0
2413 0 ▶ if (@globdir = _do_glob('d', $head)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@globdir = _do_glob("d", $head)) 0 0 0
2414 0 push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir);
2415 0 next OUTER;
2416 }
2417 }
2418 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
2419 0 $head .= $pathsep;
2420 }
2421 0 $expr = $tail;
2422 }
2423  
2424 # If file component has no wildcards, we can avoid opendir
2425 0 ▶ if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expr =~ / \A (?:$Ekoi8r::q_char)*? [*?] /mosx) 0 0 0
2426 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2427 0 $head = '';
2428 }
2429 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
2430 0 $head .= $pathsep;
2431 }
2432 0 $head .= $expr;
2433 0 ▶ if ($cond eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq 'd') { } 0 0 0
2434 0 ▶ if (-d $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $head) 0 0 0
2435 0 push @glob, $head;
2436 }
2437 }
2438 else {
2439 0 ▶ if (-e $head) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $head) 0 0 0
2440 0 push @glob, $head;
2441 }
2442 }
2443 0 next OUTER;
2444 }
2445 0 ▶ opendir(*DIR, $head) or next OUTER;
Branch: 1 branch
BranchTrueFalseTotal
opendir *DIR, $head or next OUTER 0 0 0
2446 0 my @leaf = readdir DIR;
2447 0 closedir DIR;
2448  
2449 0 ▶ if ($head eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq ".") 0 0 0
2450 0 $head = '';
2451 }
2452 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
2453 0 $head .= $pathsep;
2454 }
2455  
2456 0 my $pattern = '';
2457 0 ▶ while ($expr =~ / \G ($q_char) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ / \G ($Ekoi8r::q_char) /cgox) 0 0 0
2458 0 my $char = $1;
2459  
2460 # 6.9. Matching Shell Globs as Regular Expressions
2461 # in Chapter 6. Pattern Matching
2462 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
2463 # (and so on)
2464  
2465 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
2466 0 $pattern .= "(?:$your_char)*",
2467 }
2468 elsif ($char eq '?') {
2469 0 $pattern .= "(?:$your_char)?", # DOS style
2470 # $pattern .= "(?:$your_char)", # UNIX style
2471 }
2472 elsif ((my $fc = Ekoi8r::fc($char)) ne $char) {
2473 0 $pattern .= $fc;
2474 }
2475 else {
2476 0 $pattern .= quotemeta $char;
2477 }
2478 }
2479 0 ▶ my $matchsub = sub { Ekoi8r::fc($_[0]) =~ /\A $pattern \z/xms };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2480  
2481 # if ($@) {
2482 # print STDERR "$0: $@\n";
2483 # next OUTER;
2484 # }
2485  
2486 INNER:
2487 0 for my $leaf (@leaf) {
2488 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
2489 0 next INNER;
2490 }
2491 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
2492 0 next INNER;
2493 }
2494  
2495 0 ▶ if (&$matchsub($leaf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub($leaf)) 0 0 0
2496 0 push @matched, "$head$leaf";
2497 0 next INNER;
2498 }
2499  
2500 # [DOS compatibility special case]
2501 # Failed, add a trailing dot and try again, but only...
2502  
2503 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
2504 CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and*
2505 Ekoi8r::index($pattern,'\\.') != -1 # pattern has a dot.
2506 ) {
2507 0 ▶ if (&$matchsub("$leaf.")) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$matchsub("$leaf.")) 0 0 0
2508 0 push @matched, "$head$leaf";
2509 0 next INNER;
2510 }
2511 }
2512 }
2513 0 ▶ if (@matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matched) 0 0 0
2514 0 push @glob, @matched;
2515 }
2516 }
2517 0 ▶ if ($fix_drive_relative_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fix_drive_relative_paths) 0 0 0
2518 0 for my $glob (@glob) {
2519 0 $glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms;
2520 }
2521 }
2522 0 return @glob;
2523 }
2524  
2525 #
2526 # KOI8-R parse line
2527 #
2528 0 ▶sub _parse_line {
Subroutine _parse_line: not called CC=3 SCAR=24.8
2529  
2530 0 my($line) = @_;
2531  
2532 0 $line .= ' ';
2533 0 my @piece = ();
2534 0 ▶ while ($line =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / " ( (?>(?: [^"] )* ) ) " (?>\s+) | ( (?>(?: [^"\s] )* ) ) (?>\s+) /gmosx) 0 0 0
2535 " ( (?>(?: [^"] )* ) ) " (?>\s+) |
2536 ( (?>(?: [^"\s] )* ) ) (?>\s+)
2537 /oxmsg
2538 ) {
2539 0 ▶ push @piece, defined($1) ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
2540 }
2541 0 return @piece;
2542 }
2543  
2544 #
2545 # KOI8-R parse path
2546 #
2547 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=2 SCAR=17.9
2548  
2549 0 my($path,$pathsep) = @_;
2550  
2551 0 $path .= '/';
2552 0 my @subpath = ();
2553 0 ▶ while ($path =~ /
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m( ((?: [^/\\] )+?) [/\\] )gmosx) 0 0 0
2554 ((?: [^\/\\] )+?) [\/\\]
2555 /oxmsg
2556 ) {
2557 0 push @subpath, $1;
2558 }
2559  
2560 0 my $tail = pop @subpath;
2561 0 my $head = join $pathsep, @subpath;
2562 0 return $head, $tail;
2563 }
2564  
2565 #
2566 # via File::HomeDir::Windows 1.00
2567 #
2568 0 ▶sub my_home_MSWin32 {
Subroutine my_home_MSWin32: not called CC=9 SCAR=45.0
Pod undocumented
2569  
2570 # A lot of unix people and unix-derived tools rely on
2571 # the ability to overload HOME. We will support it too
2572 # so that they can replace raw HOME calls with File::HomeDir.
2573 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
2574 0 return $ENV{'HOME'};
2575 }
2576  
2577 # Do we have a user profile?
2578 ▶ 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
2579 0 return $ENV{'USERPROFILE'};
2580 }
2581  
2582 # Some Windows use something like $ENV{'HOME'}
2583 ▶ 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
2584 0 return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'};
2585 }
2586  
2587 0 return undef;
2588 }
2589  
2590 #
2591 # via File::HomeDir::Unix 1.00
2592 #
2593 0 ▶sub my_home {
Subroutine my_home: not called CC=7 SCAR=40.3
Pod undocumented
2594 0 my $home;
2595  
2596 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
2597 0 $home = $ENV{'HOME'};
2598 }
2599  
2600 # This is from the original code, but I'm guessing
2601 # it means "login directory" and exists on some Unixes.
2602 ▶ 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
2603 0 $home = $ENV{'LOGDIR'};
2604 }
2605  
2606 ### More-desperate methods
2607  
2608 # Light desperation on any (Unixish) platform
2609 else {
2610 0 $home = CORE::eval q{ (getpwuid($<))[7] };
2611 }
2612  
2613 # On Unix in general, a non-existant home means "no home"
2614 # For example, "nobody"-like users might use /nonexistant
2615 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
2616 0 $home = undef;
2617 }
2618 0 return $home;
2619 }
2620  
2621 #
2622 # ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched
2623 #
2624 56 ▶sub Ekoi8r::PREMATCH {
Subroutine PREMATCH: called CC=1 SCAR=0.0
Pod undocumented
2625 56 return $`;
2626 }
2627  
2628 #
2629 # ${^MATCH}, $MATCH, $& the string that matched
2630 #
2631 81 ▶sub Ekoi8r::MATCH {
Subroutine MATCH: called CC=1 SCAR=0.0
Pod undocumented
2632 81 return $&;
2633 }
2634  
2635 #
2636 # ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched
2637 #
2638 42 ▶sub Ekoi8r::POSTMATCH {
Subroutine POSTMATCH: called CC=1 SCAR=0.0
Pod undocumented
2639 42 return $';
2640 }
2641  
2642 #
2643 # KOI8-R character to order (with parameter)
2644 #
2645 0 ▶sub KOI8R::ord(;$) {
Subroutine ord: not called CC=4 SCAR=30.0
2646  
2647 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2648  
2649 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8r::q_char) /mosx) { } 0 0 0
2650 0 my @ord = unpack 'C*', $1;
2651 0 my $ord = 0;
2652 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2653 0 $ord = $ord * 0x100 + $o;
2654 }
2655 0 return $ord;
2656 }
2657 else {
2658 0 return CORE::ord $_;
2659 }
2660 }
2661  
2662 #
2663 # KOI8-R character to order (without parameter)
2664 #
2665 0 ▶sub KOI8R::ord_() {
Subroutine ord_: not called CC=3 SCAR=24.8
2666  
2667 0 ▶ if (/\A ($q_char) /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A ($Ekoi8r::q_char) /mosx) { } 0 0 0
2668 0 my @ord = unpack 'C*', $1;
2669 0 my $ord = 0;
2670 0 ▶ while (my $o = shift @ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = shift @ord) 0 0 0
2671 0 $ord = $ord * 0x100 + $o;
2672 }
2673 0 return $ord;
2674 }
2675 else {
2676 0 return CORE::ord $_;
2677 }
2678 }
2679  
2680 #
2681 # KOI8-R reverse
2682 #
2683 0 ▶sub KOI8R::reverse(@) {
Subroutine reverse: not called CC=2 SCAR=17.9
2684  
2685 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2686 0 return CORE::reverse @_;
2687 }
2688 else {
2689  
2690 # One of us once cornered Larry in an elevator and asked him what
2691 # problem he was solving with this, but he looked as far off into
2692 # the distance as he could in an elevator and said, "It seemed like
2693 # a good idea at the time."
2694  
2695 0 return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg);
2696 }
2697 }
2698  
2699 #
2700 # KOI8-R getc (with parameter, without parameter)
2701 #
2702 20 ▶sub KOI8R::getc(;*@) {
Subroutine getc: called CC=9 SCAR=26.7
2703  
2704 20 my($package) = caller;
2705 20 ▶ my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 20 0 20
2706 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
2707  
2708 0 my @length = sort { $a <=> $b } keys %range_tr;
2709 20 my $getc = '';
2710 20 for my $length ($length[0] .. $length[-1]) {
2711 20 $getc .= CORE::getc($fh);
2712 20 ▶ if (exists $range_tr{CORE::length($getc)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $range_tr{length $getc}) 20 0 20
2713 20 ▶ if ($getc =~ /\A ${Ekoi8r::dot_s} \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A $Ekoi8r::dot_s \z/mosx) 20 0 20
2714 20 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 20 20
2715 }
2716 }
2717 }
2718 0 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2719 }
2720  
2721 #
2722 # KOI8-R length by character
2723 #
2724 0 ▶sub KOI8R::length(;$) {
Subroutine length: not called CC=2 SCAR=17.9
2725  
2726 0 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
2727  
2728 0 local @_ = /\G ($q_char) /oxmsg;
2729 0 return scalar @_;
2730 }
2731  
2732 #
2733 # KOI8-R substr by character
2734 #
2735 424 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
2736  
2737 # P.232 The lvalue Attribute
2738 # in Chapter 6: Subroutines
2739 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
2740  
2741 # P.336 The lvalue Attribute
2742 # in Chapter 7: Subroutines
2743 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
2744  
2745 # P.144 8.4 Lvalue subroutines
2746 # in Chapter 8: perlsub: Perl subroutines
2747 # of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1)
2748  
2749 0 ▶ CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : '');
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine substr: called CC=11 SCAR=24.3
Branch: 10 branches
BranchTrueFalseTotal
$] >= 5.014 ? : 424 0 424
if ($offset > scalar @char or $offset < -1 * scalar(@char)) 2 25 27
if (@_ == 4) { } 1 24 25
elsif (@_ == 3) { } 21 3 24
if ($offset == 0) { } 0 21 21
elsif ($offset > 0) { } 20 1 21
if ($length == 0) { } 0 21 21
elsif ($length > 0) { } 20 1 21
if ($offset == 0) { } 0 3 3
elsif ($offset > 0) { } 2 1 3
Condition66%2/3
$offset > scalar @char or $offset < -1 * scalar(@char)
l!l&&r!l&&!r
2025
MC/DC50%1/2
$offset > scalar @char or $offset < -1 * scalar(@char)
$offset > scalar @char $offset < -1 * scalar(@char)
Truth table66%2/3
A or B
A= $offset > scalar @charB= $offset < -1 * scalar(@char)
ABresult
1X1
011
000
2750 # vv----------------------*******
2751 sub KOI8R::substr($$;$$) %s {
2752  
2753 my @char = $_[0] =~ /\G (?>$q_char) /oxmsg;
2754  
2755 # If the substring is beyond either end of the string, substr() returns the undefined
2756 # value and produces a warning. When used as an lvalue, specifying a substring that
2757 # is entirely outside the string raises an exception.
2758 # http://perldoc.perl.org/functions/substr.html
2759  
2760 # A return with no argument returns the scalar value undef in scalar context,
2761 # an empty list () in list context, and (naturally) nothing at all in void
2762 # context.
2763  
2764 my $offset = $_[1];
2765 if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) {
2766 return;
2767 }
2768  
2769 # substr($string,$offset,$length,$replacement)
2770 if (@_ == 4) {
2771 my(undef,undef,$length,$replacement) = @_;
2772 my $substr = join '', splice(@char, $offset, $length, $replacement);
2773 $_[0] = join '', @char;
2774  
2775 # return $substr; this doesn't work, don't say "return"
2776 $substr;
2777 }
2778  
2779 # substr($string,$offset,$length)
2780 elsif (@_ == 3) {
2781 my(undef,undef,$length) = @_;
2782 my $octet_offset = 0;
2783 my $octet_length = 0;
2784 if ($offset == 0) {
2785 $octet_offset = 0;
2786 }
2787 elsif ($offset > 0) {
2788 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2789 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2790 }
2791 else {
2792 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2793 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2794 }
2795 if ($length == 0) {
2796 $octet_length = 0;
2797 }
2798 elsif ($length > 0) {
2799 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2800 $octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]);
2801 }
2802 else {
2803 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
2804 $octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]);
2805 }
2806 CORE::substr($_[0], $octet_offset, $octet_length);
2807 }
2808  
2809 # substr($string,$offset)
2810 else {
2811 my $octet_offset = 0;
2812 if ($offset == 0) {
2813 $octet_offset = 0;
2814 }
2815 elsif ($offset > 0) {
2816 $octet_offset = CORE::length(join '', @char[0..$offset-1]);
2817 }
2818 else {
2819 $octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]);
2820 }
2821 CORE::substr($_[0], $octet_offset);
2822 }
2823 }
2824 END
2825 }
2826  
2827 #
2828 # KOI8-R index by character
2829 #
2830 0 ▶sub KOI8R::index($$;$) {
Subroutine index: not called CC=3 SCAR=24.8
2831  
2832 0 my $index;
2833 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2834 0 $index = Ekoi8r::index($_[0], $_[1], CORE::length(KOI8R::substr($_[0], 0, $_[2])));
2835 }
2836 else {
2837 0 $index = Ekoi8r::index($_[0], $_[1]);
2838 }
2839  
2840 0 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 0 0 0
2841 0 return -1;
2842 }
2843 else {
2844 0 return KOI8R::length(CORE::substr $_[0], 0, $index);
2845 }
2846 }
2847  
2848 #
2849 # KOI8-R rindex by character
2850 #
2851 0 ▶sub KOI8R::rindex($$;$) {
Subroutine rindex: not called CC=3 SCAR=24.8
2852  
2853 0 my $rindex;
2854 0 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
2855 0 $rindex = Ekoi8r::rindex($_[0], $_[1], CORE::length(KOI8R::substr($_[0], 0, $_[2])));
2856 }
2857 else {
2858 0 $rindex = Ekoi8r::rindex($_[0], $_[1]);
2859 }
2860  
2861 0 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 0 0 0
2862 0 return -1;
2863 }
2864 else {
2865 0 return KOI8R::length(CORE::substr $_[0], 0, $rindex);
2866 }
2867 }
2868  
2869 # when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??'
2870 # when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else)
2871 424 ▶use vars qw($slash); $slash = 'm//';
Subroutine BEGIN: called CC=1 SCAR=0.0
2872  
2873 # ord() to ord() or KOI8R::ord()
2874 424 my $function_ord = 'ord';
2875  
2876 # ord to ord or KOI8R::ord_
2877 424 my $function_ord_ = 'ord';
2878  
2879 # reverse to reverse or KOI8R::reverse
2880 424 my $function_reverse = 'reverse';
2881  
2882 # getc to getc or KOI8R::getc
2883 424 my $function_getc = 'getc';
2884  
2885 # P.1023 Appendix W.9 Multibyte Anchoring
2886 # of ISBN 1-56592-224-7 CJKV Information Processing
2887  
2888 424 my $anchor = '';
2889  
2890 424 ▶use vars qw($nest);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2891  
2892 # regexp of nested parens in qqXX
2893  
2894 # P.340 Matching Nested Constructs with Embedded Code
2895 # in Chapter 7: Perl
2896 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
2897  
2898 my $qq_paren = qr{(?{local $nest=0}) (?>(?:
2899 [^\\()] |
2900 \( (?{$nest++}) |
2901 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2902 \\ [^c] |
2903 \\c[\x40-\x5F] |
2904 [\x00-\xFF]
2905 424 }xms;
2906  
2907 my $qq_brace = qr{(?{local $nest=0}) (?>(?:
2908 [^\\{}] |
2909 \{ (?{$nest++}) |
2910 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2911 \\ [^c] |
2912 \\c[\x40-\x5F] |
2913 [\x00-\xFF]
2914 424 }xms;
2915  
2916 my $qq_bracket = qr{(?{local $nest=0}) (?>(?:
2917 [^\\\[\]] |
2918 \[ (?{$nest++}) |
2919 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2920 \\ [^c] |
2921 \\c[\x40-\x5F] |
2922 [\x00-\xFF]
2923 424 }xms;
2924  
2925 my $qq_angle = qr{(?{local $nest=0}) (?>(?:
2926 [^\\<>] |
2927 \< (?{$nest++}) |
2928 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2929 \\ [^c] |
2930 \\c[\x40-\x5F] |
2931 [\x00-\xFF]
2932 424 }xms;
2933  
2934 424 my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} |
2935 (?: ::)? (?:
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 424 my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} |
2943 (?: ::)? (?:
2944 (?>[0-9]+) |
2945 [^a-zA-Z_0-9\[\]] |
2946 ^[A-Z] |
2947 (?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* )
2948 (?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*)
2949 (?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*)
2950 ))
2951 }xms;
2952  
2953 424 my $qq_substr = qr{(?> Char::substr | KOI8R::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \)
2954 }xms;
2955  
2956 # regexp of nested parens in qXX
2957 my $q_paren = qr{(?{local $nest=0}) (?>(?:
2958 [^()] |
2959 \( (?{$nest++}) |
2960 \) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2961 [\x00-\xFF]
2962 424 }xms;
2963  
2964 my $q_brace = qr{(?{local $nest=0}) (?>(?:
2965 [^\{\}] |
2966 \{ (?{$nest++}) |
2967 \} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2968 [\x00-\xFF]
2969 424 }xms;
2970  
2971 my $q_bracket = qr{(?{local $nest=0}) (?>(?:
2972 [^\[\]] |
2973 \[ (?{$nest++}) |
2974 \] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2975 [\x00-\xFF]
2976 424 }xms;
2977  
2978 my $q_angle = qr{(?{local $nest=0}) (?>(?:
2979 [^<>] |
2980 \< (?{$nest++}) |
2981 \> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) |
2982 [\x00-\xFF]
2983 424 }xms;
2984  
2985 424 my $matched = '';
2986 424 my $s_matched = '';
2987  
2988 424 my $tr_variable = ''; # variable of tr///
2989 424 my $sub_variable = ''; # variable of s///
2990 424 my $bind_operator = ''; # =~ or !~
2991  
2992 424 my @heredoc = (); # here document
2993 424 my @heredoc_delimiter = ();
2994 424 my $here_script = ''; # here script
2995  
2996 #
2997 # escape KOI8-R script
2998 #
2999 548 ▶sub KOI8R::escape(;$) {
Subroutine escape: called CC=3 SCAR=11.0
3000 548 ▶ local($_) = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 292 256 548
3001  
3002 # P.359 The Study Function
3003 # in Chapter 7: Perl
3004 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3005  
3006 548 study $_; # Yes, I studied study yesterday.
3007  
3008 # while all script
3009  
3010 # 6.14. Matching from Where the Last Pattern Left Off
3011 # in Chapter 6. Pattern Matching
3012 # of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition.
3013 # (and so on)
3014  
3015 # one member of Tag-team
3016 #
3017 # P.128 Start of match (or end of previous match): \G
3018 # P.130 Advanced Use of \G with Perl
3019 # in Chapter 3: Overview of Regular Expression Features and Flavors
3020 # P.255 Use leading anchors
3021 # P.256 Expose ^ and \G at the front expressions
3022 # in Chapter 6: Crafting an Efficient Expression
3023 # P.315 "Tag-team" matching with /gc
3024 # in Chapter 7: Perl
3025 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3026  
3027 548 my $e_script = '';
3028 548 ▶ while (not /\G \z/oxgc) { # member
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 86214 548 86762
3029 86214 $e_script .= KOI8R::escape_token();
3030 }
3031  
3032 548 return $e_script;
3033 }
3034  
3035 #
3036 # escape KOI8-R token of script
3037 #
3038 86214 ▶sub KOI8R::escape_token {
Subroutine escape_token: called CC=504 SCAR=109.3
3039  
3040 # \n output here document
3041  
3042 86214 my $ignore_modules = join('|', qw(
3043 utf8
3044 bytes
3045 charnames
3046 I18N::Japanese
3047 I18N::Collate
3048 I18N::JExt
3049 File::DosGlob
3050 Wild
3051 Wildcard
3052 Japanese
3053 ));
3054  
3055 # another member of Tag-team
3056 #
3057 # P.315 "Tag-team" matching with /gc
3058 # in Chapter 7: Perl
3059 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
3060  
3061 86214 ▶ if (/\G ( \n ) /oxgc) { # another member (and so on)
Branch: 139 branches
BranchTrueFalseTotal
if (/\G ( \n ) /cgox) { } 12807 73407 86214
elsif (/\G ((?>\s+)|\#.*) /cgox) { } 21277 52130 73407
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /cgox) { } 1644 50486 52130
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /cgox) { } 90 50396 50486
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx) { } 4 50392 50396
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 28 50364 50392
elsif (/\G ( \$' | \$\{'\} ) /cgmosx) { } 1 50363 50364
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 3 50360 50363
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /cgox) { } 1754 48606 50360
elsif (/\G ( [,;] ) /cgox) { } 5064 43542 48606
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 43542 43542
elsif (/\G ( \$ 0 ) /cgmosx) { } 2 43540 43542
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 43540 43540
elsif (/\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 1 43539 43540
elsif (/\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 4 43535 43539
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 43535 43535
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 43535 43535
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 43535 43535
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 43535 43535
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /cgmosx) { } 0 43535 43535
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 0 43535 43535
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 43493 43535
elsif (m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 63 43430 43493
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /cgox) { } 0 43430 43430
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /cgox) { } 0 43430 43430
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /cgox) { } 0 43430 43430
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /cgox) { } 0 43430 43430
elsif (/\G \b ( if | unless | while | until | for | when ) \b /cgox) { } 251 43179 43430
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /cgox) { } 19 43160 43179
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /cgox) { } 0 43160 43160
elsif (/\G \b KOI8R::eval (?= (?>\s*) \{ ) /cgox) { } 22 43138 43160
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /cgox) { } 0 43138 43138
elsif (/\G \b KOI8R::eval \b (?! (?>\s*) => ) /cgox) { } 168 42970 43138
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /cgox) { } 2 42968 42970
elsif (/\G \b chop \b (?! (?>\s*) => ) /cgox) { } 0 42968 42968
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /cgox) { } 2 42966 42968
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b KOI8R::index \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b index \b (?! (?>\s*) => ) /cgox) { } 0 42966 42966
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /cgox) { } 2 42964 42966
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42964 42964
elsif (/\G \b KOI8R::rindex \b (?! (?>\s*) => ) /cgox) { } 0 42964 42964
elsif (/\G \b rindex \b (?! (?>\s*) => ) /cgox) { } 0 42964 42964
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42963 42964
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42963 42963
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 1 42962 42963
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42962 42962
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 6 42956 42962
elsif (/\G -s (?>\s*) (\") ((?:$Ekoi8r::qq_char)+?) (\") /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$Ekoi8r::qq_char)+?) (\#) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$Ekoi8r::qq_char)+?) (\1) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$Ekoi8r::q_char)+?) (\') /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)+?) (\#) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$Ekoi8r::q_char)+?) (\1) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /cgox) { } 0 42956 42956
elsif (/\G -s (?= (?>\s+) [a-z]+) /cgox) { } 0 42956 42956
elsif (/\G -s (?>\s+) ((?>\w+)) /cgox) { } 0 42956 42956
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42954 42956
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42952 42954
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 36 42916 42952
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 2 42914 42916
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 8 42906 42914
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /cgox) { } 0 42906 42906
elsif (/\G \b lc \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b uc \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b fc \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G -s \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b chr \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b ord \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b glob \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b reverse \b (?! (?>\s*) => ) /cgox) { } 0 42906 42906
elsif (/\G \b getc \b (?! (?>\s*) => ) /cgox) { } 8 42898 42906
elsif (/\G \b (split) \b (?! (?>\s*) => ) /cgox) { } 87 42811 42898
elsif (/\G \b ( tr | y ) \b /cgox) { } 4 42807 42811
elsif (/\G \b (qq) \b /cgox) { } 2252 40555 42807
elsif (/\G \b (qr) \b /cgox) { } 0 40555 40555
elsif (/\G \b (qw) \b /cgox) { } 16 40539 40555
elsif (/\G \b (qx) \b /cgox) { } 0 40539 40539
elsif (/\G \b (q) \b /cgox) { } 473 40066 40539
elsif (/\G \b (m) \b /cgox) { } 209 39857 40066
elsif (/\G \b (s) \b /cgox) { } 101 39756 39857
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39756 39756
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39756 39756
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39756 39756
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /cgmosx) { } 37 39719 39756
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39719 39719
elsif (/\G \b use ((?>\s+) strict) \b /cgmosx) { } 0 39719 39719
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 2 39717 39719
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /cgmosx) { } 0 39717 39717
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 2 39715 39717
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39715 39715
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39715 39715
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /cgmosx) { } 0 39715 39715
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /cgmosx) { } 0 39715 39715
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /cgmosx) { } 0 39715 39715
elsif (/\G \b use \b /cgmosx) { } 0 39715 39715
elsif (/\G \b no \b /cgmosx) { } 2 39713 39715
elsif (/\G (?<![\w\$\@\%\&\*]) (\') /cgox) { } 1142 38571 39713
elsif (/\G (\") /cgox) { } 1875 36696 38571
elsif (/\G (\`) /cgox) { } 1 36695 36696
elsif ($Ekoi8r::slash eq 'm//' and m[\G (/) ]cgox) { } 681 36014 36695
elsif ($Ekoi8r::slash eq 'm//' and /\G (\?) /cgox) { } 0 36014 36014
elsif (/\G ( <<>> ) /cgox) { } 0 36014 36014
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /cgox) { } 0 36014 36014
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /cgox) { } 6 36008 36014
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /cgox) { } 3 36005 36008
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /cgox) { } 6 35999 36005
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /cgox) { } 3 35996 35999
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /cgox) { } 6 35990 35996
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /cgox) { } 72 35918 35990
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /cgox) { } 0 35918 35918
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /cgox) { } 36 35882 35918
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /cgox) { } 42 35840 35882
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /cgox) { } 0 35840 35840
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/cgox) { } 12 35828 35840
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /cgox) { } 0 35828 35828
elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /cgox) { } 0 35828 35828
elsif (/\G ^ ( __DATA__ \n .*) \z /cgmosx) { } 0 35828 35828
elsif (/\G ^ ( __END__ \n .*) \z /cgmosx) { } 210 35618 35828
elsif (/\G ( \cD .*) \z /cgmosx) { } 0 35618 35618
elsif (/\G ( \cZ .*) \z /cgmosx) { } 0 35618 35618
elsif (/\G ( -- | \+\+ | [\)\}\]] ) /cgox) { } 5839 29779 35618
elsif (/\G ( \.\.\. ) /cgox) { } 7 29772 29779
elsif (m"\G ((?> !~~ | !~ | != | ! | %= | % | &&= | && | &= | &\.= | &\. | & | -= | -> | - | :(?>\s*)= | : | <<>> | <<= | <=> | <= | < | == | => | =~ | = | >>= | >> | >= | > | \*\*= | \*\* | \*= | \* | \+= | \+ | \.\. | \.= | \. | //= | // | /= | / | \? | \\ | \^= | \^\.= | \^\. | \^ | \b x= | \|\|= | \|\| | \|= | \|\.= | \|\. | \| | ~~ | ~\. | ~ | \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | \b(?: print )\b | [,;\(\{\[] )) "cgox) { } 9774 19998 29772
elsif (/\G ($Ekoi8r::q_char) /cgox) { } 19998 0 19998
3062 12807 my $heredoc = '';
3063 12807 ▶ if (scalar(@heredoc_delimiter) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @heredoc_delimiter >= 1) 174 12633 12807
3064 174 $slash = 'm//';
3065  
3066 174 $heredoc = join '', @heredoc;
3067 174 @heredoc = ();
3068  
3069 # skip here document
3070 174 for my $heredoc_delimiter (@heredoc_delimiter) {
3071 174 /\G .*? \n $heredoc_delimiter \n/xmsgc;
3072 }
3073 174 @heredoc_delimiter = ();
3074  
3075 174 $here_script = '';
3076 }
3077 12807 return "\n" . $heredoc;
3078 }
3079  
3080 # ignore space, comment
3081 21277 elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; }
3082  
3083 # if (, elsif (, unless (, while (, until (, given (, and when (
3084  
3085 # given, when
3086  
3087 # P.225 The given Statement
3088 # in Chapter 15: Smart Matching and given-when
3089 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3090  
3091 # P.133 The given Statement
3092 # in Chapter 4: Statements and Declarations
3093 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3094  
3095 elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) {
3096 1644 $slash = 'm//';
3097 1644 return $1;
3098 }
3099  
3100 # scalar variable ($scalar = ...) =~ tr///;
3101 # scalar variable ($scalar = ...) =~ s///;
3102  
3103 # state
3104  
3105 # P.68 Persistent, Private Variables
3106 # in Chapter 4: Subroutines
3107 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
3108  
3109 # P.160 Persistent Lexically Scoped Variables: state
3110 # in Chapter 4: Statements and Declarations
3111 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3112  
3113 # (and so on)
3114  
3115 elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) {
3116 90 my $e_string = e_string($1);
3117  
3118 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
3119 0 $tr_variable = $e_string . e_string($1);
3120 0 $bind_operator = $2;
3121 0 $slash = 'm//';
3122 0 return '';
3123 }
3124 elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3125 0 $sub_variable = $e_string . e_string($1);
3126 0 $bind_operator = $2;
3127 0 $slash = 'm//';
3128 0 return '';
3129 }
3130 else {
3131 90 $slash = 'div';
3132 90 return $e_string;
3133 }
3134 }
3135  
3136 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
3137 elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
3138 4 $slash = 'div';
3139 4 return q{Ekoi8r::PREMATCH()};
3140 }
3141  
3142 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
3143 elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
3144 28 $slash = 'div';
3145 28 return q{Ekoi8r::MATCH()};
3146 }
3147  
3148 # $', ${'} --> $', ${'}
3149 elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) {
3150 1 $slash = 'div';
3151 1 return $1;
3152 }
3153  
3154 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
3155 elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
3156 3 $slash = 'div';
3157 3 return q{Ekoi8r::POSTMATCH()};
3158 }
3159  
3160 # scalar variable $scalar =~ tr///;
3161 # scalar variable $scalar =~ s///;
3162 # substr() =~ tr///;
3163 # substr() =~ s///;
3164 elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) {
3165 1754 my $scalar = e_string($1);
3166  
3167 1754 ▶ if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /cgox) { } 2 1752 1754
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /cgox) { } 65 1687 1752
3168 2 $tr_variable = $scalar;
3169 2 $bind_operator = $1;
3170 2 $slash = 'm//';
3171 2 return '';
3172 }
3173 elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) {
3174 65 $sub_variable = $scalar;
3175 65 $bind_operator = $1;
3176 65 $slash = 'm//';
3177 65 return '';
3178 }
3179 else {
3180 1687 $slash = 'div';
3181 1687 return $scalar;
3182 }
3183 }
3184  
3185 # end of statement
3186 elsif (/\G ( [,;] ) /oxgc) {
3187 5064 $slash = 'm//';
3188  
3189 # clear tr/// variable
3190 5064 $tr_variable = '';
3191  
3192 # clear s/// variable
3193 5064 $sub_variable = '';
3194  
3195 5064 $bind_operator = '';
3196  
3197 5064 return $1;
3198 }
3199  
3200 # bareword
3201 elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
3202 0 return $1;
3203 }
3204  
3205 # $0 --> $0
3206 elsif (/\G ( \$ 0 ) /oxmsgc) {
3207 2 $slash = 'div';
3208 2 return $1;
3209 }
3210 elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
3211 0 $slash = 'div';
3212 0 return $1;
3213 }
3214  
3215 # $$ --> $$
3216 elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
3217 1 $slash = 'div';
3218 1 return $1;
3219 }
3220  
3221 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
3222 # $1, $2, $3 --> $1, $2, $3 otherwise
3223 elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
3224 4 $slash = 'div';
3225 4 return e_capture($1);
3226 }
3227 elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
3228 0 $slash = 'div';
3229 0 return e_capture($1);
3230 }
3231  
3232 # $$foo[ ... ] --> $ $foo->[ ... ]
3233 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
3234 0 $slash = 'div';
3235 0 return e_capture($1.'->'.$2);
3236 }
3237  
3238 # $$foo{ ... } --> $ $foo->{ ... }
3239 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
3240 0 $slash = 'div';
3241 0 return e_capture($1.'->'.$2);
3242 }
3243  
3244 # $$foo
3245 elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
3246 0 $slash = 'div';
3247 0 return e_capture($1);
3248 }
3249  
3250 # ${ foo }
3251 elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) {
3252 0 $slash = 'div';
3253 0 return '${' . $1 . '}';
3254 }
3255  
3256 # ${ ... }
3257 elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
3258 0 $slash = 'div';
3259 0 return e_capture($1);
3260 }
3261  
3262 # variable or function
3263 # $ @ % & * $ #
3264 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) {
3265 42 $slash = 'div';
3266 42 return $1;
3267 }
3268 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
3269 # $ @ # \ ' " / ? ( ) [ ] < >
3270 elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
3271 63 $slash = 'div';
3272 63 return $1;
3273 }
3274  
3275 # while (<FILEHANDLE>)
3276 elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) {
3277 0 return $1;
3278 }
3279  
3280 # while (<WILDCARD>) --- glob
3281  
3282 # avoid "Error: Runtime exception" of perl version 5.005_03
3283  
3284 elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^>\0\a\e\f\n\r\t])+?) > (?>\s*) \) \b /oxgc) {
3285 0 return 'while ($_ = Ekoi8r::glob("' . $1 . '"))';
3286 }
3287  
3288 # while (glob)
3289 elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) {
3290 0 return 'while ($_ = Ekoi8r::glob_)';
3291 }
3292  
3293 # while (glob(WILDCARD))
3294 elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) {
3295 0 return 'while ($_ = Ekoi8r::glob';
3296 }
3297  
3298 # doit if, doit unless, doit while, doit until, doit for, doit when
3299 251 elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; }
3300  
3301 # subroutines of package Ekoi8r
3302 19 elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; }
3303 0 elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3304 22 elsif (/\G \b KOI8R::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; }
3305 0 elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; }
3306 168 elsif (/\G \b KOI8R::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval KOI8R::escape'; }
3307 2 elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; }
3308 0 elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chop'; }
3309 2 elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; }
3310 0 elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; }
3311 0 elsif (/\G \b KOI8R::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8R::index'; }
3312 0 elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::index'; }
3313 2 elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; }
3314 0 elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; }
3315 0 elsif (/\G \b KOI8R::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'KOI8R::rindex'; }
3316 0 elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::rindex'; }
3317 1 elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lc'; }
3318 0 elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lcfirst'; }
3319 1 elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::uc'; }
3320 0 elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::ucfirst'; }
3321 6 elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::fc'; }
3322  
3323 # "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...")
3324 0 elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); }
3325 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3326 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3327 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3328 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3329 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3330 0 elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); }
3331  
3332 0 elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); }
3333 0 elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3334 0 elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3335 0 elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3336 0 elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3337 0 elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3338 0 elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); }
3339  
3340 elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc)
3341 0 { $slash = 'm//'; return "-s $1"; }
3342 0 elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; }
3343 0 elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; }
3344 0 elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; }
3345  
3346 2 elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; }
3347 2 elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; }
3348 36 elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chr'; }
3349 2 elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; }
3350 8 elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; }
3351 0 elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ekoi8r::glob'; }
3352 0 elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lc_'; }
3353 0 elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::lcfirst_'; }
3354 0 elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::uc_'; }
3355 0 elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::ucfirst_'; }
3356 0 elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::fc_'; }
3357 0 elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; }
3358  
3359 0 elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; }
3360 0 elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; }
3361 0 elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::chr_'; }
3362 0 elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; }
3363 0 elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; }
3364 0 elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ekoi8r::glob_'; }
3365 0 elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; }
3366 8 elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; }
3367 # split
3368 elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) {
3369 87 $slash = 'm//';
3370  
3371 87 my $e = '';
3372 87 ▶ while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( (?>\s+) | \( | \#.* ) /cgox) 85 87 172
3373 85 $e .= $1;
3374 }
3375  
3376 # end of split
3377 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
3378  
3379 # split scalar value
3380 1 elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Ekoi8r::split' . $e . e_string($1); }
3381  
3382 # split literal space
3383 0 elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Ekoi8r::split' . $e . qq {qq$1 $2}; }
3384 0 elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3385 0 elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3386 0 elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3387 0 elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3388 0 elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8r::split' . $e . qq{$1qq$2 $3}; }
3389 0 elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Ekoi8r::split' . $e . qq {q$1 $2}; }
3390 0 elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3391 0 elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3392 0 elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3393 0 elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3394 0 elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ekoi8r::split' . $e . qq {$1q$2 $3}; }
3395 10 elsif (/\G ' [ ] ' /oxgc) { return 'Ekoi8r::split' . $e . qq {' '}; }
3396 0 elsif (/\G " [ ] " /oxgc) { return 'Ekoi8r::split' . $e . qq {" "}; }
3397  
3398 # split qq//
3399 elsif (/\G \b (qq) \b /oxgc) {
3400 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
3401 else {
3402 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3403 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
3404 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( )
3405 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { }
3406 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ]
3407 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < >
3408 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { }
3409 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * *
3410 }
3411 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3412 }
3413 }
3414  
3415 # split qr//
3416 elsif (/\G \b (qr) \b /oxgc) {
3417 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
3418 else {
3419 12 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 12 0 12
3420 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
3421 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( )
3422 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { }
3423 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ]
3424 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < >
3425 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' '
3426 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { }
3427 12 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * *
3428 }
3429 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3430 }
3431 }
3432  
3433 # split q//
3434 elsif (/\G \b (q) \b /oxgc) {
3435 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
3436 else {
3437 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3438 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
3439 0 elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( )
3440 0 elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { }
3441 0 elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ]
3442 0 elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < >
3443 0 elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { }
3444 0 elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * *
3445 }
3446 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3447 }
3448 }
3449  
3450 # split m//
3451 elsif (/\G \b (m) \b /oxgc) {
3452 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
3453 else {
3454 18 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 18 0 18
3455 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
3456 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( )
3457 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { }
3458 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ]
3459 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < >
3460 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' '
3461 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { }
3462 18 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * *
3463 }
3464 0 die __FILE__, ": Search pattern not terminated\n";
3465 }
3466 }
3467  
3468 # split ''
3469 elsif (/\G (\') /oxgc) {
3470 0 my $q_string = '';
3471 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3472 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
3473 0 elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr''
3474 0 elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' '
3475 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3476 }
3477 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3478 }
3479  
3480 # split ""
3481 elsif (/\G (\") /oxgc) {
3482 0 my $qq_string = '';
3483 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3484 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
3485 0 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr""
3486 0 elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " "
3487 0 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
3488 }
3489 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3490 }
3491  
3492 # split //
3493 elsif (/\G (\/) /oxgc) {
3494 44 my $regexp = '';
3495 44 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 381 0 381
3496 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
3497 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr//
3498 44 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / /
3499 337 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
3500 }
3501 0 die __FILE__, ": Search pattern not terminated\n";
3502 }
3503 }
3504  
3505 # tr/// or y///
3506  
3507 # about [cdsrbB]* (/B modifier)
3508 #
3509 # P.559 appendix C
3510 # of ISBN 4-89052-384-7 Programming perl
3511 # (Japanese title is: Perl puroguramingu)
3512  
3513 elsif (/\G \b ( tr | y ) \b /oxgc) {
3514 4 my $ope = $1;
3515  
3516 # $1 $2 $3 $4 $5 $6
3517 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
3518 0 my @tr = ($tr_variable,$2);
3519 0 return e_tr(@tr,'',$4,$6);
3520 }
3521 else {
3522 4 my $e = '';
3523 4 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 4 0 4
3524 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
3525 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3526 0 my @tr = ($tr_variable,$2);
3527 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3528 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
3529 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( )
3530 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { }
3531 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ]
3532 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < >
3533 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * *
3534 }
3535 0 die __FILE__, ": Transliteration replacement not terminated\n";
3536 }
3537 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3538 0 my @tr = ($tr_variable,$2);
3539 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3540 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
3541 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( )
3542 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { }
3543 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ]
3544 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < >
3545 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * *
3546 }
3547 0 die __FILE__, ": Transliteration replacement not terminated\n";
3548 }
3549 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3550 0 my @tr = ($tr_variable,$2);
3551 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3552 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
3553 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( )
3554 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { }
3555 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ]
3556 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < >
3557 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * *
3558 }
3559 0 die __FILE__, ": Transliteration replacement not terminated\n";
3560 }
3561 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3562 0 my @tr = ($tr_variable,$2);
3563 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3564 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
3565 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( )
3566 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { }
3567 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ]
3568 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < >
3569 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * *
3570 }
3571 0 die __FILE__, ": Transliteration replacement not terminated\n";
3572 }
3573 # $1 $2 $3 $4 $5 $6
3574 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * *
3575 4 my @tr = ($tr_variable,$2);
3576 4 return e_tr(@tr,'',$4,$6);
3577 }
3578 }
3579 0 die __FILE__, ": Transliteration pattern not terminated\n";
3580 }
3581 }
3582  
3583 # qq//
3584 elsif (/\G \b (qq) \b /oxgc) {
3585 2252 my $ope = $1;
3586  
3587 # if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# #
3588 2252 ▶ if (/\G (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 2252 2252
3589 0 my $qq_string = '';
3590 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3591 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
3592 0 elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; }
3593 0 elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); }
3594 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3595 }
3596 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3597 }
3598  
3599 else {
3600 2252 my $e = '';
3601 2252 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 2252 0 2252
3602 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
3603  
3604 # elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( )
3605 elsif (/\G (\() /oxgc) { # qq ( )
3606 0 my $qq_string = '';
3607 0 local $nest = 1;
3608 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3609 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
3610 0 elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; }
3611 0 elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; }
3612 elsif (/\G (\)) /oxgc) {
3613 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3614 0 else { $qq_string .= $1; }
3615 }
3616 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3617 }
3618 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3619 }
3620  
3621 # elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { }
3622 elsif (/\G (\{) /oxgc) { # qq { }
3623 2222 my $qq_string = '';
3624 2222 local $nest = 1;
3625 2222 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 85091 0 85091
3626 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
3627 0 elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; }
3628 1189 elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; }
3629 elsif (/\G (\}) /oxgc) {
3630 3411 ▶ if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 2222 1189 3411
3631 1189 else { $qq_string .= $1; }
3632 }
3633 79769 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3634 }
3635 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3636 }
3637  
3638 # elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ]
3639 elsif (/\G (\[) /oxgc) { # qq [ ]
3640 0 my $qq_string = '';
3641 0 local $nest = 1;
3642 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3643 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
3644 0 elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; }
3645 0 elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; }
3646 elsif (/\G (\]) /oxgc) {
3647 0 ▶ if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3648 0 else { $qq_string .= $1; }
3649 }
3650 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3651 }
3652 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3653 }
3654  
3655 # elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < >
3656 elsif (/\G (\<) /oxgc) { # qq < >
3657 30 my $qq_string = '';
3658 30 local $nest = 1;
3659 30 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 1166 0 1166
3660 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
3661 0 elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; }
3662 0 elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; }
3663 elsif (/\G (\>) /oxgc) {
3664 30 ▶ if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 30 0 30
3665 0 else { $qq_string .= $1; }
3666 }
3667 1114 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3668 }
3669 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3670 }
3671  
3672 # elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * *
3673 elsif (/\G (\S) /oxgc) { # qq * *
3674 0 my $delimiter = $1;
3675 0 my $qq_string = '';
3676 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3677 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
3678 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; }
3679 0 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); }
3680 0 elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; }
3681 }
3682 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3683 }
3684 }
3685 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3686 }
3687 }
3688  
3689 # qr//
3690 elsif (/\G \b (qr) \b /oxgc) {
3691 0 my $ope = $1;
3692 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([imosxpadlunbB]*) /cgox) { } 0 0 0
3693 0 return e_qr($ope,$1,$3,$2,$4);
3694 }
3695 else {
3696 0 my $e = '';
3697 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3698 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
3699 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( )
3700 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { }
3701 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ]
3702 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < >
3703 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' '
3704 0 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { }
3705 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * *
3706 }
3707 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3708 }
3709 }
3710  
3711 # qw//
3712 elsif (/\G \b (qw) \b /oxgc) {
3713 16 my $ope = $1;
3714 16 ▶ if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) (.*?) (\#) /cgmosx) { } 0 16 16
3715 0 return e_qw($ope,$1,$3,$2);
3716 }
3717 else {
3718 16 my $e = '';
3719 16 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 16 0 16
3720 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
3721  
3722 16 elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3723 0 elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( )
3724  
3725 0 elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3726 0 elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { }
3727  
3728 0 elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3729 0 elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ]
3730  
3731 0 elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3732 0 elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < >
3733  
3734 0 elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3735 0 elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * *
3736 }
3737 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3738 }
3739 }
3740  
3741 # qx//
3742 elsif (/\G \b (qx) \b /oxgc) {
3743 0 my $ope = $1;
3744 0 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
3745 0 return e_qq($ope,$1,$3,$2);
3746 }
3747 else {
3748 0 my $e = '';
3749 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3750 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
3751 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( )
3752 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { }
3753 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ]
3754 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < >
3755 0 elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' '
3756 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * *
3757 }
3758 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3759 }
3760 }
3761  
3762 # q//
3763 elsif (/\G \b (q) \b /oxgc) {
3764 473 my $ope = $1;
3765  
3766 # if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# #
3767  
3768 # avoid "Error: Runtime exception" of perl version 5.005_03
3769 # (and so on)
3770  
3771 473 ▶ if (/\G (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) /cgox) { } 0 473 473
3772 0 my $q_string = '';
3773 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3774 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
3775 0 elsif (/\G (\\\#) /oxgc) { $q_string .= $1; }
3776 0 elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); }
3777 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3778 }
3779 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3780 }
3781  
3782 else {
3783 473 my $e = '';
3784 473 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 473 0 473
3785 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
3786  
3787 # elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( )
3788 elsif (/\G (\() /oxgc) { # q ( )
3789 0 my $q_string = '';
3790 0 local $nest = 1;
3791 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3792 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
3793 0 elsif (/\G (\\\)) /oxgc) { $q_string .= $1; }
3794 0 elsif (/\G (\\\() /oxgc) { $q_string .= $1; }
3795 0 elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; }
3796 elsif (/\G (\)) /oxgc) {
3797 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3798 0 else { $q_string .= $1; }
3799 }
3800 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3801 }
3802 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3803 }
3804  
3805 # elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { }
3806 elsif (/\G (\{) /oxgc) { # q { }
3807 467 my $q_string = '';
3808 467 local $nest = 1;
3809 467 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 8236 0 8236
3810 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
3811 0 elsif (/\G (\\\}) /oxgc) { $q_string .= $1; }
3812 0 elsif (/\G (\\\{) /oxgc) { $q_string .= $1; }
3813 159 elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; }
3814 elsif (/\G (\}) /oxgc) {
3815 626 ▶ if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 467 159 626
3816 159 else { $q_string .= $1; }
3817 }
3818 7451 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3819 }
3820 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3821 }
3822  
3823 # elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ]
3824 elsif (/\G (\[) /oxgc) { # q [ ]
3825 0 my $q_string = '';
3826 0 local $nest = 1;
3827 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3828 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
3829 0 elsif (/\G (\\\]) /oxgc) { $q_string .= $1; }
3830 0 elsif (/\G (\\\[) /oxgc) { $q_string .= $1; }
3831 0 elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; }
3832 elsif (/\G (\]) /oxgc) {
3833 0 ▶ if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 0 0 0
3834 0 else { $q_string .= $1; }
3835 }
3836 0 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3837 }
3838 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3839 }
3840  
3841 # elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < >
3842 elsif (/\G (\<) /oxgc) { # q < >
3843 5 my $q_string = '';
3844 5 local $nest = 1;
3845 5 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 88 0 88
3846 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
3847 0 elsif (/\G (\\\>) /oxgc) { $q_string .= $1; }
3848 0 elsif (/\G (\\\<) /oxgc) { $q_string .= $1; }
3849 0 elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; }
3850 elsif (/\G (\>) /oxgc) {
3851 5 ▶ if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); }
Branch: 1 branch
BranchTrueFalseTotal
if (--$Ekoi8r::nest == 0) { } 5 0 5
3852 0 else { $q_string .= $1; }
3853 }
3854 83 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3855 }
3856 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3857 }
3858  
3859 # elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * *
3860 elsif (/\G (\S) /oxgc) { # q * *
3861 1 my $delimiter = $1;
3862 1 my $q_string = '';
3863 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 14 0 14
3864 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
3865 0 elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; }
3866 1 elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); }
3867 13 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
3868 }
3869 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3870 }
3871 }
3872 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
3873 }
3874 }
3875  
3876 # m//
3877 elsif (/\G \b (m) \b /oxgc) {
3878 209 my $ope = $1;
3879 209 ▶ if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# #
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) ([cgimosxpadlunbB]*) /cgox) { } 0 209 209
3880 0 return e_qr($ope,$1,$3,$2,$4);
3881 }
3882 else {
3883 209 my $e = '';
3884 209 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 209 0 209
3885 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
3886 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( )
3887 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { }
3888 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ]
3889 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < >
3890 0 elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ?
3891 10 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' '
3892 0 elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { }
3893 199 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * *
3894 }
3895 0 die __FILE__, ": Search pattern not terminated\n";
3896 }
3897 }
3898  
3899 # s///
3900  
3901 # about [cegimosxpradlunbB]* (/cg modifier)
3902 #
3903 # P.67 Pattern-Matching Operators
3904 # of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition.
3905  
3906 elsif (/\G \b (s) \b /oxgc) {
3907 101 my $ope = $1;
3908  
3909 # $1 $2 $3 $4 $5 $6
3910 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
3911 1 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3912 }
3913 else {
3914 100 my $e = '';
3915 100 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 100 0 100
3916 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
3917 elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) {
3918 0 my @s = ($1,$2,$3);
3919 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3920 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
3921 # $1 $2 $3 $4
3922 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3923 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3924 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3925 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3926 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3927 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3928 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3929 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3930 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3931 }
3932 0 die __FILE__, ": Substitution replacement not terminated\n";
3933 }
3934 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) {
3935 0 my @s = ($1,$2,$3);
3936 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3937 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
3938 # $1 $2 $3 $4
3939 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3940 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3941 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3942 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3943 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3944 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3945 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3946 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3947 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3948 }
3949 0 die __FILE__, ": Substitution replacement not terminated\n";
3950 }
3951 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) {
3952 0 my @s = ($1,$2,$3);
3953 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3954 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
3955 # $1 $2 $3 $4
3956 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3957 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3958 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3959 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3960 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3961 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3962 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3963 }
3964 0 die __FILE__, ": Substitution replacement not terminated\n";
3965 }
3966 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) {
3967 0 my @s = ($1,$2,$3);
3968 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
3969 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
3970 # $1 $2 $3 $4
3971 0 elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3972 0 elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3973 0 elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3974 0 elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3975 0 elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3976 0 elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3977 0 elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3978 0 elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3979 0 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); }
3980 }
3981 0 die __FILE__, ": Substitution replacement not terminated\n";
3982 }
3983 # $1 $2 $3 $4 $5 $6
3984 elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) {
3985 21 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3986 }
3987 # $1 $2 $3 $4 $5 $6
3988 elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3989 0 return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { }
3990 }
3991 # $1 $2 $3 $4 $5 $6
3992 elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3993 0 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3994 }
3995 # $1 $2 $3 $4 $5 $6
3996 elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) {
3997 79 return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6);
3998 }
3999 }
4000 0 die __FILE__, ": Substitution pattern not terminated\n";
4001 }
4002 }
4003  
4004 # require ignore module
4005 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; }
4006 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# require$1\n$2"; }
4007 0 elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; }
4008  
4009 # use strict; --> use strict; no strict qw(refs);
4010 37 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; }
4011 0 elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; }
4012 0 elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; }
4013  
4014 # use 5.12.0; --> use 5.12.0; no strict qw(refs);
4015 elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4016 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
4017 0 return "use $1; no strict qw(refs);";
4018 }
4019 else {
4020 2 return "use $1;";
4021 }
4022 }
4023 elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) {
4024 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
4025 0 return "use $1; no strict qw(refs);";
4026 }
4027 else {
4028 0 return "use $1;";
4029 }
4030 }
4031  
4032 # ignore use module
4033 2 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; }
4034 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# use$1\n$2"; }
4035 0 elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; }
4036  
4037 # ignore no module
4038 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; }
4039 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^#]) /oxmsgc) { return "# no$1\n$2"; }
4040 0 elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; }
4041  
4042 # use else
4043 0 elsif (/\G \b use \b /oxmsgc) { return "use"; }
4044  
4045 # use else
4046 2 elsif (/\G \b no \b /oxmsgc) { return "no"; }
4047  
4048 # ''
4049 elsif (/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
4050 1142 my $q_string = '';
4051 1142 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 10162 0 10162
4052 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
4053 48 elsif (/\G (\\\') /oxgc) { $q_string .= $1; }
4054 1142 elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); }
4055 8968 elsif (/\G ($q_char) /oxgc) { $q_string .= $1; }
4056 }
4057 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4058 }
4059  
4060 # ""
4061 elsif (/\G (\") /oxgc) {
4062 1875 my $qq_string = '';
4063 1875 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 36856 0 36856
4064 36856 ▶ if (/\G (\\\\) /oxgc) { $qq_string .= $1; }
Branch: 4 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgox) { } 67 36789 36856
elsif (/\G (\\\") /cgox) { } 12 36777 36789
elsif (/\G \" /cgox) { } 1875 34902 36777
elsif (/\G ($Ekoi8r::q_char) /cgox) { } 34902 0 34902
4065 12 elsif (/\G (\\\") /oxgc) { $qq_string .= $1; }
4066 1875 elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); }
4067 34902 elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; }
4068 }
4069 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4070 }
4071  
4072 # ``
4073 elsif (/\G (\`) /oxgc) {
4074 1 my $qx_string = '';
4075 1 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 19 0 19
4076 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
4077 0 elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; }
4078 1 elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); }
4079 18 elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; }
4080 }
4081 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4082 }
4083  
4084 # // --- not divide operator (num / num), not defined-or
4085 ▶ elsif (($slash eq 'm//') and /\G (\/) /oxgc) {
Condition100%3/3
$Ekoi8r::slash eq "m//" and m[\G (/) ]cgox
!ll&&!rl&&r
271668848681
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
4086 681 my $regexp = '';
4087 681 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 5636 0 5636
4088 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
4089 0 elsif (/\G (\\\/) /oxgc) { $regexp .= $1; }
4090 681 elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); }
4091 4955 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4092 }
4093 0 die __FILE__, ": Search pattern not terminated\n";
4094 }
4095  
4096 # ?? --- not conditional operator (condition ? then : else)
4097 ▶ elsif (($slash eq 'm//') and /\G (\?) /oxgc) {
Condition66%2/3
$Ekoi8r::slash eq "m//" and /\G (\?) /cgox
!ll&&!rl&&r
2716688480
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
4098 0 my $regexp = '';
4099 0 ▶ while (not /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z/cgox) 0 0 0
4100 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
4101 0 elsif (/\G (\\\?) /oxgc) { $regexp .= $1; }
4102 0 elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); }
4103 0 elsif (/\G ($q_char) /oxgc) { $regexp .= $1; }
4104 }
4105 0 die __FILE__, ": Search pattern not terminated\n";
4106 }
4107  
4108 # <<>> (a safer ARGV)
4109 0 elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; }
4110  
4111 # << (bit shift) --- not here document
4112 0 elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; }
4113  
4114 # <<~'HEREDOC'
4115 elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) {
4116 6 $slash = 'm//';
4117 6 my $here_quote = $1;
4118 6 my $delimiter = $2;
4119  
4120 # get here document
4121 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4122 6 $here_script = CORE::substr $_, pos $_;
4123 6 $here_script =~ s/.*?\n//oxm;
4124 }
4125 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
4126 6 my $heredoc = $1;
4127 6 my $indent = $2;
4128 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4129 6 push @heredoc, $heredoc . qq{\n$delimiter\n};
4130 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4131 }
4132 else {
4133 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4134 }
4135 6 return qq{<<'$delimiter'};
4136 }
4137  
4138 # <<~\HEREDOC
4139  
4140 # P.66 2.6.6. "Here" Documents
4141 # in Chapter 2: Bits and Pieces
4142 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4143  
4144 # P.73 "Here" Documents
4145 # in Chapter 2: Bits and Pieces
4146 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4147  
4148 elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) {
4149 3 $slash = 'm//';
4150 3 my $here_quote = $1;
4151 3 my $delimiter = $2;
4152  
4153 # get here document
4154 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4155 3 $here_script = CORE::substr $_, pos $_;
4156 3 $here_script =~ s/.*?\n//oxm;
4157 }
4158 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
4159 3 my $heredoc = $1;
4160 3 my $indent = $2;
4161 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4162 3 push @heredoc, $heredoc . qq{\n$delimiter\n};
4163 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4164 }
4165 else {
4166 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4167 }
4168 3 return qq{<<\\$delimiter};
4169 }
4170  
4171 # <<~"HEREDOC"
4172 elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) {
4173 6 $slash = 'm//';
4174 6 my $here_quote = $1;
4175 6 my $delimiter = $2;
4176  
4177 # get here document
4178 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4179 6 $here_script = CORE::substr $_, pos $_;
4180 6 $here_script =~ s/.*?\n//oxm;
4181 }
4182 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
4183 6 my $heredoc = $1;
4184 6 my $indent = $2;
4185 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4186 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4187 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4188 }
4189 else {
4190 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4191 }
4192 6 return qq{<<"$delimiter"};
4193 }
4194  
4195 # <<~HEREDOC
4196 elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) {
4197 3 $slash = 'm//';
4198 3 my $here_quote = $1;
4199 3 my $delimiter = $2;
4200  
4201 # get here document
4202 3 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 3 0 3
4203 3 $here_script = CORE::substr $_, pos $_;
4204 3 $here_script =~ s/.*?\n//oxm;
4205 }
4206 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
4207 3 my $heredoc = $1;
4208 3 my $indent = $2;
4209 3 $heredoc =~ s{^$indent}{}msg; # no /ox
4210 3 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4211 3 push @heredoc_delimiter, qq{\\s*$delimiter};
4212 }
4213 else {
4214 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4215 }
4216 3 return qq{<<$delimiter};
4217 }
4218  
4219 # <<~`HEREDOC`
4220 elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) {
4221 6 $slash = 'm//';
4222 6 my $here_quote = $1;
4223 6 my $delimiter = $2;
4224  
4225 # get here document
4226 6 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 6 0 6
4227 6 $here_script = CORE::substr $_, pos $_;
4228 6 $here_script =~ s/.*?\n//oxm;
4229 }
4230 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
4231 6 my $heredoc = $1;
4232 6 my $indent = $2;
4233 6 $heredoc =~ s{^$indent}{}msg; # no /ox
4234 6 push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n};
4235 6 push @heredoc_delimiter, qq{\\s*$delimiter};
4236 }
4237 else {
4238 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4239 }
4240 6 return qq{<<`$delimiter`};
4241 }
4242  
4243 # <<'HEREDOC'
4244 elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) {
4245 72 $slash = 'm//';
4246 72 my $here_quote = $1;
4247 72 my $delimiter = $2;
4248  
4249 # get here document
4250 72 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 72 0 72
4251 72 $here_script = CORE::substr $_, pos $_;
4252 72 $here_script =~ s/.*?\n//oxm;
4253 }
4254 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
4255 72 push @heredoc, $1 . qq{\n$delimiter\n};
4256 72 push @heredoc_delimiter, $delimiter;
4257 }
4258 else {
4259 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4260 }
4261 72 return $here_quote;
4262 }
4263  
4264 # <<\HEREDOC
4265  
4266 # P.66 2.6.6. "Here" Documents
4267 # in Chapter 2: Bits and Pieces
4268 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4269  
4270 # P.73 "Here" Documents
4271 # in Chapter 2: Bits and Pieces
4272 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4273  
4274 elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
4275 0 $slash = 'm//';
4276 0 my $here_quote = $1;
4277 0 my $delimiter = $2;
4278  
4279 # get here document
4280 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4281 0 $here_script = CORE::substr $_, pos $_;
4282 0 $here_script =~ s/.*?\n//oxm;
4283 }
4284 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
4285 0 push @heredoc, $1 . qq{\n$delimiter\n};
4286 0 push @heredoc_delimiter, $delimiter;
4287 }
4288 else {
4289 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4290 }
4291 0 return $here_quote;
4292 }
4293  
4294 # <<"HEREDOC"
4295 elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) {
4296 36 $slash = 'm//';
4297 36 my $here_quote = $1;
4298 36 my $delimiter = $2;
4299  
4300 # get here document
4301 36 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 36 0 36
4302 36 $here_script = CORE::substr $_, pos $_;
4303 36 $here_script =~ s/.*?\n//oxm;
4304 }
4305 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
4306 36 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4307 36 push @heredoc_delimiter, $delimiter;
4308 }
4309 else {
4310 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4311 }
4312 36 return $here_quote;
4313 }
4314  
4315 # <<HEREDOC
4316 elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
4317 42 $slash = 'm//';
4318 42 my $here_quote = $1;
4319 42 my $delimiter = $2;
4320  
4321 # get here document
4322 42 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 42 0 42
4323 42 $here_script = CORE::substr $_, pos $_;
4324 42 $here_script =~ s/.*?\n//oxm;
4325 }
4326 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
4327 42 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4328 42 push @heredoc_delimiter, $delimiter;
4329 }
4330 else {
4331 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4332 }
4333 42 return $here_quote;
4334 }
4335  
4336 # <<`HEREDOC`
4337 elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
4338 0 $slash = 'm//';
4339 0 my $here_quote = $1;
4340 0 my $delimiter = $2;
4341  
4342 # get here document
4343 0 ▶ if ($here_script eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($here_script eq "") 0 0 0
4344 0 $here_script = CORE::substr $_, pos $_;
4345 0 $here_script =~ s/.*?\n//oxm;
4346 }
4347 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
4348 0 push @heredoc, e_heredoc($1) . qq{\n$delimiter\n};
4349 0 push @heredoc_delimiter, $delimiter;
4350 }
4351 else {
4352 0 die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n";
4353 }
4354 0 return $here_quote;
4355 }
4356  
4357 # <<= <=> <= < operator
4358 elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
4359 12 return $1;
4360 }
4361  
4362 # <FILEHANDLE>
4363 elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
4364 0 return $1;
4365 }
4366  
4367 # <WILDCARD> --- glob
4368  
4369 # avoid "Error: Runtime exception" of perl version 5.005_03
4370  
4371 elsif (/\G < ((?:[^>\0\a\e\f\n\r\t])+?) > /oxgc) {
4372 0 return 'Ekoi8r::glob("' . $1 . '")';
4373 }
4374  
4375 # __DATA__
4376 0 elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; }
4377  
4378 # __END__
4379 210 elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; }
4380  
4381 # \cD Control-D
4382  
4383 # P.68 2.6.8. Other Literal Tokens
4384 # in Chapter 2: Bits and Pieces
4385 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4386  
4387 # P.76 Other Literal Tokens
4388 # in Chapter 2: Bits and Pieces
4389 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4390  
4391 0 elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; }
4392  
4393 # \cZ Control-Z
4394 0 elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; }
4395  
4396 # any operator before div
4397 elsif (/\G (
4398 -- | \+\+ |
4399 [\)\}\]]
4400  
4401 5839 ) /oxgc) { $slash = 'div'; return $1; }
4402  
4403 # yada-yada or triple-dot operator
4404 elsif (/\G (
4405 \.\.\.
4406  
4407 7 ) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; }
4408  
4409 # any operator before m//
4410  
4411 # //, //= (defined-or)
4412  
4413 # P.164 Logical Operators
4414 # in Chapter 10: More Control Structures
4415 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4416  
4417 # P.119 C-Style Logical (Short-Circuit) Operators
4418 # in Chapter 3: Unary and Binary Operators
4419 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4420  
4421 # (and so on)
4422  
4423 # ~~
4424  
4425 # P.221 The Smart Match Operator
4426 # in Chapter 15: Smart Matching and given-when
4427 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
4428  
4429 # P.112 Smartmatch Operator
4430 # in Chapter 3: Unary and Binary Operators
4431 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4432  
4433 # (and so on)
4434  
4435 elsif (/\G ((?>
4436  
4437 !~~ | !~ | != | ! |
4438 %= | % |
4439 &&= | && | &= | &\.= | &\. | & |
4440 -= | -> | - |
4441 :(?>\s*)= |
4442 : |
4443 <<>> |
4444 <<= | <=> | <= | < |
4445 == | => | =~ | = |
4446 >>= | >> | >= | > |
4447 \*\*= | \*\* | \*= | \* |
4448 \+= | \+ |
4449 \.\. | \.= | \. |
4450 \/\/= | \/\/ |
4451 \/= | \/ |
4452 \? |
4453 \\ |
4454 \^= | \^\.= | \^\. | \^ |
4455 \b x= |
4456 \|\|= | \|\| | \|= | \|\.= | \|\. | \| |
4457 ~~ | ~\. | ~ |
4458 \b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
4459 \b(?: print )\b |
4460  
4461 [,;\(\{\[]
4462  
4463 9774 )) /oxgc) { $slash = 'm//'; return $1; }
4464  
4465 # other any character
4466 19998 elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; }
4467  
4468 # system error
4469 else {
4470 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4471 }
4472 }
4473  
4474 # escape KOI8-R string
4475 1873 ▶sub e_string {
Subroutine e_string: called CC=54 SCAR=72.5
Pod documented
4476 1873 my($string) = @_;
4477 1873 my $e_string = '';
4478  
4479 1873 local $slash = 'm//';
4480  
4481 # P.1024 Appendix W.10 Multibyte Processing
4482 # of ISBN 1-56592-224-7 CJKV Information Processing
4483 # (and so on)
4484  
4485 1873 my @char = $string =~ / \G (?>[^\\]|\\$q_char|$q_char) /oxmsg;
4486  
4487 # without { ... }
4488 1873 ▶ if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char) 1854 19 1873
Condition66%2/3
grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char
!ll&&!rl&&r
1854019
MC/DC50%1/2
grep /\A \{ \z/msx, @char and grep /\A \} \z/msx, @char
grep /\A \{ \z/msx, @char grep /\A \} \z/msx, @char
Truth table66%2/3
A and B
A= grep /\A \{ \z/msx, @charB= grep /\A \} \z/msx, @char
ABresult
0X0
100
111
4489 1854 ▶ if ($string !~ /<</oxms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /<</mosx) 1854 0 1854
4490 1854 return $string;
4491 }
4492 }
4493  
4494 E_STRING_LOOP:
4495 19 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 223 19 242
4496 223 ▶ if (0) {
Branch: 24 branches
BranchTrueFalseTotal
if (do { $string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /cgmosx }) { } 0 223 223
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$' | \$\{'\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ 0 ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /cgmosx) { } 0 223 223
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /cgmosx) { } 3 220 223
elsif ($string =~ /\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /cgmosx) { } 7 213 220
elsif ($string =~ m{\G ( \$[\$\@\#\\\'\"/\?\(\)\[\]\<\>] ) }cgmosx) { } 0 213 213
elsif ($string =~ /\G \b (qq) \b /cgox) { } 0 213 213
elsif ($string =~ /\G \b (qx) \b /cgox) { } 0 213 213
elsif ($string =~ /\G \b (q) \b /cgox) { } 0 213 213
elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$Ekoi8r::q_char)*?) (\') /cgox) { } 0 213 213
elsif ($string =~ /\G (\") ((?:$Ekoi8r::qq_char)*?) (\") /cgox) { } 0 213 213
elsif ($string =~ /\G (\`) ((?:$Ekoi8r::qq_char)*?) (\`) /cgox) { } 0 213 213
elsif ($string =~ /\G ($Ekoi8r::q_char) /cgox) { } 213 0 213
4497 }
4498  
4499 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Ekoi8r::PREMATCH()]}
4500 elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) {
4501 0 $e_string .= q{Ekoi8r::PREMATCH()};
4502 0 $slash = 'div';
4503 }
4504  
4505 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Ekoi8r::MATCH()]}
4506 elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) {
4507 0 $e_string .= q{Ekoi8r::MATCH()};
4508 0 $slash = 'div';
4509 }
4510  
4511 # $', ${'} --> $', ${'}
4512 elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) {
4513 0 $e_string .= $1;
4514 0 $slash = 'div';
4515 }
4516  
4517 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Ekoi8r::POSTMATCH()]}
4518 elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) {
4519 0 $e_string .= q{Ekoi8r::POSTMATCH()};
4520 0 $slash = 'div';
4521 }
4522  
4523 # bareword
4524 elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) {
4525 0 $e_string .= $1;
4526 0 $slash = 'div';
4527 }
4528  
4529 # $0 --> $0
4530 elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) {
4531 0 $e_string .= $1;
4532 0 $slash = 'div';
4533 }
4534 elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) {
4535 0 $e_string .= $1;
4536 0 $slash = 'div';
4537 }
4538  
4539 # $$ --> $$
4540 elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
4541 0 $e_string .= $1;
4542 0 $slash = 'div';
4543 }
4544  
4545 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4546 # $1, $2, $3 --> $1, $2, $3 otherwise
4547 elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) {
4548 0 $e_string .= e_capture($1);
4549 0 $slash = 'div';
4550 }
4551 elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) {
4552 0 $e_string .= e_capture($1);
4553 0 $slash = 'div';
4554 }
4555  
4556 # $$foo[ ... ] --> $ $foo->[ ... ]
4557 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) {
4558 0 $e_string .= e_capture($1.'->'.$2);
4559 0 $slash = 'div';
4560 }
4561  
4562 # $$foo{ ... } --> $ $foo->{ ... }
4563 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) {
4564 0 $e_string .= e_capture($1.'->'.$2);
4565 0 $slash = 'div';
4566 }
4567  
4568 # $$foo
4569 elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) {
4570 0 $e_string .= e_capture($1);
4571 0 $slash = 'div';
4572 }
4573  
4574 # ${ foo }
4575 elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) {
4576 0 $e_string .= '${' . $1 . '}';
4577 0 $slash = 'div';
4578 }
4579  
4580 # ${ ... }
4581 elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) {
4582 3 $e_string .= e_capture($1);
4583 3 $slash = 'div';
4584 }
4585  
4586 # variable or function
4587 # $ @ % & * $ #
4588 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) {
4589 7 $e_string .= $1;
4590 7 $slash = 'div';
4591 }
4592 # $ $ $ $ $ $ $ $ $ $ $ $ $ $
4593 # $ @ # \ ' " / ? ( ) [ ] < >
4594 elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) {
4595 0 $e_string .= $1;
4596 0 $slash = 'div';
4597 }
4598  
4599 # qq//
4600 elsif ($string =~ /\G \b (qq) \b /oxgc) {
4601 0 my $ope = $1;
4602 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
4603 0 $e_string .= e_qq($ope,$1,$3,$2);
4604 }
4605 else {
4606 0 my $e = '';
4607 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4608 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
4609 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( )
4610 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { }
4611 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ]
4612 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < >
4613 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * *
4614 }
4615 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4616 }
4617 }
4618  
4619 # qx//
4620 elsif ($string =~ /\G \b (qx) \b /oxgc) {
4621 0 my $ope = $1;
4622 0 ▶ if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:$Ekoi8r::qq_char)*?) (\#) /cgox) { } 0 0 0
4623 0 $e_string .= e_qq($ope,$1,$3,$2);
4624 }
4625 else {
4626 0 my $e = '';
4627 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4628 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
4629 0 elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( )
4630 0 elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { }
4631 0 elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ]
4632 0 elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < >
4633 0 elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' '
4634 0 elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * *
4635 }
4636 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4637 }
4638 }
4639  
4640 # q//
4641 elsif ($string =~ /\G \b (q) \b /oxgc) {
4642 0 my $ope = $1;
4643 0 ▶ if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# #
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$Ekoi8r::q_char)*?) (\#) /cgox) { } 0 0 0
4644 0 $e_string .= e_q($ope,$1,$3,$2);
4645 }
4646 else {
4647 0 my $e = '';
4648 0 ▶ while ($string !~ /\G \z/oxgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($string =~ /\G \z/cgox) 0 0 0
4649 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
4650 0 elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( )
4651 0 elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { }
4652 0 elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ]
4653 0 elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < >
4654 0 elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * *
4655 }
4656 0 die __FILE__, ": Can't find string terminator anywhere before EOF\n";
4657 }
4658 }
4659  
4660 # ''
4661 0 elsif ($string =~ /\G (?<![\w\$\@\%\&\*]) (\') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('',$1,$3,$2); }
4662  
4663 # ""
4664 0 elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4665  
4666 # ``
4667 0 elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); }
4668  
4669 # other any character
4670 213 elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; }
4671  
4672 # system error
4673 else {
4674 0 die __FILE__, ": Oops, this shouldn't happen!\n";
4675 }
4676 }
4677  
4678 19 return $e_string;
4679 }
4680  
4681 #
4682 # character class
4683 #
4684 1920 ▶sub character_class {
Subroutine character_class: called CC=3 SCAR=11.0
Pod undocumented
4685 1920 my($char,$modifier) = @_;
4686  
4687 1920 ▶ if ($char eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '.') { } 52 1868 1920
4688 52 ▶ if ($modifier =~ /s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /s/) { } 17 35 52
4689 17 return '${Ekoi8r::dot_s}';
4690 }
4691 else {
4692 35 return '${Ekoi8r::dot}';
4693 }
4694 }
4695 else {
4696 1868 return Ekoi8r::classic_character_class($char);
4697 }
4698 }
4699  
4700 #
4701 # escape capture ($1, $2, $3, ...)
4702 #
4703 212 ▶sub e_capture {
Subroutine e_capture: called CC=1 SCAR=0.0
Pod undocumented
4704  
4705 212 return join '', '${', $_[0], '}';
4706 }
4707  
4708 #
4709 # escape transliteration (tr/// or y///)
4710 #
4711 4 ▶sub e_tr {
Subroutine e_tr: called CC=5 SCAR=16.8
Pod undocumented
4712 4 my($variable,$charclass,$e,$charclass2,$modifier) = @_;
4713 4 my $e_tr = '';
4714 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
4715  
4716 4 $slash = 'div';
4717  
4718 # quote character class 1
4719 4 $charclass = q_tr($charclass);
4720  
4721 # quote character class 2
4722 4 $charclass2 = q_tr($charclass2);
4723  
4724 # /b /B modifier
4725 4 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) { } 0 4 4
4726 0 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 0 0 0
4727 0 $e_tr = qq{tr$charclass$e$charclass2$modifier};
4728 }
4729 else {
4730 0 $e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier};
4731 }
4732 }
4733 else {
4734 4 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq '') { } 2 2 4
4735 2 $e_tr = qq{Ekoi8r::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')};
4736 }
4737 else {
4738 2 $e_tr = qq{Ekoi8r::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')};
4739 }
4740 }
4741  
4742 # clear tr/// variable
4743 4 $tr_variable = '';
4744 4 $bind_operator = '';
4745  
4746 4 return $e_tr;
4747 }
4748  
4749 #
4750 # quote for escape transliteration (tr/// or y///)
4751 #
4752 8 ▶sub q_tr {
Subroutine q_tr: called CC=9 SCAR=40.6
Pod undocumented
4753 8 my($charclass) = @_;
4754  
4755 # quote character class
4756 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
4757 8 return e_q('', "'", "'", $charclass); # --> q' '
4758 }
4759 elsif ($charclass !~ /\//oxms) {
4760 0 return e_q('q', '/', '/', $charclass); # --> q/ /
4761 }
4762 elsif ($charclass !~ /\#/oxms) {
4763 0 return e_q('q', '#', '#', $charclass); # --> q# #
4764 }
4765 elsif ($charclass !~ /[\<\>]/oxms) {
4766 0 return e_q('q', '<', '>', $charclass); # --> q< >
4767 }
4768 elsif ($charclass !~ /[\(\)]/oxms) {
4769 0 return e_q('q', '(', ')', $charclass); # --> q( )
4770 }
4771 elsif ($charclass !~ /[\{\}]/oxms) {
4772 0 return e_q('q', '{', '}', $charclass); # --> q{ }
4773 }
4774 else {
4775 0 for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
4776 0 ▶ if ($charclass !~ /\Q$char\E/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($charclass =~ /\Q$char\E/msx) 0 0 0
4777 0 return e_q('q', $char, $char, $charclass);
4778 }
4779 }
4780 }
4781  
4782 0 return e_q('q', '{', '}', $charclass);
4783 }
4784  
4785 #
4786 # escape q string (q//, '')
4787 #
4788 1623 ▶sub e_q {
Subroutine e_q: called CC=1 SCAR=0.0
Pod undocumented
4789 1623 my($ope,$delimiter,$end_delimiter,$string) = @_;
4790  
4791 1623 $slash = 'div';
4792  
4793 1623 return join '', $ope, $delimiter, $string, $end_delimiter;
4794 }
4795  
4796 #
4797 # escape qq string (qq//, "", qx//, ``)
4798 #
4799 4213 ▶sub e_qq {
Subroutine e_qq: called CC=37 SCAR=50.9
Pod undocumented
4800 4213 my($ope,$delimiter,$end_delimiter,$string) = @_;
4801  
4802 4213 $slash = 'div';
4803  
4804 4213 my $left_e = 0;
4805 4213 my $right_e = 0;
4806  
4807 # split regexp
4808 4213 my @char = $string =~ /\G((?>
4809 [^\\\$] |
4810 \\x\{ (?>[0-9A-Fa-f]+) \} |
4811 \\o\{ (?>[0-7]+) \} |
4812 \\N\{ (?>[^0-9\}][^\}]*) \} |
4813 \\ $q_char |
4814 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
4815 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
4816 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
4817 \$ (?>\s* [0-9]+) |
4818 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
4819 \$ \$ (?![\w\{]) |
4820 \$ (?>\s*) \$ (?>\s*) $qq_variable |
4821 $q_char
4822 ))/oxmsg;
4823  
4824 4213 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 116443 4213 120656
4825  
4826 # "\L\u" --> "\u\L"
4827 116443 ▶ 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 116443 116443
elsif ($char[$i] eq '\\U' and $char[$i + 1] eq '\\l') { } 0 116443 116443
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/mosx) { } 1 116442 116443
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/mosx) { } 1 116441 116442
elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/mosx) { } 0 116441 116441
Condition33%1/3
$char[$i] eq "\\L" and $char[$i + 1] eq "\\u"
!ll&&!rl&&r
11644300
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
4828 0 @char[$i,$i+1] = @char[$i+1,$i];
4829 }
4830  
4831 # "\U\l" --> "\l\U"
4832 ▶ 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
11644300
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
4833 0 @char[$i,$i+1] = @char[$i+1,$i];
4834 }
4835  
4836 # octal escape sequence
4837 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
4838 1 $char[$i] = Ekoi8r::octchr($1);
4839 }
4840  
4841 # hexadecimal escape sequence
4842 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
4843 1 $char[$i] = Ekoi8r::hexchr($1);
4844 }
4845  
4846 # \N{CHARNAME} --> N{CHARNAME}
4847 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
4848 0 $char[$i] = $1;
4849 }
4850  
4851 116443 ▶ if (0) {
Branch: 23 branches
BranchTrueFalseTotal
if (do { $char[$i] =~ /\A ([<>]) \z/mosx }) { } 484 115959 116443
elsif ($char[$i] eq '\\u') { } 0 115959 115959
elsif ($char[$i] eq '\\l') { } 0 115959 115959
elsif ($char[$i] eq '\\U') { } 0 115959 115959
elsif ($char[$i] eq '\\L') { } 0 115959 115959
elsif ($char[$i] eq '\\F') { } 24 115935 115959
elsif ($char[$i] eq '\\Q') { } 0 115935 115935
elsif ($char[$i] eq '\\E') { } 24 115911 115935
elsif ($char[$i] eq '\\Q') { } 0 115911 115911
elsif ($char[$i] eq '\\E') { } 0 115911 115911
elsif ($char[$i] =~ /\A \$ 0 \z/mosx) { } 4 115907 115911
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/mosx) { } 0 115907 115907
elsif ($char[$i] =~ /\A \$\$ \z/mosx) { } 0 115907 115907
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/mosx) { } 205 115702 115907
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/mosx) { } 0 115702 115702
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/mosx) { } 0 115702 115702
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/mosx) { } 0 115702 115702
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/mosx) { } 0 115702 115702
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/cgmosx) { } 44 115658 115702
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/cgmosx) { } 45 115613 115658
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/cgmosx) { } 33 115580 115613
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/mosx) { } 0 115580 115580
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/mosx) { } 0 115580 115580
4852 }
4853  
4854 # \F
4855 #
4856 # P.69 Table 2-6. Translation escapes
4857 # in Chapter 2: Bits and Pieces
4858 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4859 # (and so on)
4860  
4861 # \u \l \U \L \F \Q \E
4862 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
4863 484 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 484 484
4864 0 $char[$i] = '\\' . $char[$i];
4865 }
4866 }
4867 elsif ($char[$i] eq '\u') {
4868  
4869 # "STRING @{[ LIST EXPR ]} MORE STRING"
4870  
4871 # P.257 Other Tricks You Can Do with Hard References
4872 # in Chapter 8: References
4873 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
4874  
4875 # P.353 Other Tricks You Can Do with Hard References
4876 # in Chapter 8: References
4877 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
4878  
4879 # (and so on)
4880  
4881 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
4882 0 $left_e++;
4883 }
4884 elsif ($char[$i] eq '\l') {
4885 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
4886 0 $left_e++;
4887 }
4888 elsif ($char[$i] eq '\U') {
4889 0 $char[$i] = '@{[Ekoi8r::uc qq<';
4890 0 $left_e++;
4891 }
4892 elsif ($char[$i] eq '\L') {
4893 0 $char[$i] = '@{[Ekoi8r::lc qq<';
4894 0 $left_e++;
4895 }
4896 elsif ($char[$i] eq '\F') {
4897 24 $char[$i] = '@{[Ekoi8r::fc qq<';
4898 24 $left_e++;
4899 }
4900 elsif ($char[$i] eq '\Q') {
4901 0 $char[$i] = '@{[CORE::quotemeta qq<';
4902 0 $left_e++;
4903 }
4904 elsif ($char[$i] eq '\E') {
4905 24 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 24 0 24
4906 24 $char[$i] = '>]}';
4907 24 $right_e++;
4908 }
4909 else {
4910 0 $char[$i] = '';
4911 }
4912 }
4913 elsif ($char[$i] eq '\Q') {
4914 0 while (1) {
4915 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
4916 0 last;
4917 }
4918 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
4919 0 last;
4920 }
4921 }
4922 }
4923 elsif ($char[$i] eq '\E') {
4924 }
4925  
4926 # $0 --> $0
4927 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
4928 }
4929 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
4930 }
4931  
4932 # $$ --> $$
4933 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
4934 }
4935  
4936 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
4937 # $1, $2, $3 --> $1, $2, $3 otherwise
4938 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
4939 205 $char[$i] = e_capture($1);
4940 }
4941 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
4942 0 $char[$i] = e_capture($1);
4943 }
4944  
4945 # $$foo[ ... ] --> $ $foo->[ ... ]
4946 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
4947 0 $char[$i] = e_capture($1.'->'.$2);
4948 }
4949  
4950 # $$foo{ ... } --> $ $foo->{ ... }
4951 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
4952 0 $char[$i] = e_capture($1.'->'.$2);
4953 }
4954  
4955 # $$foo
4956 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
4957 0 $char[$i] = e_capture($1);
4958 }
4959  
4960 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
4961 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
4962 44 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
4963 }
4964  
4965 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
4966 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
4967 45 $char[$i] = '@{[Ekoi8r::MATCH()]}';
4968 }
4969  
4970 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
4971 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
4972 33 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
4973 }
4974  
4975 # ${ foo } --> ${ foo }
4976 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
4977 }
4978  
4979 # ${ ... }
4980 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
4981 0 $char[$i] = e_capture($1);
4982 }
4983 }
4984  
4985 # return string
4986 4213 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 4213 4213
4987 0 return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter;
4988 }
4989 4213 return join '', $ope, $delimiter, @char, $end_delimiter;
4990 }
4991  
4992 #
4993 # escape qw string (qw//)
4994 #
4995 16 ▶sub e_qw {
Subroutine e_qw: called CC=11 SCAR=43.1
Pod undocumented
4996 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
4997  
4998 16 $slash = 'div';
4999  
5000 # choice again delimiter
5001 16 my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg);
5002 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
5003 16 return join '', $ope, $delimiter, $string, $end_delimiter;
5004 }
5005 elsif (not $octet{')'}) {
5006 0 return join '', $ope, '(', $string, ')';
5007 }
5008 elsif (not $octet{'}'}) {
5009 0 return join '', $ope, '{', $string, '}';
5010 }
5011 elsif (not $octet{']'}) {
5012 0 return join '', $ope, '[', $string, ']';
5013 }
5014 elsif (not $octet{'>'}) {
5015 0 return join '', $ope, '<', $string, '>';
5016 }
5017 else {
5018 0 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5019 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5020 0 return join '', $ope, $char, $string, $char;
5021 }
5022 }
5023 }
5024  
5025 # qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC')
5026 0 my @string = CORE::split(/\s+/, $string);
5027 0 for my $string (@string) {
5028 0 my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5029 0 for my $octet (@octet) {
5030 0 ▶ if ($octet =~ /\A (['\\]) \z/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet =~ /\A (['\\]) \z/mosx) 0 0 0
5031 0 $octet = '\\' . $1;
5032 }
5033 }
5034 0 $string = join '', @octet;
5035 }
5036 0 return join '', '(', (join ', ', map { "'$_'" } @string), ')';
5037 }
5038  
5039 #
5040 # escape here document (<<"HEREDOC", <<HEREDOC, <<`HEREDOC`, <<~"HEREDOC", <<~HEREDOC, <<~`HEREDOC`)
5041 #
5042 93 ▶sub e_heredoc {
Subroutine e_heredoc: called CC=37 SCAR=56.3
Pod undocumented
5043 93 my($string) = @_;
5044  
5045 93 $slash = 'm//';
5046  
5047 93 my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC`
5048  
5049 93 my $left_e = 0;
5050 93 my $right_e = 0;
5051  
5052 # split regexp
5053 93 my @char = $string =~ /\G((?>
5054 [^\\\$] |
5055 \\x\{ (?>[0-9A-Fa-f]+) \} |
5056 \\o\{ (?>[0-7]+) \} |
5057 \\N\{ (?>[^0-9\}][^\}]*) \} |
5058 \\ $q_char |
5059 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5060 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5061 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5062 \$ (?>\s* [0-9]+) |
5063 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5064 \$ \$ (?![\w\{]) |
5065 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5066 $q_char
5067 ))/oxmsg;
5068  
5069 93 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 3151 93 3244
5070  
5071 # "\L\u" --> "\u\L"
5072 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
5073 0 @char[$i,$i+1] = @char[$i+1,$i];
5074 }
5075  
5076 # "\U\l" --> "\l\U"
5077 ▶ 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
5078 0 @char[$i,$i+1] = @char[$i+1,$i];
5079 }
5080  
5081 # octal escape sequence
5082 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5083 1 $char[$i] = Ekoi8r::octchr($1);
5084 }
5085  
5086 # hexadecimal escape sequence
5087 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5088 1 $char[$i] = Ekoi8r::hexchr($1);
5089 }
5090  
5091 # \N{CHARNAME} --> N{CHARNAME}
5092 elsif ($char[$i] =~ /\A \\ ( N\{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5093 0 $char[$i] = $1;
5094 }
5095  
5096 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
5097 }
5098  
5099 # \u \l \U \L \F \Q \E
5100 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
5101 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
5102 0 $char[$i] = '\\' . $char[$i];
5103 }
5104 }
5105 elsif ($char[$i] eq '\u') {
5106 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
5107 0 $left_e++;
5108 }
5109 elsif ($char[$i] eq '\l') {
5110 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
5111 0 $left_e++;
5112 }
5113 elsif ($char[$i] eq '\U') {
5114 0 $char[$i] = '@{[Ekoi8r::uc qq<';
5115 0 $left_e++;
5116 }
5117 elsif ($char[$i] eq '\L') {
5118 0 $char[$i] = '@{[Ekoi8r::lc qq<';
5119 0 $left_e++;
5120 }
5121 elsif ($char[$i] eq '\F') {
5122 0 $char[$i] = '@{[Ekoi8r::fc qq<';
5123 0 $left_e++;
5124 }
5125 elsif ($char[$i] eq '\Q') {
5126 0 $char[$i] = '@{[CORE::quotemeta qq<';
5127 0 $left_e++;
5128 }
5129 elsif ($char[$i] eq '\E') {
5130 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
5131 0 $char[$i] = '>]}';
5132 0 $right_e++;
5133 }
5134 else {
5135 0 $char[$i] = '';
5136 }
5137 }
5138 elsif ($char[$i] eq '\Q') {
5139 0 while (1) {
5140 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5141 0 last;
5142 }
5143 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5144 0 last;
5145 }
5146 }
5147 }
5148 elsif ($char[$i] eq '\E') {
5149 }
5150  
5151 # $0 --> $0
5152 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5153 }
5154 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5155 }
5156  
5157 # $$ --> $$
5158 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5159 }
5160  
5161 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5162 # $1, $2, $3 --> $1, $2, $3 otherwise
5163 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5164 0 $char[$i] = e_capture($1);
5165 }
5166 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5167 0 $char[$i] = e_capture($1);
5168 }
5169  
5170 # $$foo[ ... ] --> $ $foo->[ ... ]
5171 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5172 0 $char[$i] = e_capture($1.'->'.$2);
5173 }
5174  
5175 # $$foo{ ... } --> $ $foo->{ ... }
5176 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5177 0 $char[$i] = e_capture($1.'->'.$2);
5178 }
5179  
5180 # $$foo
5181 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5182 0 $char[$i] = e_capture($1);
5183 }
5184  
5185 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
5186 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5187 8 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
5188 }
5189  
5190 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
5191 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5192 8 $char[$i] = '@{[Ekoi8r::MATCH()]}';
5193 }
5194  
5195 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
5196 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5197 6 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
5198 }
5199  
5200 # ${ foo } --> ${ foo }
5201 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
5202 }
5203  
5204 # ${ ... }
5205 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5206 0 $char[$i] = e_capture($1);
5207 }
5208 }
5209  
5210 # return string
5211 93 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 93 93
5212 0 return join '', @char, '>]}' x ($left_e - $right_e);
5213 }
5214 93 return join '', @char;
5215 }
5216  
5217 #
5218 # escape regexp (m//, qr//)
5219 #
5220 880 ▶sub e_qr {
Subroutine e_qr: called CC=110 SCAR=73.6
Pod undocumented
5221 880 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5222 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
5223  
5224 880 $modifier =~ tr/p//d;
5225 880 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 880 880
5226 0 my $line = 0;
5227 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5228 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5229 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5230 0 last;
5231 }
5232 }
5233 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5234 }
5235  
5236 880 $slash = 'div';
5237  
5238 # literal null string pattern
5239 880 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 872 880
elsif ($modifier =~ tr/Bb//d) { } 2 870 872
5240 8 $modifier =~ tr/bB//d;
5241 8 $modifier =~ tr/i//d;
5242 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5243 }
5244  
5245 # /b /B modifier
5246 elsif ($modifier =~ tr/bB//d) {
5247  
5248 # choice again delimiter
5249 2 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 2 2
5250 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5251 0 my %octet = map {$_ => 1} @char;
5252 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
5253 0 $delimiter = '(';
5254 0 $end_delimiter = ')';
5255 }
5256 elsif (not $octet{'}'}) {
5257 0 $delimiter = '{';
5258 0 $end_delimiter = '}';
5259 }
5260 elsif (not $octet{']'}) {
5261 0 $delimiter = '[';
5262 0 $end_delimiter = ']';
5263 }
5264 elsif (not $octet{'>'}) {
5265 0 $delimiter = '<';
5266 0 $end_delimiter = '>';
5267 }
5268 else {
5269 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5270 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5271 0 $delimiter = $char;
5272 0 $end_delimiter = $char;
5273 0 last;
5274 }
5275 }
5276 }
5277 }
5278  
5279 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
5280 0 return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier;
5281 }
5282 else {
5283 2 return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5284 }
5285 }
5286  
5287 870 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 312 558 870
5288 870 my $metachar = qr/[\@\\|[\]{^]/oxms;
5289  
5290 # split regexp
5291 870 my @char = $string =~ /\G((?>
5292 [^\\\$\@\[\(] |
5293 \\x (?>[0-9A-Fa-f]{1,2}) |
5294 \\ (?>[0-7]{2,3}) |
5295 \\c [\x40-\x5F] |
5296 \\x\{ (?>[0-9A-Fa-f]+) \} |
5297 \\o\{ (?>[0-7]+) \} |
5298 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5299 \\ $q_char |
5300 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5301 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5302 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5303 [\$\@] $qq_variable |
5304 \$ (?>\s* [0-9]+) |
5305 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5306 \$ \$ (?![\w\{]) |
5307 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5308 \[\^ |
5309 \[\: (?>[a-z]+) :\] |
5310 \[\:\^ (?>[a-z]+) :\] |
5311 \(\? |
5312 $q_char
5313 ))/oxmsg;
5314  
5315 # choice again delimiter
5316 870 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 870 870
5317 0 my %octet = map {$_ => 1} @char;
5318 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
5319 0 $delimiter = '(';
5320 0 $end_delimiter = ')';
5321 }
5322 elsif (not $octet{'}'}) {
5323 0 $delimiter = '{';
5324 0 $end_delimiter = '}';
5325 }
5326 elsif (not $octet{']'}) {
5327 0 $delimiter = '[';
5328 0 $end_delimiter = ']';
5329 }
5330 elsif (not $octet{'>'}) {
5331 0 $delimiter = '<';
5332 0 $end_delimiter = '>';
5333 }
5334 else {
5335 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5336 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5337 0 $delimiter = $char;
5338 0 $end_delimiter = $char;
5339 0 last;
5340 }
5341 }
5342 }
5343 }
5344  
5345 870 my $left_e = 0;
5346 870 my $right_e = 0;
5347 870 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2100 870 2970
5348  
5349 # "\L\u" --> "\u\L"
5350 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
5351 0 @char[$i,$i+1] = @char[$i+1,$i];
5352 }
5353  
5354 # "\U\l" --> "\l\U"
5355 ▶ 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
5356 0 @char[$i,$i+1] = @char[$i+1,$i];
5357 }
5358  
5359 # octal escape sequence
5360 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
5361 1 $char[$i] = Ekoi8r::octchr($1);
5362 }
5363  
5364 # hexadecimal escape sequence
5365 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
5366 1 $char[$i] = Ekoi8r::hexchr($1);
5367 }
5368  
5369 # \b{...} --> b\{...}
5370 # \B{...} --> B\{...}
5371 # \N{CHARNAME} --> N\{CHARNAME}
5372 # \p{PROPERTY} --> p\{PROPERTY}
5373 # \P{PROPERTY} --> P\{PROPERTY}
5374 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
5375 6 $char[$i] = $1 . '\\' . $2;
5376 }
5377  
5378 # \p, \P, \X --> p, P, X
5379 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
5380 4 $char[$i] = $1;
5381 }
5382  
5383 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
5384 }
5385  
5386 # join separated multiple-octet
5387 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
5388 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
5389 0 $char[$i] .= join '', splice @char, $i+1, 3;
5390 }
5391 ▶ 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
5392 0 $char[$i] .= join '', splice @char, $i+1, 2;
5393 }
5394 ▶ 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
5395 0 $char[$i] .= join '', splice @char, $i+1, 1;
5396 }
5397 }
5398  
5399 # open character class [...]
5400 elsif ($char[$i] eq '[') {
5401 556 my $left = $i;
5402  
5403 # [] make die "Unmatched [] in regexp ...\n"
5404 # (and so on)
5405  
5406 556 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 3 553 556
5407 3 $i++;
5408 }
5409  
5410 556 while (1) {
5411 2063 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 2063 2063
5412 0 die __FILE__, ": Unmatched [] in regexp\n";
5413 }
5414 2063 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 556 1507 2063
5415 556 my $right = $i;
5416  
5417 # [...]
5418 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
5419 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);
5420 }
5421 else {
5422 526 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
5423 }
5424  
5425 556 $i = $left;
5426 556 last;
5427 }
5428 }
5429 }
5430  
5431 # open character class [^...]
5432 elsif ($char[$i] eq '[^') {
5433 74 my $left = $i;
5434  
5435 # [^] make die "Unmatched [] in regexp ...\n"
5436 # (and so on)
5437  
5438 74 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 4 70 74
5439 4 $i++;
5440 }
5441  
5442 74 while (1) {
5443 272 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 272 272
5444 0 die __FILE__, ": Unmatched [] in regexp\n";
5445 }
5446 272 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 74 198 272
5447 74 my $right = $i;
5448  
5449 # [^...]
5450 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
5451 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);
5452 }
5453 else {
5454 44 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5455 }
5456  
5457 74 $i = $left;
5458 74 last;
5459 }
5460 }
5461 }
5462  
5463 # rewrite character class or escape character
5464 elsif (my $char = character_class($char[$i],$modifier)) {
5465 139 $char[$i] = $char;
5466 }
5467  
5468 # /i modifier
5469 ▶ 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
5470 20 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 20 0 20
5471 20 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
5472 }
5473 else {
5474 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
5475 }
5476 }
5477  
5478 # \u \l \U \L \F \Q \E
5479 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
5480 1 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 1 1
5481 0 $char[$i] = '\\' . $char[$i];
5482 }
5483 }
5484 elsif ($char[$i] eq '\u') {
5485 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
5486 0 $left_e++;
5487 }
5488 elsif ($char[$i] eq '\l') {
5489 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
5490 0 $left_e++;
5491 }
5492 elsif ($char[$i] eq '\U') {
5493 1 $char[$i] = '@{[Ekoi8r::uc qq<';
5494 1 $left_e++;
5495 }
5496 elsif ($char[$i] eq '\L') {
5497 1 $char[$i] = '@{[Ekoi8r::lc qq<';
5498 1 $left_e++;
5499 }
5500 elsif ($char[$i] eq '\F') {
5501 18 $char[$i] = '@{[Ekoi8r::fc qq<';
5502 18 $left_e++;
5503 }
5504 elsif ($char[$i] eq '\Q') {
5505 1 $char[$i] = '@{[CORE::quotemeta qq<';
5506 1 $left_e++;
5507 }
5508 elsif ($char[$i] eq '\E') {
5509 21 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 21 0 21
5510 21 $char[$i] = '>]}';
5511 21 $right_e++;
5512 }
5513 else {
5514 0 $char[$i] = '';
5515 }
5516 }
5517 elsif ($char[$i] eq '\Q') {
5518 0 while (1) {
5519 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5520 0 last;
5521 }
5522 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
5523 0 last;
5524 }
5525 }
5526 }
5527 elsif ($char[$i] eq '\E') {
5528 }
5529  
5530 # $0 --> $0
5531 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
5532 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5533 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5534 }
5535 }
5536 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
5537 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5538 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5539 }
5540 }
5541  
5542 # $$ --> $$
5543 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
5544 }
5545  
5546 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
5547 # $1, $2, $3 --> $1, $2, $3 otherwise
5548 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
5549 0 $char[$i] = e_capture($1);
5550 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5551 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5552 }
5553 }
5554 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
5555 0 $char[$i] = e_capture($1);
5556 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5557 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5558 }
5559 }
5560  
5561 # $$foo[ ... ] --> $ $foo->[ ... ]
5562 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
5563 0 $char[$i] = e_capture($1.'->'.$2);
5564 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5565 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5566 }
5567 }
5568  
5569 # $$foo{ ... } --> $ $foo->{ ... }
5570 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
5571 0 $char[$i] = e_capture($1.'->'.$2);
5572 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5573 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5574 }
5575 }
5576  
5577 # $$foo
5578 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
5579 0 $char[$i] = e_capture($1);
5580 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5581 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5582 }
5583 }
5584  
5585 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
5586 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
5587 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5588 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
5589 }
5590 else {
5591 8 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
5592 }
5593 }
5594  
5595 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
5596 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
5597 8 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 8 8
5598 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
5599 }
5600 else {
5601 8 $char[$i] = '@{[Ekoi8r::MATCH()]}';
5602 }
5603 }
5604  
5605 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
5606 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
5607 6 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 6 6
5608 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
5609 }
5610 else {
5611 6 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
5612 }
5613 }
5614  
5615 # ${ foo }
5616 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
5617 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5618 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5619 }
5620 }
5621  
5622 # ${ ... }
5623 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
5624 0 $char[$i] = e_capture($1);
5625 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
5626 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5627 }
5628 }
5629  
5630 # $scalar or @array
5631 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
5632 21 $char[$i] = e_string($char[$i]);
5633 21 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 11 10 21
5634 11 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
5635 }
5636 }
5637  
5638 # quote character before ? + * {
5639 ▶ 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
5640 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
5641 }
5642 ▶ 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
5643 0 my $char = $char[$i-1];
5644 0 ▶ if ($char[$i] eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq '{') { } 0 0 0
5645 0 die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n};
5646 }
5647 else {
5648 0 die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n};
5649 }
5650 }
5651 else {
5652 127 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5653 }
5654 }
5655 }
5656  
5657 # make regexp string
5658 870 $modifier =~ tr/i//d;
5659 870 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 870 870
5660 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
5661 0 return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier;
5662 }
5663 else {
5664 0 return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
5665 }
5666 }
5667 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
5668 0 return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier;
5669 }
5670 else {
5671 870 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5672 }
5673 }
5674  
5675 #
5676 # double quote stuff
5677 #
5678 180 ▶sub qq_stuff {
Subroutine qq_stuff: called CC=6 SCAR=18.5
Pod undocumented
5679 180 my($delimiter,$end_delimiter,$stuff) = @_;
5680  
5681 # scalar variable or array variable
5682 180 ▶ if ($stuff =~ /\A [\$\@] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff =~ /\A [\$\@] /mosx) 100 80 180
5683 100 return $stuff;
5684 }
5685  
5686 # quote by delimiter
5687 80 my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg);
5688 80 for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5689 80 ▶ next if $char eq $delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $delimiter 0 80 80
5690 80 ▶ next if $char eq $end_delimiter;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $end_delimiter 0 80 80
5691 80 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 80 0 80
5692 80 return join '', 'qq', $char, $stuff, $char;
5693 }
5694 }
5695 0 return join '', 'qq', '<', $stuff, '>';
5696 }
5697  
5698 #
5699 # escape regexp (m'', qr'', and m''b, qr''b)
5700 #
5701 10 ▶sub e_qr_q {
Subroutine e_qr_q: called CC=7 SCAR=25.3
Pod undocumented
5702 10 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5703 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
5704  
5705 10 $modifier =~ tr/p//d;
5706 10 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 10 10
5707 0 my $line = 0;
5708 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5709 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5710 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5711 0 last;
5712 }
5713 }
5714 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5715 }
5716  
5717 10 $slash = 'div';
5718  
5719 # literal null string pattern
5720 10 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 2 10
elsif ($modifier =~ tr/Bb//d) { } 0 2 2
5721 8 $modifier =~ tr/bB//d;
5722 8 $modifier =~ tr/i//d;
5723 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5724 }
5725  
5726 # with /b /B modifier
5727 elsif ($modifier =~ tr/bB//d) {
5728 0 return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
5729 }
5730  
5731 # without /b /B modifier
5732 else {
5733 2 return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
5734 }
5735 }
5736  
5737 #
5738 # escape regexp (m'', qr'')
5739 #
5740 2 ▶sub e_qr_qt {
Subroutine e_qr_qt: called CC=20 SCAR=51.8
Pod undocumented
5741 2 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5742  
5743 2 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 2 2
5744  
5745 # split regexp
5746 2 my @char = $string =~ /\G((?>
5747 [^\\\[\$\@\/] |
5748 [\x00-\xFF] |
5749 \[\^ |
5750 \[\: (?>[a-z]+) \:\] |
5751 \[\:\^ (?>[a-z]+) \:\] |
5752 [\$\@\/] |
5753 \\ (?:$q_char) |
5754 (?:$q_char)
5755 ))/oxmsg;
5756  
5757 # unescape character
5758 2 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 2 2 4
5759 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
5760 }
5761  
5762 # open character class [...]
5763 elsif ($char[$i] eq '[') {
5764 0 my $left = $i;
5765 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5766 0 $i++;
5767 }
5768 0 while (1) {
5769 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5770 0 die __FILE__, ": Unmatched [] in regexp\n";
5771 }
5772 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5773 0 my $right = $i;
5774  
5775 # [...]
5776 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
5777  
5778 0 $i = $left;
5779 0 last;
5780 }
5781 }
5782 }
5783  
5784 # open character class [^...]
5785 elsif ($char[$i] eq '[^') {
5786 0 my $left = $i;
5787 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
5788 0 $i++;
5789 }
5790 0 while (1) {
5791 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
5792 0 die __FILE__, ": Unmatched [] in regexp\n";
5793 }
5794 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
5795 0 my $right = $i;
5796  
5797 # [^...]
5798 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
5799  
5800 0 $i = $left;
5801 0 last;
5802 }
5803 }
5804 }
5805  
5806 # escape $ @ / and \
5807 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5808 0 $char[$i] = '\\' . $char[$i];
5809 }
5810  
5811 # rewrite character class or escape character
5812 elsif (my $char = character_class($char[$i],$modifier)) {
5813 0 $char[$i] = $char;
5814 }
5815  
5816 # /i modifier
5817 ▶ 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
5818 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
5819 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
5820 }
5821 else {
5822 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
5823 }
5824 }
5825  
5826 # quote character before ? + * {
5827 ▶ 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
5828 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
5829 }
5830 else {
5831 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
5832 }
5833 }
5834 }
5835  
5836 2 $delimiter = '/';
5837 2 $end_delimiter = '/';
5838  
5839 2 $modifier =~ tr/i//d;
5840 2 return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5841 }
5842  
5843 #
5844 # escape regexp (m''b, qr''b)
5845 #
5846 0 ▶sub e_qr_qb {
Subroutine e_qr_qb: not called CC=4 SCAR=30.0
Pod undocumented
5847 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5848  
5849 # split regexp
5850 0 my @char = $string =~ /\G ((?>[^\\]|\\\\)) /oxmsg;
5851  
5852 # unescape character
5853 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
5854 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
5855 }
5856  
5857 # remain \\
5858 elsif ($char[$i] eq '\\\\') {
5859 }
5860  
5861 # escape $ @ / and \
5862 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
5863 0 $char[$i] = '\\' . $char[$i];
5864 }
5865 }
5866  
5867 0 $delimiter = '/';
5868 0 $end_delimiter = '/';
5869 0 return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
5870 }
5871  
5872 #
5873 # escape regexp (s/here//)
5874 #
5875 80 ▶sub e_s1 {
Subroutine e_s1: called CC=106 SCAR=81.1
Pod undocumented
5876 80 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
5877 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
5878  
5879 80 $modifier =~ tr/p//d;
5880 80 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 80 80
5881 0 my $line = 0;
5882 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
5883 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
5884 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
5885 0 last;
5886 }
5887 }
5888 0 die qq{Unsupported modifier "$1" used at line $line.\n};
5889 }
5890  
5891 80 $slash = 'div';
5892  
5893 # literal null string pattern
5894 80 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 72 80
elsif ($modifier =~ tr/Bb//d) { } 0 72 72
5895 8 $modifier =~ tr/bB//d;
5896 8 $modifier =~ tr/i//d;
5897 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
5898 }
5899  
5900 # /b /B modifier
5901 elsif ($modifier =~ tr/bB//d) {
5902  
5903 # choice again delimiter
5904 0 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 0 0
5905 0 my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg;
5906 0 my %octet = map {$_ => 1} @char;
5907 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
5908 0 $delimiter = '(';
5909 0 $end_delimiter = ')';
5910 }
5911 elsif (not $octet{'}'}) {
5912 0 $delimiter = '{';
5913 0 $end_delimiter = '}';
5914 }
5915 elsif (not $octet{']'}) {
5916 0 $delimiter = '[';
5917 0 $end_delimiter = ']';
5918 }
5919 elsif (not $octet{'>'}) {
5920 0 $delimiter = '<';
5921 0 $end_delimiter = '>';
5922 }
5923 else {
5924 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5925 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5926 0 $delimiter = $char;
5927 0 $end_delimiter = $char;
5928 0 last;
5929 }
5930 }
5931 }
5932 }
5933  
5934 0 my $prematch = '';
5935 0 return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier;
5936 }
5937  
5938 72 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 1 71 72
5939 72 my $metachar = qr/[\@\\|[\]{^]/oxms;
5940  
5941 # split regexp
5942 72 my @char = $string =~ /\G((?>
5943 [^\\\$\@\[\(] |
5944 \\ (?>[1-9][0-9]*) |
5945 \\g (?>\s*) (?>[1-9][0-9]*) |
5946 \\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5947 \\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} |
5948 \\x (?>[0-9A-Fa-f]{1,2}) |
5949 \\ (?>[0-7]{2,3}) |
5950 \\c [\x40-\x5F] |
5951 \\x\{ (?>[0-9A-Fa-f]+) \} |
5952 \\o\{ (?>[0-7]+) \} |
5953 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
5954 \\ $q_char |
5955 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
5956 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
5957 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
5958 [\$\@] $qq_variable |
5959 \$ (?>\s* [0-9]+) |
5960 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
5961 \$ \$ (?![\w\{]) |
5962 \$ (?>\s*) \$ (?>\s*) $qq_variable |
5963 \[\^ |
5964 \[\: (?>[a-z]+) :\] |
5965 \[\:\^ (?>[a-z]+) :\] |
5966 \(\? |
5967 $q_char
5968 ))/oxmsg;
5969  
5970 # choice again delimiter
5971 72 ▶ if ($delimiter =~ / [\@:] /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter =~ / [\@:] /mosx) 0 72 72
5972 0 my %octet = map {$_ => 1} @char;
5973 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
5974 0 $delimiter = '(';
5975 0 $end_delimiter = ')';
5976 }
5977 elsif (not $octet{'}'}) {
5978 0 $delimiter = '{';
5979 0 $end_delimiter = '}';
5980 }
5981 elsif (not $octet{']'}) {
5982 0 $delimiter = '[';
5983 0 $end_delimiter = ']';
5984 }
5985 elsif (not $octet{'>'}) {
5986 0 $delimiter = '<';
5987 0 $end_delimiter = '>';
5988 }
5989 else {
5990 0 for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") {
5991 0 ▶ if (not $octet{$char}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($octet{$char}) 0 0 0
5992 0 $delimiter = $char;
5993 0 $end_delimiter = $char;
5994 0 last;
5995 }
5996 }
5997 }
5998 }
5999  
6000 # count '('
6001 72 my $parens = grep { $_ eq '(' } @char;
6002  
6003 72 my $left_e = 0;
6004 72 my $right_e = 0;
6005 72 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 200 72 272
6006  
6007 # "\L\u" --> "\u\L"
6008 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
6009 0 @char[$i,$i+1] = @char[$i+1,$i];
6010 }
6011  
6012 # "\U\l" --> "\l\U"
6013 ▶ 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
6014 0 @char[$i,$i+1] = @char[$i+1,$i];
6015 }
6016  
6017 # octal escape sequence
6018 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6019 1 $char[$i] = Ekoi8r::octchr($1);
6020 }
6021  
6022 # hexadecimal escape sequence
6023 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6024 1 $char[$i] = Ekoi8r::hexchr($1);
6025 }
6026  
6027 # \b{...} --> b\{...}
6028 # \B{...} --> B\{...}
6029 # \N{CHARNAME} --> N\{CHARNAME}
6030 # \p{PROPERTY} --> p\{PROPERTY}
6031 # \P{PROPERTY} --> P\{PROPERTY}
6032 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6033 0 $char[$i] = $1 . '\\' . $2;
6034 }
6035  
6036 # \p, \P, \X --> p, P, X
6037 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6038 0 $char[$i] = $1;
6039 }
6040  
6041 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
6042 }
6043  
6044 # join separated multiple-octet
6045 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6046 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
6047 0 $char[$i] .= join '', splice @char, $i+1, 3;
6048 }
6049 ▶ 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
6050 0 $char[$i] .= join '', splice @char, $i+1, 2;
6051 }
6052 ▶ 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
6053 0 $char[$i] .= join '', splice @char, $i+1, 1;
6054 }
6055 }
6056  
6057 # open character class [...]
6058 elsif ($char[$i] eq '[') {
6059 17 my $left = $i;
6060 17 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 17 17
6061 0 $i++;
6062 }
6063 17 while (1) {
6064 74 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 74 74
6065 0 die __FILE__, ": Unmatched [] in regexp\n";
6066 }
6067 74 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 17 57 74
6068 17 my $right = $i;
6069  
6070 # [...]
6071 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
6072 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);
6073 }
6074 else {
6075 17 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6076 }
6077  
6078 17 $i = $left;
6079 17 last;
6080 }
6081 }
6082 }
6083  
6084 # open character class [^...]
6085 elsif ($char[$i] eq '[^') {
6086 0 my $left = $i;
6087 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6088 0 $i++;
6089 }
6090 0 while (1) {
6091 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6092 0 die __FILE__, ": Unmatched [] in regexp\n";
6093 }
6094 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6095 0 my $right = $i;
6096  
6097 # [^...]
6098 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
6099 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);
6100 }
6101 else {
6102 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6103 }
6104  
6105 0 $i = $left;
6106 0 last;
6107 }
6108 }
6109 }
6110  
6111 # rewrite character class or escape character
6112 elsif (my $char = character_class($char[$i],$modifier)) {
6113 7 $char[$i] = $char;
6114 }
6115  
6116 # /i modifier
6117 ▶ 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
6118 3 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 3 0 3
6119 3 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6120 }
6121 else {
6122 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6123 }
6124 }
6125  
6126 # \u \l \U \L \F \Q \E
6127 elsif ($char[$i] =~ /\A [<>] \z/oxms) {
6128 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6129 0 $char[$i] = '\\' . $char[$i];
6130 }
6131 }
6132 elsif ($char[$i] eq '\u') {
6133 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
6134 0 $left_e++;
6135 }
6136 elsif ($char[$i] eq '\l') {
6137 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
6138 0 $left_e++;
6139 }
6140 elsif ($char[$i] eq '\U') {
6141 0 $char[$i] = '@{[Ekoi8r::uc qq<';
6142 0 $left_e++;
6143 }
6144 elsif ($char[$i] eq '\L') {
6145 0 $char[$i] = '@{[Ekoi8r::lc qq<';
6146 0 $left_e++;
6147 }
6148 elsif ($char[$i] eq '\F') {
6149 0 $char[$i] = '@{[Ekoi8r::fc qq<';
6150 0 $left_e++;
6151 }
6152 elsif ($char[$i] eq '\Q') {
6153 0 $char[$i] = '@{[CORE::quotemeta qq<';
6154 0 $left_e++;
6155 }
6156 elsif ($char[$i] eq '\E') {
6157 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6158 0 $char[$i] = '>]}';
6159 0 $right_e++;
6160 }
6161 else {
6162 0 $char[$i] = '';
6163 }
6164 }
6165 elsif ($char[$i] eq '\Q') {
6166 0 while (1) {
6167 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6168 0 last;
6169 }
6170 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6171 0 last;
6172 }
6173 }
6174 }
6175 elsif ($char[$i] eq '\E') {
6176 }
6177  
6178 # \0 --> \0
6179 elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) {
6180 }
6181  
6182 # \g{N}, \g{-N}
6183  
6184 # P.108 Using Simple Patterns
6185 # in Chapter 7: In the World of Regular Expressions
6186 # of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition
6187  
6188 # P.221 Capturing
6189 # in Chapter 5: Pattern Matching
6190 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6191  
6192 # \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3}
6193 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6194 }
6195  
6196 # \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable)
6197 elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6198 }
6199  
6200 # \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable)
6201 elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6202 }
6203  
6204 # \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable)
6205 elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) {
6206 }
6207  
6208 # $0 --> $0
6209 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6210 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6211 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6212 }
6213 }
6214 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6215 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6216 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6217 }
6218 }
6219  
6220 # $$ --> $$
6221 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6222 }
6223  
6224 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6225 # $1, $2, $3 --> $1, $2, $3 otherwise
6226 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6227 0 $char[$i] = e_capture($1);
6228 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6229 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6230 }
6231 }
6232 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6233 0 $char[$i] = e_capture($1);
6234 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6235 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6236 }
6237 }
6238  
6239 # $$foo[ ... ] --> $ $foo->[ ... ]
6240 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6241 0 $char[$i] = e_capture($1.'->'.$2);
6242 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6243 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6244 }
6245 }
6246  
6247 # $$foo{ ... } --> $ $foo->{ ... }
6248 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
6249 0 $char[$i] = e_capture($1.'->'.$2);
6250 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6251 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6252 }
6253 }
6254  
6255 # $$foo
6256 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
6257 0 $char[$i] = e_capture($1);
6258 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6259 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6260 }
6261 }
6262  
6263 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
6264 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
6265 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6266 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
6267 }
6268 else {
6269 4 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
6270 }
6271 }
6272  
6273 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
6274 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
6275 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 4 4
6276 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
6277 }
6278 else {
6279 4 $char[$i] = '@{[Ekoi8r::MATCH()]}';
6280 }
6281 }
6282  
6283 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
6284 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
6285 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 3 3
6286 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
6287 }
6288 else {
6289 3 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
6290 }
6291 }
6292  
6293 # ${ foo }
6294 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
6295 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6296 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6297 }
6298 }
6299  
6300 # ${ ... }
6301 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
6302 0 $char[$i] = e_capture($1);
6303 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6304 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6305 }
6306 }
6307  
6308 # $scalar or @array
6309 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
6310 4 $char[$i] = e_string($char[$i]);
6311 4 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 4 4
6312 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6313 }
6314 }
6315  
6316 # quote character before ? + * {
6317 ▶ 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
6318 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
6319 }
6320 else {
6321 14 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6322 }
6323 }
6324 }
6325  
6326 # make regexp string
6327 72 my $prematch = '';
6328 72 $modifier =~ tr/i//d;
6329 72 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 72 72
6330 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier;
6331 }
6332 72 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6333 }
6334  
6335 #
6336 # escape regexp (s'here'' or s'here''b)
6337 #
6338 21 ▶sub e_s1_q {
Subroutine e_s1_q: called CC=7 SCAR=24.3
Pod undocumented
6339 21 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6340 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
6341  
6342 21 $modifier =~ tr/p//d;
6343 21 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 21 21
6344 0 my $line = 0;
6345 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6346 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6347 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6348 0 last;
6349 }
6350 }
6351 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6352 }
6353  
6354 21 $slash = 'div';
6355  
6356 # literal null string pattern
6357 21 ▶ if ($string eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($string eq '') { } 8 13 21
elsif ($modifier =~ tr/Bb//d) { } 0 13 13
6358 8 $modifier =~ tr/bB//d;
6359 8 $modifier =~ tr/i//d;
6360 8 return join '', $ope, $delimiter, $end_delimiter, $modifier;
6361 }
6362  
6363 # with /b /B modifier
6364 elsif ($modifier =~ tr/bB//d) {
6365 0 return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier);
6366 }
6367  
6368 # without /b /B modifier
6369 else {
6370 13 return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier);
6371 }
6372 }
6373  
6374 #
6375 # escape regexp (s'here'')
6376 #
6377 13 ▶sub e_s1_qt {
Subroutine e_s1_qt: called CC=20 SCAR=50.1
Pod undocumented
6378 13 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6379  
6380 13 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 13 13
6381  
6382 # split regexp
6383 13 my @char = $string =~ /\G((?>
6384 [^\\\[\$\@\/] |
6385 [\x00-\xFF] |
6386 \[\^ |
6387 \[\: (?>[a-z]+) \:\] |
6388 \[\:\^ (?>[a-z]+) \:\] |
6389 [\$\@\/] |
6390 \\ (?:$q_char) |
6391 (?:$q_char)
6392 ))/oxmsg;
6393  
6394 # unescape character
6395 13 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 25 13 38
6396 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
6397 }
6398  
6399 # open character class [...]
6400 elsif ($char[$i] eq '[') {
6401 0 my $left = $i;
6402 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6403 0 $i++;
6404 }
6405 0 while (1) {
6406 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6407 0 die __FILE__, ": Unmatched [] in regexp\n";
6408 }
6409 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6410 0 my $right = $i;
6411  
6412 # [...]
6413 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6414  
6415 0 $i = $left;
6416 0 last;
6417 }
6418 }
6419 }
6420  
6421 # open character class [^...]
6422 elsif ($char[$i] eq '[^') {
6423 0 my $left = $i;
6424 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6425 0 $i++;
6426 }
6427 0 while (1) {
6428 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6429 0 die __FILE__, ": Unmatched [] in regexp\n";
6430 }
6431 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6432 0 my $right = $i;
6433  
6434 # [^...]
6435 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6436  
6437 0 $i = $left;
6438 0 last;
6439 }
6440 }
6441 }
6442  
6443 # escape $ @ / and \
6444 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6445 0 $char[$i] = '\\' . $char[$i];
6446 }
6447  
6448 # rewrite character class or escape character
6449 elsif (my $char = character_class($char[$i],$modifier)) {
6450 6 $char[$i] = $char;
6451 }
6452  
6453 # /i modifier
6454 ▶ 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
6455 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6456 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6457 }
6458 else {
6459 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6460 }
6461 }
6462  
6463 # quote character before ? + * {
6464 ▶ 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
6465 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
6466 }
6467 else {
6468 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
6469 }
6470 }
6471 }
6472  
6473 13 $modifier =~ tr/i//d;
6474 13 $delimiter = '/';
6475 13 $end_delimiter = '/';
6476 13 my $prematch = '';
6477 13 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6478 }
6479  
6480 #
6481 # escape regexp (s'here''b)
6482 #
6483 0 ▶sub e_s1_qb {
Subroutine e_s1_qb: not called CC=4 SCAR=30.0
Pod undocumented
6484 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6485  
6486 # split regexp
6487 0 my @char = $string =~ /\G (?>[^\\]|\\\\) /oxmsg;
6488  
6489 # unescape character
6490 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
6491 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
6492 }
6493  
6494 # remain \\
6495 elsif ($char[$i] eq '\\\\') {
6496 }
6497  
6498 # escape $ @ / and \
6499 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6500 0 $char[$i] = '\\' . $char[$i];
6501 }
6502 }
6503  
6504 0 $delimiter = '/';
6505 0 $end_delimiter = '/';
6506 0 my $prematch = '';
6507 0 return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier;
6508 }
6509  
6510 #
6511 # escape regexp (s''here')
6512 #
6513 16 ▶sub e_s2_q {
Subroutine e_s2_q: called CC=4 SCAR=13.9
Pod undocumented
6514 16 my($ope,$delimiter,$end_delimiter,$string) = @_;
6515  
6516 16 $slash = 'div';
6517  
6518 16 my @char = $string =~ / \G (?>[^\\]|\\\\|$q_char) /oxmsg;
6519 16 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 9 16 25
6520 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
6521 }
6522  
6523 # not escape \\
6524 elsif ($char[$i] =~ /\A \\\\ \z/oxms) {
6525 }
6526  
6527 # escape $ @ / and \
6528 elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) {
6529 5 $char[$i] = '\\' . $char[$i];
6530 }
6531 }
6532  
6533 16 return join '', $ope, $delimiter, @char, $end_delimiter;
6534 }
6535  
6536 #
6537 # escape regexp (s/here/and here/modifier)
6538 #
6539 101 ▶sub e_sub {
Subroutine e_sub: called CC=20 SCAR=32.6
Pod undocumented
6540 101 my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_;
6541 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
6542  
6543 101 $modifier =~ tr/p//d;
6544 101 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 101 101
6545 0 my $line = 0;
6546 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6547 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6548 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6549 0 last;
6550 }
6551 }
6552 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6553 }
6554  
6555 101 ▶ if ($variable eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($variable eq "") 36 65 101
6556 36 $variable = '$_';
6557 36 $bind_operator = ' =~ ';
6558 }
6559  
6560 101 $slash = 'div';
6561  
6562 # P.128 Start of match (or end of previous match): \G
6563 # P.130 Advanced Use of \G with Perl
6564 # in Chapter 3: Overview of Regular Expression Features and Flavors
6565 # P.312 Iterative Matching: Scalar Context, with /g
6566 # in Chapter 7: Perl
6567 # of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition
6568  
6569 # P.181 Where You Left Off: The \G Assertion
6570 # in Chapter 5: Pattern Matching
6571 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6572  
6573 # P.220 Where You Left Off: The \G Assertion
6574 # in Chapter 5: Pattern Matching
6575 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6576  
6577 101 my $e_modifier = $modifier =~ tr/e//d;
6578 101 my $r_modifier = $modifier =~ tr/r//d;
6579  
6580 101 my $my = '';
6581 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
6582 0 $my = $variable;
6583 0 $variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms;
6584 0 $variable =~ s/ = .+ \z//oxms;
6585 }
6586  
6587 101 (my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms;
6588 101 $variable_basename =~ s/ \s+ \z//oxms;
6589  
6590 # quote replacement string
6591 101 my $e_replacement = '';
6592 101 ▶ if ($e_modifier >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e_modifier >= 1) { } 17 84 101
6593 17 $e_replacement = e_qq('', '', '', $replacement);
6594 17 $e_modifier--;
6595 }
6596 else {
6597 84 ▶ if ($delimiter2 eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if ($delimiter2 eq q[']) { } 16 68 84
6598 16 $e_replacement = e_s2_q('qq', '/', '/', $replacement);
6599 }
6600 else {
6601 68 $e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement);
6602 }
6603 }
6604  
6605 101 my $sub = '';
6606  
6607 # with /r
6608 101 ▶ if ($r_modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r_modifier) { } 10 91 101
6609 10 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 5 5 10
6610 }
6611  
6612 # s///gr without multibyte anchoring
6613 elsif ($modifier =~ /g/oxms) {
6614 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6615 # 1 2 3 4 5
6616 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}>,
6617  
6618 $variable, # 1
6619 ($delimiter1 eq "'") ? # 2
6620 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6621 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6622 $s_matched, # 3
6623 $e_replacement, # 4
6624 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
6625 );
6626 }
6627  
6628 # s///r
6629 else {
6630  
6631 5 my $prematch = q{$`};
6632  
6633 5 ▶ $sub = sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 0 5 5
6634 # 1 2 3 4 5 6 7
6635 q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s"%s$Ekoi8r::re_r$'" } : %s>,
6636  
6637 $variable, # 1
6638 ($delimiter1 eq "'") ? # 2
6639 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6640 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6641 $s_matched, # 3
6642 $e_replacement, # 4
6643 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
6644 $prematch, # 6
6645 $variable, # 7
6646 );
6647 }
6648  
6649 # $var !~ s///r doesn't make sense
6650 10 ▶ if ($bind_operator =~ / !~ /oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bind_operator =~ / !~ /mosx) 0 10 10
6651 0 $sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub;
6652 }
6653 }
6654  
6655 # without /r
6656 else {
6657 91 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $modifier =~ /g/mosx }) { } 23 68 91
6658 }
6659  
6660 # s///g without multibyte anchoring
6661 elsif ($modifier =~ /g/oxms) {
6662 23 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$delimiter1 eq q['] ? : 3 20 23
$bind_operator =~ / !~ /mosx ? : 3 20 23
6663 # 1 2 3 4 5 6 7 8
6664 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}>,
6665  
6666 $variable, # 1
6667 ($delimiter1 eq "'") ? # 2
6668 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6669 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6670 $s_matched, # 3
6671 $e_replacement, # 4
6672 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 5
6673 $variable, # 6
6674 $variable, # 7
6675 ($bind_operator =~ / !~ /oxms) ? '!' : '', # 8
6676 );
6677 }
6678  
6679 # s///
6680 else {
6681  
6682 68 my $prematch = q{$`};
6683  
6684 68 ▶ $sub = sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$bind_operator =~ / =~ /mosx ? : 65 3 68
$delimiter1 eq q['] ? : 18 50 68
6685  
6686 ($bind_operator =~ / =~ /oxms) ?
6687  
6688 # 1 2 3 4 5 6 7 8
6689 q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s%s="%s$Ekoi8r::re_r$'"; 1 } : undef> :
6690  
6691 # 1 2 3 4 5 6 7 8
6692 q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Ekoi8r::re_r=%s; %s%s="%s$Ekoi8r::re_r$'"; undef }>,
6693  
6694 $variable, # 1
6695 $bind_operator, # 2
6696 ($delimiter1 eq "'") ? # 3
6697 e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # :
6698 e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # :
6699 $s_matched, # 4
6700 $e_replacement, # 5
6701 '$Ekoi8r::re_r=CORE::eval $Ekoi8r::re_r; ' x $e_modifier, # 6
6702 $variable, # 7
6703 $prematch, # 8
6704 );
6705 }
6706 }
6707  
6708 # (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1]
6709 101 ▶ if ($my ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($my ne "") 0 101 101
6710 0 $sub = "($my, $sub)[1]";
6711 }
6712  
6713 # clear s/// variable
6714 101 $sub_variable = '';
6715 101 $bind_operator = '';
6716  
6717 101 return $sub;
6718 }
6719  
6720 #
6721 # escape regexp of split qr//
6722 #
6723 74 ▶sub e_split {
Subroutine e_split: called CC=88 SCAR=76.4
Pod undocumented
6724 74 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
6725 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
6726  
6727 74 $modifier =~ tr/p//d;
6728 74 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 74 74
6729 0 my $line = 0;
6730 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
6731 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
6732 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
6733 0 last;
6734 }
6735 }
6736 0 die qq{Unsupported modifier "$1" used at line $line.\n};
6737 }
6738  
6739 74 $slash = 'div';
6740  
6741 # /b /B modifier
6742 74 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 74 74
6743 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
6744 }
6745  
6746 74 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 74 74
6747 74 my $metachar = qr/[\@\\|[\]{^]/oxms;
6748  
6749 # split regexp
6750 74 my @char = $string =~ /\G((?>
6751 [^\\\$\@\[\(] |
6752 \\x (?>[0-9A-Fa-f]{1,2}) |
6753 \\ (?>[0-7]{2,3}) |
6754 \\c [\x40-\x5F] |
6755 \\x\{ (?>[0-9A-Fa-f]+) \} |
6756 \\o\{ (?>[0-7]+) \} |
6757 \\[bBNpP]\{ (?>[^0-9\}][^\}]*) \} |
6758 \\ $q_char |
6759 \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} |
6760 \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} |
6761 \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} |
6762 [\$\@] $qq_variable |
6763 \$ (?>\s* [0-9]+) |
6764 \$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} |
6765 \$ \$ (?![\w\{]) |
6766 \$ (?>\s*) \$ (?>\s*) $qq_variable |
6767 \[\^ |
6768 \[\: (?>[a-z]+) :\] |
6769 \[\:\^ (?>[a-z]+) :\] |
6770 \(\? |
6771 $q_char
6772 ))/oxmsg;
6773  
6774 74 my $left_e = 0;
6775 74 my $right_e = 0;
6776 74 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 249 74 323
6777  
6778 # "\L\u" --> "\u\L"
6779 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
6780 0 @char[$i,$i+1] = @char[$i+1,$i];
6781 }
6782  
6783 # "\U\l" --> "\l\U"
6784 ▶ 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
6785 0 @char[$i,$i+1] = @char[$i+1,$i];
6786 }
6787  
6788 # octal escape sequence
6789 elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
6790 1 $char[$i] = Ekoi8r::octchr($1);
6791 }
6792  
6793 # hexadecimal escape sequence
6794 elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
6795 1 $char[$i] = Ekoi8r::hexchr($1);
6796 }
6797  
6798 # \b{...} --> b\{...}
6799 # \B{...} --> B\{...}
6800 # \N{CHARNAME} --> N\{CHARNAME}
6801 # \p{PROPERTY} --> p\{PROPERTY}
6802 # \P{PROPERTY} --> P\{PROPERTY}
6803 elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^0-9\}][^\}]*) \} ) \z/oxms) {
6804 0 $char[$i] = $1 . '\\' . $2;
6805 }
6806  
6807 # \p, \P, \X --> p, P, X
6808 elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) {
6809 0 $char[$i] = $1;
6810 }
6811  
6812 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
6813 }
6814  
6815 # join separated multiple-octet
6816 elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
6817 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
6818 0 $char[$i] .= join '', splice @char, $i+1, 3;
6819 }
6820 ▶ 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
6821 0 $char[$i] .= join '', splice @char, $i+1, 2;
6822 }
6823 ▶ 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
6824 0 $char[$i] .= join '', splice @char, $i+1, 1;
6825 }
6826 }
6827  
6828 # open character class [...]
6829 elsif ($char[$i] eq '[') {
6830 3 my $left = $i;
6831 3 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 3 3
6832 0 $i++;
6833 }
6834 3 while (1) {
6835 7 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 7 7
6836 0 die __FILE__, ": Unmatched [] in regexp\n";
6837 }
6838 7 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 3 4 7
6839 3 my $right = $i;
6840  
6841 # [...]
6842 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
6843 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);
6844 }
6845 else {
6846 3 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
6847 }
6848  
6849 3 $i = $left;
6850 3 last;
6851 }
6852 }
6853 }
6854  
6855 # open character class [^...]
6856 elsif ($char[$i] eq '[^') {
6857 0 my $left = $i;
6858 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
6859 0 $i++;
6860 }
6861 0 while (1) {
6862 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6863 0 die __FILE__, ": Unmatched [] in regexp\n";
6864 }
6865 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
6866 0 my $right = $i;
6867  
6868 # [^...]
6869 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
6870 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);
6871 }
6872 else {
6873 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
6874 }
6875  
6876 0 $i = $left;
6877 0 last;
6878 }
6879 }
6880 }
6881  
6882 # rewrite character class or escape character
6883 elsif (my $char = character_class($char[$i],$modifier)) {
6884 1 $char[$i] = $char;
6885 }
6886  
6887 # P.794 29.2.161. split
6888 # in Chapter 29: Functions
6889 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
6890  
6891 # P.951 split
6892 # in Chapter 27: Functions
6893 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
6894  
6895 # said "The //m modifier is assumed when you split on the pattern /^/",
6896 # but perl5.008 is not so. Therefore, this software adds //m.
6897 # (and so on)
6898  
6899 # split(m/^/) --> split(m/^/m)
6900 ▶ 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
6901 7 $modifier .= 'm';
6902 }
6903  
6904 # /i modifier
6905 ▶ 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
6906 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
6907 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
6908 }
6909 else {
6910 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
6911 }
6912 }
6913  
6914 # \u \l \U \L \F \Q \E
6915 elsif ($char[$i] =~ /\A ([<>]) \z/oxms) {
6916 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) 0 0 0
6917 0 $char[$i] = '\\' . $char[$i];
6918 }
6919 }
6920 elsif ($char[$i] eq '\u') {
6921 0 $char[$i] = '@{[Ekoi8r::ucfirst qq<';
6922 0 $left_e++;
6923 }
6924 elsif ($char[$i] eq '\l') {
6925 0 $char[$i] = '@{[Ekoi8r::lcfirst qq<';
6926 0 $left_e++;
6927 }
6928 elsif ($char[$i] eq '\U') {
6929 0 $char[$i] = '@{[Ekoi8r::uc qq<';
6930 0 $left_e++;
6931 }
6932 elsif ($char[$i] eq '\L') {
6933 0 $char[$i] = '@{[Ekoi8r::lc qq<';
6934 0 $left_e++;
6935 }
6936 elsif ($char[$i] eq '\F') {
6937 0 $char[$i] = '@{[Ekoi8r::fc qq<';
6938 0 $left_e++;
6939 }
6940 elsif ($char[$i] eq '\Q') {
6941 0 $char[$i] = '@{[CORE::quotemeta qq<';
6942 0 $left_e++;
6943 }
6944 elsif ($char[$i] eq '\E') {
6945 0 ▶ if ($right_e < $left_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right_e < $left_e) { } 0 0 0
6946 0 $char[$i] = '>]}';
6947 0 $right_e++;
6948 }
6949 else {
6950 0 $char[$i] = '';
6951 }
6952 }
6953 elsif ($char[$i] eq '\Q') {
6954 0 while (1) {
6955 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
6956 0 last;
6957 }
6958 0 ▶ if ($char[$i] eq '\E') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "\\E") 0 0 0
6959 0 last;
6960 }
6961 }
6962 }
6963 elsif ($char[$i] eq '\E') {
6964 }
6965  
6966 # $0 --> $0
6967 elsif ($char[$i] =~ /\A \$ 0 \z/oxms) {
6968 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6969 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6970 }
6971 }
6972 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) {
6973 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6974 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6975 }
6976 }
6977  
6978 # $$ --> $$
6979 elsif ($char[$i] =~ /\A \$\$ \z/oxms) {
6980 }
6981  
6982 # $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring
6983 # $1, $2, $3 --> $1, $2, $3 otherwise
6984 elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) {
6985 0 $char[$i] = e_capture($1);
6986 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6987 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6988 }
6989 }
6990 elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) {
6991 0 $char[$i] = e_capture($1);
6992 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
6993 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
6994 }
6995 }
6996  
6997 # $$foo[ ... ] --> $ $foo->[ ... ]
6998 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) {
6999 0 $char[$i] = e_capture($1.'->'.$2);
7000 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7001 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7002 }
7003 }
7004  
7005 # $$foo{ ... } --> $ $foo->{ ... }
7006 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) {
7007 0 $char[$i] = e_capture($1.'->'.$2);
7008 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7009 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7010 }
7011 }
7012  
7013 # $$foo
7014 elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) {
7015 0 $char[$i] = e_capture($1);
7016 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7017 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7018 }
7019 }
7020  
7021 # $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ekoi8r::PREMATCH()
7022 elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) {
7023 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7024 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::PREMATCH())]}';
7025 }
7026 else {
7027 12 $char[$i] = '@{[Ekoi8r::PREMATCH()]}';
7028 }
7029 }
7030  
7031 # $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ekoi8r::MATCH()
7032 elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) {
7033 12 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 12 12
7034 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::MATCH())]}';
7035 }
7036 else {
7037 12 $char[$i] = '@{[Ekoi8r::MATCH()]}';
7038 }
7039 }
7040  
7041 # $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ekoi8r::POSTMATCH()
7042 elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) {
7043 9 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) { } 0 9 9
7044 0 $char[$i] = '@{[Ekoi8r::ignorecase(Ekoi8r::POSTMATCH())]}';
7045 }
7046 else {
7047 9 $char[$i] = '@{[Ekoi8r::POSTMATCH()]}';
7048 }
7049 }
7050  
7051 # ${ foo }
7052 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) {
7053 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7054 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $1 . ')]}';
7055 }
7056 }
7057  
7058 # ${ ... }
7059 elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) {
7060 0 $char[$i] = e_capture($1);
7061 0 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 0 0
7062 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7063 }
7064 }
7065  
7066 # $scalar or @array
7067 elsif ($char[$i] =~ /\A [\$\@].+ /oxms) {
7068 3 $char[$i] = e_string($char[$i]);
7069 3 ▶ if ($ignorecase) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorecase) 0 3 3
7070 0 $char[$i] = '@{[Ekoi8r::ignorecase(' . $char[$i] . ')]}';
7071 }
7072 }
7073  
7074 # quote character before ? + * {
7075 ▶ 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
7076 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
7077 }
7078 else {
7079 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7080 }
7081 }
7082 }
7083  
7084 # make regexp string
7085 74 $modifier =~ tr/i//d;
7086 74 ▶ if ($left_e > $right_e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_e > $right_e) 0 74 74
7087 0 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier;
7088 }
7089 74 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7090 }
7091  
7092 #
7093 # escape regexp of split qr''
7094 #
7095 0 ▶sub e_split_q {
Subroutine e_split_q: not called CC=26 SCAR=65.5
Pod undocumented
7096 0 my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_;
7097 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
7098  
7099 0 $modifier =~ tr/p//d;
7100 0 ▶ if ($modifier =~ /([adlu])/oxms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ /([adlu])/mosx) 0 0 0
7101 0 my $line = 0;
7102 0 ▶ for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7103 0 ▶ if ($filename ne __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne __FILE__) 0 0 0
7104 0 $line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1;
7105 0 last;
7106 }
7107 }
7108 0 die qq{Unsupported modifier "$1" used at line $line.\n};
7109 }
7110  
7111 0 $slash = 'div';
7112  
7113 # /b /B modifier
7114 0 ▶ if ($modifier =~ tr/bB//d) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier =~ tr/Bb//d) 0 0 0
7115 0 return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier;
7116 }
7117  
7118 0 ▶ my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$modifier =~ /i/mosx ? : 0 0 0
7119  
7120 # split regexp
7121 0 my @char = $string =~ /\G((?>
7122 [^\\\[] |
7123 [\x00-\xFF] |
7124 \[\^ |
7125 \[\: (?>[a-z]+) \:\] |
7126 \[\:\^ (?>[a-z]+) \:\] |
7127 \\ (?:$q_char) |
7128 (?:$q_char)
7129 ))/oxmsg;
7130  
7131 # unescape character
7132 0 ▶ for (my $i=0; $i <= $#char; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#char) 0 0 0
7133 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
7134 }
7135  
7136 # open character class [...]
7137 elsif ($char[$i] eq '[') {
7138 0 my $left = $i;
7139 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7140 0 $i++;
7141 }
7142 0 while (1) {
7143 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7144 0 die __FILE__, ": Unmatched [] in regexp\n";
7145 }
7146 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7147 0 my $right = $i;
7148  
7149 # [...]
7150 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_qr(@char[$left+1..$right-1], $modifier);
7151  
7152 0 $i = $left;
7153 0 last;
7154 }
7155 }
7156 }
7157  
7158 # open character class [^...]
7159 elsif ($char[$i] eq '[^') {
7160 0 my $left = $i;
7161 0 ▶ if ($char[$i+1] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i + 1] eq "]") 0 0 0
7162 0 $i++;
7163 }
7164 0 while (1) {
7165 0 ▶ if (++$i > $#char) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i > $#char) 0 0 0
7166 0 die __FILE__, ": Unmatched [] in regexp\n";
7167 }
7168 0 ▶ if ($char[$i] eq ']') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char[$i] eq "]") 0 0 0
7169 0 my $right = $i;
7170  
7171 # [^...]
7172 0 splice @char, $left, $right-$left+1, Ekoi8r::charlist_not_qr(@char[$left+1..$right-1], $modifier);
7173  
7174 0 $i = $left;
7175 0 last;
7176 }
7177 }
7178 }
7179  
7180 # rewrite character class or escape character
7181 elsif (my $char = character_class($char[$i],$modifier)) {
7182 0 $char[$i] = $char;
7183 }
7184  
7185 # split(m/^/) --> split(m/^/m)
7186 ▶ 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
7187 0 $modifier .= 'm';
7188 }
7189  
7190 # /i modifier
7191 ▶ 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
7192 0 ▶ if (CORE::length(Ekoi8r::fc($char[$i])) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length &fc($char[$i]) == 1) { } 0 0 0
7193 0 $char[$i] = '[' . Ekoi8r::uc($char[$i]) . Ekoi8r::fc($char[$i]) . ']';
7194 }
7195 else {
7196 0 $char[$i] = '(?:' . Ekoi8r::uc($char[$i]) . '|' . Ekoi8r::fc($char[$i]) . ')';
7197 }
7198 }
7199  
7200 # quote character before ? + * {
7201 ▶ 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
7202 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
7203 }
7204 else {
7205 0 $char[$i-1] = '(?:' . $char[$i-1] . ')';
7206 }
7207 }
7208 }
7209  
7210 0 $modifier =~ tr/i//d;
7211 0 return join '', 'Ekoi8r::split', $ope, $delimiter, @char, $end_delimiter, $modifier;
7212 }
7213  
7214 #
7215 # instead of Carp::carp
7216 #
7217 0 ▶sub carp {
Subroutine carp: not called CC=1 SCAR=6.9
Pod undocumented
7218 0 my($package,$filename,$line) = caller(1);
7219 0 print STDERR "@_ at $filename line $line.\n";
7220 }
7221  
7222 #
7223 # instead of Carp::croak
7224 #
7225 0 ▶sub croak {
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
7226 0 my($package,$filename,$line) = caller(1);
7227 0 print STDERR "@_ at $filename line $line.\n";
7228 0 die "\n";
7229 }
7230  
7231 #
7232 # instead of Carp::cluck
7233 #
7234 0 ▶sub cluck {
Subroutine cluck: not called CC=2 SCAR=17.9
Pod undocumented
7235 0 my $i = 0;
7236 0 my @cluck = ();
7237 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7238 0 push @cluck, "[$i] $filename($line) $package::$subroutine\n";
7239 0 $i++;
7240 }
7241 0 print STDERR CORE::reverse @cluck;
7242 0 print STDERR "\n";
7243 0 print STDERR @_;
7244 }
7245  
7246 #
7247 # instead of Carp::confess
7248 #
7249 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
7250 0 my $i = 0;
7251 0 my @confess = ();
7252 0 ▶ while (my($package,$filename,$line,$subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
7253 0 push @confess, "[$i] $filename($line) $package::$subroutine\n";
7254 0 $i++;
7255 }
7256 0 print STDERR CORE::reverse @confess;
7257 0 print STDERR "\n";
7258 0 print STDERR @_;
7259 0 die "\n";
7260 }
7261  
7262 424 1;
7263  
7264 __END__
↑ Summary KOI8R.pm »