lib/mb.pm

filter: Statementstmt 77.3% 2078 / 2686 Branchbran 75.9% 1921 / 2528 Conditioncond 59.8% 271 / 453 MC/DCmcdc 42.5% 114 / 268 Subroutinesub 94.0% 142 / 151 Podpod 4.1% 3 / 73 totaltotal 73.5% 4529 / 6159 CC 2773 SCAR 53.9
CC
2773
Cov
75%
_r2_qr
1814.9
_r2_qr
1814.9
parse_expr
437.7
CRAP 219.0
↑ Summary eg/bm/mb_length.pl »
1 package mb;
2 0 ▶'有朋自遠方来不亦楽乎'=~/^\xE6\x9C\x89/ or die "Perl script '@{[__FILE__]}' must be UTF-8 encoding.\n";
Branch: 1 branch
BranchTrueFalseTotal
"\346\234\211\346\234\213\350\207\252\351\201\240\346\226\271\346\235\245\344\270\215\344\272\246\346\245\275\344\271\216" =~ /^\xE6\x9C\x89/ or die "Perl script '@{[__FILE__];}' must be UTF-8 encoding.\n" 181 0 181
3 # You are welcome! MOJIBAKE-san, you are our friend forever!!
4 ######################################################################
5 #
6 # mb - Can easy script in Big5, Big5-HKSCS, GBK, Sjis(also CP932), UHC, UTF-8, ...
7 #
8 # https://metacpan.org/release/mb
9 #
10 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2026 INABA Hitoshi <ina.cpan@gmail.com> in a CPAN
11 ######################################################################
12  
13 202 ▶use 5.00503; # Universal Consensus 1998 for primetools
Subroutine BEGIN: called CC=1 SCAR=0.0
14 # use 5.008001; # Lancaster Consensus 2013 for toolchains
15  
16 181 $VERSION = '0.67';
17 181 $VERSION = $VERSION;
18  
19 # internal use
20 181 $mb::last_s_passed = 0; # last s/// status (1 if s/// passed)
21  
22 # filehandle sequence counter for _open_a/_open_r/_open_w
23 181 $mb::_fh_seq = 0;
24  
25 202 ▶BEGIN { pop @INC if $INC[-1] eq '.' } # CVE-2016-1238: Important unsafe module load path flaw
Subroutine BEGIN: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 190 3 193
26 202 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 201 ▶BEGIN { if ($] < 5.006 && !defined(&warnings::import)) { $INC{'warnings.pm'} = 'stub'; eval 'package warnings; sub import {}' } } use warnings; local $^W=1;
Subroutine BEGIN: called CC=3 SCAR=11.4
Subroutine BEGIN: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.006" and not defined &warnings::import) 0 193 193
Condition33%1/3
$] < "5.006" and not defined &warnings::import
!ll&&!rl&&r
18700
MC/DC0%0/2
$] < "5.006" and not defined &warnings::import
$] < "5.006" not defined &warnings::import
Truth table33%1/3
A and not(B)
A= $] < "5.006"B= not defined &warnings::import
ABresult
0X0
100
111
28  
29 # set OSNAME
30 181 my $OSNAME = $^O;
31  
32 # encoding name of operating system
33 181 my $system_encoding = undef;
34  
35 # encoding name of MBCS script
36 181 my $script_encoding = undef;
37  
38 # over US-ASCII
39 181 my $over_ascii = undef;
40  
41 # supports qr/./ in MBCS script
42 181 my $x = undef;
43  
44 # supports [\b] \d \h \s \v \w in MBCS script
45 181 my $bare_backspace = '\x08';
46 181 my $bare_d = '0123456789';
47 181 my $bare_h = '\x09\x20';
48 181 my $bare_s = '\t\n\f\r\x20';
49 181 my $bare_v = '\x0A\x0B\x0C\x0D';
50 181 my $bare_w = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';
51  
52 # as many escapes as possible to avoid perl's feature
53 181 my $escapee_in_qq_like = join('', map {"\\$_"} grep( ! /[A-Za-z0-9_]/, map { CORE::chr } 0x21..0x7E));
54  
55 # as less escapes as possible to avoid over-escaping
56 181 my $escapee_in_q__like = '\\' . "\x5C";
57  
58 # generic linebreak
59 181 my $R = '(?>\\r\\n|\\r|\\n)';
60  
61 # check running perl interpreter
62 181 ▶if ($^X =~ /jperl/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^X =~ /jperl/i) 0 181 181
63 0 die "script '@{[__FILE__]}' can run on only perl, not JPerl\n";
64 }
65  
66 # this file is used as command on command line
67 181 ▶if ($0 eq __FILE__) {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 eq __FILE__) 0 181 181
68  
69 # register this modulino in %INC so that a "use mb;" / "require mb" inside an
70 # in-process transpiled script (see sub main) is satisfied by the already
71 # loaded modulino instead of reloading mb.pm (which would emit a flood of
72 # "Subroutine ... redefined" warnings). This mirrors the child-interpreter
73 # path, where -Mmb=ver,enc already populates $INC{'mb.pm'}.
74 0 ▶ $INC{'mb.pm'} = __FILE__ if not exists $INC{'mb.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $INC{"mb.pm"} 0 0 0
75  
76 0 main();
77 }
78  
79 ######################################################################
80 # main program
81 ######################################################################
82  
83 #---------------------------------------------------------------------
84 # running as module, runtime routines
85 170 ▶sub import {
Subroutine import: called CC=14 SCAR=36.2
86 170 ▶ my $self = shift @_;
Subroutine import: called CC=14 SCAR=36.2
87  
88 # confirm version
89 170 ▶ if (defined($_[0]) and ($_[0] =~ /\A [0-9] /xms)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_[0] and $_[0] =~ /\A [0-9] /msx) 6 167 173
if (defined $_[0] and $_[0] =~ /\A [0-9] /msx) 0 0 0
Condition33%2/6
defined $_[0] and $_[0] =~ /\A [0-9] /msx
!ll&&!rl&&r
118490
defined $_[0] and $_[0] =~ /\A [0-9] /msx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0] and $_[0] =~ /\A [0-9] /msx
defined $_[0] $_[0] =~ /\A [0-9] /msx
MC/DC0%0/2
defined $_[0] and $_[0] =~ /\A [0-9] /msx
defined $_[0] $_[0] =~ /\A [0-9] /msx
Truth table66%2/3
A and B
A= defined $_[0]B= $_[0] =~ /\A [0-9] /msx
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[0]B= $_[0] =~ /\A [0-9] /msx
ABresult
0X0
100
111
90 3 ▶ if ($_[0] ne $mb::VERSION) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_[0] ne $mb::VERSION) 0 0 0
if ($_[0] ne $mb::VERSION) 0 0 0
91 3 my($package, $filename, $line) = caller;
92 0 die "$filename requires @{[__PACKAGE__]} $_[0], however @{[__FILE__]} am only $mb::VERSION, stopped at $filename line $line.\n";
93 }
94 0 shift @_;
95 }
96  
97 # scan import arguments
98 0 my $want_runtime = 0; # *mb or %mb requested -> runtime interface, no filter
99 0 my $encoding = undef;
100 0 for my $arg (@_) {
101 0 ▶ if (($arg eq '*mb') or ($arg eq '%mb')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($arg eq '*mb' or $arg eq '%mb') { } 3 46 49
elsif ($arg =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 34 12 46
if ($arg eq '*mb' or $arg eq '%mb') { } 0 0 0
elsif ($arg =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 0 0 0
Condition50%3/6
$arg eq "*mb" or $arg eq "%mb"
l!l&&r!l&&!r
2146
$arg eq "*mb" or $arg eq "%mb"
l!l&&r!l&&!r
000
MC/DC100%2/2
$arg eq "*mb" or $arg eq "%mb"
$arg eq "*mb" $arg eq "%mb"
MC/DC0%0/2
$arg eq "*mb" or $arg eq "%mb"
$arg eq "*mb" $arg eq "%mb"
Truth table100%3/3
A or B
A= $arg eq "*mb"B= $arg eq "%mb"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $arg eq "*mb"B= $arg eq "%mb"
ABresult
1X1
011
000
102 0 $want_runtime = 1;
103 }
104 elsif ($arg =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/xms) {
105 0 $encoding = $arg;
106 }
107 else {
108 0 die "@{[__FILE__]} import argument '$arg' not supported (use one of: *mb, %mb, big5, big5hkscs, eucjp, euctw, gb18030, gbk, hp15, informixv6als, johab, rfc2279, sjis, uhc, utf8, wtf8).\n";
109 }
110 }
111  
112 # set system encoding
113 0 $system_encoding = detect_system_encoding();
114  
115 # set script encoding
116 0 ▶ if (defined $encoding) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $encoding) { } 34 121 155
if (defined $encoding) { } 0 0 0
117 0 mb::set_script_encoding($encoding);
118 }
119 else {
120 0 mb::set_script_encoding($system_encoding);
121 }
122  
123 # tie my %mb, __PACKAGE__; # makes: Parentheses missing around "my" list
124 196 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
125 0 tie my %mb, 'mb';
126 0 *{caller().'::mb'} = { %mb };
127  
128 # $^X($EXECUTABLE_NAME) for execute MBCS Perl script
129 0 $mb::PERL = qq{$^X @{[__FILE__]}};
130 0 $mb::PERL = $mb::PERL; # to avoid: Name "mb::PERL" used only once: possible typo at ...
131  
132 # original $0($PROGRAM_NAME) before transpile
133 0 ($mb::ORIG_PROGRAM_NAME = $0) =~ s/\.oo(\.[^.]+)\z/$1/;
134 0 $mb::ORIG_PROGRAM_NAME = $mb::ORIG_PROGRAM_NAME; # to avoid: Name "mb::ORIG_PROGRAM_NAME" used only once: possible typo at ...
135  
136 # Sjis software compatible subroutines
137 0 my $old_package = mb::get_old_package();
138 0 for my $subroutine (qw( chop chr do dosglob eval getc index index_byte length ord require reverse rindex rindex_byte substr tr )) {
139 0 *{$old_package . $subroutine} = \&{"mb::$subroutine"};
140 }
141  
142 # path 1: opportunistic source code filter
143 #
144 # Installed for "use mb;" style loading (no *mb/%mb token) and not when
145 # running an already transpiled *.oo script through -Mmb=ver,enc (the
146 # modulino sets PERL_MB_OCTET in that case, see sub main).
147 #
148 # ADDITIVE GUARD (zero regression): a script that calls
149 # mb::set_script_encoding() itself is, by construction, an octet-oriented
150 # / runtime-managed script (this is mb's long-standing "use mb; then call
151 # mb::* functions on octet data" convention, used throughout t/*.t). Such
152 # a script must NOT have its own source transpiled, so the filter passes it
153 # through unchanged. Only a genuine path-1 script -- one that does not
154 # manage the encoding at run time -- is auto-transpiled. This keeps every
155 # pre-existing "use mb;" caller behaving exactly as before (it was never
156 # source-filtered, because no filter existed in mb-0.63) while still letting
157 # a plain "use mb;" / "use mb 'utf8';" script be transpiled with no modulino.
158 #
159 # Filter::Util::Call has been a core module since perl 5.8.0; it is only
160 # require()d at run time, so no extra dependency is declared. On perl
161 # 5.005_03 / 5.6 the filter is unavailable and "use mb;" loads as a plain
162 # runtime import (the modulino remains the way to transpile there).
163 0 ▶ if ((not $want_runtime) and (not $ENV{'PERL_MB_OCTET'}) and ($] >= 5.008)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008") 137 18 155
if (not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008") 0 0 0
Condition41%5/12
not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008"
!ll&&!rl&&r
180137
$want_runtime || $ENV{'PERL_MB_OCTET'}
l!l&&r!l&&!r
315137
not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008"
!ll&&!rl&&r
000
$want_runtime || $ENV{'PERL_MB_OCTET'}
l!l&&r!l&&!r
000
MC/DC66%2/3
not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008"
$want_runtime $ENV{'PERL_MB_OCTET'} $] >= "5.008"
MC/DC0%0/3
not $want_runtime || $ENV{"PERL_MB_OCTET"} and $] >= "5.008"
$want_runtime $ENV{'PERL_MB_OCTET'} $] >= "5.008"
Truth table75%3/4
not(A || B) and C
A= $want_runtimeB= $ENV{'PERL_MB_OCTET'}C= $] >= "5.008"
ABCresult
1XX0
01X0
0000
0011
Truth table0%0/4
not(A || B) and C
A= $want_runtimeB= $ENV{'PERL_MB_OCTET'}C= $] >= "5.008"
ABCresult
1XX0
01X0
0000
0011
164 0 ▶ if (eval { require Filter::Util::Call; 1 }) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { require Filter::Util::Call; 1 } }) 137 0 137
if (eval { do { require Filter::Util::Call; 1 } }) 0 0 0
165 0 my $done = 0;
166 169 ▶ Filter::Util::Call::filter_add(sub {
Subroutine __ANON__: called CC=5 SCAR=21.5
167 0 ▶ return 0 if $done;
Subroutine __ANON__: called CC=5 SCAR=21.5
Branch: 2 branches
BranchTrueFalseTotal
if $done 29 137 166
if $done 0 0 0
168 0 my $buffer = '';
169 0 my $status = 0;
170 0 ▶ while (($status = Filter::Util::Call::filter_read()) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (($status = &Filter::Util::Call::filter_read()) > 0) 39468 137 39605
if (($status = Filter::Util::Call::filter_read()) > 0) 0 0 0
171 0 $buffer .= $_;
172 0 $_ = '';
173 }
174 0 ▶ if ($status == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($status == 0) 137 0 137
if ($status == 0) 0 0 0
175  
176 # runtime-managed (octet-oriented) script: pass through as is
177 0 ▶ if ($buffer =~ /\b mb::set_script_encoding \s* \(/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($buffer =~ /\b mb::set_script_encoding \s* \(/msx) { } 116 21 137
if ($buffer =~ /\b mb::set_script_encoding \s* \(/msx) { } 0 0 0
178 0 $_ = $buffer;
179 }
180 else {
181 0 $_ = mb::_insert_source_encoding_unimport(mb::parse($buffer));
182 }
183 0 $done = 1;
184 0 return 1;
185 }
186 0 return $status;
187 0 });
188 }
189 }
190 }
191  
192 #---------------------------------------------------------------------
193 # running as command
194 27 ▶sub main {
Subroutine main: called CC=26 SCAR=46.0
Pod undocumented
195  
196 # usage
197 0 ▶ if (scalar(@ARGV) == 0) {
Subroutine main: not called CC=26 SCAR=46.0
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @ARGV == 0) 0 24 24
if (scalar @ARGV == 0) 0 0 0
198 0 die <<END;
199 usage:
200  
201 perl mb.pm script_by_mbcs.pl (auto detect)
202 perl mb.pm -e big5 script_by_big5.pl
203 perl mb.pm -e big5hkscs script_by_big5hkscs.pl
204 perl mb.pm -e eucjp script_by_eucjp.pl
205 perl mb.pm -e euctw script_by_euctw.pl
206 perl mb.pm -e gb18030 script_by_gb18030.pl
207 perl mb.pm -e gbk script_by_gbk.pl
208 perl mb.pm -e hp15 script_by_hp15.pl
209 perl mb.pm -e informixv6als script_by_informixv6als.pl
210 perl mb.pm -e johab script_by_johab.pl
211 perl mb.pm -e rfc2279 script_by_rfc2279.pl
212 perl mb.pm -e sjis script_by_sjis.pl
213 perl mb.pm -e sjis script_by_cp932.pl
214 perl mb.pm -e uhc script_by_uhc.pl
215 perl mb.pm -e utf8 script_by_utf8.pl
216 perl mb.pm -e wtf8 script_by_wtf8.pl
217  
218 perl mb.pm script.pl ??-DOS-like *wildcard* available
219  
220 END
221 }
222  
223 # set system encoding
224 0 $system_encoding = detect_system_encoding();
225  
226 # set script encoding from command line
227 0 my $encoding = '';
228 0 ▶ if (($encoding) = $ARGV[0] =~ /\A -e ( .+ ) \z/xms) {
Branch: 4 branches
BranchTrueFalseTotal
if (($encoding) = $ARGV[0] =~ /\A -e ( .+ ) \z/msx) { } 14 10 24
elsif ($ARGV[0] =~ /\A -e \z/msx) { } 10 0 10
if (($encoding) = $ARGV[0] =~ /\A -e ( .+ ) \z/msx) { } 0 0 0
elsif ($ARGV[0] =~ /\A -e \z/msx) { } 0 0 0
229 0 ▶ if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 0 14 14
if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 0 0 0
230 0 mb::set_script_encoding($encoding);
231 0 shift @ARGV;
232 }
233 else {
234 0 die "script_encoding '$encoding' not supported (use one of: big5, big5hkscs, eucjp, euctw, gb18030, gbk, hp15, informixv6als, johab, rfc2279, sjis, uhc, utf8, wtf8).\n";
235 }
236 }
237 elsif ($ARGV[0] =~ /\A -e \z/xms) {
238 0 $encoding = $ARGV[1];
239 0 ▶ if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 6 4 10
if ($encoding =~ /\A (?: big5 | big5hkscs | eucjp | euctw | gb18030 | gbk | hp15 | informixv6als | johab | rfc2279 | sjis | uhc | utf8 | wtf8 ) \z/msx) { } 0 0 0
240 0 mb::set_script_encoding($encoding);
241 0 shift @ARGV;
242 0 shift @ARGV;
243 }
244 else {
245 0 die "script_encoding '$encoding' not supported (use one of: big5, big5hkscs, eucjp, euctw, gb18030, gbk, hp15, informixv6als, johab, rfc2279, sjis, uhc, utf8, wtf8).\n";
246 }
247 }
248 else {
249 0 mb::set_script_encoding($system_encoding);
250 }
251  
252 # remember the target script name and read its source once
253 0 my $script = $ARGV[0];
254  
255 # read application script
256 0 ▶ my $rfh = mb::_open_r($script) or die "$0(@{[__LINE__]}): can't open file: $script\n";
Branch: 2 branches
BranchTrueFalseTotal
my $rfh = &_open_r($script) or die "$0(@{[__LINE__];}): can't open file: $script\n" 6 0 6
my $rfh = &_open_r($script) or die "$0(@{[__LINE__];}): can't open file: $script\n" 0 0 0
257  
258 # sysread(...) has hidden binmode($fh) that's not portable
259 # local $_; sysread($fh, $_, -s $ARGV[0]);
260 0 ▶ local $_ = CORE::do { local $/; no strict 'refs'; readline(*{$rfh}) };
Subroutine BEGIN: called CC=1 SCAR=0.5
261 0 ▶ { no strict 'refs'; close($rfh) }
Subroutine BEGIN: called CC=1 SCAR=0.2
262 0 my $source = $_;
263  
264 # @ARGV wildcard globbing
265 0 ▶ if ($OSNAME =~ /MSWin32/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/) 0 6 6
if ($OSNAME =~ /MSWin32/) 0 0 0
266 0 my @argv = ();
267 0 for (@ARGV) {
268  
269 # has space
270 0 ▶ if (/\A (?:$x)*? [ ] /xms) {
Branch: 4 branches
BranchTrueFalseTotal
if (/\A (?:$x)*? [ ] /msx) { } 0 0 0
elsif (/\A (?:$x)*? [*?] /msx) { } 0 0 0
if (/\A (?:$x)*? [ ] /msx) { } 0 0 0
elsif (/\A (?:$x)*? [*?] /msx) { } 0 0 0
271 0 ▶ if (my @glob = mb::dosglob(qq{"$_"})) {
Branch: 2 branches
BranchTrueFalseTotal
if (my(@glob) = &dosglob(qq["$_"])) { } 0 0 0
if (my(@glob) = &dosglob(qq["$_"])) { } 0 0 0
272 0 push @argv, @glob;
273 }
274 else {
275 0 push @argv, $_;
276 }
277 }
278  
279 # has wildcard metachar
280 elsif (/\A (?:$x)*? [*?] /xms) {
281 0 ▶ if (my @glob = mb::dosglob($_)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my(@glob) = &dosglob($_)) { } 0 0 0
if (my(@glob) = &dosglob($_)) { } 0 0 0
282 0 push @argv, @glob;
283 }
284 else {
285 0 push @argv, $_;
286 }
287 }
288  
289 # no wildcard globbing
290 else {
291 0 push @argv, $_;
292 }
293 }
294 0 @ARGV = @argv;
295 }
296  
297 # Strategy for <DATA>:
298 # - no __DATA__/__END__ : transpile and run in-process by CORE::eval
299 # (no temporary file is created)
300 # - has __DATA__/__END__: a string eval cannot provide a working <DATA>
301 # handle, so write a *.oo script and run it as a
302 # real file through a child interpreter.
303 0 ▶ if ($source =~ /^__(?:END|DATA)__\b/m) {
Branch: 2 branches
BranchTrueFalseTotal
if ($source =~ /^__(?:END|DATA)__\b/m) { } 2 4 6
if ($source =~ /^__(?:END|DATA)__\b/m) { } 0 0 0
304  
305 # poor "make": (re)transpile to *.oo only when stale
306 0 (my $script_oo = $script) =~ s{\A (.*) \. ([^.]+) \z}{$1.oo.$2}xms;
307 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)) 1 1 2
if (not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)) 0 0 0
Condition33%4/12
not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)
l!l&&r!l&&!r
101
not -e $script_oo or mtime($script_oo) <= mtime($script)
l!l&&r!l&&!r
101
not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)
l!l&&r!l&&!r
000
not -e $script_oo or mtime($script_oo) <= mtime($script)
l!l&&r!l&&!r
000
MC/DC33%1/3
not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)
not -e $script_oo mtime($script_oo) <= mtime($script) mtime($script_oo) <= mtime(__FILE__)
MC/DC0%0/3
not -e $script_oo or mtime($script_oo) <= mtime($script) or mtime($script_oo) <= mtime(__FILE__)
not -e $script_oo mtime($script_oo) <= mtime($script) mtime($script_oo) <= mtime(__FILE__)
Truth table50%2/4
not(A) or B or C
A= not -e $script_ooB= mtime($script_oo) <= mtime($script)C= mtime($script_oo) <= mtime(__FILE__)
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
not(A) or B or C
A= not -e $script_ooB= mtime($script_oo) <= mtime($script)C= mtime($script_oo) <= mtime(__FILE__)
ABCresult
1XX1
01X1
0011
0000
308 (not -e $script_oo) or
309 (mtime($script_oo) <= mtime($script)) or
310 (mtime($script_oo) <= mtime(__FILE__))
311 ) {
312  
313 # poor file locking
314 0 ▶ local $SIG{__DIE__} = sub { rmdir "$script.lock"; };
Subroutine __ANON__: called CC=1 SCAR=0.4
315 0 ▶ if (mkdir "$script.lock", 0755) {
Branch: 2 branches
BranchTrueFalseTotal
if (mkdir "$script.lock", 493) { } 1 0 1
if (mkdir "$script.lock", 493) { } 0 0 0
316 0 ▶ my $wfh = mb::_open_w($script_oo) or die "$0(@{[__LINE__]}): can't open file: $script_oo\n";
Branch: 2 branches
BranchTrueFalseTotal
my $wfh = &_open_w($script_oo) or die "$0(@{[__LINE__];}): can't open file: $script_oo\n" 1 0 1
my $wfh = &_open_w($script_oo) or die "$0(@{[__LINE__];}): can't open file: $script_oo\n" 0 0 0
317 0 ▶ { no strict 'refs'; print {*{$wfh}} mb::_insert_source_encoding_unimport(mb::parse($source)) }
Subroutine BEGIN: called CC=1 SCAR=0.4
318 0 ▶ { no strict 'refs'; close($wfh) }
Subroutine BEGIN: called CC=1 SCAR=0.4
319 4 rmdir "$script.lock";
320 }
321 else {
322 3 die "$0(@{[__LINE__]}): can't mkdir: $script.lock\n";
323 }
324 }
325  
326 # locate this module for the child interpreter
327 5 my $module_path = '';
328 5 my $module_name = '';
329 5 my $quote = '';
330 5 ▶ if ($OSNAME =~ /MSWin32/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/) { } 0 2 2
331 3 ▶ if ($0 =~ m{ ([^\/\\]+)\.pm \z}xmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 =~ m( ([^\/\\]+)\.pm \z)imsx) { } 0 0 0
332 3 ($module_path, $module_name) = ($`, $1);
333 3 ▶ $module_path ||= '.';
Condition0%0/4
$module_path ||= "."
l!l
00
$module_path ||= "."
l!l
00
MC/DC0%0/1
$module_path ||= "."
$module_path
MC/DC0%0/1
$module_path ||= "."
$module_path
Truth table0%0/2
A
A= $module_path
Aresult
11
00
Truth table0%0/2
A
A= $module_path
Aresult
11
00
334 3 $module_path =~ s{ [\/\\] \z}{}xms;
335 }
336 else {
337 3 die "$0(@{[__LINE__]}): can't run as module.\n";
338 }
339 3 $quote = q{"};
340 }
341 else {
342 5 ▶ if ($0 =~ m{ ([^\/]+)\.pm \z}xmsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 =~ m[ ([^\/]+)\.pm \z]imsx) { } 2 0 2
343 5 ($module_path, $module_name) = ($`, $1);
344 5 ▶ $module_path ||= '.';
Condition25%1/4
$module_path ||= "."
l!l
20
$module_path ||= "."
l!l
00
MC/DC0%0/1
$module_path ||= "."
$module_path
MC/DC0%0/1
$module_path ||= "."
$module_path
Truth table50%1/2
A
A= $module_path
Aresult
11
00
Truth table0%0/2
A
A= $module_path
Aresult
11
00
345 5 $module_path =~ s{ / \z}{}xms;
346 }
347 else {
348 3 die "$0(@{[__LINE__]}): can't run as module.\n";
349 }
350 5 $quote = q{'};
351 }
352  
353 # run octet-oriented script
354 # PERL_MB_OCTET tells the child interpreter (which loads -Mmb=ver,enc) not
355 # to install the path-1 source filter on the already transpiled *.oo script.
356 5 $| = 1;
357 5 local $ENV{'PERL_MB_OCTET'} = 1;
358 5 ▶ system($^X, "-I$module_path", "-M$module_name=$mb::VERSION,$script_encoding", map { / / ? "$quote$_$quote" : $_ } $script_oo, @ARGV[1..$#ARGV]);
Branch: 1 branch
BranchTrueFalseTotal
/ / ? : 0 2 2
359 5 exit($? >> 8);
360 }
361 else {
362  
363 # transpile and run in-process (no temporary file is created)
364 7 my $transpiled = mb::_insert_source_encoding_unimport(mb::parse($source));
365  
366 # make the script see its own name and its own arguments
367 7 local $0 = $script;
368 7 local @ARGV = @ARGV[1..$#ARGV];
369  
370 # escape the file name for the #line directive so error messages
371 # point back at the original script with correct line numbers
372 7 (my $filename = $script) =~ s/([\\"])/\\$1/g;
373 7 my $code = "package main;\n#line 1 \"$filename\"\n" . $transpiled;
374  
375 # PERL_MB_OCTET keeps any "use mb ..." inside the transpiled source from
376 # re-installing the path-1 source filter (which would transpile twice).
377 7 $| = 1;
378 7 local $ENV{'PERL_MB_OCTET'} = 1;
379 7 CORE::eval $code;
380 7 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 3 4
381 4 print STDERR $@;
382 4 exit 1;
383 }
384 6 exit 0;
385 }
386 }
387  
388 #---------------------------------------------------------------------
389 # cluck() for MBCS encoding
390 3 ▶sub cluck {
Subroutine cluck: called CC=2 SCAR=7.1
Pod undocumented
391 3 my $i = 0;
392 3 my @cluck = ();
393 3 ▶ while (my($package, $filename, $line, $subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
394 3 push @cluck, "[$i] $filename($line) $subroutine\n";
395 3 $i++;
396 }
397 3 print STDERR "\n", @_, "\n";
398 3 print STDERR CORE::reverse @cluck;
399 }
400  
401 #---------------------------------------------------------------------
402 # confess() for MBCS encoding
403 3 ▶sub confess {
Subroutine confess: called CC=2 SCAR=7.1
Pod undocumented
404 3 my $i = 0;
405 3 my @confess = ();
406 3 ▶ while (my($package, $filename, $line, $subroutine) = caller($i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = caller $i) 0 0 0
407 3 push @confess, "[$i] $filename($line) $subroutine\n";
408 3 $i++;
409 }
410 3 print STDERR "\n", @_, "\n";
411 3 print STDERR CORE::reverse @confess;
412 3 die;
413 }
414  
415 #---------------------------------------------------------------------
416 # short cut of (stat(file))[9]
417 7 ▶sub mtime {
Subroutine mtime: called CC=1 SCAR=0.0
Pod undocumented
418 7 my($file) = @_;
419 7 return ((stat $file)[9]);
420 }
421  
422 ######################################################################
423 # subroutines for MBCS application programmers
424 ######################################################################
425  
426 #---------------------------------------------------------------------
427 # chop() for MBCS encoding
428 51 ▶sub mb::chop (@) {
Subroutine chop: called CC=4 SCAR=13.9
Pod undocumented
429 51 my $chop = '';
430 51 ▶ for (@_ ? @_ : $_) {
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 42 6 48
431 59 ▶ if (my @x = /\G$x/g) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@x) = /\G$x/g) 50 6 56
432 53 $chop = pop @x;
433 53 $_ = join '', @x;
434 }
435 }
436 51 return $chop;
437 }
438  
439 #---------------------------------------------------------------------
440 # chr() for MBCS encoding
441 38 ▶sub mb::chr (;$) {
Subroutine chr: called CC=3 SCAR=11.0
Pod undocumented
442 38 ▶ my $number = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 31 4 35
443  
444 # Negative values give the Unicode replacement character (chr(0xfffd)),
445 # except under the bytes pragma, where the low eight bits of the value
446 # (truncated to an integer) are used.
447  
448 38 my @octet = ();
449 38 ▶ CORE::do {
Branch: 1 branch
BranchTrueFalseTotal
$number > 0 and do { do { unshift @octet, $number % 256; $number = int $number / 256 } } 4 35 39
450 42 unshift @octet, ($number % 0x100);
451 42 $number = int($number / 0x100);
452 } while ($number > 0);
453 38 return pack 'C*', @octet;
454 }
455  
456 #---------------------------------------------------------------------
457 # do FILE for MBCS encoding
458 8 ▶sub mb::do ($) {
Subroutine do: called CC=9 SCAR=22.3
Pod undocumented
459 8 my($file) = @_;
460 8 for my $prefix_file ($file, map { "$_/$file" } @INC) {
461 8 ▶ if (-f $prefix_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $prefix_file) 5 0 5
462  
463 # poor "make"
464 8 (my $prefix_file_oo = $prefix_file) =~ s{\A (.*) \. ([^.]+) \z}{$1.oo.$2}xms;
465 8 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)) 5 0 5
Condition33%2/6
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)
l!l&&r!l&&!r
500
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file)
l!l&&r!l&&!r
500
MC/DC0%0/3
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)
not -e $prefix_file_oo mtime($prefix_file_oo) <= mtime($prefix_file) mtime($prefix_file_oo) <= mtime(__FILE__)
Truth table25%1/4
not(A) or B or C
A= not -e $prefix_file_ooB= mtime($prefix_file_oo) <= mtime($prefix_file)C= mtime($prefix_file_oo) <= mtime(__FILE__)
ABCresult
1XX1
01X1
0011
0000
466 (not -e $prefix_file_oo) or
467 (mtime($prefix_file_oo) <= mtime($prefix_file)) or
468 (mtime($prefix_file_oo) <= mtime(__FILE__))
469 ) {
470 8 ▶ my $fh = mb::_open_r($prefix_file) or confess "$0(@{[__LINE__]}): can't open file: $prefix_file\n";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = &_open_r($prefix_file) or confess("$0(@{[__LINE__];}): can't open file: $prefix_file\n") 5 0 5
471 196 ▶ local $_ = CORE::do { local $/; no strict 'refs'; readline(*{$fh}) };
Subroutine BEGIN: called CC=1 SCAR=0.0
472 190 ▶ { no strict 'refs'; close($fh) }
Subroutine BEGIN: called CC=1 SCAR=0.0
473  
474 # poor file locking
475 8 ▶ local $SIG{__DIE__} = sub { rmdir "$prefix_file.lock"; };
Subroutine __ANON__: called CC=1 SCAR=0.0
476 8 ▶ if (mkdir "$prefix_file.lock", 0755) {
Branch: 1 branch
BranchTrueFalseTotal
if (mkdir "$prefix_file.lock", 493) { } 5 0 5
477 8 ▶ my $fh = mb::_open_w($prefix_file_oo) or confess "$0(@{[__LINE__]}): can't open file: $prefix_file_oo\n";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = &_open_w($prefix_file_oo) or confess("$0(@{[__LINE__];}): can't open file: $prefix_file_oo\n") 5 0 5
478 190 ▶ { no strict 'refs'; print {*{$fh}} mb::_insert_source_encoding_unimport(mb::parse()) }
Subroutine BEGIN: called CC=1 SCAR=0.0
479 190 ▶ { no strict 'refs'; close($fh) }
Subroutine BEGIN: called CC=1 SCAR=0.0
480 8 rmdir "$prefix_file.lock";
481 }
482 else {
483 3 confess "$0(@{[__LINE__]}): can't mkdir: $prefix_file.lock\n";
484 }
485 }
486 8 $INC{$file} = $prefix_file_oo;
487  
488 # run as Perl script
489 # must use CORE::do to use <DATA>, because CORE::eval cannot do it
490 # moreover "goto &CORE::do" doesn't work
491 8 return CORE::eval sprintf(<<'END', (caller)[0,2,1]);
492 package %s;
493 #line %s "%s"
494 CORE::do "$prefix_file_oo";
495 END
496 }
497 }
498 3 confess "Can't find $file in \@INC";
499 }
500  
501 #---------------------------------------------------------------------
502 # DOS-like glob() for MBCS encoding
503 11 ▶sub mb::dosglob (;$) {
Subroutine dosglob: called CC=13 SCAR=33.1
Pod undocumented
504 11 ▶ my $expr = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 0 8
505 11 my @glob = ();
506  
507 # works on not MSWin32
508 11 ▶ if ($OSNAME !~ /MSWin32/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $OSNAME =~ /MSWin32/) { } 8 0 8
509 190 ▶ @glob = CORE::glob($expr);
Subroutine BEGIN: called CC=1 SCAR=0.0
510 }
511  
512 # works on MSWin32
513 else {
514  
515 # gets pattern
516 3 ▶ while ($expr =~ s{\A [\x20]* ( "(?:$x)+?" | (?:(?!["\x20])$x)+ ) }{}xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr =~ s/\A [\x20]* ( "(?:$x)+?" | (?:(?!["\x20])$x)+ ) //msx) 0 0 0
517 3 my $pattern = $1;
518  
519 # avoids command injection
520 3 ▶ next if $pattern =~ /\G${mb::_anchor} \& /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \& /msx 0 0 0
521 3 ▶ next if $pattern =~ /\G${mb::_anchor} \( /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \( /msx 0 0 0
522 3 ▶ next if $pattern =~ /\G${mb::_anchor} \) /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \) /msx 0 0 0
523 3 ▶ next if $pattern =~ /\G${mb::_anchor} \< /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \< /msx 0 0 0
524 3 ▶ next if $pattern =~ /\G${mb::_anchor} \> /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \> /msx 0 0 0
525 3 ▶ next if $pattern =~ /\G${mb::_anchor} \^ /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \^ /msx 0 0 0
526 3 ▶ next if $pattern =~ /\G${mb::_anchor} \| /xms;
Branch: 1 branch
BranchTrueFalseTotal
if $pattern =~ /\G$mb::_anchor \| /msx 0 0 0
527  
528 # makes globbing result
529 3 mb::tr($pattern, '/', "\x5C");
530 3 ▶ if (my($dir) = $pattern =~ m{\A ($x*) \\ }xms) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($dir) = $pattern =~ /\A ($x*) \\ /msx) { } 0 0 0
531 3 push @glob, map { "$dir\\$_" } CORE::split /\n/, `DIR /B $pattern 2>NUL`;
532 }
533 else {
534 3 push @glob, CORE::split /\n/, `DIR /B $pattern 2>NUL`;
535 }
536 }
537 }
538  
539 # returns globbing result
540 11 my %glob = map { $_ => 1 } @glob;
541 11 ▶ return sort { (mb::uc($a) cmp mb::uc($b)) || ($a cmp $b) } keys %glob;
Condition33%1/3
&mb::uc($a) cmp &mb::uc($b) || $a cmp $b
l!l&&r!l&&!r
2200
MC/DC0%0/2
&mb::uc($a) cmp &mb::uc($b) || $a cmp $b
&mb::uc($a) cmp &mb::uc($b) $a cmp $b
Truth table33%1/3
A || B
A= &mb::uc($a) cmp &mb::uc($b)B= $a cmp $b
ABresult
1X1
011
000
542 }
543  
544 #---------------------------------------------------------------------
545 # eval STRING for MBCS encoding
546 6868 ▶sub mb::eval (;$) {
Subroutine eval: called CC=4 SCAR=13.9
Pod undocumented
547 6868 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6845 20 6865
548  
549 # Perl 5.44 feature 'enhanced_xx' enabled at the caller is inherited by
550 # the string, as CORE::eval does (perl 5.10 and later have the hint hash
551 # at (caller(0))[10]; it is undef on older perl)
552 6868 my $parsed;
553 {
554 6868 my $hinthash = (caller(0))[10];
555 local $mb::_enhanced_xx_inherited =
556 6868 ▶ ((ref($hinthash) eq 'HASH') and $hinthash->{'feature_enhanced_xx'}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $hinthash eq 'HASH' && $hinthash->{'feature_enhanced_xx'} ? : 1 6864 6865
Condition66%2/3
ref $hinthash eq "HASH" and $hinthash->{"feature_enhanced_xx"}
!ll&&!rl&&r
686401
MC/DC50%1/2
ref $hinthash eq "HASH" and $hinthash->{"feature_enhanced_xx"}
ref $hinthash eq "HASH" $hinthash->{"feature_enhanced_xx"}
Truth table66%2/3
A and B
A= ref $hinthash eq "HASH"B= $hinthash->{"feature_enhanced_xx"}
ABresult
0X0
100
111
557 6868 $parsed = mb::parse();
558 }
559  
560 # run as Perl script in caller package
561 6868 return CORE::eval sprintf(<<'END', (caller)[0,2,1], $parsed);
562 package %s;
563 #line %s "%s"
564 %s
565 END
566 }
567  
568 #---------------------------------------------------------------------
569 # getc() for MBCS encoding
570 166 ▶sub mb::getc (;*) {
Subroutine getc: called CC=52 SCAR=39.5
Pod undocumented
571 166 ▶ my $fh = @_ ? shift(@_) : \*STDIN;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 162 1 163
572 166 ▶ confess 'Too many arguments for mb::getc' if @_ and not wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if @_ and not wantarray 0 163 163
Condition33%1/3
@_ and not wantarray
!ll&&!rl&&r
16300
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
573 166 my $getc = CORE::getc $fh;
574 166 ▶ return wantarray ? ($getc,@_) : $getc if not defined $getc;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $getc 38 125 163
wantarray ? : 0 38 38
575 128 ▶ if ($script_encoding =~ /\A (?: sjis ) \z/xms) {
Branch: 9 branches
BranchTrueFalseTotal
if ($script_encoding =~ /\A (?: sjis ) \z/msx) { } 42 83 125
elsif ($script_encoding =~ /\A (?: informixv6als ) \z/msx) { } 7 76 83
elsif ($script_encoding =~ /\A (?: hp15 ) \z/msx) { } 10 66 76
elsif ($script_encoding =~ /\A (?: johab ) \z/msx) { } 9 57 66
elsif ($script_encoding =~ /\A (?: eucjp ) \z/msx) { } 6 51 57
elsif ($script_encoding =~ /\A (?: euctw ) \z/msx) { } 8 43 51
elsif ($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs ) \z/msx) { } 24 19 43
elsif ($script_encoding =~ /\A (?: gb18030 ) \z/msx) { } 7 12 19
elsif ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/msx) { } 12 0 12
576 45 ▶ if ($getc =~ /\A [\x81-\x9F\xE0-\xFC] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\x9F\xE0-\xFC] \z/msx) 22 20 42
577 25 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 21 1 22
578 }
579 }
580 elsif ($script_encoding =~ /\A (?: informixv6als ) \z/xms) {
581 10 ▶ if ($getc =~ /\A [\x81-\x9F\xE0-\xFC] \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\x9F\xE0-\xFC] \z/msx) { } 2 5 7
elsif ($getc =~ /\A [\xFD] \z/msx) { } 3 2 5
582 5 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 1 2
583 }
584 elsif ($getc =~ /\A [\xFD] \z/xms) {
585 5 my $c;
586 5 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 2 1 3
587 3 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 2 3
588 }
589 }
590 elsif ($script_encoding =~ /\A (?: hp15 ) \z/xms) {
591 10 ▶ if ($getc =~ /\A [\x80-\xA0\xE0-\xFE] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x80-\xA0\xE0-\xFE] \z/msx) 7 3 10
592 7 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 4 3 7
593 }
594 }
595 elsif ($script_encoding =~ /\A (?: johab ) \z/xms) {
596 9 ▶ if ($getc =~ /\A [\x81-\xD3\xD8-\xDE\xE0-\xF9] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\xD3\xD8-\xDE\xE0-\xF9] \z/msx) 7 2 9
597 7 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 4 3 7
598 }
599 }
600 elsif ($script_encoding =~ /\A (?: eucjp ) \z/xms) {
601 6 ▶ if ($getc =~ /\A [\xA1-\xFE] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\xA1-\xFE] \z/msx) 4 2 6
602 4 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 3 1 4
603 }
604 }
605 elsif ($script_encoding =~ /\A (?: euctw ) \z/xms) {
606 8 ▶ if ($getc =~ /\A [\x8E] \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($getc =~ /\A [\x8E] \z/msx) { } 4 4 8
elsif ($getc =~ /\A [\xA1-\xFE] \z/msx) { } 2 2 4
607 4 my $c;
608 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 3 1 4
609 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 2 2 4
610 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 3 4
611 }
612 elsif ($getc =~ /\A [\xA1-\xFE] \z/xms) {
613 2 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 1 2
614 }
615 }
616 elsif ($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs ) \z/xms) {
617 24 ▶ if ($getc =~ /\A [\x81-\xFE] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\xFE] \z/msx) 16 8 24
618 16 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 12 4 16
619 }
620 }
621 elsif ($script_encoding =~ /\A (?: gb18030 ) \z/xms) {
622 7 ▶ if ($getc =~ /\A [\x81-\xFE] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\xFE] \z/msx) 5 2 7
623 5 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 4 1 5
624 5 ▶ if ($getc =~ /\A [\x81-\xFE] [\x30-\x39] \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getc =~ /\A [\x81-\xFE] [\x30-\x39] \z/msx) 3 2 5
625 3 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 2 1 3
626 3 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 2 3
627 }
628 }
629 }
630 elsif ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/xms) {
631 12 ▶ if ($getc =~ /\A [\x00-\x7F\x80-\xC1\xF5-\xFF] \z/xms) {
Branch: 4 branches
BranchTrueFalseTotal
if ($getc =~ /\A [\x00-\x7F\x80-\xC1\xF5-\xFF] \z/msx) { } 3 9 12
elsif ($getc =~ /\A [\xC2-\xDF] \z/msx) { } 2 7 9
elsif ($getc =~ /\A [\xE0-\xEF] \z/msx) { } 3 4 7
elsif ($getc =~ /\A [\xF0-\xF4] \z/msx) { } 4 0 4
632 }
633 elsif ($getc =~ /\A [\xC2-\xDF] \z/xms) {
634 2 ▶ my $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 1 2
635 }
636 elsif ($getc =~ /\A [\xE0-\xEF] \z/xms) {
637 3 my $c;
638 3 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 2 1 3
639 3 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 2 3
640 }
641 elsif ($getc =~ /\A [\xF0-\xF4] \z/xms) {
642 4 my $c;
643 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 3 1 4
644 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 2 2 4
645 4 ▶ $c = CORE::getc $fh; $getc .= $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 1 3 4
646 }
647 }
648 125 ▶ return wantarray ? ($getc,@_) : $getc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 124 125
649 }
650  
651 #---------------------------------------------------------------------
652 # index() for MBCS encoding
653 97 ▶sub mb::index ($$;$) {
Subroutine index: called CC=3 SCAR=11.0
Pod undocumented
654 94 my $index = 0;
655 94 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 4 90 94
656 4 $index = mb::index_byte($_[0], $_[1], CORE::length(mb::substr($_[0], 0, $_[2])));
657 }
658 else {
659 90 $index = mb::index_byte($_[0], $_[1]);
660 }
661 94 ▶ if ($index == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == -1) { } 22 72 94
662 22 return -1;
663 }
664 else {
665 72 return mb::length(CORE::substr $_[0], 0, $index);
666 }
667 }
668  
669 #---------------------------------------------------------------------
670 # JPerl like index() for MBCS encoding
671 105 ▶sub mb::index_byte ($$;$) {
Subroutine index_byte: called CC=6 SCAR=18.0
Pod undocumented
672 102 my($str,$substr,$position) = @_;
673 102 ▶ $position ||= 0;
Condition100%2/2
$position ||= 0
l!l
894
MC/DC100%1/1
$position ||= 0
$position
Truth table100%2/2
A
A= $position
Aresult
11
00
674 102 my $pos = 0;
675 102 ▶ while ($pos < CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < CORE::length $str) 456 26 482
676 456 ▶ if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::substr($str, $pos, CORE::length $substr) eq $substr) 80 376 456
677 80 ▶ if ($pos >= $position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= $position) 76 4 80
678 76 return $pos;
679 }
680 }
681 380 ▶ if (CORE::substr($str,$pos) =~ /\A($x)/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::substr($str, $pos) =~ /\A($x)/msx) { } 380 0 380
682 380 $pos += CORE::length($1);
683 }
684 else {
685 0 $pos += 1;
686 }
687 }
688 26 return -1;
689 }
690  
691 #---------------------------------------------------------------------
692 # universal lc() for MBCS encoding
693 14 ▶sub mb::lc (;$) {
Subroutine lc: called CC=3 SCAR=11.0
Pod documented
694 11 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 10 1 11
695 # A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z
696 11 ▶ return join '', map { {qw( A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z )}->{$_}||$_ } /\G$x/g;
Condition66%2/3
{'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'y', 'Z', 'z'}->{$_} || $_
l!l&&r!l&&!r
61580
MC/DC0%0/2
{'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'y', 'Z', 'z'}->{$_} || $_
{'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'y', 'Z', 'z'}->{$_} $_
Truth table66%2/3
A || B
A= {'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'y', 'Z', 'z'}->{$_}B= $_
ABresult
1X1
011
000
697 # A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z
698 }
699  
700 #---------------------------------------------------------------------
701 # universal lcfirst() for MBCS encoding
702 5 ▶sub mb::lcfirst (;$) {
Subroutine lcfirst: called CC=3 SCAR=11.4
Pod undocumented
703 2 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 1 2
704 2 ▶ if (/\A($x)(.*)\z/s) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A($x)(.*)\z/s) { } 2 0 2
705 2 return mb::lc($1) . $2;
706 }
707 else {
708 0 return '';
709 }
710 }
711  
712 #---------------------------------------------------------------------
713 # length() for MBCS encoding
714 166 ▶sub mb::length (;$) {
Subroutine length: called CC=2 SCAR=6.9
Pod undocumented
715 163 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 159 4 163
716 163 return scalar(() = /\G$x/g);
717 }
718  
719 #---------------------------------------------------------------------
720 # ord() for MBCS encoding
721 7 ▶sub mb::ord (;$) {
Subroutine ord: called CC=4 SCAR=13.9
Pod undocumented
722 4 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 2 4
723 4 my $ord = 0;
724 4 ▶ if (/\A($x)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A($x)/) 4 0 4
725 4 for my $octet (unpack 'C*', $1) {
726 6 $ord = $ord * 0x100 + $octet;
727 }
728 }
729 4 return $ord;
730 }
731  
732 #---------------------------------------------------------------------
733 # valid() tests well-formedness of a string for the current script encoding
734 63 ▶sub mb::valid (;$) {
Subroutine valid: called CC=5 SCAR=17.8
Pod undocumented
735 60 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 58 2 60
736  
737 # mb has no UTF-8 flag and no decode boundary, so the everyday operations
738 # are deliberately lenient (every octet is at least a one-byte character).
739 # mb::valid is the explicit, opt-in validity check for callers who do want
740 # to reject malformed input. It uses the STRICT unit -- $over_ascii (a
741 # well-formed multi-byte sequence) or a US-ASCII byte -- NOT the lenient
742 # $x, so any stray octet makes the whole string fail to match and the
743 # predicate returns false. The string itself is never modified.
744 #
745 # $over_ascii is undef until a script encoding is selected (set_script_encoding
746 # or import). If valid() is called before then, there is no multi-byte unit to
747 # test against, so fall back to US-ASCII only rather than interpolating an
748 # undefined pattern (which would warn "Use of uninitialized value").
749 60 ▶ if (not defined $over_ascii) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $over_ascii) 0 60 60
750 0 ▶ return /\A [\x00-\x7F]* \z/xms ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
/\A [\x00-\x7F]* \z/msx ? : 0 0 0
751 }
752 60 ▶ return /\A (?: $over_ascii | [\x00-\x7F] )* \z/xms ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
/\A (?: $over_ascii | [\x00-\x7F] )* \z/msx ? : 37 23 60
753 }
754  
755 #---------------------------------------------------------------------
756 # require for MBCS encoding
757 8 ▶sub mb::require (;$) {
Subroutine require: called CC=18 SCAR=35.0
Pod undocumented
758 5 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 5 0 5
759  
760 # require perl version
761 5 ▶ if (/^[0-9]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[0-9]/) { } 0 5 5
762 0 ▶ if ($] < $_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < $_) { } 0 0 0
763 0 confess "Perl $_ required--this is only version $], stopped";
764 }
765 else {
766 0 undef $@;
767 0 return 1;
768 }
769 }
770  
771 # require expr
772 else {
773  
774 # find expr in @INC
775 5 my $file = $_;
776 5 ▶ if (($file =~ s{::}{/}g) or ($file !~ m{[\./\\]})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ s[::][/]g or not $file =~ m([\./\\])) 0 5 5
Condition33%1/3
$file =~ s[::][/]g or not $file =~ m([\./\\])
l!l&&r!l&&!r
005
MC/DC0%0/2
$file =~ s[::][/]g or not $file =~ m([\./\\])
$file =~ s[::][/]g not $file =~ m([\./\\])
Truth table33%1/3
A or not(B)
A= $file =~ s[::][/]gB= not $file =~ m([\./\\])
ABresult
1X1
011
000
777 0 $file .= '.pm';
778 }
779 5 ▶ if (exists $INC{$file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $INC{$file}) 1 4 5
780 1 undef $@;
781 1 ▶ return 1 if $INC{$file};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{$file} 1 0 1
782 0 confess "Compilation failed in require";
783 }
784 4 for my $prefix_file ($file, map { "$_/$file" } @INC) {
785 4 ▶ if (-f $prefix_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $prefix_file) 4 0 4
786  
787 # poor "make"
788 4 (my $prefix_file_oo = $prefix_file) =~ s{\A (.*) \. ([^.]+) \z}{$1.oo.$2}xms;
789 4 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)) 4 0 4
Condition33%2/6
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)
l!l&&r!l&&!r
400
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file)
l!l&&r!l&&!r
400
MC/DC0%0/3
not -e $prefix_file_oo or mtime($prefix_file_oo) <= mtime($prefix_file) or mtime($prefix_file_oo) <= mtime(__FILE__)
not -e $prefix_file_oo mtime($prefix_file_oo) <= mtime($prefix_file) mtime($prefix_file_oo) <= mtime(__FILE__)
Truth table25%1/4
not(A) or B or C
A= not -e $prefix_file_ooB= mtime($prefix_file_oo) <= mtime($prefix_file)C= mtime($prefix_file_oo) <= mtime(__FILE__)
ABCresult
1XX1
01X1
0011
0000
790 (not -e $prefix_file_oo) or
791 (mtime($prefix_file_oo) <= mtime($prefix_file)) or
792 (mtime($prefix_file_oo) <= mtime(__FILE__))
793 ) {
794 0 ▶ my $fh = mb::_open_r($prefix_file) or confess "$0(@{[__LINE__]}): can't open file: $prefix_file\n";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = &_open_r($prefix_file) or confess("$0(@{[__LINE__];}): can't open file: $prefix_file\n") 4 0 4
795 190 ▶ local $_ = CORE::do { local $/; no strict 'refs'; readline(*{$fh}) };
Subroutine BEGIN: called CC=1 SCAR=0.0
796 190 ▶ { no strict 'refs'; close($fh) }
Subroutine BEGIN: called CC=1 SCAR=0.0
797  
798 # poor file locking
799 0 ▶ local $SIG{__DIE__} = sub { rmdir "$prefix_file.lock"; };
Subroutine __ANON__: called CC=1 SCAR=1.2
800 4 ▶ if (mkdir "$prefix_file.lock", 0755) {
Branch: 1 branch
BranchTrueFalseTotal
if (mkdir "$prefix_file.lock", 493) { } 4 0 4
801 0 ▶ my $fh = mb::_open_w($prefix_file_oo) or confess "$0(@{[__LINE__]}): can't open file: $prefix_file_oo\n";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = &_open_w($prefix_file_oo) or confess("$0(@{[__LINE__];}): can't open file: $prefix_file_oo\n") 4 0 4
802 190 ▶ { no strict 'refs'; print {*{$fh}} mb::_insert_source_encoding_unimport(mb::parse()) }
Subroutine BEGIN: called CC=1 SCAR=0.0
803 190 ▶ { no strict 'refs'; close($fh) }
Subroutine BEGIN: called CC=1 SCAR=0.0
804 4 rmdir "$prefix_file.lock";
805 }
806 else {
807 0 confess "$0(@{[__LINE__]}): can't mkdir: $prefix_file.lock\n";
808 }
809 }
810 4 $INC{$_} = $prefix_file_oo;
811  
812 # run as Perl script
813 # must use CORE::do to use <DATA>, because CORE::eval cannot do it.
814 4 local $@;
815 4 my $result = CORE::eval sprintf(<<'END', (caller)[0,2,1]);
816 package %s;
817 #line %s "%s"
818 CORE::do "$prefix_file_oo";
819 END
820  
821 # return result
822 4 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) { } 0 4 4
elsif (not $result) { } 0 4 4
823 0 $INC{$_} = undef;
824 0 confess $@;
825 }
826 elsif (not $result) {
827 0 delete $INC{$_};
828 0 confess "$_ did not return true value";
829 }
830 else {
831 4 return $result;
832 }
833 }
834 }
835 0 confess "Can't find $_ in \@INC";
836 }
837 }
838  
839 #---------------------------------------------------------------------
840 # reverse() for MBCS encoding
841 25 ▶sub mb::reverse (@) {
Subroutine reverse: called CC=3 SCAR=11.0
Pod undocumented
842  
843 # in list context,
844 22 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 2 20 22
845  
846 # returns a list value consisting of the elements of @_ in the opposite order
847 2 return CORE::reverse @_;
848 }
849  
850 # in scalar context,
851 else {
852  
853 # returns a string value with all characters in the opposite order of
854 20 ▶ return (join '',
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 16 4 20
855 CORE::reverse(
856 @_ ?
857 join('',@_) =~ /\G$x/g : # concatenates the elements of @_
858 /\G$x/g # $_ when without arguments
859 )
860 );
861 }
862 }
863  
864 #---------------------------------------------------------------------
865 # rindex() for MBCS encoding
866 23 ▶sub mb::rindex ($$;$) {
Subroutine rindex: called CC=3 SCAR=11.0
Pod undocumented
867 20 my $rindex = 0;
868 20 ▶ if (@_ == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 4 16 20
869 4 $rindex = mb::rindex_byte($_[0], $_[1], CORE::length(mb::substr($_[0], 0, $_[2])));
870 }
871 else {
872 16 $rindex = mb::rindex_byte($_[0], $_[1]);
873 }
874 20 ▶ if ($rindex == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rindex == -1) { } 4 16 20
875 4 return -1;
876 }
877 else {
878 16 return mb::length(CORE::substr $_[0], 0, $rindex);
879 }
880 }
881  
882 #---------------------------------------------------------------------
883 # JPerl like rindex() for MBCS encoding
884 31 ▶sub mb::rindex_byte ($$;$) {
Subroutine rindex_byte: called CC=6 SCAR=18.0
Pod undocumented
885 28 my($str,$substr,$position) = @_;
886 28 ▶ $position ||= CORE::length($str) - 1;
Condition66%2/3
$position ||= CORE::length($str) - 1
l!l&&r!l&&!r
8200
MC/DC0%0/2
$position ||= CORE::length($str) - 1
$position CORE::length($str) - 1
Truth table66%2/3
A ||= B
A= $positionB= CORE::length($str) - 1
ABresult
1X1
011
000
887 28 my $pos = 0;
888 28 my $rindex = -1;
889 28 ▶ while (($pos < CORE::length($str)) and ($pos <= $position)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < CORE::length $str and $pos <= $position) 290 28 318
Condition100%3/3
$pos < CORE::length $str and $pos <= $position
!ll&&!rl&&r
208290
MC/DC100%2/2
$pos < CORE::length $str and $pos <= $position
$pos < CORE::length $str $pos <= $position
Truth table100%3/3
A and B
A= $pos < CORE::length $strB= $pos <= $position
ABresult
0X0
100
111
890 290 ▶ if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::substr($str, $pos, CORE::length $substr) eq $substr) 43 247 290
891 43 $rindex = $pos;
892 }
893 290 ▶ if (CORE::substr($str,$pos) =~ /\A($x)/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::substr($str, $pos) =~ /\A($x)/msx) { } 290 0 290
894 290 $pos += CORE::length($1);
895 }
896 else {
897 0 $pos += 1;
898 }
899 }
900 28 return $rindex;
901 }
902  
903 #---------------------------------------------------------------------
904 # set OSNAME
905 89 ▶sub mb::set_OSNAME ($) {
Subroutine set_OSNAME: called CC=1 SCAR=0.0
Pod undocumented
906 86 $OSNAME = $_[0];
907 }
908  
909 #---------------------------------------------------------------------
910 # get OSNAME
911 46 ▶sub mb::get_OSNAME () {
Subroutine get_OSNAME: called CC=1 SCAR=0.0
Pod undocumented
912 43 return $OSNAME;
913 }
914  
915 #---------------------------------------------------------------------
916 # set script encoding name and more
917 477 ▶sub mb::set_script_encoding ($) {
Subroutine set_script_encoding: called CC=9 SCAR=25.2
Pod undocumented
918 474 $script_encoding = $_[0];
919  
920 # over US-ASCII
921 $over_ascii = {
922 'sjis' => '(?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|[\x80-\xFF])', # shift_jis ANSI/OEM Japanese; Japanese (Shift-JIS)
923 'informixv6als' => '(?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF]|[\x80-\xFF])', # INFORMIX V6 ALS: Shift_JIS-compatible 2 byte core plus \xFD 3 byte user-defined plane
924 'gbk' => '(?>[\x81-\xFE][\x00-\xFF])', # gb2312 ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312)
925 'uhc' => '(?>[\x81-\xFE][\x00-\xFF])', # ks_c_5601-1987 ANSI/OEM Korean (Unified Hangul Code)
926 'johab' => '(?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x00-\xFF])', # KS X 1001:1992 annex 3 Johab, code page 1361 (Korean, Johab): discontinuous 2 byte lead [\x81-\xD3\xD8-\xDE\xE0-\xF9] (hangul \x81-\xD3, symbols \xD8-\xDE, hanja \xE0-\xF9), no single high octet; real trail octet is \x31-\x7E and \x81-\xFE (which includes \x5C), per Microsoft CRT mbctype.c cp1361 lead/trail table; see "=head2 johab" in POD for URLs
927 'big5' => '(?>[\x81-\xFE][\x00-\xFF])', # big5 ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
928 'big5hkscs' => '(?>[\x81-\xFE][\x00-\xFF])', # HKSCS support on top of traditional Chinese Windows
929 'hp15' => '(?>[\x80-\xA0\xE0-\xFE][\x00-\xFF]|[\x80-\xFF])', # HP-15 (HP-UX Japanese): 2 byte DBCS lead [\x80-\xA0\xE0-\xFE]; JIS X 0201 katakana [\xA1-\xDF] and \xFF are single octet; the standard 2 byte area encodes JIS X 0208 with the same octets as Shift-JIS and the extra leads serve only the user-defined area (Ken Lunde, CJKV Information Processing 2nd ed., Appendixes E and F; see "=head2 hp15" in POD for URLs)
930 'eucjp' => '(?>[\xA1-\xFE][\x00-\xFF])', # EUC-JP Japanese (JIS 0208-1990 and 0121-1990)
931 'euctw' => '(?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])', # EUC-TW Traditional Chinese (CNS 11643 plane 1 (2 byte) and SS2 planes 2..16 (4 byte))
932 'gb18030' => '(?>[\x81-\xFE][\x30-\x39][\x81-\xFE][\x30-\x39]|[\x81-\xFE][\x00-\xFF])', # GB18030 Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)
933 'rfc2279' => '(?>[\xC2-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF][\x80-\xBF]|[\xF0-\xF4][\x80-\xBF][\x80-\xBF][\x80-\xBF])', # utf-8 Unicode (UTF-8) RFC2279
934 'utf8' => '(?>[\xE1-\xEC][\x80-\xBF][\x80-\xBF]|[\xC2-\xDF][\x80-\xBF]|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]|[\xF0-\xF0][\x90-\xBF][\x80-\xBF][\x80-\xBF]|[\xE0-\xE0][\xA0-\xBF][\x80-\xBF]|[\xED-\xED][\x80-\x9F][\x80-\xBF]|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]|[\xF4-\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF])', # utf-8 Unicode (UTF-8) optimized RFC3629 for ja_JP
935 'wtf8' => '(?>[\xE1-\xEF][\x80-\xBF][\x80-\xBF]|[\xC2-\xDF][\x80-\xBF]|[\xE0-\xE0][\xA0-\xBF][\x80-\xBF]|[\xF0-\xF0][\x90-\xBF][\x80-\xBF][\x80-\xBF]|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]|[\xF4-\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF])', # optimized WTF-8 for ja_JP
936 474 ▶ }->{$script_encoding} || '[\x80-\xFF]';
Condition50%1/2
{'sjis', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|[\\x80-\\xFF])', 'informixv6als', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|\\xFD[\\xA1-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'gbk', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'uhc', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'johab', '(?>[\\x81-\\xD3\\xD8-\\xDE\\xE0-\\xF9][\\x00-\\xFF])', 'big5', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'big5hkscs', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'hp15', '(?>[\\x80-\\xA0\\xE0-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'eucjp', '(?>[\\xA1-\\xFE][\\x00-\\xFF])', 'euctw', '(?>\\x8E[\\xA1-\\xB0][\\xA1-\\xFE][\\x00-\\xFF]|[\\xA1-\\xFE][\\xA1-\\xFE])', 'gb18030', '(?>[\\x81-\\xFE][\\x30-\\x39][\\x81-\\xFE][\\x30-\\x39]|[\\x81-\\xFE][\\x00-\\xFF])', 'rfc2279', '(?>[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF4][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF])', 'utf8', '(?>[\\xE1-\\xEC][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xEE-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xED-\\xED][\\x80-\\x9F][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])', 'wtf8', '(?>[\\xE1-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])'}->{$script_encoding} || '[\\x80-\\xFF]'
l!l
4740
MC/DC0%0/1
{'sjis', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|[\\x80-\\xFF])', 'informixv6als', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|\\xFD[\\xA1-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'gbk', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'uhc', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'johab', '(?>[\\x81-\\xD3\\xD8-\\xDE\\xE0-\\xF9][\\x00-\\xFF])', 'big5', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'big5hkscs', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'hp15', '(?>[\\x80-\\xA0\\xE0-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'eucjp', '(?>[\\xA1-\\xFE][\\x00-\\xFF])', 'euctw', '(?>\\x8E[\\xA1-\\xB0][\\xA1-\\xFE][\\x00-\\xFF]|[\\xA1-\\xFE][\\xA1-\\xFE])', 'gb18030', '(?>[\\x81-\\xFE][\\x30-\\x39][\\x81-\\xFE][\\x30-\\x39]|[\\x81-\\xFE][\\x00-\\xFF])', 'rfc2279', '(?>[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF4][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF])', 'utf8', '(?>[\\xE1-\\xEC][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xEE-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xED-\\xED][\\x80-\\x9F][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])', 'wtf8', '(?>[\\xE1-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])'}->{$script_encoding} || '[\\x80-\\xFF]'
{'sjis', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|[\\x80-\\xFF])', 'informixv6als', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|\\xFD[\\xA1-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'gbk', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'uhc', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'johab', '(?>[\\x81-\\xD3\\xD8-\\xDE\\xE0-\\xF9][\\x00-\\xFF])', 'big5', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'big5hkscs', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'hp15', '(?>[\\x80-\\xA0\\xE0-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'eucjp', '(?>[\\xA1-\\xFE][\\x00-\\xFF])', 'euctw', '(?>\\x8E[\\xA1-\\xB0][\\xA1-\\xFE][\\x00-\\xFF]|[\\xA1-\\xFE][\\xA1-\\xFE])', 'gb18030', '(?>[\\x81-\\xFE][\\x30-\\x39][\\x81-\\xFE][\\x30-\\x39]|[\\x81-\\xFE][\\x00-\\xFF])', 'rfc2279', '(?>[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF4][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF])', 'utf8', '(?>[\\xE1-\\xEC][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xEE-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xED-\\xED][\\x80-\\x9F][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])', 'wtf8', '(?>[\\xE1-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])'}->{$script_encoding}
Truth table50%1/2
A
A= {'sjis', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|[\\x80-\\xFF])', 'informixv6als', '(?>[\\x81-\\x9F\\xE0-\\xFC][\\x00-\\xFF]|\\xFD[\\xA1-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'gbk', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'uhc', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'johab', '(?>[\\x81-\\xD3\\xD8-\\xDE\\xE0-\\xF9][\\x00-\\xFF])', 'big5', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'big5hkscs', '(?>[\\x81-\\xFE][\\x00-\\xFF])', 'hp15', '(?>[\\x80-\\xA0\\xE0-\\xFE][\\x00-\\xFF]|[\\x80-\\xFF])', 'eucjp', '(?>[\\xA1-\\xFE][\\x00-\\xFF])', 'euctw', '(?>\\x8E[\\xA1-\\xB0][\\xA1-\\xFE][\\x00-\\xFF]|[\\xA1-\\xFE][\\xA1-\\xFE])', 'gb18030', '(?>[\\x81-\\xFE][\\x30-\\x39][\\x81-\\xFE][\\x30-\\x39]|[\\x81-\\xFE][\\x00-\\xFF])', 'rfc2279', '(?>[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF4][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF])', 'utf8', '(?>[\\xE1-\\xEC][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xEE-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xED-\\xED][\\x80-\\x9F][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])', 'wtf8', '(?>[\\xE1-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|[\\xC2-\\xDF][\\x80-\\xBF]|[\\xE0-\\xE0][\\xA0-\\xBF][\\x80-\\xBF]|[\\xF0-\\xF0][\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF4-\\xF4][\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF])'}->{$script_encoding}
Aresult
11
00
937  
938 # supports qr/./ in MBCS script
939 #
940 # NOTE (0.64 step 4 read-only audit): this transpile-path $x is kept as a
941 # qr// OBJECT on purpose. A qr// interpolates into another pattern as a
942 # modifier-isolated subpattern ((?^...:...) / (?-xism:...)); the transpile
943 # path relies on that isolation when $x is embedded inside /x and escape
944 # contexts. Re-expressing $x as a plain string (the form used by mb8 and
945 # by the local $x inside _r2_qr) drops that wrapper and regresses the
946 # qr-as-q / s-as-q escape transpilation (observed: 406 failures on perl
947 # 5.38). So the "mitigation B" stringification is NOT applied here; the
948 # file-scoped $x stays a qr// object and stays STRICT ([\x00-\x7F]).
949 # Read-only safety on perl 5.005_03 is not needed for this $x: it is only
950 # ever interpolated into search patterns, never the target of a
951 # destructive s///. The runtime engine that DOES need a writable copy
952 # (_r2_qr) already takes one via my $source = "$_[0]".
953 474 $x = qr/(?>$over_ascii|[\x00-\x7F])/;
954  
955 # regexp of multi-byte anchoring
956  
957 # Quantifiers
958 # {n,m} --- Match at least n but not more than m times
959 #
960 # n and m are limited to non-negative integral values less than a
961 # preset limit defined when perl is built. This is usually 32766 on
962 # the most common platforms.
963 #
964 # The following code is an attempt to solve the above limitations
965 # in a multi-byte anchoring.
966 #
967 # avoid "Segmentation fault" and "Error: Parse exception"
968 #
969 # perl5101delta
970 # http://perldoc.perl.org/perl5101delta.html
971 # In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767}
972 # [RT #60034, #60464]. For example, this match would fail:
973 # ("ab" x 32768) =~ /^(ab)*$/
974 #
975 # SEE ALSO
976 #
977 # Complex regular subexpression recursion limit
978 # http://www.perlmonks.org/?node_id=810857
979 #
980 # regexp iteration limits
981 # http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html
982 #
983 # latest Perl won't match certain regexes more than 32768 characters long
984 # http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long
985 #
986 # Break through the limitations of regular expressions of Perl
987 # http://d.hatena.ne.jp/gfx/20110212/1297512479
988 #
989 # REG_INF has been raised from 65,536 to 2,147,483,647
990 # https://perldoc.perl.org/perl5380delta#REG_INF-has-been-raised-from-65,536-to-2,147,483,647
991  
992 474 ▶ if ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/xms) {
Branch: 4 branches
BranchTrueFalseTotal
if ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/msx) { } 233 241 474
elsif ($] >= 5.038) { } 241 0 241
elsif ($] >= 5.03) { } 0 0 0
elsif ($] >= 5.010001) { } 0 0 0
993 233 ${mb::_anchor} = qr{.*?}xms;
994 }
995 elsif ($] >= 5.038000) {
996 ${mb::_anchor} = {
997 'sjis' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))}xms,
998 'hp15' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))}xms,
999 'informixv6als' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))}xms,
1000 'eucjp' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))}xms,
1001 'euctw' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))}xms,
1002 'gbk' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1003 'uhc' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1004 'johab' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))}xms,
1005 'big5' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1006 'big5hkscs' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1007 'gb18030' => qr{(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1008 241 ▶ }->{$script_encoding} || die;
Condition50%1/2
{'sjis', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
l!l
2410
MC/DC0%0/1
{'sjis', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
{'sjis', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Truth table50%1/2
A
A= {'sjis', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,2147483646}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Aresult
11
00
1009 }
1010 elsif ($] >= 5.030000) {
1011 ${mb::_anchor} = {
1012 'sjis' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))}xms,
1013 'hp15' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))}xms,
1014 'informixv6als' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))}xms,
1015 'eucjp' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))}xms,
1016 'euctw' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))}xms,
1017 'gbk' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1018 'uhc' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1019 'johab' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))}xms,
1020 'big5' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1021 'big5hkscs' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1022 'gb18030' => qr{(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1023 0 ▶ }->{$script_encoding} || die;
Condition0%0/2
{'sjis', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
l!l
00
MC/DC0%0/1
{'sjis', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
{'sjis', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Truth table0%0/2
A
A= {'sjis', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,65534}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Aresult
11
00
1024 }
1025 elsif ($] >= 5.010001) {
1026 ${mb::_anchor} = {
1027 'sjis' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))}xms,
1028 'hp15' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))}xms,
1029 'informixv6als' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))}xms,
1030 'eucjp' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))}xms,
1031 'euctw' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))}xms,
1032 'gbk' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1033 'uhc' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1034 'johab' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))}xms,
1035 'big5' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1036 'big5hkscs' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1037 'gb18030' => qr{(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))}xms,
1038 0 ▶ }->{$script_encoding} || die;
Condition0%0/2
{'sjis', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
l!l
00
MC/DC0%0/1
{'sjis', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding} || die()
{'sjis', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Truth table0%0/2
A
A= {'sjis', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFC]+\z).*?|.*?[^\x81-\x9F\xE0-\xFC](?>[\x81-\x9F\xE0-\xFC][\x81-\x9F\xE0-\xFC])*?))/msx, 'hp15', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x80-\xA0\xE0-\xFE]+\z).*?|.*?[^\x80-\xA0\xE0-\xFE](?>[\x80-\xA0\xE0-\xFE][\x80-\xA0\xE0-\xFE])*?))/msx, 'informixv6als', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\x9F\xE0-\xFD]+\z).*?|.*?[^\x81-\x9F\xE0-\xFD](?>[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\xFD[\xA1-\xFE][\x00-\xFF])*?))/msx, 'eucjp', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\xA1-\xFE\xA1-\xFE]+\z).*?|.*?[^\xA1-\xFE\xA1-\xFE](?>[\xA1-\xFE\xA1-\xFE][\xA1-\xFE\xA1-\xFE])*?))/msx, 'euctw', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x8E\xA1-\xFE]+\z).*?|.*?[^\x8E\xA1-\xFE](?>\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\xA1-\xFE][\xA1-\xFE])*?))/msx, 'gbk', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'uhc', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'johab', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xD3\xD8-\xDE\xE0-\xF9]+\z).*?|.*?[^\x81-\xD3\xD8-\xDE\xE0-\xF9](?>[\x81-\xD3\xD8-\xDE\xE0-\xF9][\x81-\xD3\xD8-\xDE\xE0-\xF9])*?))/msx, 'big5', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'big5hkscs', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx, 'gb18030', qr/(?(?=.{0,32766}\z)(?:$x)*?|(?(?=[^\x81-\xFE\x81-\xFE]+\z).*?|.*?[^\x81-\xFE\x81-\xFE](?>[\x81-\xFE\x81-\xFE][\x81-\xFE\x81-\xFE])*?))/msx}->{$script_encoding}
Aresult
11
00
1039 }
1040 else {
1041 0 ${mb::_anchor} = qr{(?:$x)*?}xms;
1042 }
1043  
1044 # codepoint class shortcuts in qq-like regular expression
1045 474 @{mb::_dot} = "(?>$over_ascii|.)"; # supports /s modifier by /./
1046 474 @{mb::_B} = "(?:(?<![$bare_w])(?![$bare_w])|(?<=[$bare_w])(?=[$bare_w]))";
1047 474 @{mb::_D} = "(?:(?![0-9])$x)";
1048 474 @{mb::_H} = "(?:(?![\\x09\\x20])$x)";
1049 474 @{mb::_N} = "(?:(?!\\n)$x)";
1050 474 @{mb::_R} = "(?>\\r\\n|[\\x0A\\x0B\\x0C\\x0D])";
1051 474 @{mb::_S} = "(?:(?![\\t\\n\\f\\r\\x20])$x)";
1052 474 @{mb::_V} = "(?:(?![\\x0A\\x0B\\x0C\\x0D])$x)";
1053 474 @{mb::_W} = "(?:(?![A-Za-z0-9_])$x)";
1054 474 @{mb::_b} = "(?:(?<![$bare_w])(?=[$bare_w])|(?<=[$bare_w])(?![$bare_w]))";
1055 474 @{mb::_d} = "[0-9]";
1056 474 @{mb::_h} = "[\\x09\\x20]";
1057 474 @{mb::_s} = "[\\t\\n\\f\\r\\x20]";
1058 474 @{mb::_v} = "[\\x0A\\x0B\\x0C\\x0D]";
1059 474 @{mb::_w} = "[A-Za-z0-9_]";
1060 }
1061  
1062 #---------------------------------------------------------------------
1063 # get script encoding name
1064 164558 ▶sub mb::get_script_encoding () {
Subroutine get_script_encoding: called CC=1 SCAR=0.0
Pod undocumented
1065 164555 return $script_encoding;
1066 }
1067  
1068 #---------------------------------------------------------------------
1069 # get old package name
1070 164542 ▶sub mb::get_old_package () {
Subroutine get_old_package: called CC=2 SCAR=7.6
Pod undocumented
1071 return {qw(
1072 sjis Sjis::
1073 hp15 HP15::
1074 informixv6als INFORMIXV6ALS::
1075 gbk GBK::
1076 uhc UHC::
1077 johab JOHAB::
1078 big5 Big5::
1079 big5hkscs Big5HKSCS::
1080 eucjp EUCJP::
1081 euctw EUCTW::
1082 gb18030 GB18030::
1083 rfc2279 RFC2279::
1084 utf8 UTF2::
1085 wtf8 WTF8::
1086 164539 ▶ )}->{mb::get_script_encoding()} || die;
Condition50%1/2
{'sjis', 'Sjis::', 'hp15', 'HP15::', 'informixv6als', 'INFORMIXV6ALS::', 'gbk', 'GBK::', 'uhc', 'UHC::', 'johab', 'JOHAB::', 'big5', 'Big5::', 'big5hkscs', 'Big5HKSCS::', 'eucjp', 'EUCJP::', 'euctw', 'EUCTW::', 'gb18030', 'GB18030::', 'rfc2279', 'RFC2279::', 'utf8', 'UTF2::', 'wtf8', 'WTF8::'}->{&get_script_encoding()} || die()
l!l
1645390
MC/DC0%0/1
{'sjis', 'Sjis::', 'hp15', 'HP15::', 'informixv6als', 'INFORMIXV6ALS::', 'gbk', 'GBK::', 'uhc', 'UHC::', 'johab', 'JOHAB::', 'big5', 'Big5::', 'big5hkscs', 'Big5HKSCS::', 'eucjp', 'EUCJP::', 'euctw', 'EUCTW::', 'gb18030', 'GB18030::', 'rfc2279', 'RFC2279::', 'utf8', 'UTF2::', 'wtf8', 'WTF8::'}->{&get_script_encoding()} || die()
{'sjis', 'Sjis::', 'hp15', 'HP15::', 'informixv6als', 'INFORMIXV6ALS::', 'gbk', 'GBK::', 'uhc', 'UHC::', 'johab', 'JOHAB::', 'big5', 'Big5::', 'big5hkscs', 'Big5HKSCS::', 'eucjp', 'EUCJP::', 'euctw', 'EUCTW::', 'gb18030', 'GB18030::', 'rfc2279', 'RFC2279::', 'utf8', 'UTF2::', 'wtf8', 'WTF8::'}->{&get_script_encoding()}
Truth table50%1/2
A
A= {'sjis', 'Sjis::', 'hp15', 'HP15::', 'informixv6als', 'INFORMIXV6ALS::', 'gbk', 'GBK::', 'uhc', 'UHC::', 'johab', 'JOHAB::', 'big5', 'Big5::', 'big5hkscs', 'Big5HKSCS::', 'eucjp', 'EUCJP::', 'euctw', 'EUCTW::', 'gb18030', 'GB18030::', 'rfc2279', 'RFC2279::', 'utf8', 'UTF2::', 'wtf8', 'WTF8::'}->{&get_script_encoding()}
Aresult
11
00
1087 }
1088  
1089 #---------------------------------------------------------------------
1090 # substr() for MBCS encoding
1091 190 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
1092 190 ▶ CORE::eval sprintf <<'END', ($] >= 5.014) ? ':lvalue' : '';
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine substr: called CC=11 SCAR=24.0
Pod undocumented
Branch: 10 branches
BranchTrueFalseTotal
$] >= 5.014 ? : 193 0 193
if ($_[1] < -1 * scalar(@x) or 1 * scalar(@x) < $_[1]) 2 177 179
if (@_ == 4) { } 16 161 177
elsif (@_ == 3) { } 131 30 161
$_[1] < 0 ? : 20 111 131
$_[1] > 0 ? : 69 42 111
$_[2] < 0 ? : 8 123 131
$_[2] > 0 ? : 123 0 123
$_[1] < 0 ? : 4 26 30
$_[1] > 0 ? : 26 0 26
Condition100%3/3
$_[1] < -1 * scalar(@x) or 1 * scalar(@x) < $_[1]
l!l&&r!l&&!r
11177
MC/DC100%2/2
$_[1] < -1 * scalar(@x) or 1 * scalar(@x) < $_[1]
$_[1] < -1 * scalar(@x) 1 * scalar(@x) < $_[1]
Truth table100%3/3
A or B
A= $_[1] < -1 * scalar(@x)B= 1 * scalar(@x) < $_[1]
ABresult
1X1
011
000
1093 # VV------------------------AAAAAAA
1094 sub mb::substr ($$;$$) %s {
1095 my @x = $_[0] =~ /\G$x/g;
1096  
1097 # If the substring is beyond either end of the string, substr() returns the undefined
1098 # value and produces a warning. When used as an lvalue, specifying a substring that
1099 # is entirely outside the string raises an exception.
1100 # http://perldoc.perl.org/functions/substr.html
1101  
1102 # A return with no argument returns the scalar value undef in scalar context,
1103 # an empty list () in list context, and (naturally) nothing at all in void
1104 # context.
1105  
1106 if (($_[1] < (-1 * scalar(@x))) or (+1 * scalar(@x) < $_[1])) {
1107 return;
1108 }
1109  
1110 # substr($string,$offset,$length,$replacement)
1111 if (@_ == 4) {
1112 my $substr = join '', splice @x, $_[1], $_[2], $_[3];
1113 $_[0] = join '', @x;
1114 $substr; # "return $substr" doesn't work, don't write "return"
1115 }
1116  
1117 # substr($string,$offset,$length)
1118 elsif (@_ == 3) {
1119 local $SIG{__WARN__} = sub {}; # avoid: Use of uninitialized value in join or string at here
1120 my $octet_offset =
1121 ($_[1] < 0) ? -1 * CORE::length(join '', @x[$#x+$_[1]+1 .. $#x]) :
1122 ($_[1] > 0) ? CORE::length(join '', @x[0 .. $_[1]-1]) :
1123 0;
1124 my $octet_length =
1125 ($_[2] < 0) ? -1 * CORE::length(join '', @x[$#x+$_[2]+1 .. $#x]) :
1126 ($_[2] > 0) ? CORE::length(join '', @x[$_[1] .. $_[1]+$_[2]-1]) :
1127 0;
1128 CORE::substr($_[0], $octet_offset, $octet_length);
1129 }
1130  
1131 # substr($string,$offset)
1132 else {
1133 my $octet_offset =
1134 ($_[1] < 0) ? -1 * CORE::length(join '', @x[$#x+$_[1]+1 .. $#x]) :
1135 ($_[1] > 0) ? CORE::length(join '', @x[0 .. $_[1]-1]) :
1136 0;
1137 CORE::substr($_[0], $octet_offset);
1138 }
1139 }
1140 END
1141 }
1142  
1143 #---------------------------------------------------------------------
1144 # tr/// and y/// for MBCS encoding
1145 2533 ▶sub mb::tr ($$$;$) {
Subroutine tr: called CC=30 SCAR=34.0
Pod documented
1146 2530 my @x = $_[0] =~ /\G($x)/xmsg;
1147 2530 my @search = list_all_ASCII_by_hyphen($_[1] =~ /\G(\\-|$x)/xmsg);
1148 2530 my @replacement = list_all_ASCII_by_hyphen($_[2] =~ /\G(\\-|$x)/xmsg);
1149 2530 ▶ my %modifier = (defined $_[3]) ? (map { $_ => 1 } CORE::split //, $_[3]) : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $_[3] ? : 2488 42 2530
1150  
1151 2530 my %tr = ();
1152 2530 ▶ for (my $i=0; $i <= $#search; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#search) 3388 2530 5918
1153  
1154 # tr/AAA/123/ works as tr/A/1/
1155 3388 ▶ if (not exists $tr{$search[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $tr{$search[$i]}) 3328 60 3388
1156  
1157 # tr/ABC/123/ makes %tr = ('A'=>'1','B'=>'2','C'=>'3',);
1158 3328 ▶ if (defined($replacement[$i]) and ($replacement[$i] ne '')) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $replacement[$i] and $replacement[$i] ne '') { } 3123 205 3328
elsif (exists $modifier{'d'}) { } 108 97 205
elsif (defined $replacement[-1] and $replacement[-1] ne '') { } 89 8 97
Condition66%2/3
defined $replacement[$i] and $replacement[$i] ne ""
!ll&&!rl&&r
20503123
MC/DC50%1/2
defined $replacement[$i] and $replacement[$i] ne ""
defined $replacement[$i] $replacement[$i] ne ""
Truth table66%2/3
A and B
A= defined $replacement[$i]B= $replacement[$i] ne ""
ABresult
0X0
100
111
1159 3123 $tr{$search[$i]} = $replacement[$i];
1160 }
1161  
1162 # tr/ABC/12/d makes %tr = ('A'=>'1','B'=>'2','C'=>'',);
1163 elsif (exists $modifier{d}) {
1164 108 $tr{$search[$i]} = '';
1165 }
1166  
1167 # tr/ABC/12/ makes %tr = ('A'=>'1','B'=>'2','C'=>'2',);
1168 ▶ elsif (defined($replacement[-1]) and ($replacement[-1] ne '')) {
Condition66%2/3
defined $replacement[-1] and $replacement[-1] ne ""
!ll&&!rl&&r
8089
MC/DC50%1/2
defined $replacement[-1] and $replacement[-1] ne ""
defined $replacement[-1] $replacement[-1] ne ""
Truth table66%2/3
A and B
A= defined $replacement[-1]B= $replacement[-1] ne ""
ABresult
0X0
100
111
1169 89 $tr{$search[$i]} = $replacement[-1];
1170 }
1171  
1172 # tr/ABC// makes %tr = ('A'=>'A','B'=>'B','C'=>'C',);
1173 else {
1174 8 $tr{$search[$i]} = $search[$i];
1175 }
1176 }
1177 }
1178  
1179 2530 my $tr = 0;
1180 2530 my $replaced = '';
1181  
1182 # has /c modifier
1183 2530 ▶ if (exists $modifier{c}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $modifier{'c'}) { } 126 2404 2530
1184  
1185 # has /s modifier
1186 126 ▶ if (exists $modifier{s}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $modifier{'s'}) { } 54 72 126
1187 54 my $last_transliterated = undef;
1188 54 ▶ while (defined(my $x = shift @x)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $x = shift @x)) 428 54 482
1189  
1190 # /c modifier works here
1191 428 ▶ if (exists $tr{$x}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$x}) { } 252 176 428
1192 252 $replaced .= $x;
1193 252 $last_transliterated = undef;
1194 }
1195 else {
1196  
1197 # /d modifier works here
1198 176 ▶ if (exists $modifier{d}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $modifier{'d'}) { } 124 52 176
elsif (defined $replacement[-1]) { } 52 0 52
1199 }
1200  
1201 elsif (defined $replacement[-1]) {
1202  
1203 # /s modifier works here
1204 52 ▶ if (defined($last_transliterated) and ($replacement[-1] eq $last_transliterated)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last_transliterated and $replacement[-1] eq $last_transliterated) { } 9 43 52
Condition66%2/3
defined $last_transliterated and $replacement[-1] eq $last_transliterated
!ll&&!rl&&r
4309
MC/DC50%1/2
defined $last_transliterated and $replacement[-1] eq $last_transliterated
defined $last_transliterated $replacement[-1] eq $last_transliterated
Truth table66%2/3
A and B
A= defined $last_transliteratedB= $replacement[-1] eq $last_transliterated
ABresult
0X0
100
111
1205 }
1206  
1207 # tr/// works here
1208 else {
1209 43 $replaced .= ($last_transliterated = $replacement[-1]);
1210 }
1211 }
1212 176 $tr++;
1213 }
1214 }
1215 }
1216  
1217 # has no /s modifier
1218 else {
1219 72 ▶ while (defined(my $x = shift @x)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $x = shift @x)) 314 72 386
1220  
1221 # /c modifier works here
1222 314 ▶ if (exists $tr{$x}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$x}) { } 210 104 314
1223 210 $replaced .= $x;
1224 }
1225 else {
1226  
1227 # /d modifier works here
1228 104 ▶ if (exists $modifier{d}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $modifier{'d'}) { } 34 70 104
elsif (defined $replacement[-1]) { } 70 0 70
1229 }
1230  
1231 # tr/// works here
1232 elsif (defined $replacement[-1]) {
1233 70 $replaced .= $replacement[-1];
1234 }
1235 104 $tr++;
1236 }
1237 }
1238 }
1239 }
1240  
1241 # has no /c modifier
1242 else {
1243  
1244 # has /s modifier
1245 2404 ▶ if (exists $modifier{s}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $modifier{'s'}) { } 85 2319 2404
1246 85 my $last_transliterated = undef;
1247 85 ▶ while (defined(my $x = shift @x)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $x = shift @x)) 593 85 678
1248 593 ▶ if (exists $tr{$x}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$x}) { } 425 168 593
1249  
1250 # /d modifier works here
1251 425 ▶ if ($tr{$x} eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($tr{$x} eq '') { } 89 336 425
elsif (defined $last_transliterated and $tr{$x} eq $last_transliterated) { } 177 159 336
1252 }
1253  
1254 # /s modifier works here
1255 ▶ elsif (defined($last_transliterated) and ($tr{$x} eq $last_transliterated)) {
Condition100%3/3
defined $last_transliterated and $tr{$x} eq $last_transliterated
!ll&&!rl&&r
13128177
MC/DC100%2/2
defined $last_transliterated and $tr{$x} eq $last_transliterated
defined $last_transliterated $tr{$x} eq $last_transliterated
Truth table100%3/3
A and B
A= defined $last_transliteratedB= $tr{$x} eq $last_transliterated
ABresult
0X0
100
111
1256 }
1257  
1258 # tr/// works here
1259 else {
1260 159 $replaced .= ($last_transliterated = $tr{$x});
1261 }
1262 425 $tr++;
1263 }
1264 else {
1265 168 $replaced .= $x;
1266 168 $last_transliterated = undef;
1267 }
1268 }
1269 }
1270  
1271 # has no /s modifier
1272 else {
1273 2319 ▶ while (defined(my $x = shift @x)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $x = shift @x)) 2749 2319 5068
1274 2749 ▶ if (exists $tr{$x}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tr{$x}) { } 2621 128 2749
1275 2621 $replaced .= $tr{$x};
1276 2621 $tr++;
1277 }
1278 else {
1279 128 $replaced .= $x;
1280 }
1281 }
1282 }
1283 }
1284  
1285 # /r modifier works here
1286 2530 ▶ if (exists $modifier{r}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $modifier{'r'}) { } 2362 168 2530
1287 2362 return $replaced;
1288 }
1289  
1290 # has no /r modifier
1291 else {
1292 168 $_[0] = $replaced;
1293 168 return $tr;
1294 }
1295 }
1296  
1297 #---------------------------------------------------------------------
1298 # universal uc() for MBCS encoding
1299 53 ▶sub mb::uc (;$) {
Subroutine uc: called CC=3 SCAR=11.0
Pod documented
1300 50 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 49 1 50
1301 # a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z
1302 50 ▶ return join '', map { {qw( a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z )}->{$_}||$_ } /\G$x/g;
Condition100%3/3
{'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'}->{$_} || $_
l!l&&r!l&&!r
49636288
MC/DC100%2/2
{'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'}->{$_} || $_
{'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'}->{$_} $_
Truth table100%3/3
A || B
A= {'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'}->{$_}B= $_
ABresult
1X1
011
000
1303 # a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z
1304 }
1305  
1306 #---------------------------------------------------------------------
1307 # universal ucfirst() for MBCS encoding
1308 5 ▶sub mb::ucfirst (;$) {
Subroutine ucfirst: called CC=3 SCAR=11.4
Pod undocumented
1309 2 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 1 2
1310 2 ▶ if (/\A($x)(.*)\z/s) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\A($x)(.*)\z/s) { } 2 0 2
1311 2 return mb::uc($1) . $2;
1312 }
1313 else {
1314 0 return '';
1315 }
1316 }
1317  
1318 ######################################################################
1319 # runtime routines on all operating systems (used automatically)
1320 ######################################################################
1321  
1322 #---------------------------------------------------------------------
1323 # implement of special variable $1,$2,$3,...
1324 93 ▶sub mb::_CAPTURE (;$) {
Subroutine _CAPTURE: called CC=8 SCAR=34.8
1325 90 ▶ if ($mb::last_s_passed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::last_s_passed) { } 29 61 90
1326 29 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) { } 29 0 29
1327  
1328 # $1 is used for multi-byte anchoring
1329 29 return CORE::eval('$' . ($_[0] + 1));
1330 }
1331 else {
1332 0 my @capture = ();
1333 0 ▶ if ($] >= 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.006) { } 0 0 0
1334  
1335 # $1 is used for multi-byte anchoring in s///
1336 0 push @capture, map { CORE::eval('$'.$_) } 2 .. CORE::eval('$#-');
1337 }
1338 else {
1339  
1340 # @{^CAPTURE} doesn't work enough in perl 5.005
1341 0 ▶ for (my $n_th=2; defined(CORE::eval('$'.$n_th)); $n_th++) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined eval '$' . $n_th) 0 0 0
1342 0 push @capture, CORE::eval('$'.$n_th);
1343 }
1344 }
1345 0 return @capture;
1346 }
1347 }
1348 else {
1349 61 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) { } 61 0 61
1350 61 return CORE::eval('$' . $_[0]);
1351 }
1352 else {
1353 0 my @capture = ();
1354 0 ▶ if ($] >= 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.006) { } 0 0 0
1355 0 push @capture, map { CORE::eval('$'.$_) } 1 .. CORE::eval('$#-');
1356 }
1357 else {
1358  
1359 # @{^CAPTURE} doesn't work enough in perl 5.005
1360 0 ▶ for (my $n_th=1; defined(CORE::eval('$'.$n_th)); $n_th++) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined eval '$' . $n_th) 0 0 0
1361 0 push @capture, CORE::eval('$'.$n_th);
1362 }
1363 }
1364 0 return @capture;
1365 }
1366 }
1367 }
1368  
1369 #---------------------------------------------------------------------
1370 # implement of special variable @+
1371 13 ▶sub mb::_LAST_MATCH_END (@) {
Subroutine _LAST_MATCH_END: called CC=4 SCAR=15.0
1372  
1373 # perl 5.005 does not support @+, so it need CORE::eval
1374  
1375 10 ▶ if ($mb::last_s_passed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::last_s_passed) { } 5 5 10
1376 5 ▶ if (scalar(@_) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ >= 1) { } 5 0 5
1377 5 return CORE::eval q{ ($+[0], @+[2..$#-])[ @_ ] };
1378 }
1379 else {
1380 0 return CORE::eval q{ ($+[0], @+[2..$#-]) };
1381 }
1382 }
1383 else {
1384 5 ▶ if (scalar(@_) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ >= 1) { } 5 0 5
1385 5 return CORE::eval q{ @+[ @_ ] };
1386 }
1387 else {
1388 0 return CORE::eval q{ @+ };
1389 }
1390 }
1391 }
1392  
1393 #---------------------------------------------------------------------
1394 # implement of special variable @-
1395 21 ▶sub mb::_LAST_MATCH_START (@) {
Subroutine _LAST_MATCH_START: called CC=4 SCAR=15.0
1396  
1397 # perl 5.005 does not support @-, so it need CORE::eval
1398  
1399 18 ▶ if ($mb::last_s_passed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::last_s_passed) { } 9 9 18
1400 9 ▶ if (scalar(@_) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ >= 1) { } 9 0 9
1401 9 return CORE::eval q{ ($-[2], @-[2..$#-])[ @_ ] };
1402 }
1403 else {
1404 0 return CORE::eval q{ ($-[2], @-[2..$#-]) };
1405 }
1406 }
1407 else {
1408 9 ▶ if (scalar(@_) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ >= 1) { } 9 0 9
1409 9 return CORE::eval q{ @-[ @_ ] };
1410 }
1411 else {
1412 0 return CORE::eval q{ @- };
1413 }
1414 }
1415 }
1416  
1417 #---------------------------------------------------------------------
1418 # implement of special variable $&
1419 64 ▶sub mb::_MATCH () {
Subroutine _MATCH: called CC=7 SCAR=24.0
1420 61 ▶ if (defined $&) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $&) { } 61 0 61
1421 61 ▶ if ($mb::last_s_passed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::last_s_passed) { } 8 53 61
1422 8 ▶ if (defined($1) and (CORE::substr($&, 0, CORE::length($1)) eq $1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1 and CORE::substr($&, 0, CORE::length $1) eq $1) { } 8 0 8
Condition33%1/3
defined $1 and CORE::substr($&, 0, CORE::length $1) eq $1
!ll&&!rl&&r
008
MC/DC0%0/2
defined $1 and CORE::substr($&, 0, CORE::length $1) eq $1
defined $1 CORE::substr($&, 0, CORE::length $1) eq $1
Truth table33%1/3
A and B
A= defined $1B= CORE::substr($&, 0, CORE::length $1) eq $1
ABresult
0X0
100
111
1423 8 return CORE::substr($&, CORE::length($1));
1424 }
1425 else {
1426 0 confess 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp';
1427 }
1428 }
1429 else {
1430 53 ▶ if (defined($1) and (CORE::substr($&, -CORE::length($1)) eq $1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1 and CORE::substr($&, -CORE::length($1)) eq $1) { } 53 0 53
Condition33%1/3
defined $1 and CORE::substr($&, -CORE::length($1)) eq $1
!ll&&!rl&&r
0053
MC/DC0%0/2
defined $1 and CORE::substr($&, -CORE::length($1)) eq $1
defined $1 CORE::substr($&, -CORE::length($1)) eq $1
Truth table33%1/3
A and B
A= defined $1B= CORE::substr($&, -CORE::length($1)) eq $1
ABresult
0X0
100
111
1431 53 return $1;
1432 }
1433 else {
1434 0 confess 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp';
1435 }
1436 }
1437 }
1438 else {
1439 0 return '';
1440 }
1441 }
1442  
1443 #---------------------------------------------------------------------
1444 # implement of special variable $`
1445 18 ▶sub mb::_PREMATCH () {
Subroutine _PREMATCH: called CC=5 SCAR=18.4
1446 15 ▶ if (defined $&) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $&) { } 15 0 15
1447 15 ▶ if ($mb::last_s_passed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::last_s_passed) { } 8 7 15
1448 8 return $1;
1449 }
1450 else {
1451 7 ▶ if (defined($1) and (CORE::substr($&,-CORE::length($1)) eq $1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1 and CORE::substr($&, -CORE::length($1)) eq $1) { } 7 0 7
Condition33%1/3
defined $1 and CORE::substr($&, -CORE::length($1)) eq $1
!ll&&!rl&&r
007
MC/DC0%0/2
defined $1 and CORE::substr($&, -CORE::length($1)) eq $1
defined $1 CORE::substr($&, -CORE::length($1)) eq $1
Truth table33%1/3
A and B
A= defined $1B= CORE::substr($&, -CORE::length($1)) eq $1
ABresult
0X0
100
111
1452 7 return CORE::substr($&, 0, -CORE::length($1));
1453 }
1454 else {
1455 0 confess 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp';
1456 }
1457 }
1458 }
1459 else {
1460 0 return '';
1461 }
1462 }
1463  
1464 #---------------------------------------------------------------------
1465 # flag off if last m// was pass
1466 130797 ▶sub mb::_m_passed () {
Subroutine _m_passed: called CC=1 SCAR=0.0
1467 130794 $mb::last_s_passed = 0;
1468 130794 return '';
1469 }
1470  
1471 #---------------------------------------------------------------------
1472 # flag on if last s/// was pass
1473 105 ▶sub mb::_s_passed () {
Subroutine _s_passed: called CC=1 SCAR=0.0
1474 102 $mb::last_s_passed = 1;
1475 102 return '';
1476 }
1477  
1478 #---------------------------------------------------------------------
1479 # ignore space of m/[here]/xx, qr/[here]/xx, s/[here]//xx
1480 132 ▶sub mb::_ignore_space ($) {
Subroutine _ignore_space: called CC=5 SCAR=16.1
1481 129 my($has_space) = @_;
1482 129 my $has_no_space = '';
1483  
1484 # parse into elements
1485 129 ▶ while ($has_space =~ /\G (
Branch: 1 branch
BranchTrueFalseTotal
if ($has_space =~ /\G ( \(\? \^? [a-z]* [:\)] | # cloister (?^x) (?^x: ... \(\? \^? [a-z]*-[a-z]+ [:\)] | # cloister (?^x-y) (?^x-y: ... \[ ((?: \\@mb::_dot | @mb::_dot )+?) \] | \\x\{ [0-9A-Fa-f]{2} \} | \\o\{ [0-7]{3} \} | \\x [0-9A-Fa-f]{2} | \\ [0-7]{3} | \\@mb::_dot | @mb::_dot ) /cgmsx) 1535 129 1664
1486 \(\? \^? [a-z]* [:\)] | # cloister (?^x) (?^x: ...
1487 \(\? \^? [a-z]*-[a-z]+ [:\)] | # cloister (?^x-y) (?^x-y: ...
1488 \[ ((?: \\@{mb::_dot} | @{mb::_dot} )+?) \] |
1489 \\x\{ [0-9A-Fa-f]{2} \} |
1490 \\o\{ [0-7]{3} \} |
1491 \\x [0-9A-Fa-f]{2} |
1492 \\ [0-7]{3} |
1493 \\@{mb::_dot} |
1494 @{mb::_dot}
1495 ) /xmsgc) {
1496 1535 my($element, $classmate) = ($1, $2);
1497  
1498 # in codepoint class
1499 1535 ▶ if (defined $classmate) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $classmate) { } 141 1394 1535
1500 141 $has_no_space .= '[';
1501 141 ▶ while ($classmate =~ /\G (
Branch: 1 branch
BranchTrueFalseTotal
if ($classmate =~ /\G ( \\x\{ [0-9A-Fa-f]{2} \} | \\o\{ [0-7]{3} \} | \\x [0-9A-Fa-f]{2} | \\ [0-7]{3} | \\@mb::_dot | @mb::_dot ) /cgmsx) 1947 141 2088
1502 \\x\{ [0-9A-Fa-f]{2} \} |
1503 \\o\{ [0-7]{3} \} |
1504 \\x [0-9A-Fa-f]{2} |
1505 \\ [0-7]{3} |
1506 \\@{mb::_dot} |
1507 @{mb::_dot}
1508 ) /xmsgc) {
1509 1947 my $element = $1;
1510 # perlre: /xx ignores unescaped tabs and space characters
1511 # within bracketed character classes (not vertical space)
1512 1947 ▶ if ($element !~ /\A[\t\x20]\z/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($element =~ /\A[\t\x20]\z/) 1947 0 1947
1513 1947 $has_no_space .= $element;
1514 }
1515 }
1516 141 $has_no_space .= ']';
1517 }
1518  
1519 # out of codepoint class
1520 else {
1521 1394 $has_no_space .= $element;
1522 }
1523 }
1524 129 return $has_no_space;
1525 }
1526  
1527 #---------------------------------------------------------------------
1528 # ignore case of m//i, qr//i, s///i
1529 67 ▶sub mb::_ignorecase ($) {
Subroutine _ignorecase: called CC=6 SCAR=18.0
1530 64 my($has_case) = @_;
1531 64 my $has_no_case = '';
1532  
1533 # parse into elements
1534 64 ▶ while ($has_case =~ /\G (
Branch: 1 branch
BranchTrueFalseTotal
if ($has_case =~ /\G ( \(\? \^? [a-z]* [:\)] | # cloister (?^x) (?^x: ... \(\? \^? [a-z]*-[a-z]+ [:\)] | # cloister (?^x-y) (?^x-y: ... \[ ((?: \\@mb::_dot | @mb::_dot )+?) \] | \\x\{ [0-9A-Fa-f]{2} \} | \\o\{ [0-7]{3} \} | \\x [0-9A-Fa-f]{2} | \\ [0-7]{3} | \\@mb::_dot | @mb::_dot ) /cgmsx) 512 64 576
1535 \(\? \^? [a-z]* [:\)] | # cloister (?^x) (?^x: ...
1536 \(\? \^? [a-z]*-[a-z]+ [:\)] | # cloister (?^x-y) (?^x-y: ...
1537 \[ ((?: \\@{mb::_dot} | @{mb::_dot} )+?) \] |
1538 \\x\{ [0-9A-Fa-f]{2} \} |
1539 \\o\{ [0-7]{3} \} |
1540 \\x [0-9A-Fa-f]{2} |
1541 \\ [0-7]{3} |
1542 \\@{mb::_dot} |
1543 @{mb::_dot}
1544 ) /xmsgc) {
1545 512 my($element, $classmate) = ($1, $2);
1546  
1547 # in codepoint class
1548 512 ▶ if (defined $classmate) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $classmate) { } 60 452 512
1549 60 $has_no_case .= '[';
1550 60 ▶ while ($classmate =~ /\G (
Branch: 1 branch
BranchTrueFalseTotal
if ($classmate =~ /\G ( \\x\{ [0-9A-Fa-f]{2} \} | \\o\{ [0-7]{3} \} | \\x [0-9A-Fa-f]{2} | \\ [0-7]{3} | \\@mb::_dot | @mb::_dot ) /cgmsx) 192 60 252
1551 \\x\{ [0-9A-Fa-f]{2} \} |
1552 \\o\{ [0-7]{3} \} |
1553 \\x [0-9A-Fa-f]{2} |
1554 \\ [0-7]{3} |
1555 \\@{mb::_dot} |
1556 @{mb::_dot}
1557 ) /xmsgc) {
1558 192 my $element = $1;
1559 $has_no_case .= {qw(
1560 A Aa a Aa
1561 B Bb b Bb
1562 C Cc c Cc
1563 D Dd d Dd
1564 E Ee e Ee
1565 F Ff f Ff
1566 G Gg g Gg
1567 H Hh h Hh
1568 I Ii i Ii
1569 J Jj j Jj
1570 K Kk k Kk
1571 L Ll l Ll
1572 M Mm m Mm
1573 N Nn n Nn
1574 O Oo o Oo
1575 P Pp p Pp
1576 Q Qq q Qq
1577 R Rr r Rr
1578 S Ss s Ss
1579 T Tt t Tt
1580 U Uu u Uu
1581 V Vv v Vv
1582 W Ww w Ww
1583 X Xx x Xx
1584 Y Yy y Yy
1585 Z Zz z Zz
1586 192 ▶ )}->{$element} || $element;
Condition66%2/3
{'A', 'Aa', 'a', 'Aa', 'B', 'Bb', 'b', 'Bb', 'C', 'Cc', 'c', 'Cc', 'D', 'Dd', 'd', 'Dd', 'E', 'Ee', 'e', 'Ee', 'F', 'Ff', 'f', 'Ff', 'G', 'Gg', 'g', 'Gg', 'H', 'Hh', 'h', 'Hh', 'I', 'Ii', 'i', 'Ii', 'J', 'Jj', 'j', 'Jj', 'K', 'Kk', 'k', 'Kk', 'L', 'Ll', 'l', 'Ll', 'M', 'Mm', 'm', 'Mm', 'N', 'Nn', 'n', 'Nn', 'O', 'Oo', 'o', 'Oo', 'P', 'Pp', 'p', 'Pp', 'Q', 'Qq', 'q', 'Qq', 'R', 'Rr', 'r', 'Rr', 'S', 'Ss', 's', 'Ss', 'T', 'Tt', 't', 'Tt', 'U', 'Uu', 'u', 'Uu', 'V', 'Vv', 'v', 'Vv', 'W', 'Ww', 'w', 'Ww', 'X', 'Xx', 'x', 'Xx', 'Y', 'Yy', 'y', 'Yy', 'Z', 'Zz', 'z', 'Zz'}->{$element} || $element
l!l&&r!l&&!r
121800
MC/DC0%0/2
{'A', 'Aa', 'a', 'Aa', 'B', 'Bb', 'b', 'Bb', 'C', 'Cc', 'c', 'Cc', 'D', 'Dd', 'd', 'Dd', 'E', 'Ee', 'e', 'Ee', 'F', 'Ff', 'f', 'Ff', 'G', 'Gg', 'g', 'Gg', 'H', 'Hh', 'h', 'Hh', 'I', 'Ii', 'i', 'Ii', 'J', 'Jj', 'j', 'Jj', 'K', 'Kk', 'k', 'Kk', 'L', 'Ll', 'l', 'Ll', 'M', 'Mm', 'm', 'Mm', 'N', 'Nn', 'n', 'Nn', 'O', 'Oo', 'o', 'Oo', 'P', 'Pp', 'p', 'Pp', 'Q', 'Qq', 'q', 'Qq', 'R', 'Rr', 'r', 'Rr', 'S', 'Ss', 's', 'Ss', 'T', 'Tt', 't', 'Tt', 'U', 'Uu', 'u', 'Uu', 'V', 'Vv', 'v', 'Vv', 'W', 'Ww', 'w', 'Ww', 'X', 'Xx', 'x', 'Xx', 'Y', 'Yy', 'y', 'Yy', 'Z', 'Zz', 'z', 'Zz'}->{$element} || $element
{'A', 'Aa', 'a', 'Aa', 'B', 'Bb', 'b', 'Bb', 'C', 'Cc', 'c', 'Cc', 'D', 'Dd', 'd', 'Dd', 'E', 'Ee', 'e', 'Ee', 'F', 'Ff', 'f', 'Ff', 'G', 'Gg', 'g', 'Gg', 'H', 'Hh', 'h', 'Hh', 'I', 'Ii', 'i', 'Ii', 'J', 'Jj', 'j', 'Jj', 'K', 'Kk', 'k', 'Kk', 'L', 'Ll', 'l', 'Ll', 'M', 'Mm', 'm', 'Mm', 'N', 'Nn', 'n', 'Nn', 'O', 'Oo', 'o', 'Oo', 'P', 'Pp', 'p', 'Pp', 'Q', 'Qq', 'q', 'Qq', 'R', 'Rr', 'r', 'Rr', 'S', 'Ss', 's', 'Ss', 'T', 'Tt', 't', 'Tt', 'U', 'Uu', 'u', 'Uu', 'V', 'Vv', 'v', 'Vv', 'W', 'Ww', 'w', 'Ww', 'X', 'Xx', 'x', 'Xx', 'Y', 'Yy', 'y', 'Yy', 'Z', 'Zz', 'z', 'Zz'}->{$element} $element
Truth table66%2/3
A || B
A= {'A', 'Aa', 'a', 'Aa', 'B', 'Bb', 'b', 'Bb', 'C', 'Cc', 'c', 'Cc', 'D', 'Dd', 'd', 'Dd', 'E', 'Ee', 'e', 'Ee', 'F', 'Ff', 'f', 'Ff', 'G', 'Gg', 'g', 'Gg', 'H', 'Hh', 'h', 'Hh', 'I', 'Ii', 'i', 'Ii', 'J', 'Jj', 'j', 'Jj', 'K', 'Kk', 'k', 'Kk', 'L', 'Ll', 'l', 'Ll', 'M', 'Mm', 'm', 'Mm', 'N', 'Nn', 'n', 'Nn', 'O', 'Oo', 'o', 'Oo', 'P', 'Pp', 'p', 'Pp', 'Q', 'Qq', 'q', 'Qq', 'R', 'Rr', 'r', 'Rr', 'S', 'Ss', 's', 'Ss', 'T', 'Tt', 't', 'Tt', 'U', 'Uu', 'u', 'Uu', 'V', 'Vv', 'v', 'Vv', 'W', 'Ww', 'w', 'Ww', 'X', 'Xx', 'x', 'Xx', 'Y', 'Yy', 'y', 'Yy', 'Z', 'Zz', 'z', 'Zz'}->{$element}B= $element
ABresult
1X1
011
000
1587 }
1588 60 $has_no_case .= ']';
1589 }
1590  
1591 # out of codepoint class
1592 else {
1593 $has_no_case .= {qw(
1594 A [Aa] a [Aa]
1595 B [Bb] b [Bb]
1596 C [Cc] c [Cc]
1597 D [Dd] d [Dd]
1598 E [Ee] e [Ee]
1599 F [Ff] f [Ff]
1600 G [Gg] g [Gg]
1601 H [Hh] h [Hh]
1602 I [Ii] i [Ii]
1603 J [Jj] j [Jj]
1604 K [Kk] k [Kk]
1605 L [Ll] l [Ll]
1606 M [Mm] m [Mm]
1607 N [Nn] n [Nn]
1608 O [Oo] o [Oo]
1609 P [Pp] p [Pp]
1610 Q [Qq] q [Qq]
1611 R [Rr] r [Rr]
1612 S [Ss] s [Ss]
1613 T [Tt] t [Tt]
1614 U [Uu] u [Uu]
1615 V [Vv] v [Vv]
1616 W [Ww] w [Ww]
1617 X [Xx] x [Xx]
1618 Y [Yy] y [Yy]
1619 Z [Zz] z [Zz]
1620 452 ▶ )}->{$element} || $element;
Condition66%2/3
{'A', '[Aa]', 'a', '[Aa]', 'B', '[Bb]', 'b', '[Bb]', 'C', '[Cc]', 'c', '[Cc]', 'D', '[Dd]', 'd', '[Dd]', 'E', '[Ee]', 'e', '[Ee]', 'F', '[Ff]', 'f', '[Ff]', 'G', '[Gg]', 'g', '[Gg]', 'H', '[Hh]', 'h', '[Hh]', 'I', '[Ii]', 'i', '[Ii]', 'J', '[Jj]', 'j', '[Jj]', 'K', '[Kk]', 'k', '[Kk]', 'L', '[Ll]', 'l', '[Ll]', 'M', '[Mm]', 'm', '[Mm]', 'N', '[Nn]', 'n', '[Nn]', 'O', '[Oo]', 'o', '[Oo]', 'P', '[Pp]', 'p', '[Pp]', 'Q', '[Qq]', 'q', '[Qq]', 'R', '[Rr]', 'r', '[Rr]', 'S', '[Ss]', 's', '[Ss]', 'T', '[Tt]', 't', '[Tt]', 'U', '[Uu]', 'u', '[Uu]', 'V', '[Vv]', 'v', '[Vv]', 'W', '[Ww]', 'w', '[Ww]', 'X', '[Xx]', 'x', '[Xx]', 'Y', '[Yy]', 'y', '[Yy]', 'Z', '[Zz]', 'z', '[Zz]'}->{$element} || $element
l!l&&r!l&&!r
763760
MC/DC0%0/2
{'A', '[Aa]', 'a', '[Aa]', 'B', '[Bb]', 'b', '[Bb]', 'C', '[Cc]', 'c', '[Cc]', 'D', '[Dd]', 'd', '[Dd]', 'E', '[Ee]', 'e', '[Ee]', 'F', '[Ff]', 'f', '[Ff]', 'G', '[Gg]', 'g', '[Gg]', 'H', '[Hh]', 'h', '[Hh]', 'I', '[Ii]', 'i', '[Ii]', 'J', '[Jj]', 'j', '[Jj]', 'K', '[Kk]', 'k', '[Kk]', 'L', '[Ll]', 'l', '[Ll]', 'M', '[Mm]', 'm', '[Mm]', 'N', '[Nn]', 'n', '[Nn]', 'O', '[Oo]', 'o', '[Oo]', 'P', '[Pp]', 'p', '[Pp]', 'Q', '[Qq]', 'q', '[Qq]', 'R', '[Rr]', 'r', '[Rr]', 'S', '[Ss]', 's', '[Ss]', 'T', '[Tt]', 't', '[Tt]', 'U', '[Uu]', 'u', '[Uu]', 'V', '[Vv]', 'v', '[Vv]', 'W', '[Ww]', 'w', '[Ww]', 'X', '[Xx]', 'x', '[Xx]', 'Y', '[Yy]', 'y', '[Yy]', 'Z', '[Zz]', 'z', '[Zz]'}->{$element} || $element
{'A', '[Aa]', 'a', '[Aa]', 'B', '[Bb]', 'b', '[Bb]', 'C', '[Cc]', 'c', '[Cc]', 'D', '[Dd]', 'd', '[Dd]', 'E', '[Ee]', 'e', '[Ee]', 'F', '[Ff]', 'f', '[Ff]', 'G', '[Gg]', 'g', '[Gg]', 'H', '[Hh]', 'h', '[Hh]', 'I', '[Ii]', 'i', '[Ii]', 'J', '[Jj]', 'j', '[Jj]', 'K', '[Kk]', 'k', '[Kk]', 'L', '[Ll]', 'l', '[Ll]', 'M', '[Mm]', 'm', '[Mm]', 'N', '[Nn]', 'n', '[Nn]', 'O', '[Oo]', 'o', '[Oo]', 'P', '[Pp]', 'p', '[Pp]', 'Q', '[Qq]', 'q', '[Qq]', 'R', '[Rr]', 'r', '[Rr]', 'S', '[Ss]', 's', '[Ss]', 'T', '[Tt]', 't', '[Tt]', 'U', '[Uu]', 'u', '[Uu]', 'V', '[Vv]', 'v', '[Vv]', 'W', '[Ww]', 'w', '[Ww]', 'X', '[Xx]', 'x', '[Xx]', 'Y', '[Yy]', 'y', '[Yy]', 'Z', '[Zz]', 'z', '[Zz]'}->{$element} $element
Truth table66%2/3
A || B
A= {'A', '[Aa]', 'a', '[Aa]', 'B', '[Bb]', 'b', '[Bb]', 'C', '[Cc]', 'c', '[Cc]', 'D', '[Dd]', 'd', '[Dd]', 'E', '[Ee]', 'e', '[Ee]', 'F', '[Ff]', 'f', '[Ff]', 'G', '[Gg]', 'g', '[Gg]', 'H', '[Hh]', 'h', '[Hh]', 'I', '[Ii]', 'i', '[Ii]', 'J', '[Jj]', 'j', '[Jj]', 'K', '[Kk]', 'k', '[Kk]', 'L', '[Ll]', 'l', '[Ll]', 'M', '[Mm]', 'm', '[Mm]', 'N', '[Nn]', 'n', '[Nn]', 'O', '[Oo]', 'o', '[Oo]', 'P', '[Pp]', 'p', '[Pp]', 'Q', '[Qq]', 'q', '[Qq]', 'R', '[Rr]', 'r', '[Rr]', 'S', '[Ss]', 's', '[Ss]', 'T', '[Tt]', 't', '[Tt]', 'U', '[Uu]', 'u', '[Uu]', 'V', '[Vv]', 'v', '[Vv]', 'W', '[Ww]', 'w', '[Ww]', 'X', '[Xx]', 'x', '[Xx]', 'Y', '[Yy]', 'y', '[Yy]', 'Z', '[Zz]', 'z', '[Zz]'}->{$element}B= $element
ABresult
1X1
011
000
1621 }
1622 }
1623 64 return qr{$has_no_case};
1624 }
1625  
1626 #---------------------------------------------------------------------
1627 # custom codepoint class in qq-like regular expression
1628 130942 ▶sub mb::_cc ($) {
Subroutine _cc: called CC=2 SCAR=6.9
1629 130939 my($classmate) = @_;
1630 130939 ▶ if ($classmate =~ s{\A \^ }{}xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($classmate =~ s/\A \^ //msx) { } 64959 65980 130939
1631 64959 return '(?:(?!' . parse_re_codepoint_class($classmate) . ")$x)";
1632 }
1633 else {
1634 65980 return '(?:(?=' . parse_re_codepoint_class($classmate) . ")$x)";
1635 }
1636 }
1637  
1638 #---------------------------------------------------------------------
1639 # makes clustered codepoint from string
1640 25 ▶sub mb::_clustered_codepoint ($) {
Subroutine _clustered_codepoint: called CC=3 SCAR=11.0
1641 22 ▶ if (my @codepoint = $_[0] =~ /\G($x)/xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@codepoint) = $_[0] =~ /\G($x)/cgmsx) { } 10 12 22
1642 10 ▶ if (CORE::length($codepoint[$#codepoint]) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $codepoint[$#codepoint] == 1) { } 5 5 10
1643 5 return $_[0];
1644 }
1645 else {
1646 5 return join '', @codepoint[ 0 .. $#codepoint-1 ], "(?:$codepoint[$#codepoint])";
1647 }
1648 }
1649 else {
1650 12 return '';
1651 }
1652 }
1653  
1654 #---------------------------------------------------------------------
1655 # open for append -- returns glob-name string on success, "" on failure.
1656 # Works on Perl 5.005_03 and all later versions.
1657 # Always uses a unique numbered package glob (mb::FH::H<n>) so that
1658 # concurrent callers each get their own IO slot.
1659 3 ▶sub mb::_open_a ($) {
Subroutine _open_a: called CC=2 SCAR=12.2
1660 0 $mb::_fh_seq++;
1661 0 my $fhn = "mb::FH::H$mb::_fh_seq";
1662 0 ▶ { no strict 'refs'; open($fhn, ">> $_[0]") or return "" }
Subroutine BEGIN: called CC=1 SCAR=1.7
Branch: 1 branch
BranchTrueFalseTotal
open $fhn, ">> $_[0]" or return "" 0 0 0
1663 0 return $fhn;
1664 }
1665  
1666 #---------------------------------------------------------------------
1667 # open for read -- returns glob-name string on success, "" on failure.
1668 18 ▶sub mb::_open_r ($) {
Subroutine _open_r: called CC=2 SCAR=7.0
1669 15 $mb::_fh_seq++;
1670 15 my $fhn = "mb::FH::H$mb::_fh_seq";
1671 190 ▶ { no strict 'refs'; open($fhn, "< $_[0]") or return "" }
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
open $fhn, "< $_[0]" or return "" 15 0 15
1672 15 return $fhn;
1673 }
1674  
1675 #---------------------------------------------------------------------
1676 # open for write -- returns glob-name string on success, "" on failure.
1677 13 ▶sub mb::_open_w ($) {
Subroutine _open_w: called CC=2 SCAR=7.0
1678 10 $mb::_fh_seq++;
1679 10 my $fhn = "mb::FH::H$mb::_fh_seq";
1680 190 ▶ { no strict 'refs'; open($fhn, "> $_[0]") or return "" }
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
open $fhn, "> $_[0]" or return "" 10 0 10
1681 10 return $fhn;
1682 }
1683  
1684 #---------------------------------------------------------------------
1685 # split() runtime function (UTF8::R2 compatible)
1686 #
1687 # This is the runtime entry point that a path-3 user calls directly as
1688 # mb::split(...). It mirrors UTF8::R2::split so that scripts ported from the
1689 # UTF8::R2 environment behave identically. The transpiler does NOT use this;
1690 # transpiled "split" is rewritten to mb::_split() below, which is a separate,
1691 # more elaborate implementation tuned for the filter/modulino paths.
1692 #
1693 # Note: mb::qr() returns a plain regular-expression STRING (not a qr// object,
1694 # which matters on perl 5.005_03; see _r2_qr), so the pattern is interpolated
1695 # into a fresh qr{...} before it is handed to CORE::split.
1696 59 ▶sub mb::split (;$$$) {
Subroutine split: called CC=14 SCAR=28.5
Pod undocumented
1697 56 ▶ if (defined($_[0]) and (($_[0] eq '') or ($_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x))) {
Branch: 4 branches
BranchTrueFalseTotal
if (defined $_[0] and $_[0] eq '' || $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x) { } 38 18 56
elsif (@_ == 3) { } 12 6 18
elsif (@_ == 2) { } 6 0 6
elsif (@_ == 1) { } 0 0 0
Condition83%5/6
defined $_[0] and $_[0] eq "" || $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x
!ll&&!rl&&r
01838
$_[0] eq "" or $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x
l!l&&r!l&&!r
122618
MC/DC66%2/3
defined $_[0] and $_[0] eq "" || $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x
defined $_[0] $_[0] eq "" $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x
Truth table75%3/4
A and B or C
A= defined $_[0]B= $_[0] eq ""C= $_[0] =~ /\A \( \? \^? [-a-z]* : \) \z/x
ABCresult
0XX0
1000
11X1
1011
1698 38 ▶ my @x = (defined($_[1]) ? $_[1] : $_) =~ /\G$x/g;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 30 8 38
1699 38 ▶ if (defined($_[2]) and ($_[2] > 0) and (scalar(@x) > $_[2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[2] and $_[2] > 0 and scalar @x > $_[2]) 12 26 38
Condition100%6/6
defined $_[2] and $_[2] > 0 and scalar @x > $_[2]
!ll&&!rl&&r
22412
defined $_[2] and $_[2] > 0
!ll&&!rl&&r
20216
MC/DC100%3/3
defined $_[2] and $_[2] > 0 and scalar @x > $_[2]
defined $_[2] $_[2] > 0 scalar @x > $_[2]
Truth table100%4/4
A and B and C
A= defined $_[2]B= $_[2] > 0C= scalar @x > $_[2]
ABCresult
0XX0
10X0
1100
1111
1700 12 @x = (@x[0..$_[2]-1-1], join('', @x[$_[2]-1..$#x]));
1701 }
1702 38 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 26 12 38
1703 26 return @x;
1704 }
1705 else {
1706 12 ▶ if ($] < 5.012) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.012") 0 12 12
1707 0 ▶ warn "Use of implicit split to \@_ is deprecated" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
1708 0 @_ = @x; # unlike camel book and perldoc saying, can return only scalar(@_), cannot @_
1709 }
1710 12 return scalar @x;
1711 }
1712 }
1713 elsif (@_ == 3) {
1714 12 return CORE::split qr{@{[mb::qr($_[0])]}}, $_[1], $_[2];
1715 }
1716 elsif (@_ == 2) {
1717 6 return CORE::split qr{@{[mb::qr($_[0])]}}, $_[1];
1718 }
1719 elsif (@_ == 1) {
1720 0 return CORE::split qr{@{[mb::qr($_[0])]}};
1721 }
1722 else {
1723 0 return CORE::split;
1724 }
1725 }
1726  
1727 #---------------------------------------------------------------------
1728 # split() for MBCS encoding
1729 347 ▶sub mb::_split (;$$$) {
Subroutine _split: called CC=23 SCAR=31.4
1730 344 ▶ my $pattern = defined($_[0]) ? $_[0] : ' ';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 314 30 344
1731 344 ▶ my $string = defined($_[1]) ? $_[1] : $_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 210 134 344
1732 344 my @split = ();
1733  
1734 # split's first argument is more consistently interpreted
1735 #
1736 # After some changes earlier in v5.17, split's behavior has been simplified:
1737 # if the PATTERN argument evaluates to a string containing one space, it is
1738 # treated the way that a literal string containing one space once was.
1739 # http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted
1740 # if $pattern is also omitted or is the literal space, " ", the function splits
1741 # on whitespace, /\s+/, after skipping any leading whitespace
1742  
1743 344 ▶ if ($pattern eq ' ') {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern eq " ") 108 236 344
1744 108 $pattern = qr/\s+/;
1745 108 $string =~ s{\A \s+ }{}xms;
1746 }
1747  
1748 # count '(' in pattern
1749 344 my @parsed = ();
1750 344 my $modifier = '';
1751 344 ▶ if ((($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /xms) and ($modifier =~ /x/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /msx and $modifier =~ /x/msx) { } 39 305 344
Condition100%3/3
($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /msx and $modifier =~ /x/msx
!ll&&!rl&&r
430139
MC/DC100%2/2
($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /msx and $modifier =~ /x/msx
($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /msx $modifier =~ /x/msx
Truth table100%3/3
A and B
A= ($modifier) = $pattern =~ /\A \(\?\^? (.+?) [\)\-\:] /msxB= $modifier =~ /x/msx
ABresult
0X0
100
111
1752 39 @parsed = $pattern =~ m{ \G (
1753 \\ $x |
1754 \# .*? $ | # comment on /x modifier
1755 \(\?\# (?:$x)*? \) |
1756 \[ (?:$x)+? \] |
1757 \(\? |
1758 \(\+ |
1759 \(\* |
1760 $x |
1761 [\x00-\xFF]
1762 ) }xgc;
1763 }
1764 else {
1765 305 @parsed = $pattern =~ m{ \G (
1766 \\ $x |
1767 \(\?\# (?:$x)*? \) |
1768 \[ (?:$x)+? \] |
1769 \(\? |
1770 \(\+ |
1771 \(\* |
1772 $x |
1773 [\x00-\xFF]
1774 ) }xgc;
1775 }
1776 my $last_match_no =
1777 1 + # first '(' is for substring
1778 344 scalar(grep { $_ eq '(' } @parsed); # other '(' are for pattern of split()
1779  
1780 # Repeated Patterns Matching a Zero-length Substring
1781 # https://perldoc.perl.org/perlre.html#Repeated-Patterns-Matching-a-Zero-length-Substring
1782 344 ▶ my $substring_quantifier = ('' =~ / \A $pattern \z /xms) ? '+?' : '*?';
Branch: 1 branch
BranchTrueFalseTotal
'' =~ / \A $pattern \z /msx ? : 21 323 344
1783  
1784 # if $_[2] specified and positive
1785 344 ▶ if (defined($_[2]) and ($_[2] >= 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[2] and $_[2] >= 1) { } 21 323 344
Condition100%3/3
defined $_[2] and $_[2] >= 1
!ll&&!rl&&r
3111221
MC/DC100%2/2
defined $_[2] and $_[2] >= 1
defined $_[2] $_[2] >= 1
Truth table100%3/3
A and B
A= defined $_[2]B= $_[2] >= 1
ABresult
0X0
100
111
1786 21 my $limit = $_[2];
1787  
1788 21 CORE::eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (nnnnn) exceeded at ...
1789  
1790 # gets substrings by repeat chopping by pattern
1791 21 ▶ while ((--$limit > 0) and ($string =~ s<\A((?:$x)$substring_quantifier)$pattern><>)) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$limit > 0 and $string =~ s/\A((?:$x)$substring_quantifier)$pattern//) 42 21 63
Condition100%3/3
--$limit > 0 and $string =~ s/\A((?:$x)$substring_quantifier)$pattern//
!ll&&!rl&&r
15642
MC/DC100%2/2
--$limit > 0 and $string =~ s/\A((?:$x)$substring_quantifier)$pattern//
--$limit > 0 $string =~ s/\A((?:$x)$substring_quantifier)$pattern//
Truth table100%3/3
A and B
A= --$limit > 0B= $string =~ s/\A((?:$x)$substring_quantifier)$pattern//
ABresult
0X0
100
111
1792 42 ▶ for (my $n_th=1; $n_th <= $last_match_no; $n_th++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n_th <= $last_match_no) 42 42 84
1793 42 push @split, CORE::eval('$'.$n_th);
1794 }
1795 }
1796 }
1797  
1798 # if $_[2] is omitted or zero or negative
1799 else {
1800 323 CORE::eval q{ no warnings }; # avoid: Complex regular subexpression recursion limit (nnnnn) exceeded at ...
1801  
1802 # gets substrings by repeat chopping by pattern
1803 323 ▶ while ($string =~ s<\A((?:$x)$substring_quantifier)$pattern><>) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\A((?:$x)$substring_quantifier)$pattern//) 754 323 1077
1804 754 ▶ for (my $n_th=1; $n_th <= $last_match_no; $n_th++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n_th <= $last_match_no) 806 754 1560
1805 806 push @split, CORE::eval('$'.$n_th);
1806 }
1807 }
1808 }
1809  
1810 # get last substring
1811 344 ▶ if (CORE::length($string) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (CORE::length $string > 0) { } 311 33 344
elsif (defined $_[2] and $_[2] >= 1) { } 6 48 54
1812 311 push @split, $string;
1813 }
1814 ▶ elsif (defined($_[2]) and ($_[2] >= 1)) {
Condition100%3/3
defined $_[2] and $_[2] >= 1
!ll&&!rl&&r
2166
MC/DC100%2/2
defined $_[2] and $_[2] >= 1
defined $_[2] $_[2] >= 1
Truth table100%3/3
A and B
A= defined $_[2]B= $_[2] >= 1
ABresult
0X0
100
111
1815 6 ▶ if (scalar(@split) < $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @split < $_[2]) 6 0 6
1816 6 push @split, ('') x ($_[2] - scalar(@split));
1817 }
1818 }
1819  
1820 # if $_[2] is omitted or zero, trailing null fields are stripped from the result
1821 344 ▶ if ((not defined $_[2]) or ($_[2] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_[2] or $_[2] == 0) 317 27 344
Condition100%3/3
not defined $_[2] or $_[2] == 0
l!l&&r!l&&!r
311627
MC/DC100%2/2
not defined $_[2] or $_[2] == 0
not defined $_[2] $_[2] == 0
Truth table100%3/3
not(A) or B
A= not defined $_[2]B= $_[2] == 0
ABresult
1X1
011
000
1822 317 ▶ while ((scalar(@split) >= 1) and ($split[-1] eq '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @split >= 1 and $split[-1] eq "") 0 317 317
Condition33%1/3
scalar @split >= 1 and $split[-1] eq ""
!ll&&!rl&&r
03170
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
1823 0 pop @split;
1824 }
1825 }
1826  
1827 # old days, split had write its result to @_ on scalar context,
1828 # but this usage is no longer supported
1829  
1830 344 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 211 133 344
1831 211 return @split;
1832 }
1833 else {
1834 133 return scalar @split;
1835 }
1836 }
1837  
1838 ######################################################################
1839 # runtime routines for MSWin32 (used automatically)
1840 ######################################################################
1841  
1842 #---------------------------------------------------------------------
1843 # chdir() for MSWin32
1844 5 ▶sub mb::_chdir (;$) {
Subroutine _chdir: called CC=17 SCAR=54.1
1845  
1846 # not on MSWin32 or UTF-8
1847 2 ▶ if (($OSNAME !~ /MSWin32/) or ($script_encoding !~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx) 2 0 2
Condition33%1/3
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
200
MC/DC0%0/2
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
Truth table33%1/3
A and B
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
ABresult
0X0
100
111
1848 2 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 0 2 2
1849 0 return CORE::chdir;
1850 }
1851 else {
1852 2 return CORE::chdir $_[0];
1853 }
1854 }
1855  
1856 # on MSWin32
1857 0 ▶ if (@_ == 0) {
Branch: 5 branches
BranchTrueFalseTotal
if (@_ == 0) { } 0 0 0
elsif ($script_encoding =~ /\A (?: sjis | informixv6als ) \z/msx and $_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/msx) { } 0 0 0
elsif ($script_encoding =~ /\A (?: hp15 ) \z/msx and $_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/msx) { } 0 0 0
elsif ($script_encoding =~ /\A (?: johab ) \z/msx and $_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/msx) { } 0 0 0
elsif ($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/msx and $_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/msx) { } 0 0 0
1858 0 return CORE::chdir;
1859 }
1860 ▶ elsif (($script_encoding =~ /\A (?: sjis | informixv6als ) \z/xms) and ($_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/xms)) {
Condition0%0/3
$script_encoding =~ /\A (?: sjis | informixv6als ) \z/msx and $_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/msx
!ll&&!rl&&r
000
MC/DC0%0/2
$script_encoding =~ /\A (?: sjis | informixv6als ) \z/msx and $_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/msx
$script_encoding =~ /\A (?: sjis | informixv6als ) \z/msx $_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/msx
Truth table0%0/3
A and B
A= $script_encoding =~ /\A (?: sjis | informixv6als ) \z/msxB= $_[0] =~ /\A $x* [\x81-\x9F\xE0-\xFC][\x5C] \z/msx
ABresult
0X0
100
111
1861 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
1862 0 return 0;
1863 }
1864 else {
1865 0 confess "mb::_chdir: Can't chdir '$_[0]'\n";
1866 }
1867 }
1868 ▶ elsif (($script_encoding =~ /\A (?: hp15 ) \z/xms) and ($_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/xms)) {
Condition0%0/3
$script_encoding =~ /\A (?: hp15 ) \z/msx and $_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/msx
!ll&&!rl&&r
000
MC/DC0%0/2
$script_encoding =~ /\A (?: hp15 ) \z/msx and $_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/msx
$script_encoding =~ /\A (?: hp15 ) \z/msx $_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/msx
Truth table0%0/3
A and B
A= $script_encoding =~ /\A (?: hp15 ) \z/msxB= $_[0] =~ /\A $x* [\x80-\xA0\xE0-\xFE][\x5C] \z/msx
ABresult
0X0
100
111
1869 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
1870 0 return 0;
1871 }
1872 else {
1873 0 confess "mb::_chdir: Can't chdir '$_[0]'\n";
1874 }
1875 }
1876 ▶ elsif (($script_encoding =~ /\A (?: johab ) \z/xms) and ($_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/xms)) {
Condition0%0/3
$script_encoding =~ /\A (?: johab ) \z/msx and $_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/msx
!ll&&!rl&&r
000
MC/DC0%0/2
$script_encoding =~ /\A (?: johab ) \z/msx and $_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/msx
$script_encoding =~ /\A (?: johab ) \z/msx $_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/msx
Truth table0%0/3
A and B
A= $script_encoding =~ /\A (?: johab ) \z/msxB= $_[0] =~ /\A $x* [\x81-\xD3\xD8-\xDE\xE0-\xF9][\x5C] \z/msx
ABresult
0X0
100
111
1877 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
1878 0 return 0;
1879 }
1880 else {
1881 0 confess "mb::_chdir: Can't chdir '$_[0]'\n";
1882 }
1883 }
1884 ▶ elsif (($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/xms) and ($_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/xms)) {
Condition0%0/3
$script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/msx and $_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/msx
!ll&&!rl&&r
000
MC/DC0%0/2
$script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/msx and $_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/msx
$script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/msx $_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/msx
Truth table0%0/3
A and B
A= $script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs | gb18030 ) \z/msxB= $_[0] =~ /\A $x* [\x81-\xFE][\x5C] \z/msx
ABresult
0X0
100
111
1885 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
1886 0 return 0;
1887 }
1888 else {
1889 0 confess "mb::_chdir: Can't chdir '$_[0]'\n";
1890 }
1891 }
1892 else {
1893 0 return CORE::chdir $_[0];
1894 }
1895 }
1896  
1897 #---------------------------------------------------------------------
1898 # stackable filetest -X -Y -Z for MSWin32
1899 3038 ▶sub mb::_filetest {
Subroutine _filetest: called CC=14 SCAR=31.3
1900 3035 my @filetest = map { /(-[A-Za-z])/g } @{ shift(@_) };
1901 3035 ▶ local $_ = @_ ? shift : (($filetest[-1] eq '-t') ? \*STDIN : $_);
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 3035 0 3035
$filetest[-1] eq '-t' ? : 0 0 0
1902 3035 ▶ confess "Too many arguments for filetest @filetest" if @_ and not wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if @_ and not wantarray 0 3035 3035
Condition33%1/3
@_ and not wantarray
!ll&&!rl&&r
303500
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
1903  
1904 # testee has "\x5C" octet at end
1905 3035 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/) 0 3035 3035
Condition33%2/6
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
!ll&&!rl&&r
303500
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
303500
MC/DC0%0/3
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx /[\x5C]\z/
Truth table25%1/4
A and B and C
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msxC= /[\x5C]\z/
ABCresult
0XX0
10X0
1100
1111
1906 ($OSNAME =~ /MSWin32/) and
1907 ($script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms) and
1908 /[\x5C]\z/
1909 ) {
1910 0 $_ = qq{$_.};
1911 }
1912  
1913 # supports stackable filetest
1914 3035 my $result;
1915 3035 my $filetest = pop @filetest;
1916 3035 ▶ if ($result = CORE::eval($filetest . ' $_')) { # '$_' at 1st time, and ...
Branch: 1 branch
BranchTrueFalseTotal
if ($result = eval $filetest . ' $_') { } 1272 1763 3035
1917 }
1918 else {
1919 1763 ▶ return wantarray ? ($result, @_) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1763 1763
1920 }
1921 1272 for my $filetest (CORE::reverse @filetest) {
1922 10 ▶ if ($result = CORE::eval($filetest . ' _')) { # '_' at 2nd time or later
Branch: 1 branch
BranchTrueFalseTotal
if ($result = eval $filetest . ' _') { } 9 1 10
1923 }
1924 else {
1925 1 ▶ return wantarray ? ($result, @_) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
1926 }
1927 }
1928 1271 ▶ return wantarray ? ($result, @_) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1271 1271
1929 }
1930  
1931 #---------------------------------------------------------------------
1932 # lstat() for MSWin32
1933 6 ▶sub mb::_lstat (;$) {
Subroutine _lstat: called CC=6 SCAR=23.5
1934 3 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3 0 3
1935 3 ▶ if ($_ eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "_") 0 3 3
1936 0 confess qq{lstat doesn't support '_'\n};
1937 }
1938  
1939 # testee has "\x5C" octet at end
1940 3 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/) 0 3 3
Condition33%2/6
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
!ll&&!rl&&r
300
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
300
MC/DC0%0/3
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx /[\x5C]\z/
Truth table25%1/4
A and B and C
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msxC= /[\x5C]\z/
ABCresult
0XX0
10X0
1100
1111
1941 ($OSNAME =~ /MSWin32/) and
1942 ($script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms) and
1943 /[\x5C]\z/
1944 ) {
1945 0 $_ = qq{$_.};
1946 }
1947  
1948 3 return CORE::lstat $_;
1949 }
1950  
1951 #---------------------------------------------------------------------
1952 # opendir() for MSWin32
1953 10 ▶sub mb::_opendir ($$) {
Subroutine _opendir: called CC=6 SCAR=24.2
1954 7 ▶ if (not defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[0]) 3 4 7
1955 3 $_[0] = \do { local *_ };
1956 }
1957  
1958 # works on MSWin32 only
1959 7 ▶ if (($OSNAME !~ /MSWin32/) or ($script_encoding !~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $OSNAME =~ /MSWin32/ && $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx) { } 7 0 7
elsif (-d $_[1]) { } 0 0 0
elsif (-d "$_[1].") { } 0 0 0
Condition33%1/3
$OSNAME =~ /MSWin32/ && $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
700
MC/DC0%0/2
$OSNAME =~ /MSWin32/ && $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
Truth table33%1/3
A && B
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
ABresult
0X0
100
111
1960 7 return CORE::opendir $_[0], $_[1];
1961 }
1962 elsif (-d $_[1]) {
1963 0 return CORE::opendir $_[0], $_[1];
1964 }
1965 elsif (-d qq{$_[1].}) {
1966 0 return CORE::opendir $_[0], qq{$_[1].};
1967 }
1968 0 return undef;
1969 }
1970  
1971 #---------------------------------------------------------------------
1972 # stat() for MSWin32
1973 12 ▶sub mb::_stat (;$) {
Subroutine _stat: called CC=5 SCAR=20.9
1974 9 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 9 0 9
1975  
1976 # testee has "\x5C" octet at end
1977 9 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/) 0 9 9
Condition33%2/6
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
!ll&&!rl&&r
900
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
900
MC/DC0%0/3
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx and /[\x5C]\z/
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx /[\x5C]\z/
Truth table25%1/4
A and B and C
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msxC= /[\x5C]\z/
ABCresult
0XX0
10X0
1100
1111
1978 ($OSNAME =~ /MSWin32/) and
1979 ($script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms) and
1980 /[\x5C]\z/
1981 ) {
1982 0 $_ = qq{$_.};
1983 }
1984  
1985 9 return CORE::stat $_;
1986 }
1987  
1988 #---------------------------------------------------------------------
1989 # unlink() for MSWin32
1990 2133 ▶sub mb::_unlink (@) {
Subroutine _unlink: called CC=8 SCAR=35.9
1991  
1992 # works on MSWin32 only
1993 2130 ▶ if (($OSNAME !~ /MSWin32/) or ($script_encoding !~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx) 2130 0 2130
Condition33%1/3
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
!ll&&!rl&&r
213000
MC/DC0%0/2
$OSNAME =~ /MSWin32/ and $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
$OSNAME =~ /MSWin32/ $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
Truth table33%1/3
A and B
A= $OSNAME =~ /MSWin32/B= $script_encoding =~ /\A (?: sjis | informixv6als | hp15 | gbk | uhc | johab | big5 | big5hkscs | gb18030 ) \z/msx
ABresult
0X0
100
111
1994 2130 ▶ return CORE::unlink(@_ ? @_ : $_);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2130 0 2130
1995 }
1996  
1997 0 my $unlink = 0;
1998 0 ▶ for (@_ ? @_ : $_) {
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
1999 0 ▶ if (CORE::unlink) {
Branch: 2 branches
BranchTrueFalseTotal
if (unlink $_) { } 0 0 0
elsif (unlink "$_.") { } 0 0 0
2000 0 $unlink++;
2001 }
2002 elsif (CORE::unlink qq{$_.}) {
2003 0 $unlink++;
2004 }
2005 }
2006 0 return $unlink;
2007 }
2008  
2009 ######################################################################
2010 # source code filter
2011 ######################################################################
2012  
2013 #---------------------------------------------------------------------
2014 # detect system encoding any of big5, big5hkscs, eucjp, euctw, gb18030, gbk, sjis, uhc, utf8
2015 # (hp15, informixv6als, johab, rfc2279, and wtf8 are never auto-detected: no operating
2016 # system ships a system locale under those names; rfc2279/wtf8 scripts run
2017 # under the utf8 default, hp15/informixv6als must be selected with -e)
2018 225 ▶sub detect_system_encoding {
Subroutine detect_system_encoding: called CC=22 SCAR=34.2
Pod undocumented
2019  
2020 # running on Microsoft Windows
2021 222 ▶ if ($OSNAME =~ /MSWin32/) {
Branch: 4 branches
BranchTrueFalseTotal
if ($OSNAME =~ /MSWin32/) { } 0 222 222
elsif ($OSNAME =~ /solaris/) { } 10 212 222
elsif ($OSNAME =~ /hpux/) { } 8 204 212
elsif ($OSNAME =~ /aix/) { } 8 196 204
2022 0 ▶ if (my($codepage) = qx{chcp} =~ m/[^0123456789](932|936|949|950|951|20932|54936)\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($codepage) = `chcp` =~ /[^0123456789](932|936|949|950|951|20932|54936)\Z/) { } 0 0 0
2023  
2024 # "Code Page Identifiers" (Microsoft Learn)
2025 # https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
2026 return {
2027 '932' => 'sjis', # ANSI/OEM Japanese; Japanese (Shift-JIS)
2028 '936' => 'gbk', # ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312), GBK since Windows 95
2029 '949' => 'uhc', # ANSI/OEM Korean (Unified Hangul Code)
2030 '950' => 'big5', # ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
2031 '951' => 'big5hkscs', # Big5-HKSCS variant of 950 installed by the HKSCS support update; not listed on the Code Page Identifiers page
2032 '20932' => 'eucjp', # Japanese (JIS 0208-1990 and 0212-1990), EUC-JP
2033 '54936' => 'gb18030', # Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)
2034 0 }->{$codepage};
2035 }
2036 else {
2037 0 return 'utf8';
2038 }
2039 }
2040  
2041 # running on Oracle Solaris
2042 elsif ($OSNAME =~ /solaris/) {
2043 my $LANG =
2044 defined($ENV{'LC_ALL'}) ? $ENV{'LC_ALL'} :
2045 defined($ENV{'LC_CTYPE'}) ? $ENV{'LC_CTYPE'} :
2046 10 ▶ defined($ENV{'LANG'}) ? $ENV{'LANG'} :
Branch: 3 branches
BranchTrueFalseTotal
defined $ENV{'LC_ALL'} ? : 1 9 10
defined $ENV{'LC_CTYPE'} ? : 0 9 9
defined $ENV{'LANG'} ? : 9 0 9
2047 '';
2048  
2049 # "International Language Environments Guide" (Solaris 9), Chapter 4 Supported Asian Locales
2050 # https://docs.oracle.com/cd/E19683-01/806-6642/new-27777/index.html
2051 # "International Language Environments Guide for Oracle Solaris 11.3"
2052 # https://docs.oracle.com/cd/E53394_01/pdf/E54757.pdf
2053 # "Chinese: Simplified and Traditional" (Solaris 7)
2054 # https://docs.oracle.com/cd/E19620-01/805-4123/new-71/index.html
2055 return {
2056 'ja_JP.PCK' => 'sjis', # PC-Kanji code (known as Shift_JIS), Solaris 9 ILE guide
2057 'ja' => 'eucjp', # Japanese EUC, traditional specification, Solaris 9 ILE guide
2058 'japanese' => 'eucjp', # Japanese EUC, legacy SunOS 4.x alias of ja (no surviving official manual)
2059 'ja_JP.eucJP' => 'eucjp', # Japanese EUC, UI-OSF Ver 1.1, Solaris 9 ILE guide
2060 'zh' => 'gbk', # EUC-encoded GB2312-80, handled as its GBK superset, Solaris 9 ILE guide
2061 'zh.GBK' => 'gbk', # GBK codeset, Solaris 9 ILE guide
2062 'zh_CN.GBK' => 'gbk', # GBK codeset, Solaris 11.3 ILE guide
2063 'zh_CN.EUC' => 'gbk', # EUC-encoded GB2312, handled as its GBK superset, Solaris 11.3 ILE guide
2064 'zh_CN.GB18030' => 'gb18030', # GB18030-2000 codeset, Solaris 9 9/04 and later
2065 'ko' => 'uhc', # EUC-encoded KS X 1001, handled as its UHC superset, Solaris 9 ILE guide
2066 'ko_KR.EUC' => 'uhc', # EUC-encoded KS X 1001, handled as its UHC superset, Solaris 11.3 ILE guide
2067 'zh_TW' => 'euctw', # EUC-encoded CNS 11643.1992 codeset, Solaris 7 guide
2068 'zh_TW.EUC' => 'euctw', # EUC-encoded CNS11643.1992 codeset, Solaris 9 and 11.3 ILE guides
2069 'zh_TW.BIG5' => 'big5', # Big5 codeset, Solaris 9 and 11.3 ILE guides
2070 'zh_HK.BIG5HK' => 'big5hkscs', # Big5-HKSCS codeset, Solaris 9 and 11.3 ILE guides
2071 10 ▶ }->{$LANG} || 'utf8';
Condition100%2/2
{'ja_JP.PCK', 'sjis', 'ja', 'eucjp', 'japanese', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh', 'gbk', 'zh.GBK', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB18030', 'gb18030', 'ko', 'uhc', 'ko_KR.EUC', 'uhc', 'zh_TW', 'euctw', 'zh_TW.EUC', 'euctw', 'zh_TW.BIG5', 'big5', 'zh_HK.BIG5HK', 'big5hkscs'}->{$LANG} || 'utf8'
l!l
91
MC/DC100%1/1
{'ja_JP.PCK', 'sjis', 'ja', 'eucjp', 'japanese', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh', 'gbk', 'zh.GBK', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB18030', 'gb18030', 'ko', 'uhc', 'ko_KR.EUC', 'uhc', 'zh_TW', 'euctw', 'zh_TW.EUC', 'euctw', 'zh_TW.BIG5', 'big5', 'zh_HK.BIG5HK', 'big5hkscs'}->{$LANG} || 'utf8'
{'ja_JP.PCK', 'sjis', 'ja', 'eucjp', 'japanese', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh', 'gbk', 'zh.GBK', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB18030', 'gb18030', 'ko', 'uhc', 'ko_KR.EUC', 'uhc', 'zh_TW', 'euctw', 'zh_TW.EUC', 'euctw', 'zh_TW.BIG5', 'big5', 'zh_HK.BIG5HK', 'big5hkscs'}->{$LANG}
Truth table100%2/2
A
A= {'ja_JP.PCK', 'sjis', 'ja', 'eucjp', 'japanese', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh', 'gbk', 'zh.GBK', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB18030', 'gb18030', 'ko', 'uhc', 'ko_KR.EUC', 'uhc', 'zh_TW', 'euctw', 'zh_TW.EUC', 'euctw', 'zh_TW.BIG5', 'big5', 'zh_HK.BIG5HK', 'big5hkscs'}->{$LANG}
Aresult
11
00
2072 }
2073  
2074 # running on HP HP-UX
2075 elsif ($OSNAME =~ /hpux/) {
2076 my $LANG =
2077 defined($ENV{'LC_ALL'}) ? $ENV{'LC_ALL'} :
2078 defined($ENV{'LC_CTYPE'}) ? $ENV{'LC_CTYPE'} :
2079 8 ▶ defined($ENV{'LANG'}) ? $ENV{'LANG'} :
Branch: 3 branches
BranchTrueFalseTotal
defined $ENV{'LC_ALL'} ? : 1 7 8
defined $ENV{'LC_CTYPE'} ? : 0 7 7
defined $ENV{'LANG'} ? : 7 0 7
2080 '';
2081  
2082 # "Configuring HP-UX for Different Languages" (UXL10N-90302), Appendix A Locale Names
2083 # https://community.hpe.com/hpeb/attachments/hpeb/itrc-156/211158/1/198250.pdf
2084 return {
2085 'japanese' => 'sjis', # legacy pre-11.0 HP-UX locale name (no surviving official manual)
2086 'ja_JP.SJIS' => 'sjis', # Shift-JIS, UXL10N-90302 Table A-1
2087 'japanese.euc' => 'eucjp', # legacy pre-11.0 HP-UX locale name (no surviving official manual)
2088 'ja_JP.eucJP' => 'eucjp', # Japanese EUC, UXL10N-90302 Table A-1
2089 'zh_CN.hp15CN' => 'gbk', # HP-15CN Simplified Chinese, handled as GBK, UXL10N-90302 Table A-1
2090 'zh_CN.gb18030' => 'gb18030', # GB18030, HP-UX 11i (patch PHCO_26453 and later, in 11.31 locale -a)
2091 'ko_KR.eucKR' => 'uhc', # Korean EUC, handled as its UHC superset, UXL10N-90302 Table A-1
2092 'zh_TW.eucTW' => 'euctw', # Taiwanese EUC, UXL10N-90302 Table A-1
2093 'zh_TW.big5' => 'big5', # Big5, UXL10N-90302 Table A-1
2094 'zh_HK.big5' => 'big5hkscs', # kept for compatibility (not in UXL10N-90302; HP-UX ships zh_HK.hkbig5)
2095 'zh_HK.hkbig5' => 'big5hkscs', # Big5-HKSCS, HP-UX 11i (patch PHCO_26453 and later, in 11.31 locale -a)
2096 8 ▶ }->{$LANG} || 'utf8';
Condition100%2/2
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'japanese.euc', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh_CN.hp15CN', 'gbk', 'zh_CN.gb18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.big5', 'big5', 'zh_HK.big5', 'big5hkscs', 'zh_HK.hkbig5', 'big5hkscs'}->{$LANG} || 'utf8'
l!l
71
MC/DC100%1/1
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'japanese.euc', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh_CN.hp15CN', 'gbk', 'zh_CN.gb18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.big5', 'big5', 'zh_HK.big5', 'big5hkscs', 'zh_HK.hkbig5', 'big5hkscs'}->{$LANG} || 'utf8'
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'japanese.euc', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh_CN.hp15CN', 'gbk', 'zh_CN.gb18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.big5', 'big5', 'zh_HK.big5', 'big5hkscs', 'zh_HK.hkbig5', 'big5hkscs'}->{$LANG}
Truth table100%2/2
A
A= {'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'japanese.euc', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'zh_CN.hp15CN', 'gbk', 'zh_CN.gb18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.big5', 'big5', 'zh_HK.big5', 'big5hkscs', 'zh_HK.hkbig5', 'big5hkscs'}->{$LANG}
Aresult
11
00
2097 }
2098  
2099 # running on IBM AIX
2100 elsif ($OSNAME =~ /aix/) {
2101 my $LANG =
2102 defined($ENV{'LC_ALL'}) ? $ENV{'LC_ALL'} :
2103 defined($ENV{'LC_CTYPE'}) ? $ENV{'LC_CTYPE'} :
2104 8 ▶ defined($ENV{'LANG'}) ? $ENV{'LANG'} :
Branch: 3 branches
BranchTrueFalseTotal
defined $ENV{'LC_ALL'} ? : 1 7 8
defined $ENV{'LC_CTYPE'} ? : 0 7 7
defined $ENV{'LANG'} ? : 7 0 7
2105 '';
2106  
2107 # "Supported languages and locales" (IBM AIX documentation)
2108 # https://www.ibm.com/docs/en/aix/7.2.0?topic=globalization-supported-languages-locales
2109 # (the language / territory / code set / locale table; AIX locale
2110 # lookups are case-sensitive: zh_* is EUC, Zh_* is the PC code set)
2111 return {
2112 'Ja_JP' => 'sjis', # code set IBM-943 (Shift-JIS)
2113 'Ja_JP.IBM-943' => 'sjis', # code set IBM-943 (Shift-JIS)
2114 'ja_JP' => 'eucjp', # code set IBM-eucJP
2115 'ja_JP.IBM-eucJP' => 'eucjp', # code set IBM-eucJP
2116 'zh_CN' => 'gbk', # code set IBM-eucCN, handled as its GBK superset
2117 'zh_CN.IBM-eucCN' => 'gbk', # code set IBM-eucCN, handled as its GBK superset
2118 'Zh_CN' => 'gb18030', # code set GB18030
2119 'Zh_CN.GB18030' => 'gb18030', # code set GB18030
2120 'ko_KR' => 'uhc', # code set IBM-eucKR, handled as its UHC superset
2121 'ko_KR.IBM-eucKR' => 'uhc', # code set IBM-eucKR, handled as its UHC superset
2122 'zh_TW' => 'euctw', # code set IBM-eucTW
2123 'zh_TW.IBM-eucTW' => 'euctw', # code set IBM-eucTW
2124 'Zh_TW' => 'big5', # code set big5
2125 'Zh_TW.big-5' => 'big5', # code set big5
2126 'Zh_HK' => 'big5hkscs', # code set BIG5-HKSCS
2127 'Zh_HK.BIG5-HKSCS' => 'big5hkscs', # code set BIG5-HKSCS
2128 8 ▶ }->{$LANG} || 'utf8';
Condition100%2/2
{'Ja_JP', 'sjis', 'Ja_JP.IBM-943', 'sjis', 'ja_JP', 'eucjp', 'ja_JP.IBM-eucJP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.IBM-eucCN', 'gbk', 'Zh_CN', 'gb18030', 'Zh_CN.GB18030', 'gb18030', 'ko_KR', 'uhc', 'ko_KR.IBM-eucKR', 'uhc', 'zh_TW', 'euctw', 'zh_TW.IBM-eucTW', 'euctw', 'Zh_TW', 'big5', 'Zh_TW.big-5', 'big5', 'Zh_HK', 'big5hkscs', 'Zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG} || 'utf8'
l!l
71
MC/DC100%1/1
{'Ja_JP', 'sjis', 'Ja_JP.IBM-943', 'sjis', 'ja_JP', 'eucjp', 'ja_JP.IBM-eucJP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.IBM-eucCN', 'gbk', 'Zh_CN', 'gb18030', 'Zh_CN.GB18030', 'gb18030', 'ko_KR', 'uhc', 'ko_KR.IBM-eucKR', 'uhc', 'zh_TW', 'euctw', 'zh_TW.IBM-eucTW', 'euctw', 'Zh_TW', 'big5', 'Zh_TW.big-5', 'big5', 'Zh_HK', 'big5hkscs', 'Zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG} || 'utf8'
{'Ja_JP', 'sjis', 'Ja_JP.IBM-943', 'sjis', 'ja_JP', 'eucjp', 'ja_JP.IBM-eucJP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.IBM-eucCN', 'gbk', 'Zh_CN', 'gb18030', 'Zh_CN.GB18030', 'gb18030', 'ko_KR', 'uhc', 'ko_KR.IBM-eucKR', 'uhc', 'zh_TW', 'euctw', 'zh_TW.IBM-eucTW', 'euctw', 'Zh_TW', 'big5', 'Zh_TW.big-5', 'big5', 'Zh_HK', 'big5hkscs', 'Zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG}
Truth table100%2/2
A
A= {'Ja_JP', 'sjis', 'Ja_JP.IBM-943', 'sjis', 'ja_JP', 'eucjp', 'ja_JP.IBM-eucJP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.IBM-eucCN', 'gbk', 'Zh_CN', 'gb18030', 'Zh_CN.GB18030', 'gb18030', 'ko_KR', 'uhc', 'ko_KR.IBM-eucKR', 'uhc', 'zh_TW', 'euctw', 'zh_TW.IBM-eucTW', 'euctw', 'Zh_TW', 'big5', 'Zh_TW.big-5', 'big5', 'Zh_HK', 'big5hkscs', 'Zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG}
Aresult
11
00
2129 }
2130  
2131 # running on Other Systems
2132 else {
2133 my $LANG =
2134 defined($ENV{'LC_ALL'}) ? $ENV{'LC_ALL'} :
2135 defined($ENV{'LC_CTYPE'}) ? $ENV{'LC_CTYPE'} :
2136 196 ▶ defined($ENV{'LANG'}) ? $ENV{'LANG'} :
Branch: 3 branches
BranchTrueFalseTotal
defined $ENV{'LC_ALL'} ? : 0 196 196
defined $ENV{'LC_CTYPE'} ? : 0 196 196
defined $ENV{'LANG'} ? : 17 179 196
2137 '';
2138  
2139 # GNU libc localedata/SUPPORTED (locale/codeset list for Linux and other glibc systems)
2140 # https://github.com/bminor/glibc/blob/master/localedata/SUPPORTED
2141 # (a bare zh_TW is intentionally NOT mapped here: it is Big5 on glibc
2142 # but EUC-encoded CNS 11643 on the Solaris lineage, so guessing
2143 # either encoding on an unknown system would be wrong half the time)
2144 return {
2145 'japanese' => 'sjis', # legacy vendor UNIX locale name (no surviving official manual)
2146 'ja_JP.SJIS' => 'sjis', # Shift-JIS (shipped by some glibc distributions and HP-UX)
2147 'ja_JP.mscode' => 'sjis', # legacy vendor UNIX locale name (no surviving official manual)
2148 'ja' => 'eucjp', # Japanese EUC, Solaris-style short name
2149 'japan' => 'eucjp', # legacy vendor UNIX locale name (no surviving official manual)
2150 'japanese.euc' => 'eucjp', # legacy vendor UNIX locale name (no surviving official manual)
2151 'Japanese-EUC' => 'eucjp', # legacy vendor UNIX locale name (no surviving official manual)
2152 'ja_JP' => 'eucjp', # Japanese EUC, glibc SUPPORTED: ja_JP/EUC-JP
2153 'ja_JP.ujis' => 'eucjp', # Japanese EUC, legacy alias (ujis)
2154 'ja_JP.eucJP' => 'eucjp', # Japanese EUC, HP-UX/Solaris-style spelling
2155 'ja_JP.EUC-JP' => 'eucjp', # Japanese EUC, glibc SUPPORTED: ja_JP.EUC-JP/EUC-JP
2156 'ja_JP.AJEC' => 'eucjp', # Japanese EUC, legacy vendor UNIX locale name (no surviving official manual)
2157 'ja_JP.EUC' => 'eucjp', # Japanese EUC, legacy vendor UNIX locale name (no surviving official manual)
2158 'Jp_JP' => 'eucjp', # legacy vendor UNIX locale name (no surviving official manual)
2159 'zh_CN' => 'gbk', # glibc SUPPORTED: zh_CN/GB2312, handled as its GBK superset
2160 'zh_CN.EUC' => 'gbk', # EUC-encoded GB2312, handled as its GBK superset
2161 'zh_CN.GB2312' => 'gbk', # GB2312, handled as its GBK superset
2162 'zh_CN.GBK' => 'gbk', # glibc SUPPORTED: zh_CN.GBK/GBK
2163 'zh_CN.hp15CN' => 'gbk', # HP-15CN Simplified Chinese, handled as GBK (HP-UX name, UXL10N-90302 Table A-1)
2164 'zh_SG' => 'gbk', # glibc SUPPORTED: zh_SG/GB2312, handled as its GBK superset
2165 'zh_SG.GBK' => 'gbk', # glibc SUPPORTED: zh_SG.GBK/GBK
2166 'zh_CN.gb18030' => 'gb18030', # GB18030, HP-UX-style spelling
2167 'zh_CN.GB18030' => 'gb18030', # GB18030, glibc SUPPORTED: zh_CN.GB18030/GB18030
2168 'ko_KR.eucKR' => 'uhc', # Korean EUC, handled as its UHC superset, HP-UX-style spelling
2169 'ko_KR.EUC-KR' => 'uhc', # Korean EUC, handled as its UHC superset, glibc SUPPORTED: ko_KR.EUC-KR/EUC-KR
2170 'zh_TW.eucTW' => 'euctw', # Taiwanese EUC, HP-UX-style spelling (UXL10N-90302 Table A-1; also Tru64 UNIX Chinese(5))
2171 'zh_TW.EUC-TW' => 'euctw', # EUC-TW, glibc SUPPORTED: zh_TW.EUC-TW/EUC-TW
2172 'zh_TW.Big5' => 'big5', # Big5, legacy spelling
2173 'zh_TW.big5' => 'big5', # Big5, HP-UX-style spelling (UXL10N-90302 Table A-1)
2174 'zh_HK' => 'big5hkscs', # glibc SUPPORTED: zh_HK/BIG5-HKSCS
2175 'zh_HK.big5' => 'big5hkscs', # kept for compatibility (Big5 locale of Hong Kong handled as Big5-HKSCS)
2176 'zh_HK.BIG5-HKSCS' => 'big5hkscs', # Big5-HKSCS, glibc SUPPORTED: zh_HK.BIG5-HKSCS/BIG5-HKSCS
2177 196 ▶ }->{$LANG} || 'utf8';
Condition100%2/2
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'ja_JP.mscode', 'sjis', 'ja', 'eucjp', 'japan', 'eucjp', 'japanese.euc', 'eucjp', 'Japanese-EUC', 'eucjp', 'ja_JP', 'eucjp', 'ja_JP.ujis', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'ja_JP.EUC-JP', 'eucjp', 'ja_JP.AJEC', 'eucjp', 'ja_JP.EUC', 'eucjp', 'Jp_JP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB2312', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.hp15CN', 'gbk', 'zh_SG', 'gbk', 'zh_SG.GBK', 'gbk', 'zh_CN.gb18030', 'gb18030', 'zh_CN.GB18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'ko_KR.EUC-KR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.EUC-TW', 'euctw', 'zh_TW.Big5', 'big5', 'zh_TW.big5', 'big5', 'zh_HK', 'big5hkscs', 'zh_HK.big5', 'big5hkscs', 'zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG} || 'utf8'
l!l
15181
MC/DC100%1/1
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'ja_JP.mscode', 'sjis', 'ja', 'eucjp', 'japan', 'eucjp', 'japanese.euc', 'eucjp', 'Japanese-EUC', 'eucjp', 'ja_JP', 'eucjp', 'ja_JP.ujis', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'ja_JP.EUC-JP', 'eucjp', 'ja_JP.AJEC', 'eucjp', 'ja_JP.EUC', 'eucjp', 'Jp_JP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB2312', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.hp15CN', 'gbk', 'zh_SG', 'gbk', 'zh_SG.GBK', 'gbk', 'zh_CN.gb18030', 'gb18030', 'zh_CN.GB18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'ko_KR.EUC-KR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.EUC-TW', 'euctw', 'zh_TW.Big5', 'big5', 'zh_TW.big5', 'big5', 'zh_HK', 'big5hkscs', 'zh_HK.big5', 'big5hkscs', 'zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG} || 'utf8'
{'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'ja_JP.mscode', 'sjis', 'ja', 'eucjp', 'japan', 'eucjp', 'japanese.euc', 'eucjp', 'Japanese-EUC', 'eucjp', 'ja_JP', 'eucjp', 'ja_JP.ujis', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'ja_JP.EUC-JP', 'eucjp', 'ja_JP.AJEC', 'eucjp', 'ja_JP.EUC', 'eucjp', 'Jp_JP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB2312', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.hp15CN', 'gbk', 'zh_SG', 'gbk', 'zh_SG.GBK', 'gbk', 'zh_CN.gb18030', 'gb18030', 'zh_CN.GB18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'ko_KR.EUC-KR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.EUC-TW', 'euctw', 'zh_TW.Big5', 'big5', 'zh_TW.big5', 'big5', 'zh_HK', 'big5hkscs', 'zh_HK.big5', 'big5hkscs', 'zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG}
Truth table100%2/2
A
A= {'japanese', 'sjis', 'ja_JP.SJIS', 'sjis', 'ja_JP.mscode', 'sjis', 'ja', 'eucjp', 'japan', 'eucjp', 'japanese.euc', 'eucjp', 'Japanese-EUC', 'eucjp', 'ja_JP', 'eucjp', 'ja_JP.ujis', 'eucjp', 'ja_JP.eucJP', 'eucjp', 'ja_JP.EUC-JP', 'eucjp', 'ja_JP.AJEC', 'eucjp', 'ja_JP.EUC', 'eucjp', 'Jp_JP', 'eucjp', 'zh_CN', 'gbk', 'zh_CN.EUC', 'gbk', 'zh_CN.GB2312', 'gbk', 'zh_CN.GBK', 'gbk', 'zh_CN.hp15CN', 'gbk', 'zh_SG', 'gbk', 'zh_SG.GBK', 'gbk', 'zh_CN.gb18030', 'gb18030', 'zh_CN.GB18030', 'gb18030', 'ko_KR.eucKR', 'uhc', 'ko_KR.EUC-KR', 'uhc', 'zh_TW.eucTW', 'euctw', 'zh_TW.EUC-TW', 'euctw', 'zh_TW.Big5', 'big5', 'zh_TW.big5', 'big5', 'zh_HK', 'big5hkscs', 'zh_HK.big5', 'big5hkscs', 'zh_HK.BIG5-HKSCS', 'big5hkscs'}->{$LANG}
Aresult
11
00
2178 }
2179 }
2180  
2181 181 my @here_document_delimiter = ();
2182  
2183 # Perl 5.44 experimental feature 'enhanced_xx' (see "Perl 5.44 Syntax" in POD)
2184 # 1 while 'use feature "enhanced_xx"' is seen in the script being parsed
2185 181 $mb::_enhanced_xx = 0;
2186  
2187 # 1 if the running Perl has feature 'enhanced_xx' (Perl 5.44 and later);
2188 # decides "use if COND, feature => 'enhanced_xx';" whose COND is not
2189 # evaluated at transpile time
2190 181 ▶$mb::_perl_has_enhanced_xx = ($] >= 5.044) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.044 ? : 181 0 181
2191  
2192 # warnings of category 'regexp' in the script being parsed: 1 after
2193 # "use warnings" (or 'regexp', or use v5.35 and later), 0 after
2194 # "no warnings", undef when the script says nothing ($^W decides then);
2195 # used for the warnings of a comment under 'enhanced_xx', which mb gives
2196 # at transpile time because it removes the comment
2197 181 $mb::_warn_regexp = undef;
2198  
2199 # initial value of $mb::_enhanced_xx for mb::parse(); set by mb::eval
2200 # when the caller enables 'enhanced_xx'
2201 181 $mb::_enhanced_xx_inherited = 0;
2202  
2203 # number of 'x' in modifiers of the regular expression being parsed (looked ahead),
2204 # and its delimiters
2205 181 $mb::_re_x = 0;
2206 181 $mb::_re_open = '';
2207 181 $mb::_re_close = '';
2208  
2209 #---------------------------------------------------------------------
2210 # parse script
2211 28353 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod undocumented
2212 28350 ▶ local $_ = @_ ? $_[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 17107 11243 28350
2213  
2214 # Yes, I studied study yesterday, once again.
2215 28350 study $_; # acts between perl 5.005 to perl 5.014
2216  
2217 28350 @here_document_delimiter = ();
2218 28350 ▶ local $mb::_enhanced_xx = $mb::_enhanced_xx_inherited ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mb::_enhanced_xx_inherited ? : 1 28349 28350
2219 28350 local $mb::_warn_regexp = undef;
2220  
2221 # transpile JPerl script to Perl script
2222 28350 my $parsed_script = '';
2223 28350 ▶ while (not /\G \z /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G \z /cgmsx) 157714 28344 186058
2224 157714 $parsed_script .= parse_expr();
2225 }
2226  
2227 # return octet-oriented Perl script
2228 28344 return $parsed_script;
2229 }
2230  
2231 #---------------------------------------------------------------------
2232 # Perl 5.42 introduces source::encoding and automatically enables
2233 # ASCII-only checking for "use v5.41" and later.
2234 #
2235 # mb transpiles scripts to mostly US-ASCII, but it intentionally keeps
2236 # comments and POD as-is. Those may contain multibyte characters.
2237 #
2238 # source::encoding is only activated when "use v5.41" or later appears
2239 # in the script. We append "no source::encoding;" on the same line as
2240 # the "use VERSION" statement (replacing any trailing semicolon first)
2241 # to avoid introducing extra lines that would shift line numbers in
2242 # error messages.
2243 74 ▶sub _insert_source_encoding_unimport {
Subroutine _insert_source_encoding_unimport: called CC=1 SCAR=0.0
2244 71 my($script) = @_;
2245  
2246 # append "no source::encoding;" on the same line as "use v5.41" or later,
2247 # before any trailing comment, to avoid line number shifts in error messages.
2248 # matches: use v5.41; use v5.42; use 5.041; use 5.042; etc.
2249 71 $script =~ s{
2250 ( \buse \s+
2251 (?: v5\. (?:4[1-9]|[5-9]\d|\d{3,}) # use v5.41 and later
2252 | 5\.0(?:4[1-9]|[5-9]\d|\d{3,}) # use 5.041 and later
2253 )
2254 [^\n#;]* # rest of statement (no # or ;)
2255 )
2256 ;? # consume trailing semicolon
2257 ( [^\n]* ) # trailing comment (if any)
2258 ( (?:\r\n|\r|\n) ) # line ending
2259 }{$1; no source::encoding;$2$3}xmsg;
2260  
2261 71 return $script;
2262 }
2263  
2264 #---------------------------------------------------------------------
2265 # parse ambiguous characters
2266 64512 ▶sub parse_ambiguous_char {
Subroutine parse_ambiguous_char: called CC=2 SCAR=6.9
Pod undocumented
2267 64509 my $parsed = '';
2268  
2269 # Ambiguous characters
2270 # --------------------------------------------------------
2271 # Character Operator Term
2272 # --------------------------------------------------------
2273 # % modulo %hash
2274 # & &, && &subroutine
2275 # ' package 'string'
2276 # * multiplication *typeglob
2277 # + addition unary plus
2278 # - subtraction unary minus
2279 # . concatenation .3333
2280 # / division /pattern/
2281 # < less than <>, <HANDLE>, <fileglob>
2282 # << left shift <<HERE, <<~HERE, <<>>
2283 # ? ?: ?pattern?
2284 # --------------------------------------------------------
2285  
2286 # any term then operator
2287 64509 ▶ if (m{\G ( \s* (?:
Branch: 1 branch
BranchTrueFalseTotal
if (m[\G ( \s* (?: # 12345 | 12345 | 12345 | 12345 | 12345 | 12345 | %= | % | # "\x25" [%] PERCENT SIGN (U+0025) &&= | && | &\.= | &\. | &= | & | # "\x26" [&] AMPERSAND (U+0026) \*\*= | \*\* | \*= | \* | # "\x2A" [*] ASTERISK (U+002A) \.\.\.| \.\. | \.= | \. | # "\x2E" [.] FULL STOP (U+002E) \/\/= | \/\/ | \/= | \/ | # "\x2F" [/] SOLIDUS (U+002F) <=> | << | <= | < | # "\x3C" [<] LESS-THAN SIGN (U+003C) \? # "\x3F" [?] QUESTION MARK (U+003F) )) ]cgmsx) 293 64216 64509
2288  
2289 # 12345 | 12345 | 12345 | 12345 | 12345 | 12345 |
2290 %= | % | # "\x25" [%] PERCENT SIGN (U+0025)
2291 &&= | && | &\.= | &\. | &= | & | # "\x26" [&] AMPERSAND (U+0026)
2292 \*\*= | \*\* | \*= | \* | # "\x2A" [*] ASTERISK (U+002A)
2293 \.\.\.| \.\. | \.= | \. | # "\x2E" [.] FULL STOP (U+002E)
2294 \/\/= | \/\/ | \/= | \/ | # "\x2F" [/] SOLIDUS (U+002F)
2295 <=> | << | <= | < | # "\x3C" [<] LESS-THAN SIGN (U+003C)
2296 \? # "\x3F" [?] QUESTION MARK (U+003F)
2297 )) }xmsgc) {
2298 293 $parsed .= $1;
2299 }
2300  
2301 64509 return $parsed;
2302 }
2303  
2304 #---------------------------------------------------------------------
2305 # parse expression in script
2306 164387 ▶sub parse_expr {
Subroutine parse_expr: called CC=280 SCAR=60.8
Pod undocumented
2307 164384 my $parsed = '';
2308 164384 my $old_package = mb::get_old_package();
2309  
2310 # __END__ or __DATA__
2311 164384 ▶ if (/\G ^ ( (?: __END__ | __DATA__ ) $R .* ) \z/xmsgc) {
Branch: 89 branches
BranchTrueFalseTotal
if (/\G ^ ( (?: __END__ | __DATA__ ) $R .* ) \z/cgmsx) { } 18 164366 164384
elsif (/\G ^ ( = [A-Za-z_][A-Za-z_0-9]* [\x00-\xFF]*? $R =cut \b [^\n]* $R ) /cgmsx) { } 1 164365 164366
elsif (/\G (?= $R ) /cgmsx) { } 9628 154737 164365
elsif (/\G ( [\t ]+ ) /cgmsx) { } 51226 103511 154737
elsif (/\G ( ; ) /cgmsx) { } 5695 97816 103511
elsif (/\G ( use | no ) (?= \s ) /cgmsx) { } 120 97696 97816
elsif (/\G ( [(\{\[] ) /cgmsx) { } 978 96718 97696
elsif (/\G ( v [0-9]+ (?: \.[0-9]+ ){1,} \b | [0-9]+ (?: \.[0-9]+ ){2,} \b ) /cgmsx) { } 3 96715 96718
elsif (/\G v ( [0-9]+ ) \b (?! \s* => ) /cgmsx) { } 1 96714 96715
elsif (m[\G ( # since Perl v5.22 adds hexadecimal floating point literals # https://perldoc.perl.org/perl5220delta#Floating-point-parsing-has-been-improved # https://perldoc.perl.org/5.32.0/perldata#Scalar-value-constructors # https://qiita.com/mod_poppo/items/3fa4cdc35f9bfb352ad5 # https://qiita.com/mod_poppo/items/3fa4cdc35f9bfb352ad5#perl # # $ perl -l -e 'print(0x1.23); print(0x1.23p0)' # makes ==> 123 # makes ==> 1.13671875 0[Xx] [0-9A-Fa-f_]+ \. [0-9A-Fa-f_]* [Pp] [+-]? [0-9_]+ | 0[Xx] \. [0-9A-Fa-f_]+ [Pp] [+-]? [0-9_]+ | 0[Xx] [0-9A-Fa-f_]+ | # since perl v5.33.5 Core Enhancements New octal syntax 0oddddd 0[Oo] [0-7_]+ | 0 [0-7_]* | 0[Bb] [01_]+ | [1-9] [0-9_]* \. [0-9_]* [Ee] [+-]? [0-9_]+ | [1-9] [0-9_]* | \. [0-9_]+ [Ee] [+-]? [0-9_]+ | \. [0-9_]+ ) ]cgmsx) { } 1310 95404 96714
elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) (?= (?: \( \s* )* (?: ' | " | ` | \$ | (?: (?: m | q | qq | qr | qw | qx | s | tr | y ) \b )) ) /cgmsx) { } 0 95404 95404
elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) (?= [A-Za-z_][A-Za-z0-9_]* ) /cgmsx) { } 784 94620 95404
elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) /cgmsx) { } 2279 92341 94620
elsif (/\G ( \.\.\. ) /cgmsx) { } 1 92340 92341
elsif (/\G ( -> \s* [A-Za-z_][A-Za-z_0-9]* ) /cgmsx) { } 1 92339 92340
elsif (/\G ( # 12345 | 12345 | 12345 | 12345 | 12345 | 12345 | != | !~ | ! | # "\x21" [!] EXCLAMATION MARK (U+0021) \+\+ | \+= | \+ | # "\x2B" [+] PLUS SIGN (U+002B) , | # "\x2C" [,] COMMA (U+002C) -- | -= | -> | - | # "\x2D" [-] HYPHEN-MINUS (U+002D) == | => | =~ | = | # "\x3D" [=] EQUALS SIGN (U+003D) >> | >= | > | # "\x3E" [>] GREATER-THAN SIGN (U+003E) \\ | # "\x5C" [\] REVERSE SOLIDUS (U+005C) \^\^= | \^\^ | \^\.= | \^\. | \^= | \^ | # "\x5E" [^] CIRCUMFLEX ACCENT (U+005E) \|\|= | \|\| | \|\.= | \|\. | \|= | \| | # "\x7C" [|] VERTICAL LINE (U+007C) ~~ | ~\. | ~= | ~ # "\x7E" [~] TILDE (U+007E) ) /cgmsx) { } 21298 71041 92339
elsif (/\G ( (?: and | cmp | eq | ge | gt | isa | le | lt | ne | not | or | x | x= | xor ) \b ) /cgmsx) { } 2433 68608 71041
elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /cgmsx) { } 20 68588 68608
elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /cgmsx) { } 68 68520 68588
elsif (/\G \$ ([1-9][0-9]*) /cgmsx) { } 55 68465 68520
elsif (/\G \@\{\^CAPTURE\} /cgmsx) { } 3 68462 68465
elsif (/\G \$\{\^CAPTURE\} \s* (\[) /cgmsx) { } 3 68459 68462
elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /cgmsx) { } 12 68447 68459
elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /cgmsx) { } 22 68425 68447
elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /cgmsx) { } 12 68413 68425
elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /cgmsx) { } 14 68399 68413
elsif (/\G ( CORE:: (?: do | eval | try | finally ) \s* ) ( \{ ) /cgmsx) { } 11 68388 68399
elsif (/\G (?: mb:: | $old_package )? ( (?: do | eval | try | finally ) \s* ) ( \{ ) /cgmsx) { } 30 68358 68388
elsif (/\G ((?: \$[#] | [\$\@%&*] | defer | sub ) \s* ) ( \{ ) /cgmsx) { } 301 68057 68358
elsif (/\G ( (?: mb:: | CORE:: )? do ) \b /cgmsx) { } 3 68054 68057
elsif (/\G ( (?: mb:: | CORE:: )? eval ) \b /cgmsx) { } 3 68051 68054
elsif (/\G ( [\$] [#] (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) ) /cgmsx) { } 3 68048 68051
elsif (m(\G ( [\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | ^\{[A-Za-z_][A-Za-z_0-9]*\} | [0-9]+ | [!"#\$%&'()+,\-./:;<=>?\@\[\\\]\^_`|~] ) (?: \s* (?: \+\+ | -- ) )? ) )cgmsx) { } 8950 59098 68048
elsif (/\G ( [\@\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | [_] ) ) /cgmsx) { } 208 58890 59098
elsif (/\G ( [\%\@\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | [!+\-] ) ) /cgmsx) { } 13 58877 58890
elsif (/\G ( [&*] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) ) /cgmsx) { } 236 58641 58877
elsif (/\G ( [#] [^\n]* ) /cgmsx) { } 49 58592 58641
elsif (/\G ( ' ) /cgmsx) { } 6471 52121 58592
elsif (/\G ( ["`] ) /cgmsx) { } 15296 36825 52121
elsif (m[\G ( [/] ) ]cgmsx) { } 16975 19850 36825
elsif (/\G ( [?] ) /cgmsx) { } 1 19849 19850
elsif (/\G ( <<>> ) /cgmsx) { } 1 19848 19849
elsif (/\G (<) ((?:(?!\s)$x)*?) (>) /cgmsx) { } 5 19843 19848
elsif (/\G ( qw | q ) \b /cgmsx) { } 178 19665 19843
elsif (/\G ( qq ) \b /cgmsx) { } 70 19595 19665
elsif (/\G ( qx ) \b /cgmsx) { } 67 19528 19595
elsif (/\G ( m | qr ) \b /cgmsx) { } 2438 17090 19528
elsif (/\G ( s ) \b /cgmsx) { } 1730 15360 17090
elsif (/\G (?: tr | y ) \b /cgmsx) { } 2159 13201 15360
elsif (/\G ( <<~ ) /cgmsx) { } 11 13190 13201
elsif (/\G ( << ) /cgmsx) { } 12 13178 13190
elsif (/\G ( sub \s+ [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* \s* ) /cgmsx) { } 37 13141 13178
elsif (/\G ( while \s* \( \s* ) ( <<>> ) ( \s* \) ) /cgmsx) { } 2 13139 13141
elsif (/\G ( while \s* \( \s* ) (<) ((?:(?!\s)$x)*?) (>) ( \s* \) ) /cgmsx) { } 9 13130 13139
elsif (/\G ( while \s* ) ( <<>> ) /cgmsx) { } 0 13130 13130
elsif (/\G ( while \s* ) (<) ((?:(?!\s)$x)*?) (>) /cgmsx) { } 0 13130 13130
elsif (/\G ( (?: if | elsif | unless | while | until | given | when | (?: CORE:: )? catch ) \s* ) ( \( ) /cgmsx) { } 25 13105 13130
elsif (/\G mb:: ( catch \s* ) ( \( ) /cgmsx) { } 4 13101 13105
elsif (/\G ( else ) \b /cgmsx) { } 1 13100 13101
elsif (/\G ( if | unless | while | until ) \b /cgmsx) { } 19 13081 13100
elsif (/\G ( (?: foreach | for ) \s+ my \s* [\$] [A-Za-z_][A-Za-z_0-9]* ) ( \( ) /cgmsx) { } 0 13081 13081
elsif (/\G ( (?: foreach | for ) \s* [\$] [\$]* (?: \{[A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)*\} | [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]* ) ) ) ( \( ) /cgmsx) { } 0 13081 13081
elsif (/\G ( (?: foreach | for ) \s* ) ( \( ) /cgmsx) { } 4 13077 13081
elsif (/\G (?: CORE:: | mb:: | $old_package )? ( split ) \b /cgmsx) { } 687 12390 13077
elsif (/\G ( (?: lc | lcfirst | uc | ucfirst ) ) \b /cgmsx) { } 15 12375 12390
elsif (/\G ( (?: CORE:: | mb:: )? require ) /cgmsx) { } 6 12369 12375
elsif (/\G ( mb::use | mb::no ) \b /cgmsx) { } 42 12327 12369
elsif (/\G ( mb::getc ) (?= (?: \s* \( )+ \s* \) ) /cgmsx) { } 1 12326 12327
elsif (/\G ( mb::getc ) (?= (?: \s* \( )* \s* \$ ) /cgmsx) { } 2 12324 12326
elsif (/\G ( mb::getc ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \b ) /cgmsx) { } 2 12322 12324
elsif (/\G ( mb::getc ) /cgmsx) { } 1 12321 12322
elsif (/\G ( (?: CORE:: | mb:: )? (?: chop | chr | getc | lc | lcfirst | length | ord | uc | ucfirst ) ) \b /cgmsx) { } 41 12280 12321
elsif (/\G ( (?: CORE:: | mb:: )? (?: index | reverse | rindex | substr ) ) \b /cgmsx) { } 26 12254 12280
elsif (/\G ( mb:: (?: index_byte | rindex_byte ) ) \b /cgmsx) { } 2 12252 12254
elsif (/\G ( (?: CORE:: )? (?: _ | abs | chomp | cos | exp | fc | hex | int | __LINE__ | log | oct | pop | pos | quotemeta | rand | rmdir | shift | sin | sqrt | tell | time | umask | wantarray ) ) \b /cgmsx) { } 841 11411 12252
elsif (/\G ( lstat | stat ) (?= (?: \s* \( )+ \s* \) ) /cgmsx) { } 2 11409 11411
elsif (/\G ( lstat | stat ) (?= (?: \s* \( )* \b (?: ' | " | ` | m | q | qq | qr | qw | qx | s | tr | y | \$ ) \b ) /cgmsx) { } 18 11391 11409
elsif (/\G ( lstat | stat ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \b ) /cgmsx) { } 10 11381 11391
elsif (/\G ( opendir ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \s* , ) /cgmsx) { } 4 11377 11381
elsif (/\G ( chdir | lstat | stat | unlink ) \b /cgmsx) { } 32 11345 11377
elsif (/\G ( opendir ) \b /cgmsx) { } 4 11341 11345
elsif (/\G ( Carp::carp | Carp::cluck | Carp::confess | Carp::croak | carp | cluck | confess | croak | die | print | printf | say | warn ) (?= (?: \s+ | [#] .* )* << ) /cgx) { } 0 11341 11341
elsif (/\G ( (?: printf | print | say ) (?: \s+ | [#] .* )* (?! [a-z]+ ) # lowercase is considered to be function (?: \b [A-Za-z_][A-Za-z_0-9]*(?: :: [A-Za-z_][A-Za-z_0-9]*)* | \$ [A-Za-z_][A-Za-z_0-9]*(?: :: [A-Za-z_][A-Za-z_0-9]*)* ) ) /cgx) { } 29 11312 11341
elsif (/\G ( (?: printf | print | say ) (?: \s+ | [#] .* )* ) (\{) /cgx) { } 0 11312 11312
elsif (/\G ( return ) /cgmsx) { } 14 11298 11312
elsif (/\G ( [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) /cgmsx) { } 1097 10201 11298
elsif (/\G ([\)\}\]]) /cgmsx) { } 402 9799 10201
elsif (/\G ([\x00-\x7F]) /cgmsx) { } 9799 0 9799
elsif (/\G ($x) /cgmsx) { } 0 0 0
2312 18 $parsed .= $1;
2313 }
2314  
2315 # =pod ... =cut
2316 elsif (/\G ^ ( = [A-Za-z_][A-Za-z_0-9]* [\x00-\xFF]*? $R =cut \b [^\n]* $R ) /xmsgc) {
2317 1 $parsed .= $1;
2318 }
2319  
2320 # "\r\n", "\r", "\n"
2321 elsif (/\G (?= $R ) /xmsgc) {
2322 9628 ▶ while (my $here_document_delimiter = shift @here_document_delimiter) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $here_document_delimiter = shift @here_document_delimiter) 23 9628 9651
2323 23 my($delimiter, $quote_type) = @{$here_document_delimiter};
2324 23 ▶ if ($quote_type eq 'qq') {
Branch: 2 branches
BranchTrueFalseTotal
if ($quote_type eq 'qq') { } 14 9 23
elsif ($quote_type eq 'q') { } 9 0 9
2325 14 $parsed .= parse_heredocument_as_qq_endswith($delimiter);
2326 }
2327 elsif ($quote_type eq 'q') {
2328  
2329 # perlop > Quote-Like Operators > <<EOF > Single Quotes
2330 #
2331 # Single quotes indicate the text is to be treated literally
2332 # with no interpolation of its content. This is similar to
2333 # single quoted strings except that backslashes have no special
2334 # meaning, with \\ being treated as two backslashes and not
2335 # one as they would in every other quoting construct.
2336 # https://perldoc.perl.org/perlop.html#Quote-Like-Operators
2337  
2338 9 $parsed .= parse_heredocument_as_q_endswith($delimiter);
2339 }
2340 else {
2341 0 die "$0(@{[__LINE__]}): $ARGV[0] here document delimiter '$delimiter' not found.\n";
2342 }
2343 }
2344 }
2345  
2346 # "\t"
2347 # "\x20" [ ] SPACE (U+0020)
2348 elsif (/\G ( [\t ]+ ) /xmsgc) {
2349 51226 $parsed .= $1;
2350 }
2351  
2352 # "\x3B" [;] SEMICOLON (U+003B)
2353 elsif (/\G ( ; ) /xmsgc) {
2354 5695 $parsed .= $1;
2355 }
2356  
2357 # use feature 'enhanced_xx'; no feature 'enhanced_xx'; (Perl 5.44)
2358 # keyword is passed through as-is; only the feature state is tracked
2359 elsif (/\G ( use | no ) (?= \s ) /xmsgc) {
2360 120 my $keyword = $1;
2361 120 $parsed .= $keyword;
2362 120 mb::_track_feature($keyword);
2363  
2364 # use VERSION; no VERSION; use Module VERSION ...;
2365 # (e.g. "use v5.44;") VERSION is a version, not a string of codepoints
2366 120 ▶ if (/\G (
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ (?: [A-Za-z_][A-Za-z_0-9]* (?: :: [A-Za-z_0-9]+ )* \s+ )? (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* ) ) (?! [0-9._A-Za-z] ) (?! \s* (?: , | => ) ) /cgmsx) 21 99 120
2367 \s+ (?: [A-Za-z_][A-Za-z_0-9]* (?: :: [A-Za-z_0-9]+ )* \s+ )?
2368 (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* )
2369 ) (?! [0-9._A-Za-z] ) (?! \s* (?: , | => ) ) /xmsgc) {
2370 21 $parsed .= $1;
2371 }
2372 }
2373  
2374 # balanced brackets
2375 # "\x28" [(] LEFT PARENTHESIS (U+0028)
2376 # "\x7B" [{] LEFT CURLY BRACKET (U+007B)
2377 # "\x5B" [[] LEFT SQUARE BRACKET (U+005B)
2378 elsif (/\G ( [(\{\[] ) /xmsgc) {
2379 978 $parsed .= parse_expr_balanced($1);
2380 978 $parsed .= parse_ambiguous_char();
2381 }
2382  
2383 # version string
2384 # v102.111.111
2385 # 102.111.111
2386 elsif (/\G (
2387 v [0-9]+ (?: \.[0-9]+ ){1,} \b |
2388 [0-9]+ (?: \.[0-9]+ ){2,} \b
2389 ) /xmsgc) {
2390 3 my $v_string = $1;
2391 3 $parsed .= join('.', map { "mb::chr($_)" } ($v_string =~ /[0-9]+/g));
2392 3 $parsed .= parse_ambiguous_char();
2393 }
2394  
2395 # version string
2396 # v9786
2397 elsif (/\G v ( [0-9]+ ) \b (?! \s* => ) /xmsgc) {
2398 1 $parsed .= "mb::chr($1)";
2399 1 $parsed .= parse_ambiguous_char();
2400 }
2401  
2402 # numbers
2403 # "\x2E" [.] [0-9]
2404 # "\x30" [0] DIGIT ZERO (U+0030)
2405 # "\x31" [1] DIGIT ONE (U+0031)
2406 # "\x32" [2] DIGIT TWO (U+0032)
2407 # "\x33" [3] DIGIT THREE (U+0033)
2408 # "\x34" [4] DIGIT FOUR (U+0034)
2409 # "\x35" [5] DIGIT FIVE (U+0035)
2410 # "\x36" [6] DIGIT SIX (U+0036)
2411 # "\x37" [7] DIGIT SEVEN (U+0037)
2412 # "\x38" [8] DIGIT EIGHT (U+0038)
2413 # "\x39" [9] DIGIT NINE (U+0039)
2414 elsif (m{\G (
2415  
2416 # since Perl v5.22 adds hexadecimal floating point literals
2417 # https://perldoc.perl.org/perl5220delta#Floating-point-parsing-has-been-improved
2418 # https://perldoc.perl.org/5.32.0/perldata#Scalar-value-constructors
2419  
2420 # https://qiita.com/mod_poppo/items/3fa4cdc35f9bfb352ad5
2421 # https://qiita.com/mod_poppo/items/3fa4cdc35f9bfb352ad5#perl
2422 #
2423 # $ perl -l -e 'print(0x1.23); print(0x1.23p0)'
2424 # makes ==> 123
2425 # makes ==> 1.13671875
2426  
2427 0[Xx] [0-9A-Fa-f_]+ \. [0-9A-Fa-f_]* [Pp] [+-]? [0-9_]+ |
2428 0[Xx] \. [0-9A-Fa-f_]+ [Pp] [+-]? [0-9_]+ |
2429 0[Xx] [0-9A-Fa-f_]+ |
2430  
2431 # since perl v5.33.5 Core Enhancements New octal syntax 0oddddd
2432  
2433 0[Oo] [0-7_]+ |
2434 0 [0-7_]* |
2435  
2436 0[Bb] [01_]+ |
2437  
2438 [1-9] [0-9_]* \. [0-9_]* [Ee] [+-]? [0-9_]+ |
2439 [1-9] [0-9_]* |
2440 \. [0-9_]+ [Ee] [+-]? [0-9_]+ |
2441 \. [0-9_]+
2442  
2443 ) }xmsgc) {
2444 1310 $parsed .= $1;
2445 1310 $parsed .= parse_ambiguous_char();
2446 }
2447  
2448 # file test operators on MSWin32
2449 # "\x2D" [-] HYPHEN-MINUS (U+002D)
2450  
2451 # -X -Y -Z 'file' --> mb::_filetest [qw( -X -Y -Z )], 'file'
2452 # -X -Y -Z "file" --> mb::_filetest [qw( -X -Y -Z )], "file"
2453 # -X -Y -Z `file` --> mb::_filetest [qw( -X -Y -Z )], `file`
2454 # -X -Y -Z $file --> mb::_filetest [qw( -X -Y -Z )], $file
2455 # ..., and filetest any word except file handle or directory handle
2456 # -X -Y -Z m// --> mb::_filetest [qw( -X -Y -Z )], m//
2457 # -X -Y -Z q// --> mb::_filetest [qw( -X -Y -Z )], q//
2458 # -X -Y -Z qq// --> mb::_filetest [qw( -X -Y -Z )], qq//
2459 # -X -Y -Z qr// --> mb::_filetest [qw( -X -Y -Z )], qr//
2460 # -X -Y -Z qw// --> mb::_filetest [qw( -X -Y -Z )], qw//
2461 # -X -Y -Z qx// --> mb::_filetest [qw( -X -Y -Z )], qx//
2462 # -X -Y -Z s/// --> mb::_filetest [qw( -X -Y -Z )], s///
2463 # -X -Y -Z tr/// --> mb::_filetest [qw( -X -Y -Z )], tr///
2464 # -X -Y -Z y/// --> mb::_filetest [qw( -X -Y -Z )], y///
2465 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2466 # vvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2467 elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) (?= (?: \( \s* )* (?: ' | " | ` | \$ | (?: (?: m | q | qq | qr | qw | qx | s | tr | y ) \b )) ) /xmsgc) {
2468 0 $parsed .= "mb::_filetest [qw( $1 )], ";
2469 }
2470  
2471 # filetest file handle or directory handle
2472 # -X -Y -Z _ --> mb::_filetest [qw( -X -Y -Z )], \*_
2473 # -X -Y -Z FILE --> mb::_filetest [qw( -X -Y -Z )], \*FILE
2474 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2475 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvv
2476 elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) (?= [A-Za-z_][A-Za-z0-9_]* ) /xmsgc) {
2477 784 $parsed .= "mb::_filetest [qw( $1)], ";
2478 784 $parsed .= '\\*';
2479 }
2480  
2481 # -X -Y -Z ... --> mb::_filetest [qw( -X -Y -Z )], ...
2482 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2483 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2484 elsif (/\G ( (?: -[ABCMORSTWXbcdefgkloprstuwxz] \s* )+ \b ) /xmsgc) {
2485 2279 $parsed .= "mb::_filetest [qw( $1)]";
2486 2279 ▶ if (my $ambiguous_char = parse_ambiguous_char()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ambiguous_char = parse_ambiguous_char()) { } 0 2279 2279
2487 0 $parsed .= $ambiguous_char;
2488 }
2489 else {
2490 2279 $parsed .= ', ';
2491 }
2492 }
2493  
2494 # yada-yada or triple-dot operator
2495 elsif (/\G ( \.\.\. ) /xmsgc) {
2496 1 $parsed .= $1;
2497 }
2498  
2499 # -> and any method
2500 elsif (/\G ( -> \s* [A-Za-z_][A-Za-z_0-9]* ) /xmsgc) {
2501 1 $parsed .= $1;
2502 }
2503  
2504 # symbolic operators
2505 elsif (/\G (
2506  
2507 # 12345 | 12345 | 12345 | 12345 | 12345 | 12345 |
2508 != | !~ | ! | # "\x21" [!] EXCLAMATION MARK (U+0021)
2509 \+\+ | \+= | \+ | # "\x2B" [+] PLUS SIGN (U+002B)
2510 , | # "\x2C" [,] COMMA (U+002C)
2511 -- | -= | -> | - | # "\x2D" [-] HYPHEN-MINUS (U+002D)
2512 == | => | =~ | = | # "\x3D" [=] EQUALS SIGN (U+003D)
2513 >> | >= | > | # "\x3E" [>] GREATER-THAN SIGN (U+003E)
2514 \\ | # "\x5C" [\] REVERSE SOLIDUS (U+005C)
2515 \^\^= | \^\^ | \^\.= | \^\. | \^= | \^ | # "\x5E" [^] CIRCUMFLEX ACCENT (U+005E)
2516 \|\|= | \|\| | \|\.= | \|\. | \|= | \| | # "\x7C" [|] VERTICAL LINE (U+007C)
2517 ~~ | ~\. | ~= | ~ # "\x7E" [~] TILDE (U+007E)
2518  
2519 ) /xmsgc) {
2520 21298 $parsed .= $1;
2521 }
2522  
2523 # named operators
2524 elsif (/\G ( (?: and | cmp | eq | ge | gt | isa | le | lt | ne | not | or | x | x= | xor ) \b ) /xmsgc) {
2525 2433 $parsed .= $1;
2526 }
2527  
2528 # $` --> mb::_PREMATCH()
2529 # ${`} --> mb::_PREMATCH()
2530 # $PREMATCH --> mb::_PREMATCH()
2531 # ${PREMATCH} --> mb::_PREMATCH()
2532 # ${^PREMATCH} --> mb::_PREMATCH()
2533 elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /xmsgc) {
2534 20 $parsed .= 'mb::_PREMATCH()';
2535 20 $parsed .= parse_ambiguous_char();
2536 }
2537  
2538 # $& --> mb::_MATCH()
2539 # ${&} --> mb::_MATCH()
2540 # $MATCH --> mb::_MATCH()
2541 # ${MATCH} --> mb::_MATCH()
2542 # ${^MATCH} --> mb::_MATCH()
2543 elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /xmsgc) {
2544 68 $parsed .= 'mb::_MATCH()';
2545 68 $parsed .= parse_ambiguous_char();
2546 }
2547  
2548 # $1 --> mb::_CAPTURE(1)
2549 # $2 --> mb::_CAPTURE(2)
2550 # $3 --> mb::_CAPTURE(3)
2551 elsif (/\G \$ ([1-9][0-9]*) /xmsgc) {
2552 55 $parsed .= "mb::_CAPTURE($1)";
2553 55 $parsed .= parse_ambiguous_char();
2554 }
2555  
2556 # @{^CAPTURE} --> mb::_CAPTURE()
2557 elsif (/\G \@\{\^CAPTURE\} /xmsgc) {
2558 3 $parsed .= 'mb::_CAPTURE()';
2559 3 $parsed .= parse_ambiguous_char();
2560 }
2561  
2562 # ${^CAPTURE}[0] --> mb::_CAPTURE(1)
2563 # ${^CAPTURE}[1] --> mb::_CAPTURE(2)
2564 # ${^CAPTURE}[2] --> mb::_CAPTURE(3)
2565 elsif (/\G \$\{\^CAPTURE\} \s* (\[) /xmsgc) {
2566 3 my $n_th = quotee_of(parse_expr_balanced($1));
2567 3 $parsed .= "mb::_CAPTURE($n_th+1)";
2568 3 $parsed .= parse_ambiguous_char();
2569 }
2570  
2571 # @- --> mb::_LAST_MATCH_START()
2572 # @LAST_MATCH_START --> mb::_LAST_MATCH_START()
2573 # @{LAST_MATCH_START} --> mb::_LAST_MATCH_START()
2574 # @{^LAST_MATCH_START} --> mb::_LAST_MATCH_START()
2575 elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /xmsgc) {
2576 12 $parsed .= 'mb::_LAST_MATCH_START()';
2577 12 $parsed .= parse_ambiguous_char();
2578 }
2579  
2580 # $-[1] --> mb::_LAST_MATCH_START(1)
2581 # $LAST_MATCH_START[1] --> mb::_LAST_MATCH_START(1)
2582 # ${LAST_MATCH_START}[1] --> mb::_LAST_MATCH_START(1)
2583 # ${^LAST_MATCH_START}[1] --> mb::_LAST_MATCH_START(1)
2584 elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /xmsgc) {
2585 22 my $n_th = quotee_of(parse_expr_balanced($1));
2586 22 $parsed .= "mb::_LAST_MATCH_START($n_th)";
2587 22 $parsed .= parse_ambiguous_char();
2588 }
2589  
2590 # @+ --> mb::_LAST_MATCH_END()
2591 # @LAST_MATCH_END --> mb::_LAST_MATCH_END()
2592 # @{LAST_MATCH_END} --> mb::_LAST_MATCH_END()
2593 # @{^LAST_MATCH_END} --> mb::_LAST_MATCH_END()
2594 elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /xmsgc) {
2595 12 $parsed .= 'mb::_LAST_MATCH_END()';
2596 12 $parsed .= parse_ambiguous_char();
2597 }
2598  
2599 # $+[1] --> mb::_LAST_MATCH_END(1)
2600 # $LAST_MATCH_END[1] --> mb::_LAST_MATCH_END(1)
2601 # ${LAST_MATCH_END}[1] --> mb::_LAST_MATCH_END(1)
2602 # ${^LAST_MATCH_END}[1] --> mb::_LAST_MATCH_END(1)
2603 elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /xmsgc) {
2604 14 my $n_th = quotee_of(parse_expr_balanced($1));
2605 14 $parsed .= "mb::_LAST_MATCH_END($n_th)";
2606 14 $parsed .= parse_ambiguous_char();
2607 }
2608  
2609 # CORE::do { block } --> CORE::do { block }
2610 # CORE::eval { block } --> CORE::eval { block }
2611 # CORE::try { block } --> CORE::try { block }
2612 # CORE::finally { block } --> CORE::finally { block }
2613 elsif (/\G ( CORE:: (?: do | eval | try | finally ) \s* ) ( \{ ) /xmsgc) {
2614 11 $parsed .= $1;
2615 11 $parsed .= parse_expr_balanced($2);
2616 11 $parsed .= parse_ambiguous_char();
2617 }
2618  
2619 # mb::do { block } --> do { block }
2620 # mb::eval { block } --> eval { block }
2621 # mb::try { block } --> try { block }
2622 # mb::finally { block } --> finally { block }
2623 # do { block } --> do { block }
2624 # eval { block } --> eval { block }
2625 # try { block } --> try { block }
2626 # finally { block } --> finally { block }
2627 elsif (/\G (?: mb:: | $old_package )? ( (?: do | eval | try | finally ) \s* ) ( \{ ) /xmsgc) {
2628 30 $parsed .= $1;
2629 30 $parsed .= parse_expr_balanced($2);
2630 30 $parsed .= parse_ambiguous_char();
2631 }
2632  
2633 # $#{}, ${}, @{}, %{}, &{}, *{}, defer {}, sub {}
2634 # "\x24" [$] DOLLAR SIGN (U+0024)
2635 elsif (/\G ((?: \$[#] | [\$\@%&*] | defer | sub ) \s* ) ( \{ ) /xmsgc) {
2636 301 $parsed .= $1;
2637 301 $parsed .= parse_expr_balanced($2);
2638 301 $parsed .= parse_ambiguous_char();
2639 }
2640  
2641 # mb::do --> mb::do
2642 # CORE::do --> CORE::do
2643 # do --> do
2644 elsif (/\G ( (?: mb:: | CORE:: )? do ) \b /xmsgc) {
2645 3 $parsed .= $1;
2646 }
2647  
2648 # mb::eval --> mb::eval
2649 # CORE::eval --> CORE::eval
2650 # eval --> eval
2651 elsif (/\G ( (?: mb:: | CORE:: )? eval ) \b /xmsgc) {
2652 3 $parsed .= $1;
2653 3 $parsed .= parse_ambiguous_char();
2654 }
2655  
2656 # last index of array
2657 elsif (/\G ( [\$] [#] (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) ) /xmsgc) {
2658 3 $parsed .= $1;
2659 3 $parsed .= parse_ambiguous_char();
2660 }
2661  
2662 # scalar variable
2663 elsif (/\G ( [\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | ^\{[A-Za-z_][A-Za-z_0-9]*\} | [0-9]+ | [!"#\$%&'()+,\-.\/:;<=>?\@\[\\\]\^_`|~] ) (?: \s* (?: \+\+ | -- ) )? ) /xmsgc) {
2664 8950 $parsed .= $1;
2665 8950 $parsed .= parse_ambiguous_char();
2666 }
2667  
2668 # array variable
2669 # "\x40" [@] COMMERCIAL AT (U+0040)
2670 elsif (/\G ( [\@\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | [_] ) ) /xmsgc) {
2671 208 $parsed .= $1;
2672 208 $parsed .= parse_ambiguous_char();
2673 }
2674  
2675 # hash variable
2676 elsif (/\G ( [\%\@\$] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* | [!+\-] ) ) /xmsgc) {
2677 13 $parsed .= $1;
2678 13 $parsed .= parse_ambiguous_char();
2679 }
2680  
2681 # user subroutine call
2682 # type glob
2683 elsif (/\G ( [&*] [\$]* (?: [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) ) /xmsgc) {
2684 236 $parsed .= $1;
2685 236 $parsed .= parse_ambiguous_char();
2686 }
2687  
2688 # comment
2689 # "\x23" [#] NUMBER SIGN (U+0023)
2690 elsif (/\G ( [#] [^\n]* ) /xmsgc) {
2691 49 $parsed .= $1;
2692 }
2693  
2694 # 2-quotes
2695  
2696 # '...'
2697 # "\x27" ['] APOSTROPHE (U+0027)
2698 elsif (m{\G ( ' ) }xmsgc) {
2699 6471 $parsed .= parse_q__like_endswith($1);
2700 6471 $parsed .= parse_ambiguous_char();
2701 }
2702  
2703 # "...", `...`
2704 # "\x22" ["] QUOTATION MARK (U+0022)
2705 # "\x60" [`] GRAVE ACCENT (U+0060)
2706 elsif (m{\G ( ["`] ) }xmsgc) {
2707 15296 $parsed .= parse_qq_like_endswith($1);
2708 15296 $parsed .= parse_ambiguous_char();
2709 }
2710  
2711 # /.../
2712 elsif (m{\G ( [/] ) }xmsgc) {
2713 16975 my $regexp = parse_re_endswith('m',$1);
2714 16971 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
2715  
2716 # /xx modifier
2717 16971 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 77 16894 16971
2718 77 $regexp = mb::_ignore_space($regexp);
2719 }
2720  
2721 # /i modifier
2722 16971 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 23 16948 16971
2723 23 $parsed .= sprintf('m{\\G${mb::_anchor}@{[mb::_ignorecase(qr%s%s)]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2724 }
2725 else {
2726 16948 $parsed .= sprintf('m{\\G${mb::_anchor}@{[' . 'qr%s%s ]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2727 }
2728 16971 $parsed .= parse_ambiguous_char();
2729 }
2730  
2731 # ?...?
2732 elsif (m{\G ( [?] ) }xmsgc) {
2733 1 my $regexp = parse_re_endswith('m',$1);
2734 1 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
2735  
2736 # /xx modifier
2737 1 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 0 1 1
2738 0 $regexp = mb::_ignore_space($regexp);
2739 }
2740  
2741 # /i modifier
2742 1 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 0 1 1
2743 0 $parsed .= sprintf('m{\\G${mb::_anchor}@{[mb::_ignorecase(qr%s%s)]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2744 }
2745 else {
2746 1 $parsed .= sprintf('m{\\G${mb::_anchor}@{[' . 'qr%s%s ]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2747 }
2748 1 $parsed .= parse_ambiguous_char();
2749 }
2750  
2751 # <<>> double-diamond operator
2752 elsif (/\G ( <<>> ) /xmsgc) {
2753 1 $parsed .= $1;
2754 1 $parsed .= parse_ambiguous_char();
2755 }
2756  
2757 # <FILE> diamond operator
2758 # <${file}>
2759 # <$file>
2760 # <fileglob>
2761 elsif (/\G (<) ((?:(?!\s)$x)*?) (>) /xmsgc) {
2762 5 my($open_bracket, $quotee, $close_bracket) = ($1, $2, $3);
2763 5 $parsed .= $open_bracket;
2764 5 ▶ while ($quotee =~ /\G ($x) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quotee =~ /\G ($x) /cgmsx) 25 5 30
2765 25 $parsed .= escape_qq($1, $close_bracket);
2766 }
2767 5 $parsed .= $close_bracket;
2768 5 $parsed .= parse_ambiguous_char();
2769 }
2770  
2771 # qw/.../, q/.../
2772 elsif (/\G ( qw | q ) \b /xmsgc) {
2773 178 $parsed .= $1;
2774 178 ▶ if (/\G ( [#] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 2 176 178
elsif (/\G ( ['] ) /cgmsx) { } 2 174 176
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 52 122 174
elsif (m[\G( [/] ) ]cgmsx) { } 6 116 122
elsif (/\G ( [\S] ) /cgmsx) { } 48 68 116
elsif (/\G ( \s+ ) /cgmsx) { } 68 0 68
2775 2 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2776 52 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_q__like_balanced($1); }
2777 6 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_q__like_endswith($1); }
2778 48 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2779 68 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1;
2780 68 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 4 68 72
2781 4 $parsed .= $1;
2782 }
2783 68 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 6 62 68
elsif (/\G ( ['] ) /cgmsx) { } 2 60 62
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 8 52 60
elsif (m[\G( [/] ) ]cgmsx) { } 2 50 52
elsif (/\G ( [\S] ) /cgmsx) { } 50 0 50
2784 2 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2785 8 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_q__like_balanced($1); }
2786 2 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_q__like_endswith($1); }
2787 50 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2788 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2789 }
2790 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2791 178 $parsed .= parse_ambiguous_char();
2792 }
2793  
2794 # qq/.../
2795 elsif (/\G ( qq ) \b /xmsgc) {
2796 70 $parsed .= $1;
2797 70 ▶ if (/\G ( [#] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 1 69 70
elsif (/\G ( ['] ) /cgmsx) { } 1 68 69
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 7 61 68
elsif (m[\G( [/] ) ]cgmsx) { } 3 58 61
elsif (/\G ( [\S] ) /cgmsx) { } 24 34 58
elsif (/\G ( \s+ ) /cgmsx) { } 34 0 34
2798 1 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); } # qq'...' works as "..."
2799 7 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_qq_like_balanced($1); }
2800 3 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2801 24 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2802 34 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1;
2803 34 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 2 34 36
2804 2 $parsed .= $1;
2805 }
2806 34 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 3 31 34
elsif (/\G ( ['] ) /cgmsx) { } 1 30 31
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 4 26 30
elsif (m[\G( [/] ) ]cgmsx) { } 1 25 26
elsif (/\G ( [\S] ) /cgmsx) { } 25 0 25
2807 1 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); } # qq'...' works as "..."
2808 4 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_qq_like_balanced($1); }
2809 1 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2810 25 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2811 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2812 }
2813 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2814 70 $parsed .= parse_ambiguous_char();
2815 }
2816  
2817 # qx/.../
2818 elsif (/\G ( qx ) \b /xmsgc) {
2819 67 $parsed .= $1;
2820 67 ▶ if (/\G ( [#] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 1 66 67
elsif (/\G ( ['] ) /cgmsx) { } 1 65 66
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 4 61 65
elsif (m[\G( [/] ) ]cgmsx) { } 3 58 61
elsif (/\G ( [\S] ) /cgmsx) { } 24 34 58
elsif (/\G ( \s+ ) /cgmsx) { } 34 0 34
2821 1 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2822 4 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_qq_like_balanced($1); }
2823 3 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2824 24 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2825 34 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1;
2826 34 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 2 34 36
2827 2 $parsed .= $1;
2828 }
2829 34 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 3 31 34
elsif (/\G ( ['] ) /cgmsx) { } 1 30 31
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 4 26 30
elsif (m[\G( [/] ) ]cgmsx) { } 1 25 26
elsif (/\G ( [\S] ) /cgmsx) { } 25 0 25
2830 1 elsif (/\G ( ['] ) /xmsgc) { $parsed .= parse_q__like_endswith($1); }
2831 4 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $parsed .= parse_qq_like_balanced($1); }
2832 1 elsif (m{\G( [/] ) }xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2833 25 elsif (/\G ( [\S] ) /xmsgc) { $parsed .= parse_qq_like_endswith($1); }
2834 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2835 }
2836 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2837 67 $parsed .= parse_ambiguous_char();
2838 }
2839  
2840 # m/.../, qr/.../
2841 elsif (/\G ( m | qr ) \b /xmsgc) {
2842 2438 $parsed .= $1;
2843 2438 my $regexp = '';
2844 2438 ▶ if (/\G ( [#] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr#...#
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 10 2428 2438
elsif (/\G ( ['] ) /cgmsx) { } 1263 1165 2428
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 65 1100 1165
elsif (m[\G( [/] ) ]cgmsx) { } 434 666 1100
elsif (/\G ( [:\@] ) /cgmsx) { } 530 136 666
elsif (/\G ( [\S] ) /cgmsx) { } 68 68 136
elsif (/\G ( \s+ ) /cgmsx) { } 68 0 68
2845 1263 elsif (/\G ( ['] ) /xmsgc) { $regexp .= parse_re_as_q_endswith('m',$1); } # qr'...'
2846 65 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp .= parse_re_balanced('m',$1); } # qr{...}
2847 434 elsif (m{\G( [/] ) }xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr/.../
2848 530 elsif (/\G ( [:\@] ) /xmsgc) { $regexp .= ('`' . quotee_of(parse_re_endswith('m',$1)) . '`'); } # qr@...@
2849 68 elsif (/\G ( [\S] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr?...?
2850 68 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1; $regexp .= $1; # qr SPACE ...
2851 68 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 4 68 72
2852 4 $parsed .= $1;
2853 }
2854 68 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr SPACE A...A
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 6 62 68
elsif (/\G ( ['] ) /cgmsx) { } 2 60 62
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 8 52 60
elsif (m[\G( [/] ) ]cgmsx) { } 2 50 52
elsif (/\G ( [:\@] ) /cgmsx) { } 4 46 50
elsif (/\G ( [\S] ) /cgmsx) { } 46 0 46
2855 2 elsif (/\G ( ['] ) /xmsgc) { $regexp .= parse_re_as_q_endswith('m',$1); } # qr SPACE '...'
2856 8 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp .= parse_re_balanced('m',$1); } # qr SPACE {...}
2857 2 elsif (m{\G( [/] ) }xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr SPACE /.../
2858 4 elsif (/\G ( [:\@] ) /xmsgc) { $regexp .= ('`' . quotee_of(parse_re_endswith('m',$1)) . '`'); } # qr SPACE @...@
2859 46 elsif (/\G ( [\S] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # qr SPACE ?...?
2860 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2861 }
2862 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2863  
2864 2436 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
2865  
2866 # /xx modifier
2867 2436 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 40 2396 2436
2868 40 $regexp = mb::_ignore_space($regexp);
2869 }
2870  
2871 # /i modifier
2872 2436 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 37 2399 2436
2873 37 $parsed .= sprintf('{\\G${mb::_anchor}@{[mb::_ignorecase(qr%s%s)]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2874 }
2875 else {
2876 2399 $parsed .= sprintf('{\\G${mb::_anchor}@{[' . 'qr%s%s ]}@{[mb::_m_passed()]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
2877 }
2878 2436 $parsed .= parse_ambiguous_char();
2879 }
2880  
2881 # 3-quotes
2882  
2883 # s/.../.../
2884 elsif (/\G ( s ) \b /xmsgc) {
2885 1730 $parsed .= $1;
2886 1730 my $regexp = '';
2887 1730 my $comment = '';
2888 1730 my @replacement = ();
2889 1730 ▶ if (/\G ( [#] ) /xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s#...#...#
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 1 1729 1730
elsif (/\G ( ['] ) /cgmsx) { } 286 1443 1729
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 247 1196 1443
elsif (m[\G( [/] ) ]cgmsx) { } 364 832 1196
elsif (/\G ( [:\@] ) /cgmsx) { } 528 304 832
elsif (/\G ( [\S] ) /cgmsx) { } 22 282 304
elsif (/\G ( \s+ ) /cgmsx) { } 282 0 282
2890 286 elsif (/\G ( ['] ) /xmsgc) { $regexp .= parse_re_as_q_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s'...'...'
2891 247 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp .= parse_re_balanced('s',$1); # s{...}...
2892 0 ▶ if (/\G ( [#] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{}#...#
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 0 247 247
elsif (/\G ( ['] ) /cgmsx) { } 4 243 247
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 23 220 243
elsif (m[\G( [/] ) ]cgmsx) { } 4 216 220
elsif (/\G ( [\S] ) /cgmsx) { } 96 120 216
elsif (/\G ( \s+ ) /cgmsx) { } 120 0 120
2893 4 elsif (/\G ( ['] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{}'...'
2894 23 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { @replacement = parse_qq_like_balanced($1); } # s{}{...}
2895 4 elsif (m{\G( [/] ) }xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{}/.../
2896 96 elsif (/\G ( [\S] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{}?...?
2897 120 elsif (/\G ( \s+ ) /xmsgc) { $comment .= $1; # s{} SPACE ...
2898 120 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 0 120 120
2899 0 $comment .= $1;
2900 }
2901 0 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{} SPACE A...A
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 0 120 120
elsif (/\G ( ['] ) /cgmsx) { } 4 116 120
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 16 100 116
elsif (m[\G( [/] ) ]cgmsx) { } 4 96 100
elsif (/\G ( [\S] ) /cgmsx) { } 96 0 96
2902 4 elsif (/\G ( ['] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{} SPACE '...'
2903 16 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { @replacement = parse_qq_like_balanced($1); } # s{} SPACE {...}
2904 4 elsif (m{\G( [/] ) }xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{} SPACE /.../
2905 96 elsif (/\G ( [\S] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s{} SPACE ?...?
2906 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2907 }
2908 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2909 }
2910 364 elsif (m{\G( [/] ) }xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s/.../.../
2911 528 elsif (/\G ( [:\@] ) /xmsgc) { $regexp .= ('`' . quotee_of(parse_re_endswith('s',$1)) . '`');
2912 528 @replacement = parse_qq_like_endswith($1); } # s@...@...@
2913 22 elsif (/\G ( [\S] ) /xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s?...?...?
2914 282 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1; $regexp .= $1; # s SPACE ...
2915 282 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 12 282 294
2916 12 $parsed .= $1;
2917 }
2918 282 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s SPACE A...A...A
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 12 270 282
elsif (/\G ( ['] ) /cgmsx) { } 1 269 270
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 244 25 269
elsif (m[\G( [/] ) ]cgmsx) { } 1 24 25
elsif (/\G ( [:\@] ) /cgmsx) { } 2 22 24
elsif (/\G ( [\S] ) /cgmsx) { } 22 0 22
2919 1 elsif (/\G ( ['] ) /xmsgc) { $regexp .= parse_re_as_q_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s SPACE '...'...'
2920 244 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp .= parse_re_balanced('s',$1); # s SPACE {...}...
2921 244 ▶ if (/\G ( [#] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {}#...#
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 1 243 244
elsif (/\G ( ['] ) /cgmsx) { } 4 239 243
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 17 222 239
elsif (m[\G( [/] ) ]cgmsx) { } 4 218 222
elsif (/\G ( [\S] ) /cgmsx) { } 96 122 218
elsif (/\G ( \s+ ) /cgmsx) { } 122 0 122
2922 4 elsif (/\G ( ['] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {}'...'
2923 17 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { @replacement = parse_qq_like_balanced($1); } # s SPACE {}{...}
2924 4 elsif (m{\G( [/] ) }xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {}/.../
2925 96 elsif (/\G ( [\S] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {}?...?
2926 122 elsif (/\G ( \s+ ) /xmsgc) { $comment .= $1; # s SPACE {} SPACE ...
2927 122 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 8 122 130
2928 8 $comment .= $1;
2929 }
2930 0 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {} SPACE A...A
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 0 122 122
elsif (/\G ( ['] ) /cgmsx) { } 4 118 122
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 18 100 118
elsif (m[\G( [/] ) ]cgmsx) { } 4 96 100
elsif (/\G ( [\S] ) /cgmsx) { } 96 0 96
2931 4 elsif (/\G ( ['] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {} SPACE '...'
2932 18 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { @replacement = parse_qq_like_balanced($1); } # s SPACE {} SPACE {...}
2933 4 elsif (m{\G( [/] ) }xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {} SPACE /.../
2934 96 elsif (/\G ( [\S] ) /xmsgc) { @replacement = parse_qq_like_endswith($1); } # s SPACE {} SPACE ?...?
2935 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2936 }
2937 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2938 }
2939 1 elsif (m{\G( [/] ) }xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s SPACE /.../.../
2940 2 elsif (/\G ( [:\@] ) /xmsgc) { $regexp .= ('`' . quotee_of(parse_re_endswith('s',$1)) . '`');
2941 2 @replacement = parse_qq_like_endswith($1); } # s SPACE @...@...@
2942 22 elsif (/\G ( [\S] ) /xmsgc) { $regexp .= parse_re_endswith('s',$1); @replacement = parse_qq_like_endswith($1); } # s SPACE ?...?...?
2943 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2944 }
2945 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
2946  
2947 1730 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
2948 1730 my $replacement = '';
2949 1730 my $eval = '';
2950  
2951 # has /e modifier
2952 1730 ▶ if (my $e = $modifier_cegr =~ tr/e//d) {
Branch: 3 branches
BranchTrueFalseTotal
if (my $e = $modifier_cegr =~ tr/e//d) { } 9 1721 1730
elsif ($replacement[0] =~ /\A ' /msx) { } 300 1421 1721
elsif ($replacement[0] =~ /\A [#] /msx) { } 2 1419 1421
2953 9 $replacement = 'q'. $replacement[1]; # q-type quotee
2954 9 $eval = 'mb::eval ' x $e;
2955 }
2956  
2957 # s''q-quotee'
2958 elsif ($replacement[0] =~ /\A ' /xms) {
2959 300 $replacement = $replacement[1]; # q-type quotee
2960 }
2961  
2962 # s##qq-quotee#
2963 elsif ($replacement[0] =~ /\A [#] /xms) {
2964 2 $replacement = 'qq' . $replacement[0]; # qq-type quotee
2965 }
2966  
2967 # s//qq-quotee/
2968 else {
2969 1419 $replacement = 'qq ' . $replacement[0]; # qq-type quotee
2970 }
2971  
2972 # /xx modifier
2973 1730 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 7 1723 1730
2974 7 $regexp = mb::_ignore_space($regexp);
2975 }
2976  
2977 # /i modifier
2978 1730 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 18 1712 1730
2979 18 $parsed .= sprintf('{(\\G${mb::_anchor})@{[mb::_ignorecase(qr%s%s)]}@{[mb::_s_passed()]}}%s{$1 . %s%s}e%s', $regexp, $modifier_not_cegir, $comment, $eval, $replacement, $modifier_cegr);
2980 }
2981 else {
2982 1712 $parsed .= sprintf('{(\\G${mb::_anchor})@{[' . 'qr%s%s ]}@{[mb::_s_passed()]}}%s{$1 . %s%s}e%s', $regexp, $modifier_not_cegir, $comment, $eval, $replacement, $modifier_cegr);
2983 }
2984 1730 $parsed .= parse_ambiguous_char();
2985 }
2986  
2987 # tr/.../.../, y/.../.../
2988 elsif (/\G (?: tr | y ) \b /xmsgc) {
2989 2159 $parsed .= 's'; # not 'tr'
2990 2159 my $search = '';
2991 2159 my $comment = '';
2992 2159 my $replacement = '';
2993 2159 ▶ if (/\G ( [#] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr#...#...#
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 4 2155 2159
elsif (/\G ( ['] ) /cgmsx) { } 4 2151 2155
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 912 1239 2151
elsif (m[\G( [/] ) ]cgmsx) { } 98 1141 1239
elsif (/\G ( [\S] ) /cgmsx) { } 131 1010 1141
elsif (/\G ( \s+ ) /cgmsx) { } 1010 0 1010
2994 4 elsif (/\G ( ['] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr'...'...'
2995 912 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $search .= parse_tr_like_balanced($1); # tr{...}...
2996 0 ▶ if (/\G ( [#] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{}#...#
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 0 912 912
elsif (/\G ( ['] ) /cgmsx) { } 16 896 912
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 64 832 896
elsif (m[\G( [/] ) ]cgmsx) { } 16 816 832
elsif (/\G ( [\S] ) /cgmsx) { } 360 456 816
elsif (/\G ( \s+ ) /cgmsx) { } 456 0 456
2997 16 elsif (/\G ( ['] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{}'...'
2998 64 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $replacement .= parse_tr_like_balanced($1); } # tr{}{...}
2999 16 elsif (m{\G( [/] ) }xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{}/.../
3000 360 elsif (/\G ( [\S] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{}?...?
3001 456 elsif (/\G ( \s+ ) /xmsgc) { $comment .= $1; # tr{} SPACE ...
3002 456 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 0 456 456
3003 0 $comment .= $1;
3004 }
3005 0 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{} SPACE A...A
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 0 456 456
elsif (/\G ( ['] ) /cgmsx) { } 16 440 456
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 64 376 440
elsif (m[\G( [/] ) ]cgmsx) { } 16 360 376
elsif (/\G ( [\S] ) /cgmsx) { } 360 0 360
3006 16 elsif (/\G ( ['] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{} SPACE '...'
3007 64 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $replacement .= parse_tr_like_balanced($1); } # tr{} SPACE {...}
3008 16 elsif (m{\G( [/] ) }xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{} SPACE /.../
3009 360 elsif (/\G ( [\S] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr{} SPACE ?...?
3010 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3011 }
3012 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3013 }
3014 98 elsif (m{\G( [/] ) }xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr/.../.../
3015 131 elsif (/\G ( [\S] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr?...?...?
3016 1010 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1; # tr SPACE ...
3017 1010 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 0 1010 1010
3018 0 $parsed .= $1;
3019 }
3020 0 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr SPACE A...A...A
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 0 1010 1010
elsif (/\G ( ['] ) /cgmsx) { } 4 1006 1010
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 912 94 1006
elsif (m[\G( [/] ) ]cgmsx) { } 4 90 94
elsif (/\G ( [\S] ) /cgmsx) { } 90 0 90
3021 4 elsif (/\G ( ['] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr SPACE '...'...'
3022 912 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $search .= parse_tr_like_balanced($1); # tr SPACE {...}...
3023 0 ▶ if (/\G ( [#] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {}#...#
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 0 912 912
elsif (/\G ( ['] ) /cgmsx) { } 16 896 912
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 64 832 896
elsif (m[\G( [/] ) ]cgmsx) { } 16 816 832
elsif (/\G ( [\S] ) /cgmsx) { } 360 456 816
elsif (/\G ( \s+ ) /cgmsx) { } 456 0 456
3024 16 elsif (/\G ( ['] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {}'...'
3025 64 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $replacement .= parse_tr_like_balanced($1); } # tr SPACE {}{...}
3026 16 elsif (m{\G( [/] ) }xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {}/.../
3027 360 elsif (/\G ( [\S] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {}?...?
3028 456 elsif (/\G ( \s+ ) /xmsgc) { $comment .= $1; # tr SPACE {} SPACE ...
3029 456 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 0 456 456
3030 0 $comment .= $1;
3031 }
3032 0 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {} SPACE A...A
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 0 456 456
elsif (/\G ( ['] ) /cgmsx) { } 16 440 456
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 64 376 440
elsif (m[\G( [/] ) ]cgmsx) { } 16 360 376
elsif (/\G ( [\S] ) /cgmsx) { } 360 0 360
3033 16 elsif (/\G ( ['] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {} SPACE '...'
3034 64 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $replacement .= parse_tr_like_balanced($1); } # tr SPACE {} SPACE {...}
3035 16 elsif (m{\G( [/] ) }xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {} SPACE /.../
3036 360 elsif (/\G ( [\S] ) /xmsgc) { $replacement .= parse_tr_like_endswith($1); } # tr SPACE {} SPACE ?...?
3037 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3038 }
3039 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3040 }
3041 4 elsif (m{\G( [/] ) }xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr SPACE /.../.../
3042 90 elsif (/\G ( [\S] ) /xmsgc) { $search .= parse_tr_like_endswith($1); $replacement .= parse_tr_like_endswith($1); } # tr SPACE ?...?...?
3043 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3044 }
3045 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3046  
3047 # modifier
3048 2159 my($modifier_not_r, $modifier_r) = parse_tr_modifier();
3049 2159 ▶ if ($modifier_r) {
Branch: 2 branches
BranchTrueFalseTotal
if ($modifier_r) { } 0 2159 2159
elsif ($modifier_not_r =~ /s/) { } 28 2131 2159
3050 0 $parsed .= sprintf(q<{[\x00-\xFF]*}%s{mb::tr($&,q%s,q%s,'%sr')}ser>, $comment, $search, $replacement, $modifier_not_r);
3051 }
3052 elsif ($modifier_not_r =~ /s/) {
3053  
3054 # this implementation cannot return right count of codepoints replaced.
3055 # if you want right count, you can call mb::tr() yourself.
3056 28 $parsed .= sprintf(q<{[\x00-\xFF]+}%s{mb::tr($&,q%s,q%s,'%sr')}se>, $comment, $search, $replacement, $modifier_not_r);
3057 }
3058 else {
3059  
3060 # $parsed .= sprintf(q<{@{mb::_dot}}%s{mb::tr($&,q%s,q%s,'%sr')}msge>, $comment, $search, $replacement, $modifier_not_r);
3061 #------------------------------------------------------------------------------------------------------------------------------------------------
3062 # do { $_='AAABBCDEA'; $r=tr/ABC/12/; ($r,$_) } => (9,111222DE1)
3063 # do { $_='AAABBCDEA'; $r=tr/ABC/12/s; ($r,$_) } => (9,111222DE1)
3064 # do { $_='AAABBCDEA'; $r=tr/ABC/12/d; ($r,$_) } => (9,11122DE1)
3065 # do { $_='AAABBCDEA'; $r=tr/ABC/12/ds; ($r,$_) } => (9,11122DE1)
3066 # do { $_='AAABBCDEA'; $r=tr/ABC/12/c; ($r,$_) } => (9,AAABBC22A)
3067 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cs; ($r,$_) } => (9,AAABBC22A)
3068 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cd; ($r,$_) } => (9,AAABBCA)
3069 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cds; ($r,$_) } => (9,AAABBCA)
3070  
3071 # $parsed .= sprintf(q<{[\x00-\xFF]*}%s{mb::tr($&,q%s,q%s,'%sr')}msge>, $comment, $search, $replacement, $modifier_not_r);
3072 #------------------------------------------------------------------------------------------------------------------------------------------------
3073 # do { $_='AAABBCDEA'; $r=tr/ABC/12/; ($r,$_) } => (2,111222DE1)
3074 # do { $_='AAABBCDEA'; $r=tr/ABC/12/s; ($r,$_) } => (2,12DE1)
3075 # do { $_='AAABBCDEA'; $r=tr/ABC/12/d; ($r,$_) } => (2,11122DE1)
3076 # do { $_='AAABBCDEA'; $r=tr/ABC/12/ds; ($r,$_) } => (2,12DE1)
3077 # do { $_='AAABBCDEA'; $r=tr/ABC/12/c; ($r,$_) } => (2,AAABBC22A)
3078 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cs; ($r,$_) } => (2,AAABBC2A)
3079 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cd; ($r,$_) } => (2,AAABBCA)
3080 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cds; ($r,$_) } => (2,AAABBCA)
3081  
3082 # if ($modifier_not_r =~ /c/) {
3083 # $parsed .= sprintf(q<{@{[mb::_cc(q[^%s])]}}%s{mb::tr($&,q%s,q%s,'%sr')}msge>, $search, $comment, $search, $replacement, $modifier_not_r);
3084 # }
3085 # else {
3086 # $parsed .= sprintf(q<{@{[mb::_cc(q[%s])]}}%s{mb::tr($&,q%s,q%s,'%sr')}msge>, $search, $comment, $search, $replacement, $modifier_not_r);
3087 # }
3088 #------------------------------------------------------------------------------------------------------------------------------------------------
3089 # do { $_='AAABBCDEA'; $r=tr/ABC/12/; ($r,$_) } => (7,111222DE1)
3090 # do { $_='AAABBCDEA'; $r=tr/ABC/12/s; ($r,$_) } => (7,111222DE1)
3091 # do { $_='AAABBCDEA'; $r=tr/ABC/12/d; ($r,$_) } => (7,11122DE1)
3092 # do { $_='AAABBCDEA'; $r=tr/ABC/12/ds; ($r,$_) } => (7,11122DE1)
3093 # do { $_='AAABBCDEA'; $r=tr/ABC/12/c; ($r,$_) } => (2,AAABBC22A)
3094 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cs; ($r,$_) } => (2,AAABBC22A)
3095 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cd; ($r,$_) } => (2,AAABBCA)
3096 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cds; ($r,$_) } => (2,AAABBCA)
3097  
3098 # better idea of mine
3099 2131 ▶ if ($modifier_not_r =~ /c/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_r =~ /c/) { } 16 2115 2131
3100 16 $parsed .= sprintf(q<{(\\G${mb::_anchor})((?!%s)@{mb::_dot})}%s{$1.mb::tr($2,q%s,q%s,'%sr')}sge>, codepoint_tr($search), $comment, $search, $replacement, $modifier_not_r);
3101 }
3102 else {
3103 2115 $parsed .= sprintf(q<{(\\G${mb::_anchor})((?=%s)@{mb::_dot})}%s{$1.mb::tr($2,q%s,q%s,'%sr')}sge>, codepoint_tr($search), $comment, $search, $replacement, $modifier_not_r);
3104 }
3105 #------------------------------------------------------------------------------------------------------------------------------------------------
3106 # do { $_='AAABBCDEA'; $r=tr/ABC/12/; ($r,$_) } => (7,111222DE1)
3107 # do { $_='AAABBCDEA'; $r=tr/ABC/12/s; ($r,$_) } => (1,12DE1)
3108 # do { $_='AAABBCDEA'; $r=tr/ABC/12/d; ($r,$_) } => (7,11122DE1)
3109 # do { $_='AAABBCDEA'; $r=tr/ABC/12/ds; ($r,$_) } => (1,12DE1)
3110 # do { $_='AAABBCDEA'; $r=tr/ABC/12/c; ($r,$_) } => (2,AAABBC22A)
3111 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cs; ($r,$_) } => (1,AAABBC2A)
3112 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cd; ($r,$_) } => (2,AAABBCA)
3113 # do { $_='AAABBCDEA'; $r=tr/ABC/12/cds; ($r,$_) } => (1,AAABBCA)
3114 }
3115 2159 $parsed .= parse_ambiguous_char();
3116 }
3117  
3118 # indented here document
3119 elsif (/\G ( <<~ ) /xmsgc) {
3120 11 $parsed .= $1;
3121 11 ▶ if (/\G ( ([A-Za-z_][A-Za-z_0-9]*) ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, ["[\\t ]*$2$R", 'qq']; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( ([A-Za-z_][A-Za-z_0-9]*) ) /cgmsx) { } 1 10 11
elsif (/\G ( \\([A-Za-z_][A-Za-z_0-9]*) ) /cgmsx) { } 1 9 10
elsif (/\G ( [\t ]* '([A-Za-z_][A-Za-z_0-9]*)' ) /cgmsx) { } 3 6 9
elsif (/\G ( [\t ]* "([A-Za-z_][A-Za-z_0-9]*)" ) /cgmsx) { } 3 3 6
elsif (/\G ( [\t ]* `([A-Za-z_][A-Za-z_0-9]*)` ) /cgmsx) { } 3 0 3
3122 1 elsif (/\G ( \\([A-Za-z_][A-Za-z_0-9]*) ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, ["[\\t ]*$2$R", 'q' ]; }
3123 3 elsif (/\G ( [\t ]* '([A-Za-z_][A-Za-z_0-9]*)' ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, ["[\\t ]*$2$R", 'q' ]; }
3124 3 elsif (/\G ( [\t ]* "([A-Za-z_][A-Za-z_0-9]*)" ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, ["[\\t ]*$2$R", 'qq']; }
3125 3 elsif (/\G ( [\t ]* `([A-Za-z_][A-Za-z_0-9]*)` ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, ["[\\t ]*$2$R", 'qq']; }
3126 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3127 11 $parsed .= parse_ambiguous_char();
3128 }
3129  
3130 # here document
3131 elsif (/\G ( << ) /xmsgc) {
3132 12 $parsed .= $1;
3133 12 ▶ if (/\G ( ([A-Za-z_][A-Za-z_0-9]*) ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, [ "$2$R", 'qq']; }
Branch: 5 branches
BranchTrueFalseTotal
if (/\G ( ([A-Za-z_][A-Za-z_0-9]*) ) /cgmsx) { } 1 11 12
elsif (/\G ( \\([A-Za-z_][A-Za-z_0-9]*) ) /cgmsx) { } 1 10 11
elsif (/\G ( [\t ]* '([A-Za-z_][A-Za-z_0-9]*)' ) /cgmsx) { } 4 6 10
elsif (/\G ( [\t ]* "([A-Za-z_][A-Za-z_0-9]*)" ) /cgmsx) { } 3 3 6
elsif (/\G ( [\t ]* `([A-Za-z_][A-Za-z_0-9]*)` ) /cgmsx) { } 3 0 3
3134 1 elsif (/\G ( \\([A-Za-z_][A-Za-z_0-9]*) ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, [ "$2$R", 'q' ]; }
3135 4 elsif (/\G ( [\t ]* '([A-Za-z_][A-Za-z_0-9]*)' ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, [ "$2$R", 'q' ]; }
3136 3 elsif (/\G ( [\t ]* "([A-Za-z_][A-Za-z_0-9]*)" ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, [ "$2$R", 'qq']; }
3137 3 elsif (/\G ( [\t ]* `([A-Za-z_][A-Za-z_0-9]*)` ) /xmsgc) { $parsed .= $1; push @here_document_delimiter, [ "$2$R", 'qq']; }
3138 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3139 12 $parsed .= parse_ambiguous_char();
3140 }
3141  
3142 # sub subroutine();
3143 elsif (/\G ( sub \s+ [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* \s* ) /xmsgc) {
3144 37 $parsed .= $1;
3145 }
3146  
3147 # while (<<>>)
3148 elsif (/\G ( while \s* \( \s* ) ( <<>> ) ( \s* \) ) /xmsgc) {
3149 2 $parsed .= $1;
3150 2 $parsed .= $2;
3151 2 $parsed .= $3;
3152 }
3153  
3154 # while (<${file}>)
3155 # while (<$file>)
3156 # while (<FILE>)
3157 # while (<fileglob>)
3158 elsif (/\G ( while \s* \( \s* ) (<) ((?:(?!\s)$x)*?) (>) ( \s* \) ) /xmsgc) {
3159 9 $parsed .= $1;
3160 9 my($open_bracket, $quotee, $close_bracket) = ($2, $3, $4);
3161 9 my $close_bracket2 = $5;
3162 9 $parsed .= $open_bracket;
3163 9 ▶ while ($quotee =~ /\G ($x) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quotee =~ /\G ($x) /cgmsx) 54 9 63
3164 54 $parsed .= escape_qq($1, $close_bracket);
3165 }
3166 9 $parsed .= $close_bracket;
3167 9 $parsed .= $close_bracket2;
3168 }
3169  
3170 # while <<>>
3171 elsif (/\G ( while \s* ) ( <<>> ) /xmsgc) {
3172 0 $parsed .= $1;
3173 0 $parsed .= $2;
3174 }
3175  
3176 # while <${file}>
3177 # while <$file>
3178 # while <FILE>
3179 # while <fileglob>
3180 elsif (/\G ( while \s* ) (<) ((?:(?!\s)$x)*?) (>) /xmsgc) {
3181 0 $parsed .= $1;
3182 0 my($open_bracket, $quotee, $close_bracket) = ($2, $3, $4);
3183 0 $parsed .= $open_bracket;
3184 0 ▶ while ($quotee =~ /\G ($x) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quotee =~ /\G ($x) /cgmsx) 0 0 0
3185 0 $parsed .= escape_qq($1, $close_bracket);
3186 }
3187 0 $parsed .= $close_bracket;
3188 }
3189  
3190 # if (expr)
3191 # elsif (expr)
3192 # unless (expr)
3193 # while (expr)
3194 # until (expr)
3195 # given (expr)
3196 # when (expr)
3197 # CORE::catch (expr)
3198 # catch (expr)
3199 elsif (/\G ( (?: if | elsif | unless | while | until | given | when | (?: CORE:: )? catch ) \s* ) ( \( ) /xmsgc) {
3200 25 $parsed .= $1;
3201  
3202 # outputs expr
3203 25 my $expr = parse_expr_balanced($2);
3204 25 $parsed .= $expr;
3205 }
3206  
3207 # mb::catch (expr) --> catch (expr)
3208 elsif (/\G mb:: ( catch \s* ) ( \( ) /xmsgc) {
3209 4 $parsed .= $1;
3210  
3211 # outputs expr
3212 4 my $expr = parse_expr_balanced($2);
3213 4 $parsed .= $expr;
3214 }
3215  
3216 # else
3217 elsif (/\G ( else ) \b /xmsgc) {
3218 1 $parsed .= $1;
3219 }
3220  
3221 # ... if expr;
3222 # ... unless expr;
3223 # ... while expr;
3224 # ... until expr;
3225 elsif (/\G ( if | unless | while | until ) \b /xmsgc) {
3226 19 $parsed .= $1;
3227 }
3228  
3229 # foreach my $var (expr) --> foreach my $var (expr)
3230 # for my $var (expr) --> for my $var (expr)
3231 elsif (/\G ( (?: foreach | for ) \s+ my \s* [\$] [A-Za-z_][A-Za-z_0-9]* ) ( \( ) /xmsgc) {
3232 0 $parsed .= $1;
3233 0 $parsed .= parse_expr_balanced($2);
3234 }
3235  
3236 # foreach $var (expr) --> foreach $var (expr)
3237 # for $var (expr) --> for $var (expr)
3238 elsif (/\G ( (?: foreach | for ) \s* [\$] [\$]* (?: \{[A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)*\} | [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]* ) ) ) ( \( ) /xmsgc) {
3239 0 $parsed .= $1;
3240 0 $parsed .= parse_expr_balanced($2);
3241 }
3242  
3243 # foreach (expr1; expr2; expr3) --> foreach (expr1; expr2; expr3)
3244 # foreach (expr) --> foreach (expr)
3245 # for (expr1; expr2; expr3) --> for (expr1; expr2; expr3)
3246 # for (expr) --> for (expr)
3247 elsif (/\G ( (?: foreach | for ) \s* ) ( \( ) /xmsgc) {
3248 4 $parsed .= $1;
3249 4 $parsed .= parse_expr_balanced($2);
3250 }
3251  
3252 # CORE::split --> mb::_split
3253 # mb::split --> mb::_split
3254 # split --> mb::_split
3255 elsif (/\G (?: CORE:: | mb:: | $old_package )? ( split ) \b /xmsgc) {
3256 687 $parsed .= "mb::_split";
3257  
3258 # parse \s and '('
3259 687 while (1) {
3260 1380 ▶ if (/\G ( \s+ ) /xmsgc) {
Branch: 3 branches
BranchTrueFalseTotal
if (/\G ( \s+ ) /cgmsx) { } 298 1082 1380
elsif (/\G ( \( ) /cgmsx) { } 395 687 1082
elsif (/\G ( \# .* \n ) /cgmx) { } 16 671 687
3261 298 $parsed .= $1;
3262 }
3263 elsif (/\G ( \( ) /xmsgc) {
3264 395 $parsed .= $1;
3265 }
3266 elsif (/\G ( \# .* \n ) /xmgc) {
3267 16 $parsed .= $1;
3268 16 last;
3269 }
3270 else {
3271 671 last;
3272 }
3273 }
3274 687 my $regexp = '';
3275  
3276 # split /^/ --> mb::_split qr/^/m
3277 # split /.../ --> mb::_split qr/.../
3278 687 ▶ if (m{\G ( [/] ) }xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (m[\G ( [/] ) ]cgmsx) { } 32 655 687
elsif (/\G ( m | qr ) \b /cgmsx) { } 611 44 655
3279 32 $parsed .= "qr";
3280 32 $regexp = parse_re_endswith('m',$1); # split /.../
3281 32 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
3282  
3283 # P.794 29.2.161. split
3284 # in Chapter 29: Functions
3285 # of ISBN 0-596-00027-8 Programming Perl Third Edition.
3286  
3287 # P.951 split
3288 # in Chapter 27: Functions
3289 # of ISBN 978-0-596-00492-7 Programming Perl 4th Edition.
3290  
3291 # said "The //m modifier is assumed when you split on the pattern /^/",
3292 # but perl5.008 is not so. Therefore, this software adds //m.
3293 # (and so on)
3294  
3295 32 ▶ if ($modifier_not_cegir !~ /m/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($modifier_not_cegir =~ /m/msx) 26 6 32
3296 26 $modifier_not_cegir .= 'm';
3297 }
3298  
3299 # /xx modifier
3300 32 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 4 28 32
3301 4 $regexp = mb::_ignore_space($regexp);
3302 }
3303  
3304 # /i modifier
3305 32 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 6 26 32
3306 6 $parsed .= sprintf('{@{[mb::_ignorecase(qr%s%s)]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
3307 }
3308 else {
3309 26 $parsed .= sprintf('{@{[' . 'qr%s%s ]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
3310 }
3311 }
3312  
3313 # split m/^/ --> mb::_split qr/^/m
3314 # split m/.../ --> mb::_split qr/.../
3315 elsif (/\G ( m | qr ) \b /xmsgc) {
3316 611 $parsed .= "qr";
3317  
3318 611 ▶ if (/\G ( [#] ) /xmsgc) { $regexp = parse_re_endswith('m',$1); } # split qr#...#
Branch: 7 branches
BranchTrueFalseTotal
if (/\G ( [#] ) /cgmsx) { } 8 603 611
elsif (/\G ( ['] ) /cgmsx) { } 8 595 603
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 32 563 595
elsif (m[\G( [/] ) ]cgmsx) { } 83 480 563
elsif (/\G ( [:\@] ) /cgmsx) { } 16 464 480
elsif (/\G ( [\S] ) /cgmsx) { } 184 280 464
elsif (/\G ( \s+ ) /cgmsx) { } 280 0 280
3319 8 elsif (/\G ( ['] ) /xmsgc) { $regexp = parse_re_as_q_endswith('m',$1); } # split qr'...'
3320 32 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp = parse_re_balanced('m',$1); } # split qr{...}
3321 83 elsif (m{\G( [/] ) }xmsgc) { $regexp = parse_re_endswith('m',$1); } # split qr/.../
3322 16 elsif (/\G ( [:\@] ) /xmsgc) { $regexp = ('`' . quotee_of(parse_re_endswith('m',$1)) . '`'); } # split qr@...@
3323 184 elsif (/\G ( [\S] ) /xmsgc) { $regexp = parse_re_endswith('m',$1); } # split qr?...?
3324 280 elsif (/\G ( \s+ ) /xmsgc) { $parsed .= $1; $regexp = $1; # split qr SPACE ...
3325 280 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 32 280 312
3326 32 $parsed .= $1;
3327 }
3328 280 ▶ if (/\G ( [A-Za-z_0-9] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # split qr SPACE A...A
Branch: 6 branches
BranchTrueFalseTotal
if (/\G ( [A-Za-z_0-9] ) /cgmsx) { } 24 256 280
elsif (/\G ( ['] ) /cgmsx) { } 8 248 256
elsif (/\G ( [\(\{\[\<] ) /cgmsx) { } 32 216 248
elsif (m[\G( [/] ) ]cgmsx) { } 8 208 216
elsif (/\G ( [:\@] ) /cgmsx) { } 16 192 208
elsif (/\G ( [\S] ) /cgmsx) { } 192 0 192
3329 8 elsif (/\G ( ['] ) /xmsgc) { $regexp .= parse_re_as_q_endswith('m',$1); } # split qr SPACE '...'
3330 32 elsif (/\G ( [\(\{\[\<] ) /xmsgc) { $regexp .= parse_re_balanced('m',$1); } # split qr SPACE {...}
3331 8 elsif (m{\G( [/] ) }xmsgc) { $regexp .= parse_re_endswith('m',$1); } # split qr SPACE /.../
3332 16 elsif (/\G ( [:\@] ) /xmsgc) { $regexp .= ('`' . quotee_of(parse_re_endswith('m',$1)) . '`'); } # split qr SPACE @...@
3333 192 elsif (/\G ( [\S] ) /xmsgc) { $regexp .= parse_re_endswith('m',$1); } # split qr SPACE ?...?
3334 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3335 }
3336 0 else { die "$0(@{[__LINE__]}): $ARGV[0] has not closed:\n", $parsed; }
3337  
3338 611 my($modifier_i, $modifier_not_cegir, $modifier_cegr) = parse_re_modifier();
3339  
3340 611 ▶ if ($modifier_not_cegir !~ /m/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($modifier_not_cegir =~ /m/msx) 607 4 611
3341 607 $modifier_not_cegir .= 'm';
3342 }
3343  
3344 # /xx modifier
3345 611 ▶ if (($modifier_not_cegir =~ tr/x//) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_not_cegir =~ tr/x// >= 2) 1 610 611
3346 1 $regexp = mb::_ignore_space($regexp);
3347 }
3348  
3349 # /i modifier
3350 611 ▶ if ($modifier_i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier_i) { } 16 595 611
3351 16 $parsed .= sprintf('{@{[mb::_ignorecase(qr%s%s)]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
3352 }
3353 else {
3354 595 $parsed .= sprintf('{@{[' . 'qr%s%s ]}}%s', $regexp, $modifier_not_cegir, $modifier_cegr);
3355 }
3356 }
3357  
3358 687 $parsed .= parse_ambiguous_char();
3359 }
3360  
3361 # provides bare Perl and JPerl compatible functions
3362 elsif (/\G ( (?: lc | lcfirst | uc | ucfirst ) ) \b /xmsgc) {
3363 15 $parsed .= "mb::$1";
3364 15 $parsed .= parse_ambiguous_char();
3365 }
3366  
3367 # CORE::require, mb::require, require
3368 elsif (/\G ( (?: CORE:: | mb:: )? require ) /xmsgc) {
3369 6 $parsed .= $1;
3370  
3371 # require VERSION; (e.g. "require v5.6.1;") VERSION is a version,
3372 # not a string of codepoints
3373 6 ▶ if (/\G (
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* ) ) (?! [0-9._A-Za-z] ) /cgmsx) 3 3 6
3374 \s+ (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* )
3375 ) (?! [0-9._A-Za-z] ) /xmsgc) {
3376 3 $parsed .= $1;
3377 }
3378 6 $parsed .= parse_ambiguous_char();
3379 }
3380  
3381 # mb::use --> BEGIN { mb::require ... }
3382 # mb::no --> BEGIN { mb::require ... }
3383 elsif (/\G ( mb::use | mb::no ) \b /xmsgc) {
3384 42 ▶ my $method = { 'mb::use'=>'import', 'mb::no'=>'unimport' }->{$1} || die;
Condition50%1/2
{'mb::use', 'import', 'mb::no', 'unimport'}->{$1} || die()
l!l
420
MC/DC0%0/1
{'mb::use', 'import', 'mb::no', 'unimport'}->{$1} || die()
{'mb::use', 'import', 'mb::no', 'unimport'}->{$1}
Truth table50%1/2
A
A= {'mb::use', 'import', 'mb::no', 'unimport'}->{$1}
Aresult
11
00
3385 42 $parsed .= "BEGIN { mb::require";
3386 42 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 58 42 100
3387 58 $parsed .= $1;
3388 }
3389 42 ▶ if (/\G ( [A-Za-z_][A-Za-z_0-9]* (?: ::[A-Za-z_][A-Za-z_0-9]*)* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( [A-Za-z_][A-Za-z_0-9]* (?: ::[A-Za-z_][A-Za-z_0-9]*)* ) /cgmsx) 42 0 42
3390 42 my $module = $1;
3391 42 $parsed .= qq{'$module';};
3392 42 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 54 42 96
3393 54 $parsed .= $1;
3394 }
3395 42 ▶ if (/\G ( [0-9]+ (?: \.[0-9]+)* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( [0-9]+ (?: \.[0-9]+)* ) /cgmsx) 26 16 42
3396 26 my $version = $1;
3397 26 $parsed .= qq{$module->VERSION($version);};
3398 26 ▶ while (/\G ( \s+ | [#] [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ( \s+ | [#] [^\n]* ) /cgmsx) 46 26 72
3399 46 $parsed .= $1;
3400 }
3401 }
3402 42 my $list = parse_expr_endswith(qr< [;\}] | \z >xms);
3403 42 ▶ if ($list eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($list eq '') { } 12 30 42
elsif (scalar eval "()=$list" == 0) { } 8 22 30
3404 12 $parsed .= qq{ $module->$method; };
3405 }
3406 elsif (scalar(CORE::eval("()=$list")) == 0) {
3407 }
3408 else {
3409 22 $parsed .= qq{ $module->$method($list); };
3410 }
3411 }
3412 42 $parsed .= "}";
3413 }
3414  
3415 # mb::getc() --> mb::getc()
3416 # vvvvvvvvvvvvvvvvvvvvvvvvvv
3417 # vvvvvvvvvvvv
3418 elsif (/\G ( mb::getc ) (?= (?: \s* \( )+ \s* \) ) /xmsgc) {
3419 1 $parsed .= $1;
3420 }
3421  
3422 # mb::getc($fh) --> mb::getc($fh)
3423 # mb::getc $fh --> mb::getc $fh
3424 # vvvvvvvvvvvvvvvvvvvvvvvvvv
3425 # vvvvvvvvvvvv
3426 elsif (/\G ( mb::getc ) (?= (?: \s* \( )* \s* \$ ) /xmsgc) {
3427 2 $parsed .= $1;
3428 }
3429  
3430 # mb::getc(FILE) --> mb::getc(\*FILE)
3431 # mb::getc FILE --> mb::getc \*FILE
3432 # vvvvvvvvvvvvvvvvvvvvv
3433 # vvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3434 elsif (/\G ( mb::getc ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \b ) /xmsgc) {
3435 2 $parsed .= $1;
3436 2 $parsed .= $2;
3437 2 $parsed .= '\\*';
3438 }
3439  
3440 # mb::getc --> mb::getc
3441 elsif (/\G ( mb::getc ) /xmsgc) {
3442 1 $parsed .= $1;
3443 1 $parsed .= parse_ambiguous_char();
3444 }
3445  
3446 # CORE::functions that allow zero parameters
3447 # mb::functions that allow zero parameters
3448 elsif (/\G ( (?: CORE:: | mb:: )? (?:
3449 chop |
3450 chr |
3451 getc |
3452 lc |
3453 lcfirst |
3454 length |
3455 ord |
3456 uc |
3457 ucfirst
3458 ) ) \b /xmsgc) {
3459 41 $parsed .= $1;
3460 41 $parsed .= parse_ambiguous_char();
3461 }
3462  
3463 # CORE::functions that must parameters
3464 # mb::functions that must parameters
3465 elsif (/\G ( (?: CORE:: | mb:: )? (?:
3466 index |
3467 reverse |
3468 rindex |
3469 substr
3470 ) ) \b /xmsgc) {
3471 26 $parsed .= $1;
3472 }
3473  
3474 # mb::subroutines
3475 elsif (/\G ( mb:: (?: index_byte | rindex_byte ) ) \b /xmsgc) {
3476 2 $parsed .= $1;
3477 }
3478  
3479 # CORE::functions that allow zero parameters
3480 # functions that allow zero parameters
3481 elsif (/\G ( (?: CORE:: )? (?:
3482 _ |
3483 abs |
3484 chomp |
3485 cos |
3486 exp |
3487 fc |
3488 hex |
3489 int |
3490 __LINE__ |
3491 log |
3492 oct |
3493 pop |
3494 pos |
3495 quotemeta |
3496 rand |
3497 rmdir |
3498 shift |
3499 sin |
3500 sqrt |
3501 tell |
3502 time |
3503 umask |
3504 wantarray
3505 ) ) \b /xmsgc) {
3506 841 $parsed .= $1;
3507 841 $parsed .= parse_ambiguous_char();
3508 }
3509  
3510 # lstat(), stat() on MSWin32
3511  
3512 # lstat() --> mb::_lstat()
3513 # stat() --> mb::_stat()
3514 # vvvvvvvvvvvvvvvvvvvvvvvvvv
3515 # vvvvvvvvvvvv
3516 elsif (/\G ( lstat | stat ) (?= (?: \s* \( )+ \s* \) ) /xmsgc) {
3517 2 $parsed .= "mb::_$1";
3518 }
3519  
3520 # lstat(...) --> mb::_lstat(...)
3521 # stat(...) --> mb::_stat(...)
3522 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3523 # vvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3524 elsif (/\G ( lstat | stat ) (?= (?: \s* \( )* \b (?: ' | " | ` | m | q | qq | qr | qw | qx | s | tr | y | \$ ) \b ) /xmsgc) {
3525 18 $parsed .= "mb::_$1";
3526 }
3527  
3528 # lstat(FILE) --> mb::_lstat(\*FILE)
3529 # lstat FILE --> mb::_lstat \*FILE
3530 # stat(FILE) --> mb::_stat(\*FILE)
3531 # stat FILE --> mb::_stat \*FILE
3532 # vvvvvvvvvvvvvvvvvvvvv
3533 # vvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3534 elsif (/\G ( lstat | stat ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \b ) /xmsgc) {
3535 10 $parsed .= "mb::_$1";
3536 10 $parsed .= $2;
3537 10 $parsed .= '\\*';
3538 }
3539  
3540 # opendir(DIR, ...) --> mb::_opendir(\*DIR, ...)
3541 # opendir DIR, ... --> mb::_opendir \*DIR, ...
3542 # vvvvvvvvvvvvvvvvvvvvv
3543 # vvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3544 elsif (/\G ( opendir ) \b ( (?: \s* \( )* \s* ) (?= [A-Za-z_][A-Za-z0-9_]* \s* , ) /xmsgc) {
3545 4 $parsed .= "mb::_$1";
3546 4 $parsed .= $2;
3547 4 $parsed .= '\\*';
3548 }
3549  
3550 # function --> mb::subroutine on MSWin32
3551 # implements run on any systems by transpiling once
3552 elsif (/\G ( chdir | lstat | stat | unlink ) \b /xmsgc) {
3553 32 $parsed .= "mb::_$1";
3554 32 $parsed .= parse_ambiguous_char();
3555 }
3556 elsif (/\G ( opendir ) \b /xmsgc) {
3557 4 $parsed .= "mb::_$1";
3558 }
3559  
3560 # Carp::carp <<HEREDOC
3561 # Carp::cluck <<HEREDOC
3562 # Carp::confess <<HEREDOC
3563 # Carp::croak <<HEREDOC
3564 # carp <<HEREDOC
3565 # cluck <<HEREDOC
3566 # confess <<HEREDOC
3567 # croak <<HEREDOC
3568 # die <<HEREDOC
3569 # print <<HEREDOC
3570 # printf <<HEREDOC
3571 # say <<HEREDOC
3572 # warn <<HEREDOC
3573 elsif (/\G (
3574 Carp::carp |
3575 Carp::cluck |
3576 Carp::confess |
3577 Carp::croak |
3578 carp |
3579 cluck |
3580 confess |
3581 croak |
3582 die |
3583 print |
3584 printf |
3585 say |
3586 warn
3587 ) (?= (?: \s+ | [#] .* )* << ) /xgc) {
3588 0 $parsed .= $1;
3589 # without $parsed .= parse_ambiguous_char();
3590 }
3591  
3592 # printf FILEHANDLE <<HEREDOC
3593 # print FILEHANDLE <<HEREDOC
3594 # say FILEHANDLE <<HEREDOC
3595 elsif (/\G (
3596 (?: printf | print | say )
3597 (?: \s+ | [#] .* )*
3598 (?! [a-z]+ ) # lowercase is considered to be function
3599 (?: \b [A-Za-z_][A-Za-z_0-9]*(?: :: [A-Za-z_][A-Za-z_0-9]*)* |
3600 \$ [A-Za-z_][A-Za-z_0-9]*(?: :: [A-Za-z_][A-Za-z_0-9]*)*
3601 )
3602 ) /xgc) {
3603 29 $parsed .= $1;
3604 # without $parsed .= parse_ambiguous_char();
3605 }
3606  
3607 # printf {FILEHANDLE} <<HEREDOC
3608 # print {FILEHANDLE} <<HEREDOC
3609 # say {FILEHANDLE} <<HEREDOC
3610 elsif (/\G (
3611 (?: printf | print | say )
3612 (?: \s+ | [#] .* )*
3613 ) (\{)
3614 /xgc) {
3615 0 $parsed .= $1;
3616 0 $parsed .= parse_expr_balanced($2);
3617 # without $parsed .= parse_ambiguous_char();
3618 }
3619  
3620 # return
3621 elsif (/\G ( return ) /xmsgc) {
3622 14 $parsed .= $1;
3623 }
3624  
3625 # any word
3626 # "\x5F" [_] LOW LINE (U+005F)
3627 # "\x41" [A] LATIN CAPITAL LETTER A (U+0041)
3628 # "\x42" [B] LATIN CAPITAL LETTER B (U+0042)
3629 # "\x43" [C] LATIN CAPITAL LETTER C (U+0043)
3630 # "\x44" [D] LATIN CAPITAL LETTER D (U+0044)
3631 # "\x45" [E] LATIN CAPITAL LETTER E (U+0045)
3632 # "\x46" [F] LATIN CAPITAL LETTER F (U+0046)
3633 # "\x47" [G] LATIN CAPITAL LETTER G (U+0047)
3634 # "\x48" [H] LATIN CAPITAL LETTER H (U+0048)
3635 # "\x49" [I] LATIN CAPITAL LETTER I (U+0049)
3636 # "\x4A" [J] LATIN CAPITAL LETTER J (U+004A)
3637 # "\x4B" [K] LATIN CAPITAL LETTER K (U+004B)
3638 # "\x4C" [L] LATIN CAPITAL LETTER L (U+004C)
3639 # "\x4D" [M] LATIN CAPITAL LETTER M (U+004D)
3640 # "\x4E" [N] LATIN CAPITAL LETTER N (U+004E)
3641 # "\x4F" [O] LATIN CAPITAL LETTER O (U+004F)
3642 # "\x50" [P] LATIN CAPITAL LETTER P (U+0050)
3643 # "\x51" [Q] LATIN CAPITAL LETTER Q (U+0051)
3644 # "\x52" [R] LATIN CAPITAL LETTER R (U+0052)
3645 # "\x53" [S] LATIN CAPITAL LETTER S (U+0053)
3646 # "\x54" [T] LATIN CAPITAL LETTER T (U+0054)
3647 # "\x55" [U] LATIN CAPITAL LETTER U (U+0055)
3648 # "\x56" [V] LATIN CAPITAL LETTER V (U+0056)
3649 # "\x57" [W] LATIN CAPITAL LETTER W (U+0057)
3650 # "\x58" [X] LATIN CAPITAL LETTER X (U+0058)
3651 # "\x59" [Y] LATIN CAPITAL LETTER Y (U+0059)
3652 # "\x5A" [Z] LATIN CAPITAL LETTER Z (U+005A)
3653 # "\x61" [a] LATIN SMALL LETTER A (U+0061)
3654 # "\x62" [b] LATIN SMALL LETTER B (U+0062)
3655 # "\x63" [c] LATIN SMALL LETTER C (U+0063)
3656 # "\x64" [d] LATIN SMALL LETTER D (U+0064)
3657 # "\x65" [e] LATIN SMALL LETTER E (U+0065)
3658 # "\x66" [f] LATIN SMALL LETTER F (U+0066)
3659 # "\x67" [g] LATIN SMALL LETTER G (U+0067)
3660 # "\x68" [h] LATIN SMALL LETTER H (U+0068)
3661 # "\x69" [i] LATIN SMALL LETTER I (U+0069)
3662 # "\x6A" [j] LATIN SMALL LETTER J (U+006A)
3663 # "\x6B" [k] LATIN SMALL LETTER K (U+006B)
3664 # "\x6C" [l] LATIN SMALL LETTER L (U+006C)
3665 # "\x6D" [m] LATIN SMALL LETTER M (U+006D)
3666 # "\x6E" [n] LATIN SMALL LETTER N (U+006E)
3667 # "\x6F" [o] LATIN SMALL LETTER O (U+006F)
3668 # "\x70" [p] LATIN SMALL LETTER P (U+0070)
3669 # "\x71" [q] LATIN SMALL LETTER Q (U+0071)
3670 # "\x72" [r] LATIN SMALL LETTER R (U+0072)
3671 # "\x73" [s] LATIN SMALL LETTER S (U+0073)
3672 # "\x74" [t] LATIN SMALL LETTER T (U+0074)
3673 # "\x75" [u] LATIN SMALL LETTER U (U+0075)
3674 # "\x76" [v] LATIN SMALL LETTER V (U+0076)
3675 # "\x77" [w] LATIN SMALL LETTER W (U+0077)
3676 # "\x78" [x] LATIN SMALL LETTER X (U+0078)
3677 # "\x79" [y] LATIN SMALL LETTER Y (U+0079)
3678 # "\x7A" [z] LATIN SMALL LETTER Z (U+007A)
3679 elsif (/\G ( [A-Za-z_][A-Za-z_0-9]*(?:(?:'|::)[A-Za-z_][A-Za-z_0-9]*)* ) /xmsgc) {
3680 1097 $parsed .= $1;
3681 1097 $parsed .= parse_ambiguous_char();
3682 }
3683  
3684 # any right parenthesis
3685 # "\x29" [)] RIGHT PARENTHESIS (U+0029)
3686 # "\x7D" [}] RIGHT CURLY BRACKET (U+007D)
3687 # "\x5D" []] RIGHT SQUARE BRACKET (U+005D)
3688 elsif (/\G ([\)\}\]]) /xmsgc) {
3689 402 $parsed .= $1;
3690 402 $parsed .= parse_ambiguous_char();
3691 }
3692  
3693 # any US-ASCII
3694 # "\x3A" [:] COLON (U+003A)
3695 elsif (/\G ([\x00-\x7F]) /xmsgc) {
3696 9799 $parsed .= $1;
3697 }
3698  
3699 # otherwise
3700 elsif (/\G ($x) /xmsgc) {
3701 0 die "$0(@{[__LINE__]}): can't parse not US-ASCII '$1'.\n";
3702 }
3703  
3704 164378 return $parsed;
3705 }
3706  
3707 #---------------------------------------------------------------------
3708 # parse expression in balanced blackets
3709 1395 ▶sub parse_expr_balanced {
Subroutine parse_expr_balanced: called CC=5 SCAR=16.1
Pod undocumented
3710 1392 my($open_bracket) = @_;
3711 1392 ▶ my $close_bracket = {qw| ( ) { } [ ] < > |}->{$open_bracket} || die;
Condition50%1/2
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
l!l
13920
MC/DC0%0/1
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Truth table50%1/2
A
A= {'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Aresult
11
00
3712 1392 my $parsed = $open_bracket;
3713 1392 my $nest_bracket = 1;
3714  
3715 # "use feature 'enhanced_xx'" and "no feature 'enhanced_xx'" in a block
3716 # are effective to the end of the block (lexically scoped), and so are
3717 # "use warnings" and "no warnings"
3718 1392 local $mb::_enhanced_xx = $mb::_enhanced_xx;
3719 1392 local $mb::_warn_regexp = $mb::_warn_regexp;
3720  
3721 1392 while (1) {
3722  
3723 # open bracket
3724 8136 ▶ if (/\G (\Q$open_bracket\E) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G (\Q$open_bracket\E) /cgmsx) { } 52 8084 8136
elsif (/\G (\Q$close_bracket\E) /cgmsx) { } 1444 6640 8084
3725 52 $parsed .= $1;
3726 52 $nest_bracket++;
3727 }
3728  
3729 # close bracket
3730 elsif (/\G (\Q$close_bracket\E) /xmsgc) {
3731 1444 $parsed .= $1;
3732 1444 $parsed .= parse_ambiguous_char();
3733 1444 ▶ if (--$nest_bracket <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest_bracket <= 0) 1392 52 1444
3734 1392 last;
3735 }
3736 }
3737  
3738 # otherwise
3739 else {
3740 6640 $parsed .= parse_expr();
3741 }
3742 }
3743 1392 return $parsed;
3744 }
3745  
3746 #---------------------------------------------------------------------
3747 # parse expression that ends with a regexp
3748 45 ▶sub parse_expr_endswith {
Subroutine parse_expr_endswith: called CC=2 SCAR=6.9
Pod undocumented
3749 42 my($endswith) = @_;
3750 42 my $parsed = '';
3751 42 while (1) {
3752 72 ▶ if (/\G (?= $endswith ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (?= $endswith ) /cgmsx) { } 42 30 72
3753 42 last;
3754 }
3755 else {
3756 30 $parsed .= parse_expr();
3757 }
3758 }
3759 42 return $parsed;
3760 }
3761  
3762 #---------------------------------------------------------------------
3763 # parse <<'HERE_DOCUMENT' as q-like
3764 12 ▶sub parse_heredocument_as_q_endswith {
Subroutine parse_heredocument_as_q_endswith: called CC=3 SCAR=11.3
Pod undocumented
3765 9 my($endswith) = @_;
3766 9 my $parsed = '';
3767 9 while (1) {
3768 465 ▶ if (/\G ( $R $endswith ) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ( $R $endswith ) /cgmsx) { } 9 456 465
elsif (/\G ($x) /cgmsx) { } 456 0 456
3769 9 $parsed .= $1;
3770 9 last;
3771 }
3772 elsif (/\G ($x) /xmsgc) {
3773 456 $parsed .= $1;
3774 }
3775  
3776 # something wrong happened
3777 else {
3778 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
3779 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
3780 ------------------------------------------------------------------------------
3781 %s
3782 ------------------------------------------------------------------------------
3783 END
3784 }
3785 }
3786 9 return $parsed;
3787 }
3788  
3789 #---------------------------------------------------------------------
3790 # parse <<"HERE_DOCUMENT" as qq-like
3791 17 ▶sub parse_heredocument_as_qq_endswith {
Subroutine parse_heredocument_as_qq_endswith: called CC=23 SCAR=59.8
Pod undocumented
3792 14 my($endswith) = @_;
3793 14 my $parsed = '';
3794 14 my $nest_escape = 0;
3795 14 while (1) {
3796 14 ▶ if (/\G ( $R $endswith ) /xmsgc) {
Branch: 22 branches
BranchTrueFalseTotal
if (/\G ( $R $endswith ) /cgmsx) { } 14 0 14
elsif (/\G \\L \\u /cgmsx) { } 0 0 0
elsif (/\G \\U \\l /cgmsx) { } 0 0 0
elsif (/\G \\L /cgmsx) { } 0 0 0
elsif (/\G \\U /cgmsx) { } 0 0 0
elsif (/\G \\l /cgmsx) { } 0 0 0
elsif (/\G \\u /cgmsx) { } 0 0 0
elsif (/\G \\Q /cgmsx) { } 0 0 0
elsif (/\G \\E /cgmsx) { } 0 0 0
elsif (/\G \\o\{ (.*?) \} /cgmsx) { } 0 0 0
elsif (/\G \\x\{ (.*?) \} /cgmsx) { } 0 0 0
elsif (/\G (\\) ($x) /cgmsx) { } 0 0 0
elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /cgmsx) { } 0 0 0
elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /cgmsx) { } 0 0 0
elsif (/\G \$ ([1-9][0-9]*) /cgmsx) { } 0 0 0
elsif (/\G \@\{\^CAPTURE\} /cgmsx) { } 0 0 0
elsif (/\G \$\{\^CAPTURE\} \s* (\[) /cgmsx) { } 0 0 0
elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /cgmsx) { } 0 0 0
elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /cgmsx) { } 0 0 0
elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /cgmsx) { } 0 0 0
elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /cgmsx) { } 0 0 0
elsif (/\G ($x) /cgmsx) { } 0 0 0
3797 14 $parsed .= ('>)]}' x $nest_escape);
3798 14 $parsed .= $1;
3799 14 last;
3800 }
3801  
3802 # \L\u --> \u\L
3803 elsif (/\G \\L \\u /xmsgc) {
3804 0 $parsed .= '@{[mb::ucfirst(qq<';
3805 0 $parsed .= '@{[mb::lc(qq<';
3806 0 $nest_escape++;
3807 0 $nest_escape++;
3808 }
3809  
3810 # \U\l --> \l\U
3811 elsif (/\G \\U \\l /xmsgc) {
3812 0 $parsed .= '@{[mb::lcfirst(qq<';
3813 0 $parsed .= '@{[mb::uc(qq<';
3814 0 $nest_escape++;
3815 0 $nest_escape++;
3816 }
3817  
3818 # \L
3819 elsif (/\G \\L /xmsgc) {
3820 0 $parsed .= '@{[mb::lc(qq<';
3821 0 $nest_escape++;
3822 }
3823  
3824 # \U
3825 elsif (/\G \\U /xmsgc) {
3826 0 $parsed .= '@{[mb::uc(qq<';
3827 0 $nest_escape++;
3828 }
3829  
3830 # \l
3831 elsif (/\G \\l /xmsgc) {
3832 0 $parsed .= '@{[mb::lcfirst(qq<';
3833 0 $nest_escape++;
3834 }
3835  
3836 # \u
3837 elsif (/\G \\u /xmsgc) {
3838 0 $parsed .= '@{[mb::ucfirst(qq<';
3839 0 $nest_escape++;
3840 }
3841  
3842 # \Q
3843 elsif (/\G \\Q /xmsgc) {
3844 0 $parsed .= '@{[quotemeta(qq<';
3845 0 $nest_escape++;
3846 }
3847  
3848 # \E
3849 elsif (/\G \\E /xmsgc) {
3850 0 $parsed .= ('>)]}' x $nest_escape);
3851 0 $nest_escape = 0;
3852 }
3853  
3854 # \o{...}
3855 elsif (/\G \\o\{ (.*?) \} /xmsgc) {
3856 0 $parsed .= escape_to_hex(mb::chr(oct $1), '\\');
3857 }
3858  
3859 # \x{...}
3860 elsif (/\G \\x\{ (.*?) \} /xmsgc) {
3861 0 $parsed .= escape_to_hex(mb::chr(hex $1), '\\');
3862 }
3863  
3864 # \any
3865 elsif (/\G (\\) ($x) /xmsgc) {
3866 0 $parsed .= ($1 . escape_qq($2, '\\'));
3867 }
3868  
3869 # $` --> @{[mb::_PREMATCH()]}
3870 # ${`} --> @{[mb::_PREMATCH()]}
3871 # $PREMATCH --> @{[mb::_PREMATCH()]}
3872 # ${PREMATCH} --> @{[mb::_PREMATCH()]}
3873 # ${^PREMATCH} --> @{[mb::_PREMATCH()]}
3874 elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /xmsgc) {
3875 0 $parsed .= '@{[mb::_PREMATCH()]}';
3876 }
3877  
3878 # $& --> @{[mb::_MATCH()]}
3879 # ${&} --> @{[mb::_MATCH()]}
3880 # $MATCH --> @{[mb::_MATCH()]}
3881 # ${MATCH} --> @{[mb::_MATCH()]}
3882 # ${^MATCH} --> @{[mb::_MATCH()]}
3883 elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /xmsgc) {
3884 0 $parsed .= '@{[mb::_MATCH()]}';
3885 }
3886  
3887 # $1 --> @{[mb::_CAPTURE(1)]}
3888 # $2 --> @{[mb::_CAPTURE(2)]}
3889 # $3 --> @{[mb::_CAPTURE(3)]}
3890 elsif (/\G \$ ([1-9][0-9]*) /xmsgc) {
3891 0 $parsed .= "\@{[mb::_CAPTURE($1)]}";
3892 }
3893  
3894 # @{^CAPTURE} --> @{[mb::_CAPTURE()]}
3895 elsif (/\G \@\{\^CAPTURE\} /xmsgc) {
3896 0 $parsed .= '@{[mb::_CAPTURE()]}';
3897 }
3898  
3899 # ${^CAPTURE}[0] --> @{[mb::_CAPTURE(1)]}
3900 # ${^CAPTURE}[1] --> @{[mb::_CAPTURE(2)]}
3901 # ${^CAPTURE}[2] --> @{[mb::_CAPTURE(3)]}
3902 elsif (/\G \$\{\^CAPTURE\} \s* (\[) /xmsgc) {
3903 0 my $n_th = quotee_of(parse_expr_balanced($1));
3904 0 $parsed .= "\@{[mb::_CAPTURE($n_th+1)]}";
3905 }
3906  
3907 # @- --> @{[mb::_LAST_MATCH_START()]}
3908 # @LAST_MATCH_START --> @{[mb::_LAST_MATCH_START()]}
3909 # @{LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
3910 # @{^LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
3911 elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /xmsgc) {
3912 0 $parsed .= '@{[mb::_LAST_MATCH_START()]}';
3913 }
3914  
3915 # $-[1] --> @{[mb::_LAST_MATCH_START(1)]}
3916 # $LAST_MATCH_START[1] --> @{[mb::_LAST_MATCH_START(1)]}
3917 # ${LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
3918 # ${^LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
3919 elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /xmsgc) {
3920 0 my $n_th = quotee_of(parse_expr_balanced($1));
3921 0 $parsed .= "\@{[mb::_LAST_MATCH_START($n_th)]}";
3922 }
3923  
3924 # @+ --> @{[mb::_LAST_MATCH_END()]}
3925 # @LAST_MATCH_END --> @{[mb::_LAST_MATCH_END()]}
3926 # @{LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
3927 # @{^LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
3928 elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /xmsgc) {
3929 0 $parsed .= '@{[mb::_LAST_MATCH_END()]}';
3930 }
3931  
3932 # $+[1] --> @{[mb::_LAST_MATCH_END(1)]}
3933 # $LAST_MATCH_END[1] --> @{[mb::_LAST_MATCH_END(1)]}
3934 # ${LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
3935 # ${^LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
3936 elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /xmsgc) {
3937 0 my $n_th = quotee_of(parse_expr_balanced($1));
3938 0 $parsed .= "\@{[mb::_LAST_MATCH_END($n_th)]}";
3939 }
3940  
3941 # any
3942 elsif (/\G ($x) /xmsgc) {
3943 0 $parsed .= escape_qq($1, '\\');
3944 }
3945  
3946 # something wrong happened
3947 else {
3948 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
3949 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
3950 ------------------------------------------------------------------------------
3951 %s
3952 ------------------------------------------------------------------------------
3953 END
3954 }
3955 }
3956 14 return $parsed;
3957 }
3958  
3959 #---------------------------------------------------------------------
3960 # parse q{string} in balanced blackets
3961 63 ▶sub parse_q__like_balanced {
Subroutine parse_q__like_balanced: called CC=6 SCAR=19.3
Pod undocumented
3962 60 my($open_bracket) = @_;
3963 60 ▶ my $close_bracket = {qw| ( ) { } [ ] < > |}->{$open_bracket} || die;
Condition50%1/2
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
l!l
600
MC/DC0%0/1
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Truth table50%1/2
A
A= {'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Aresult
11
00
3964 60 my $parsed = $open_bracket;
3965 60 my $nest_bracket = 1;
3966 60 while (1) {
3967 324 ▶ if (/\G (\Q$open_bracket\E) /xmsgc) {
Branch: 3 branches
BranchTrueFalseTotal
if (/\G (\Q$open_bracket\E) /cgmsx) { } 0 324 324
elsif (/\G (\Q$close_bracket\E) /cgmsx) { } 60 264 324
elsif (/\G (\\ \Q$close_bracket\E) /cgmsx) { } 0 264 264
3968 0 $parsed .= $1;
3969 0 $nest_bracket++;
3970 }
3971 elsif (/\G (\Q$close_bracket\E) /xmsgc) {
3972 60 $parsed .= $1;
3973 60 ▶ if (--$nest_bracket <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest_bracket <= 0) 60 0 60
3974 60 last;
3975 }
3976 }
3977 elsif (/\G (\\ \Q$close_bracket\E) /xmsgc) {
3978 0 $parsed .= $1;
3979 }
3980 else {
3981 264 $parsed .= parse_q__like($close_bracket);
3982 }
3983 }
3984 60 return $parsed;
3985 }
3986  
3987 #---------------------------------------------------------------------
3988 # parse q/string/ that ends with a character
3989 6594 ▶sub parse_q__like_endswith {
Subroutine parse_q__like_endswith: called CC=3 SCAR=11.1
Pod undocumented
3990 6591 my($endswith) = @_;
3991 6591 my $parsed = $endswith;
3992 6591 while (1) {
3993 16584 ▶ if (/\G (\Q$endswith\E) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G (\Q$endswith\E) /cgmsx) { } 6591 9993 16584
elsif (/\G (\\ \Q$endswith\E) /cgmsx) { } 0 9993 9993
3994 6591 $parsed .= $1;
3995 6591 last;
3996 }
3997 elsif (/\G (\\ \Q$endswith\E) /xmsgc) {
3998 0 $parsed .= $1;
3999 }
4000 else {
4001 9993 $parsed .= parse_q__like($endswith);
4002 }
4003 }
4004 6591 return $parsed;
4005 }
4006  
4007 #---------------------------------------------------------------------
4008 # parse q/string/ common routine
4009 10260 ▶sub parse_q__like {
Subroutine parse_q__like: called CC=3 SCAR=11.8
Pod undocumented
4010 10257 my($closewith) = @_;
4011 10257 ▶ if (/\G (\\\\) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G (\\\\) /cgmsx) { } 20 10237 10257
elsif (/\G ($x) /cgmsx) { } 10237 0 10237
4012 20 return $1;
4013 }
4014 elsif (/\G ($x) /xmsgc) {
4015 10237 return escape_q($1, $closewith);
4016 }
4017  
4018 # something wrong happened
4019 else {
4020 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
4021 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
4022 ------------------------------------------------------------------------------
4023 %s
4024 ------------------------------------------------------------------------------
4025 END
4026 }
4027 }
4028  
4029 #---------------------------------------------------------------------
4030 # parse qq{string} in balanced blackets
4031 96 ▶sub parse_qq_like_balanced {
Subroutine parse_qq_like_balanced: called CC=16 SCAR=42.1
Pod undocumented
4032 93 my($open_bracket) = @_;
4033 93 ▶ my $close_bracket = {qw| ( ) { } [ ] < > |}->{$open_bracket} || die;
Condition33%1/3
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
l!l
9300
MC/DC0%0/1
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Truth table50%1/2
A
A= {'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Aresult
11
00
4034 93 my $parsed_as_q = $open_bracket;
4035 93 my $parsed_as_qq = $open_bracket;
4036 93 my $nest_bracket = 1;
4037 93 my $nest_escape = 0;
4038 93 while (1) {
4039  
4040 # blackets
4041 334 ▶ if (/\G (\\ \Q$open_bracket\E) /xmsgc) {
Branch: 12 branches
BranchTrueFalseTotal
if (/\G (\\ \Q$open_bracket\E) /cgmsx) { } 0 334 334
elsif (/\G (\\ \Q$close_bracket\E) /cgmsx) { } 0 334 334
elsif (/\G (\Q$open_bracket\E) /cgmsx) { } 0 334 334
elsif (/\G (\Q$close_bracket\E) /cgmsx) { } 93 241 334
elsif (/\G (\\L \\u) /cgmsx) { } 0 241 241
elsif (/\G (\\U \\l) /cgmsx) { } 0 241 241
elsif (/\G (\\L) /cgmsx) { } 0 241 241
elsif (/\G (\\U) /cgmsx) { } 0 241 241
elsif (/\G (\\l) /cgmsx) { } 0 241 241
elsif (/\G (\\u) /cgmsx) { } 0 241 241
elsif (/\G (\\Q) /cgmsx) { } 0 241 241
elsif (/\G (\\E) /cgmsx) { } 0 241 241
4042 0 $parsed_as_q .= $1;
4043 0 $parsed_as_qq .= $1;
4044 }
4045 elsif (/\G (\\ \Q$close_bracket\E) /xmsgc) {
4046 0 $parsed_as_q .= $1;
4047 0 $parsed_as_qq .= $1;
4048 }
4049 elsif (/\G (\Q$open_bracket\E) /xmsgc) {
4050 0 $parsed_as_q .= $1;
4051 0 $parsed_as_qq .= $1;
4052 0 $nest_bracket++;
4053 }
4054 elsif (/\G (\Q$close_bracket\E) /xmsgc) {
4055 93 ▶ if (--$nest_bracket <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest_bracket <= 0) { } 93 0 93
4056 93 $parsed_as_q .= $1;
4057 93 $parsed_as_qq .= ('>)]}' x $nest_escape);
4058 93 $parsed_as_qq .= $1;
4059 93 last;
4060 }
4061 else {
4062 0 $parsed_as_q .= $1;
4063 0 $parsed_as_qq .= $1;
4064 }
4065 }
4066  
4067 # \L\u --> \u\L
4068 elsif (/\G (\\L \\u) /xmsgc) {
4069 0 $parsed_as_q .= $1;
4070 0 $parsed_as_qq .= '@{[mb::ucfirst(qq<';
4071 0 $parsed_as_qq .= '@{[mb::lc(qq<';
4072 0 $nest_escape++;
4073 0 $nest_escape++;
4074 }
4075  
4076 # \U\l --> \l\U
4077 elsif (/\G (\\U \\l) /xmsgc) {
4078 0 $parsed_as_q .= $1;
4079 0 $parsed_as_qq .= '@{[mb::lcfirst(qq<';
4080 0 $parsed_as_qq .= '@{[mb::uc(qq<';
4081 0 $nest_escape++;
4082 0 $nest_escape++;
4083 }
4084  
4085 # \L
4086 elsif (/\G (\\L) /xmsgc) {
4087 0 $parsed_as_q .= $1;
4088 0 $parsed_as_qq .= '@{[mb::lc(qq<';
4089 0 $nest_escape++;
4090 }
4091  
4092 # \U
4093 elsif (/\G (\\U) /xmsgc) {
4094 0 $parsed_as_q .= $1;
4095 0 $parsed_as_qq .= '@{[mb::uc(qq<';
4096 0 $nest_escape++;
4097 }
4098  
4099 # \l
4100 elsif (/\G (\\l) /xmsgc) {
4101 0 $parsed_as_q .= $1;
4102 0 $parsed_as_qq .= '@{[mb::lcfirst(qq<';
4103 0 $nest_escape++;
4104 }
4105  
4106 # \u
4107 elsif (/\G (\\u) /xmsgc) {
4108 0 $parsed_as_q .= $1;
4109 0 $parsed_as_qq .= '@{[mb::ucfirst(qq<';
4110 0 $nest_escape++;
4111 }
4112  
4113 # \Q
4114 elsif (/\G (\\Q) /xmsgc) {
4115 0 $parsed_as_q .= $1;
4116 0 $parsed_as_qq .= '@{[quotemeta(qq<';
4117 0 $nest_escape++;
4118 }
4119  
4120 # \E
4121 elsif (/\G (\\E) /xmsgc) {
4122 0 $parsed_as_q .= $1;
4123 0 $parsed_as_qq .= ('>)]}' x $nest_escape);
4124 0 $nest_escape = 0;
4125 }
4126  
4127 else {
4128 241 my($as_qq, $as_q) = parse_qq_like($close_bracket);
4129 241 $parsed_as_q .= $as_q;
4130 241 $parsed_as_qq .= $as_qq;
4131 }
4132 }
4133  
4134 # return qq-like and q-like quotee
4135 93 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 74 19 93
4136 74 return ($parsed_as_qq, $parsed_as_q);
4137 }
4138 else {
4139 19 return $parsed_as_qq;
4140 }
4141 }
4142  
4143 #---------------------------------------------------------------------
4144 # parse qq/string/ that ends with a character
4145 17071 ▶sub parse_qq_like_endswith {
Subroutine parse_qq_like_endswith: called CC=13 SCAR=35.6
Pod undocumented
4146 17068 my($endswith) = @_;
4147 17068 my $parsed_as_q = $endswith;
4148 17068 my $parsed_as_qq = $endswith;
4149 17068 my $nest_escape = 0;
4150 17068 while (1) {
4151  
4152 # ends with
4153 181689 ▶ if (/\G (\\ \Q$endswith\E) /xmsgc) {
Branch: 10 branches
BranchTrueFalseTotal
if (/\G (\\ \Q$endswith\E) /cgmsx) { } 0 181689 181689
elsif (/\G (\Q$endswith\E) /cgmsx) { } 17068 164621 181689
elsif (/\G (\\L \\u) /cgmsx) { } 0 164621 164621
elsif (/\G (\\U \\l) /cgmsx) { } 0 164621 164621
elsif (/\G (\\L) /cgmsx) { } 0 164621 164621
elsif (/\G (\\U) /cgmsx) { } 0 164621 164621
elsif (/\G (\\l) /cgmsx) { } 0 164621 164621
elsif (/\G (\\u) /cgmsx) { } 0 164621 164621
elsif (/\G (\\Q) /cgmsx) { } 1 164620 164621
elsif (/\G (\\E) /cgmsx) { } 0 164620 164620
4154 0 $parsed_as_q .= $1;
4155 0 $parsed_as_qq .= $1;
4156 }
4157 elsif (/\G (\Q$endswith\E) /xmsgc) {
4158 17068 $parsed_as_q .= $1;
4159 17068 $parsed_as_qq .= ('>)]}' x $nest_escape);
4160 17068 ▶ $parsed_as_qq .= "\n" if CORE::length($1) >= 2; # here document
Branch: 1 branch
BranchTrueFalseTotal
if CORE::length $1 >= 2 0 17068 17068
4161 17068 $parsed_as_qq .= $1;
4162 17068 last;
4163 }
4164  
4165 # \L\u --> \u\L
4166 elsif (/\G (\\L \\u) /xmsgc) {
4167 0 $parsed_as_q .= $1;
4168 0 $parsed_as_qq .= '@{[mb::ucfirst(qq<';
4169 0 $parsed_as_qq .= '@{[mb::lc(qq<';
4170 0 $nest_escape++;
4171 0 $nest_escape++;
4172 }
4173  
4174 # \U\l --> \l\U
4175 elsif (/\G (\\U \\l) /xmsgc) {
4176 0 $parsed_as_q .= $1;
4177 0 $parsed_as_qq .= '@{[mb::lcfirst(qq<';
4178 0 $parsed_as_qq .= '@{[mb::uc(qq<';
4179 0 $nest_escape++;
4180 0 $nest_escape++;
4181 }
4182  
4183 # \L
4184 elsif (/\G (\\L) /xmsgc) {
4185 0 $parsed_as_q .= $1;
4186 0 $parsed_as_qq .= '@{[mb::lc(qq<';
4187 0 $nest_escape++;
4188 }
4189  
4190 # \U
4191 elsif (/\G (\\U) /xmsgc) {
4192 0 $parsed_as_q .= $1;
4193 0 $parsed_as_qq .= '@{[mb::uc(qq<';
4194 0 $nest_escape++;
4195 }
4196  
4197 # \l
4198 elsif (/\G (\\l) /xmsgc) {
4199 0 $parsed_as_q .= $1;
4200 0 $parsed_as_qq .= '@{[mb::lcfirst(qq<';
4201 0 $nest_escape++;
4202 }
4203  
4204 # \u
4205 elsif (/\G (\\u) /xmsgc) {
4206 0 $parsed_as_q .= $1;
4207 0 $parsed_as_qq .= '@{[mb::ucfirst(qq<';
4208 0 $nest_escape++;
4209 }
4210  
4211 # \Q
4212 elsif (/\G (\\Q) /xmsgc) {
4213 1 $parsed_as_q .= $1;
4214 1 $parsed_as_qq .= '@{[quotemeta(qq<';
4215 1 $nest_escape++;
4216 }
4217  
4218 # \E
4219 elsif (/\G (\\E) /xmsgc) {
4220 0 $parsed_as_q .= $1;
4221 0 $parsed_as_qq .= ('>)]}' x $nest_escape);
4222 0 $nest_escape = 0;
4223 }
4224  
4225 else {
4226 164620 my($as_qq, $as_q) = parse_qq_like($endswith);
4227 164620 $parsed_as_q .= $as_q;
4228 164620 $parsed_as_qq .= $as_qq;
4229 }
4230 }
4231  
4232 # return qq-like and q-like quotee
4233 17068 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 1656 15412 17068
4234 1656 return ($parsed_as_qq, $parsed_as_q);
4235 }
4236 else {
4237 15412 return $parsed_as_qq;
4238 }
4239 }
4240  
4241 #---------------------------------------------------------------------
4242 # parse qq/string/ common routine
4243 164885 ▶sub parse_qq_like {
Subroutine parse_qq_like: called CC=17 SCAR=36.8
Pod undocumented
4244 164882 my($closewith) = @_;
4245 164882 my $parsed_as_q = '';
4246 164882 my $parsed_as_qq = '';
4247  
4248 # \o{...}
4249 164882 ▶ if (/\G ( \\o\{ (.*?) \} ) /xmsgc) {
Branch: 14 branches
BranchTrueFalseTotal
if (/\G ( \\o\{ (.*?) \} ) /cgmsx) { } 0 164882 164882
elsif (/\G ( \\x\{ (.*?) \} ) /cgmsx) { } 1 164881 164882
elsif (CORE::substr($_, pos $_, 2) eq '$\\' and CORE::substr($_, pos($_) + 2, 1) ne $closewith) { } 7 164874 164881
elsif (/\G ( (\\) ($x) ) /cgmsx) { } 299 164575 164874
elsif (/\G ( \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /cgmsx) { } 2 164573 164575
elsif (/\G ( \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /cgmsx) { } 2 164571 164573
elsif (/\G ( \$ ([1-9][0-9]*) ) /cgmsx) { } 23 164548 164571
elsif (/\G ( \@\{\^CAPTURE\} ) /cgmsx) { } 0 164548 164548
elsif (/\G (\$\{\^CAPTURE\}) \s* (\[) /cgmsx) { } 0 164548 164548
elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /cgmsx) { } 0 164548 164548
elsif (/\G ( \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /cgmsx) { } 0 164548 164548
elsif (/\G ( \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /cgmsx) { } 0 164548 164548
elsif (/\G ( \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /cgmsx) { } 0 164548 164548
elsif (/\G ($x) /cgmsx) { } 164548 0 164548
4250 0 $parsed_as_q .= $1;
4251 0 $parsed_as_qq .= escape_to_hex(mb::chr(oct $2), $closewith);
4252 }
4253  
4254 # \x{...}
4255 elsif (/\G ( \\x\{ (.*?) \} ) /xmsgc) {
4256 1 $parsed_as_q .= $1;
4257 1 $parsed_as_qq .= escape_to_hex(mb::chr(hex $2), $closewith);
4258 }
4259  
4260 # $\ (output record separator) is interpolated, and the next character
4261 # is a literal character: "a$\b" is "a".$\."b", "a\Q$\E" is
4262 # "a".quotemeta($\."E") (an escaped close delimiter is not $\)
4263 ▶ elsif ((CORE::substr($_, pos($_), 2) eq '$\\') and (CORE::substr($_, pos($_) + 2, 1) ne $closewith)) {
Condition66%2/3
CORE::substr($_, pos $_, 2) eq "\$\\" and CORE::substr($_, pos($_) + 2, 1) ne $closewith
!ll&&!rl&&r
16487407
MC/DC50%1/2
CORE::substr($_, pos $_, 2) eq "\$\\" and CORE::substr($_, pos($_) + 2, 1) ne $closewith
CORE::substr($_, pos $_, 2) eq "\$\\" CORE::substr($_, pos($_) + 2, 1) ne $closewith
Truth table66%2/3
A and B
A= CORE::substr($_, pos $_, 2) eq "\$\\"B= CORE::substr($_, pos($_) + 2, 1) ne $closewith
ABresult
0X0
100
111
4264 7 pos($_) += 2;
4265 7 $parsed_as_q .= '$\\';
4266 7 $parsed_as_qq .= '@{[$\\ ]}';
4267 }
4268  
4269 # \any
4270 elsif (/\G ( (\\) ($x) ) /xmsgc) {
4271 299 $parsed_as_q .= $1;
4272 299 $parsed_as_qq .= ($2 . escape_qq($3, $closewith));
4273 }
4274  
4275 # $` --> @{[mb::_PREMATCH()]}
4276 # ${`} --> @{[mb::_PREMATCH()]}
4277 # $PREMATCH --> @{[mb::_PREMATCH()]}
4278 # ${PREMATCH} --> @{[mb::_PREMATCH()]}
4279 # ${^PREMATCH} --> @{[mb::_PREMATCH()]}
4280 elsif (/\G ( \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /xmsgc) {
4281 2 $parsed_as_q .= $1;
4282 2 $parsed_as_qq .= '@{[mb::_PREMATCH()]}';
4283 }
4284  
4285 # $& --> @{[mb::_MATCH()]}
4286 # ${&} --> @{[mb::_MATCH()]}
4287 # $MATCH --> @{[mb::_MATCH()]}
4288 # ${MATCH} --> @{[mb::_MATCH()]}
4289 # ${^MATCH} --> @{[mb::_MATCH()]}
4290 elsif (/\G ( \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /xmsgc) {
4291 2 $parsed_as_q .= $1;
4292 2 $parsed_as_qq .= '@{[mb::_MATCH()]}';
4293 }
4294  
4295 # $1 --> @{[mb::_CAPTURE(1)]}
4296 # $2 --> @{[mb::_CAPTURE(2)]}
4297 # $3 --> @{[mb::_CAPTURE(3)]}
4298 elsif (/\G ( \$ ([1-9][0-9]*) ) /xmsgc) {
4299 23 $parsed_as_q .= $1;
4300 23 $parsed_as_qq .= "\@{[mb::_CAPTURE($2)]}";
4301 }
4302  
4303 # @{^CAPTURE} --> @{[mb::_CAPTURE()]}
4304 elsif (/\G ( \@\{\^CAPTURE\} ) /xmsgc) {
4305 0 $parsed_as_q .= $1;
4306 0 $parsed_as_qq .= '@{[mb::_CAPTURE()]}';
4307 }
4308  
4309 # ${^CAPTURE}[0] --> @{[mb::_CAPTURE(1)]}
4310 # ${^CAPTURE}[1] --> @{[mb::_CAPTURE(2)]}
4311 # ${^CAPTURE}[2] --> @{[mb::_CAPTURE(3)]}
4312 elsif (/\G (\$\{\^CAPTURE\}) \s* (\[) /xmsgc) {
4313 0 my $indexing = parse_expr_balanced($2);
4314 0 $parsed_as_q .= ($1 . $indexing);
4315 0 my $n_th = quotee_of($indexing);
4316 0 $parsed_as_qq .= "\@{[mb::_CAPTURE($n_th)]}";
4317 }
4318  
4319 # @- --> @{[mb::_LAST_MATCH_START()]}
4320 # @LAST_MATCH_START --> @{[mb::_LAST_MATCH_START()]}
4321 # @{LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
4322 # @{^LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
4323 elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /xmsgc) {
4324 0 $parsed_as_q .= $&;
4325 0 $parsed_as_qq .= '@{[mb::_LAST_MATCH_START()]}';
4326 }
4327  
4328 # $-[1] --> @{[mb::_LAST_MATCH_START(1)]}
4329 # $LAST_MATCH_START[1] --> @{[mb::_LAST_MATCH_START(1)]}
4330 # ${LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
4331 # ${^LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
4332 elsif (/\G ( \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /xmsgc) {
4333 0 my $indexing = parse_expr_balanced($2);
4334 0 $parsed_as_q .= ($1 . $indexing);
4335 0 my $n_th = quotee_of($indexing);
4336 0 $parsed_as_qq .= "\@{[mb::_LAST_MATCH_START($n_th)]}";
4337 }
4338  
4339 # @+ --> @{[mb::_LAST_MATCH_END()]}
4340 # @LAST_MATCH_END --> @{[mb::_LAST_MATCH_END()]}
4341 # @{LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
4342 # @{^LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
4343 elsif (/\G ( \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /xmsgc) {
4344 0 $parsed_as_q .= $1;
4345 0 $parsed_as_qq .= '@{[mb::_LAST_MATCH_END()]}';
4346 }
4347  
4348 # $+[1] --> @{[mb::_LAST_MATCH_END(1)]}
4349 # $LAST_MATCH_END[1] --> @{[mb::_LAST_MATCH_END(1)]}
4350 # ${LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
4351 # ${^LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
4352 elsif (/\G ( \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /xmsgc) {
4353 0 my $indexing = parse_expr_balanced($2);
4354 0 $parsed_as_q .= ($1 . $indexing);
4355 0 my $n_th = quotee_of($indexing);
4356 0 $parsed_as_qq .= "\@{[mb::_LAST_MATCH_END($n_th)]}";
4357 }
4358  
4359 # any
4360 elsif (/\G ($x) /xmsgc) {
4361 164548 $parsed_as_q .= escape_q ($1, $closewith);
4362 164548 $parsed_as_qq .= escape_qq($1, $closewith);
4363 }
4364  
4365 # something wrong happened
4366 else {
4367 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
4368 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
4369 ------------------------------------------------------------------------------
4370 %s
4371 ------------------------------------------------------------------------------
4372 END
4373 }
4374  
4375 # return qq-like and q-like quotee
4376 164882 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 164882 0 164882
4377 164882 return ($parsed_as_qq, $parsed_as_q);
4378 }
4379 else {
4380 0 return $parsed_as_qq;
4381 }
4382 }
4383  
4384 #---------------------------------------------------------------------
4385 # tr/A-C/1-3/ for US-ASCII codepoint
4386 5063 ▶sub list_all_ASCII_by_hyphen {
Subroutine list_all_ASCII_by_hyphen: called CC=11 SCAR=25.3
Pod undocumented
4387 5060 my @hyphened = @_;
4388 5060 my @list_all = ();
4389 5060 ▶ for (my $i=0; $i <= $#hyphened; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#hyphened) 6417 5060 11477
4390 6417 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $#hyphened and $hyphened[$i + 1] eq '-' and 1) { } 95 6322 6417
Condition83%5/6
$i + 1 < $#hyphened and $hyphened[$i + 1] eq "-" and 1
!ll
6322950
$i + 1 < $#hyphened and $hyphened[$i + 1] eq "-"
!ll&&!rl&&r
569263095
MC/DC100%2/2
$i + 1 < $#hyphened and $hyphened[$i + 1] eq "-" and 1
$i + 1 < $#hyphened $hyphened[$i + 1] eq "-"
Truth table100%3/3
A and B
A= $i + 1 < $#hyphenedB= $hyphened[$i + 1] eq "-"
ABresult
0X0
100
111
4391 ($i+1 < $#hyphened) and
4392 ($hyphened[$i+1] eq '-') and
4393 1) {
4394 95 ▶ $hyphened[$i+0] = ($hyphened[$i+0] eq '\\-') ? '-' : $hyphened[$i+0];
Branch: 1 branch
BranchTrueFalseTotal
$hyphened[$i + 0] eq '\\-' ? : 4 91 95
4395 95 ▶ $hyphened[$i+2] = ($hyphened[$i+2] eq '\\-') ? '-' : $hyphened[$i+2];
Branch: 1 branch
BranchTrueFalseTotal
$hyphened[$i + 2] eq '\\-' ? : 4 91 95
4396 95 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { not $hyphened[$i + 0] =~ /\A [\x00-\x7F] \z/msx }) { } 0 95 95
elsif (not $hyphened[$i + 2] =~ /\A [\x00-\x7F] \z/msx) { } 0 95 95
elsif ($hyphened[$i + 0] gt $hyphened[$i + 2]) { } 0 95 95
4397 elsif ($hyphened[$i+0] !~ m/\A [\x00-\x7F] \z/xms) {
4398 0 confess sprintf(qq{@{[__FILE__]}: "$hyphened[$i+0]-$hyphened[$i+2]" in tr/// is not US-ASCII});
4399 }
4400 elsif ($hyphened[$i+2] !~ m/\A [\x00-\x7F] \z/xms) {
4401 0 confess sprintf(qq{@{[__FILE__]}: "$hyphened[$i+0]-$hyphened[$i+2]" in tr/// is not US-ASCII});
4402 }
4403 elsif ($hyphened[$i+0] gt $hyphened[$i+2]) {
4404 0 confess sprintf(qq{@{[__FILE__]}: "$hyphened[$i+0]-$hyphened[$i+2]" in tr/// is not "$hyphened[$i+0]" le "$hyphened[$i+2]"});
4405 }
4406 else {
4407 95 push @list_all, map { CORE::chr($_) } (CORE::ord($hyphened[$i+0]) .. CORE::ord($hyphened[$i+2]));
4408 95 $i += 3;
4409 }
4410 }
4411 else {
4412 6322 ▶ if ($hyphened[$i] eq '\\-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hyphened[$i] eq '\\-') { } 19 6303 6322
4413 19 push @list_all, '-';
4414 }
4415 else {
4416 6303 push @list_all, $hyphened[$i];
4417 }
4418 6322 $i++;
4419 }
4420 }
4421 5060 return @list_all;
4422 }
4423  
4424 #---------------------------------------------------------------------
4425 # parse tr{here}{here} in balanced blackets
4426 2083 ▶sub parse_tr_like_balanced {
Subroutine parse_tr_like_balanced: called CC=8 SCAR=24.9
Pod undocumented
4427 2080 my($open_bracket) = @_;
4428 2080 ▶ my $close_bracket = {qw| ( ) { } [ ] < > |}->{$open_bracket} || die;
Condition50%1/2
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
l!l
20800
MC/DC0%0/1
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Truth table50%1/2
A
A= {'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Aresult
11
00
4429 2080 my @x = ();
4430 2080 my $nest_bracket = 1;
4431 2080 while (1) {
4432  
4433 # blackets
4434 4160 ▶ if (/\G (\\ \Q$open_bracket\E) /xmsgc) {
Branch: 5 branches
BranchTrueFalseTotal
if (/\G (\\ \Q$open_bracket\E) /cgmsx) { } 0 4160 4160
elsif (/\G (\\ \Q$close_bracket\E) /cgmsx) { } 0 4160 4160
elsif (/\G (\Q$open_bracket\E) /cgmsx) { } 0 4160 4160
elsif (/\G (\Q$close_bracket\E) /cgmsx) { } 2080 2080 4160
elsif (/\G (\\ -) /cgmsx) { } 0 2080 2080
4435 0 push @x, $1;
4436 }
4437 elsif (/\G (\\ \Q$close_bracket\E) /xmsgc) {
4438 0 push @x, $1;
4439 }
4440 elsif (/\G (\Q$open_bracket\E) /xmsgc) {
4441 0 push @x, $1;
4442 0 $nest_bracket++;
4443 }
4444 elsif (/\G (\Q$close_bracket\E) /xmsgc) {
4445 2080 ▶ if (--$nest_bracket <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest_bracket <= 0) 2080 0 2080
4446 2080 last;
4447 }
4448 0 push @x, $1;
4449 }
4450  
4451 # \-
4452 elsif (/\G (\\ -) /xmsgc) {
4453 0 push @x, $1;
4454 }
4455  
4456 else {
4457 2080 push @x, parse_tr_like($close_bracket);
4458 }
4459 }
4460 2080 return join('', $open_bracket, @x, $close_bracket);
4461 }
4462  
4463 #---------------------------------------------------------------------
4464 # parse tr/here/here/ that ends with a character
4465 2241 ▶sub parse_tr_like_endswith {
Subroutine parse_tr_like_endswith: called CC=4 SCAR=13.9
Pod undocumented
4466 2238 my($endswith) = @_;
4467 2238 my $openwith = $endswith;
4468 2238 my @x = ();
4469 2238 while (1) {
4470 4800 ▶ if (/\G (\\ \Q$endswith\E) /xmsgc) {
Branch: 3 branches
BranchTrueFalseTotal
if (/\G (\\ \Q$endswith\E) /cgmsx) { } 0 4800 4800
elsif (/\G (\Q$endswith\E) /cgmsx) { } 2238 2562 4800
elsif (/\G (\\ -) /cgmsx) { } 9 2553 2562
4471 0 push @x, $1;
4472 }
4473 elsif (/\G (\Q$endswith\E) /xmsgc) {
4474 2238 last;
4475 }
4476  
4477 # \-
4478 elsif (/\G (\\ -) /xmsgc) {
4479 9 push @x, $1;
4480 }
4481  
4482 else {
4483 2553 push @x, parse_tr_like($endswith);
4484 }
4485 }
4486 2238 return join('', $openwith, @x, $endswith);
4487 }
4488  
4489 #---------------------------------------------------------------------
4490 # parse tr/here/here/ common routine
4491 4636 ▶sub parse_tr_like {
Subroutine parse_tr_like: called CC=11 SCAR=24.6
Pod undocumented
4492 4633 my($closewith) = @_;
4493  
4494 4633 ▶ if (0) {
Branch: 8 branches
BranchTrueFalseTotal
if (do { /\G \\ ( [0-3][0-7][0-7] | [0-7][0-7] | [0-7] ) /cgmsx }) { } 4 4629 4633
elsif (/\G \\o ( [0-3][0-7][0-7] | [0-7][0-7] | [0-7] ) /cgmsx) { } 4 4625 4629
elsif (/\G \\o\{ (.*?) \} /cgmsx) { } 4 4621 4625
elsif (/\G \\x ( [0-9A-Fa-f][0-9A-Fa-f] | [0-9A-Fa-f] ) /cgmsx) { } 3 4618 4621
elsif (/\G \\x\{ (.*?) \} /cgmsx) { } 3 4615 4618
elsif (/\G ( \\c [\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_?] ) /cgmsx) { } 9 4606 4615
elsif (/\G ( \\ ([\\abefnrtElLuUQ]) ) /cgmsx) { } 16 4590 4606
elsif (/\G ($x) /cgmsx) { } 4590 0 4590
4495 }
4496  
4497 # https://perldoc.perl.org/perlop#Interpolation
4498 # tr///, y///
4499 # No variable interpolation occurs.
4500 # String modifying combinations for case and quoting such as \Q, \U, and \E are not recognized.
4501 # The other escape sequences such as \200 and \t and backslashed characters such as \\ and \- are converted to appropriate literals.
4502 # The character "-" is treated specially and therefore \- is treated as a literal "-".
4503  
4504 # \ddd
4505 elsif (/\G \\ ( [0-3][0-7][0-7] | [0-7][0-7] | [0-7] ) /xmsgc) {
4506 4 return escape_tr(mb::chr(oct $1), $closewith);
4507 }
4508  
4509 # \oddd
4510 elsif (/\G \\o ( [0-3][0-7][0-7] | [0-7][0-7] | [0-7] ) /xmsgc) {
4511 4 return escape_tr(mb::chr(oct $1), $closewith);
4512 }
4513  
4514 # \o{...}
4515 elsif (/\G \\o\{ (.*?) \} /xmsgc) {
4516 4 return escape_tr(mb::chr(oct $1), $closewith);
4517 }
4518  
4519 # \xhh
4520 elsif (/\G \\x ( [0-9A-Fa-f][0-9A-Fa-f] | [0-9A-Fa-f] ) /xmsgc) {
4521 3 return escape_tr(mb::chr(hex $1), $closewith);
4522 }
4523  
4524 # \x{...}
4525 elsif (/\G \\x\{ (.*?) \} /xmsgc) {
4526 3 return escape_tr(mb::chr(hex $1), $closewith);
4527 }
4528  
4529 # \cX
4530 elsif (/\G ( \\c [\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_?] ) /xmsgc) {
4531 return {
4532 '\\c@' => "\c@",
4533 '\\cA' => "\cA",
4534 '\\cB' => "\cB",
4535 '\\cC' => "\cC",
4536 '\\cD' => "\cD",
4537 '\\cE' => "\cE",
4538 '\\cF' => "\cF",
4539 '\\cG' => "\cG",
4540 '\\cH' => "\cH",
4541 '\\cI' => "\cI",
4542 '\\cJ' => "\cJ",
4543 '\\cK' => "\cK",
4544 '\\cL' => "\cL",
4545 '\\cM' => "\cM",
4546 '\\cN' => "\cN",
4547 '\\cO' => "\cO",
4548 '\\cP' => "\cP",
4549 '\\cQ' => "\cQ",
4550 '\\cR' => "\cR",
4551 '\\cS' => "\cS",
4552 '\\cT' => "\cT",
4553 '\\cU' => "\cU",
4554 '\\cV' => "\cV",
4555 '\\cW' => "\cW",
4556 '\\cX' => "\cX",
4557 '\\cY' => "\cY",
4558 '\\cZ' => "\cZ",
4559 '\\c[' => "\c[",
4560 '\\c\\' => CORE::chr(0x1C),
4561 '\\c]' => "\c]",
4562 '\\c^' => "\c^",
4563 '\\c_' => "\c_",
4564 '\\c?' => CORE::chr(0x7F),
4565 9 ▶ }->{$1} || die;
Condition33%1/3
{'\\c@', "\000", '\\cA', "\cA", '\\cB', "\cB", '\\cC', "\cC", '\\cD', "\cD", '\\cE', "\cE", '\\cF', "\cF", '\\cG', "\a", '\\cH', "\cH", '\\cI', "\t", '\\cJ', "\n", '\\cK', "\cK", '\\cL', "\f", '\\cM', "\r", '\\cN', "\cN", '\\cO', "\cO", '\\cP', "\cP", '\\cQ', "\cQ", '\\cR', "\cR", '\\cS', "\cS", '\\cT', "\cT", '\\cU', "\cU", '\\cV', "\cV", '\\cW', "\cW", '\\cX', "\cX", '\\cY', "\cY", '\\cZ', "\cZ", '\\c[', "\e", '\\c\\', "\034", '\\c]', "\035", '\\c^', "\036", '\\c_', "\037", '\\c?', "\177"}->{$1} || die()
l!l
900
MC/DC0%0/1
{'\\c@', "\000", '\\cA', "\cA", '\\cB', "\cB", '\\cC', "\cC", '\\cD', "\cD", '\\cE', "\cE", '\\cF', "\cF", '\\cG', "\a", '\\cH', "\cH", '\\cI', "\t", '\\cJ', "\n", '\\cK', "\cK", '\\cL', "\f", '\\cM', "\r", '\\cN', "\cN", '\\cO', "\cO", '\\cP', "\cP", '\\cQ', "\cQ", '\\cR', "\cR", '\\cS', "\cS", '\\cT', "\cT", '\\cU', "\cU", '\\cV', "\cV", '\\cW', "\cW", '\\cX', "\cX", '\\cY', "\cY", '\\cZ', "\cZ", '\\c[', "\e", '\\c\\', "\034", '\\c]', "\035", '\\c^', "\036", '\\c_', "\037", '\\c?', "\177"}->{$1} || die()
{'\\c@', "\000", '\\cA', "\cA", '\\cB', "\cB", '\\cC', "\cC", '\\cD', "\cD", '\\cE', "\cE", '\\cF', "\cF", '\\cG', "\a", '\\cH', "\cH", '\\cI', "\t", '\\cJ', "\n", '\\cK', "\cK", '\\cL', "\f", '\\cM', "\r", '\\cN', "\cN", '\\cO', "\cO", '\\cP', "\cP", '\\cQ', "\cQ", '\\cR', "\cR", '\\cS', "\cS", '\\cT', "\cT", '\\cU', "\cU", '\\cV', "\cV", '\\cW', "\cW", '\\cX', "\cX", '\\cY', "\cY", '\\cZ', "\cZ", '\\c[', "\e", '\\c\\', "\034", '\\c]', "\035", '\\c^', "\036", '\\c_', "\037", '\\c?', "\177"}->{$1}
Truth table50%1/2
A
A= {'\\c@', "\000", '\\cA', "\cA", '\\cB', "\cB", '\\cC', "\cC", '\\cD', "\cD", '\\cE', "\cE", '\\cF', "\cF", '\\cG', "\a", '\\cH', "\cH", '\\cI', "\t", '\\cJ', "\n", '\\cK', "\cK", '\\cL', "\f", '\\cM', "\r", '\\cN', "\cN", '\\cO', "\cO", '\\cP', "\cP", '\\cQ', "\cQ", '\\cR', "\cR", '\\cS', "\cS", '\\cT', "\cT", '\\cU', "\cU", '\\cV', "\cV", '\\cW', "\cW", '\\cX', "\cX", '\\cY', "\cY", '\\cZ', "\cZ", '\\c[', "\e", '\\c\\', "\034", '\\c]', "\035", '\\c^', "\036", '\\c_', "\037", '\\c?', "\177"}->{$1}
Aresult
11
00
4566 }
4567  
4568 # \\ \a \b \e \f \n \r \t \E \l \L \u \U \Q
4569 elsif (/\G ( \\ ([\\abefnrtElLuUQ]) ) /xmsgc) {
4570 return {
4571 "\x5C\x5C" => "\x5C\x5C",
4572 '\a' => "\a",
4573 '\b' => "\b",
4574 '\e' => "\e",
4575 '\f' => "\f",
4576 '\n' => "\n",
4577 '\r' => "\r",
4578 '\t' => "\t",
4579 16 ▶ }->{$1} || $2;
Condition66%2/3
{'\\\\', '\\\\', '\\a', "\a", '\\b', "\cH", '\\e', "\e", '\\f', "\f", '\\n', "\n", '\\r', "\r", '\\t', "\t"}->{$1} || $2
l!l&&r!l&&!r
1060
MC/DC0%0/2
{'\\\\', '\\\\', '\\a', "\a", '\\b', "\cH", '\\e', "\e", '\\f', "\f", '\\n', "\n", '\\r', "\r", '\\t', "\t"}->{$1} || $2
{'\\\\', '\\\\', '\\a', "\a", '\\b', "\cH", '\\e', "\e", '\\f', "\f", '\\n', "\n", '\\r', "\r", '\\t', "\t"}->{$1} $2
Truth table66%2/3
A || B
A= {'\\\\', '\\\\', '\\a', "\a", '\\b', "\cH", '\\e', "\e", '\\f', "\f", '\\n', "\n", '\\r', "\r", '\\t', "\t"}->{$1}B= $2
ABresult
1X1
011
000
4580 }
4581  
4582 # any
4583 elsif (/\G ($x) /xmsgc) {
4584 4590 return escape_tr($1, $closewith);
4585 }
4586  
4587 # something wrong happened
4588 else {
4589 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
4590 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
4591 ------------------------------------------------------------------------------
4592 %s
4593 ------------------------------------------------------------------------------
4594 END
4595 }
4596 }
4597  
4598 #---------------------------------------------------------------------
4599 # qr/ [A-Z] / for Shift_JIS-like encoding
4600 8438 ▶sub list_all_by_hyphen_sjis_like {
Subroutine list_all_by_hyphen_sjis_like: called CC=15 SCAR=28.4
Pod undocumented
4601 8435 my($a, $b) = @_;
4602 8435 my @a = (undef, unpack 'C*', $a);
4603 8435 my @b = (undef, unpack 'C*', $b);
4604  
4605 8435 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 2995 5440 8435
elsif (CORE::length $a == 2) { } 5440 0 5440
4606 elsif (CORE::length($a) == 1) {
4607 2995 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 435 2560 2995
elsif (CORE::length $b == 2) { } 2560 0 2560
4608 elsif (CORE::length($b) == 1) {
4609 return (
4610 435 ▶(($a[1] <= 0x80) and (0xA0 <= $b[1])) ?
Branch: 2 branches
BranchTrueFalseTotal
$a[1] <= 128 && 160 <= $b[1] ? : 160 275 435
$a[1] <= $b[1] ? : 275 0 275
Condition100%3/3
$a[1] <= 128 and 160 <= $b[1]
!ll&&!rl&&r
120155160
MC/DC100%2/2
$a[1] <= 128 and 160 <= $b[1]
$a[1] <= 128 160 <= $b[1]
Truth table100%3/3
A and B
A= $a[1] <= 128B= 160 <= $b[1]
ABresult
0X0
100
111
4611 sprintf(join('', qw( [\x%02x-\x80\xA0-\x%02x] )), $a[1],
4612 $b[1]) :
4613 $a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1],
4614 $b[1]) : (),
4615 );
4616 }
4617 elsif (CORE::length($b) == 2) {
4618 return (
4619 2560 ▶ sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
Branch: 4 branches
BranchTrueFalseTotal
129 < $b[1] ? : 1920 640 2560
$a[1] <= 128 ? : 1280 1280 2560
$a[1] < 160 ? : 0 1280 1280
$a[1] <= 223 ? : 1280 0 1280
4620 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4621 $a[1] <= 0x80 ? sprintf(join('', qw( [\x%02x-\x80\xA0-\xDF] )), $a[1]) :
4622 $a[1] < 0xA0 ? () :
4623 $a[1] <= 0xDF ? sprintf(join('', qw( [\x%02x-\xDF] )), $a[1]) : (),
4624 );
4625 }
4626 }
4627 elsif (CORE::length($a) == 2) {
4628 5440 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) 5440 0 5440
4629 0 elsif (CORE::length($b) == 2) {
4630 5440 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 252 ? : 5040 400 5440
4631 $a[1] < 0xFC ? sprintf(join('', qw( [\x%02x-\xFC] [\x00-\xFF ] )), $a[1]+1 ) : (),
4632 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
4633 );
4634 5440 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 5040 400 5440
4635 sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
4636 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4637 );
4638 5440 return qq{(?=$lower_limit)(?=$upper_limit)};
4639 }
4640 }
4641  
4642 # over range of codepoint
4643 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
4644 }
4645  
4646 #---------------------------------------------------------------------
4647 # the one-octet universe of INFORMIX V6 ALS, intersected with [$from,$to]
4648 # (when $to is omitted it defaults to \xFF, the top of the universe), as a
4649 # regex alternation. \xFD is ambiguous as a bare byte value: it is a genuine
4650 # one-octet character only when NOT followed by \xA1-\xFE (otherwise it is
4651 # the lead of the three-octet plane), so it needs a negative lookahead rather
4652 # than a plain byte-range member; \xE0-\xFC are never one-octet (always a
4653 # two-octet lead) and are excluded entirely; every other byte in \xA0-\xFF is
4654 # an unambiguous one-octet character. This helper is the single source of the
4655 # one-octet set: every branch that needs "the valid single octets in a range"
4656 # calls it, so the \xFD guard and the \xE0-\xFC exclusion cannot drift.
4657 2764 ▶sub _informixv6als_onebyte_sweep {
Subroutine _informixv6als_onebyte_sweep: called CC=16 SCAR=27.7
4658 2761 my ($from, $to) = @_;
4659 2761 ▶ $to = 0xFF unless defined $to;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to 1680 1081 2761
4660 2761 my @piece = ();
4661  
4662 # contiguous single sub-range [\x00-\x80] intersected with [$from,$to]
4663 2761 ▶ my $lo1 = ($from > 0x00) ? $from : 0x00;
Branch: 1 branch
BranchTrueFalseTotal
$from > 0 ? : 2311 450 2761
4664 2761 ▶ my $hi1 = ($to < 0x80) ? $to : 0x80;
Branch: 1 branch
BranchTrueFalseTotal
$to < 128 ? : 91 2670 2761
4665 2761 ▶ if ($lo1 <= $hi1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lo1 <= $hi1) 1261 1500 2761
4666 1261 ▶ push @piece, ($lo1 == $hi1) ? sprintf('\x%02x', $lo1)
Branch: 1 branch
BranchTrueFalseTotal
$lo1 == $hi1 ? : 450 811 1261
4667 : sprintf('[\x%02x-\x%02x]', $lo1, $hi1);
4668 }
4669  
4670 # contiguous single sub-range [\xA0-\xDF] intersected with [$from,$to]
4671 2761 ▶ my $lo2 = ($from > 0xA0) ? $from : 0xA0;
Branch: 1 branch
BranchTrueFalseTotal
$from > 160 ? : 1140 1621 2761
4672 2761 ▶ my $hi2 = ($to < 0xDF) ? $to : 0xDF;
Branch: 1 branch
BranchTrueFalseTotal
$to < 223 ? : 301 2460 2761
4673 2761 ▶ if ($lo2 <= $hi2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lo2 <= $hi2) 1770 991 2761
4674 1770 ▶ push @piece, ($lo2 == $hi2) ? sprintf('\x%02x', $lo2)
Branch: 1 branch
BranchTrueFalseTotal
$lo2 == $hi2 ? : 450 1320 1770
4675 : sprintf('[\x%02x-\x%02x]', $lo2, $hi2);
4676 }
4677  
4678 # \xFD is a genuine one-octet character only when NOT the lead of the
4679 # three-octet plane (i.e. when NOT followed by \xA1-\xFE), so it needs the
4680 # negative lookahead rather than a bare byte-range member.
4681 2761 ▶ if (($from <= 0xFD) and (0xFD <= $to)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from <= 253 and 253 <= $to) 1800 961 2761
Condition100%3/3
$from <= 253 and 253 <= $to
!ll&&!rl&&r
5104511800
MC/DC100%2/2
$from <= 253 and 253 <= $to
$from <= 253 253 <= $to
Truth table100%3/3
A and B
A= $from <= 253B= 253 <= $to
ABresult
0X0
100
111
4682 1800 push @piece, '\xFD(?![\xA1-\xFE])';
4683 }
4684 2761 ▶ if (($from <= 0xFE) and (0xFE <= $to)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from <= 254 and 254 <= $to) 1890 871 2761
Condition100%3/3
$from <= 254 and 254 <= $to
!ll&&!rl&&r
2406311890
MC/DC100%2/2
$from <= 254 and 254 <= $to
$from <= 254 254 <= $to
Truth table100%3/3
A and B
A= $from <= 254B= 254 <= $to
ABresult
0X0
100
111
4685 1890 push @piece, '\xFE';
4686 }
4687 2761 ▶ if (($from <= 0xFF) and (0xFF <= $to)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from <= 255 and 255 <= $to) 1920 841 2761
Condition66%2/3
$from <= 255 and 255 <= $to
!ll&&!rl&&r
08411920
MC/DC50%1/2
$from <= 255 and 255 <= $to
$from <= 255 255 <= $to
Truth table66%2/3
A and B
A= $from <= 255B= 255 <= $to
ABresult
0X0
100
111
4688 1920 push @piece, '\xFF';
4689 }
4690  
4691 2761 return join('|', @piece);
4692 }
4693  
4694 #---------------------------------------------------------------------
4695 # qr/ [A-Z] / for INFORMIX V6 ALS-like encoding
4696 #
4697 # INFORMIX V6 ALS codepoint structure (all in byte form):
4698 # 1 octet US-ASCII plus the non-lead high bytes [\x00-\x80\xA0-\xDF\xFD-\xFF]
4699 # 2 octets Shift_JIS-compatible core (== sjis) [\x81-\x9F\xE0-\xFC][\x00-\xFF]
4700 # 3 octets \xFD user-defined plane \xFD[\xA1-\xFE][\x00-\xFF]
4701 # The 1- and 2-octet cases are byte-for-byte the same as sjis (see
4702 # list_all_by_hyphen_sjis_like) and are reused verbatim here; only the cases
4703 # that touch the 3-octet \xFD plane are new. mb orders codepoints length-first
4704 # (every one-octet unit before every two-octet unit before every three-octet
4705 # unit), the same order list_all_by_hyphen_sjis_like assumes.
4706 3603 ▶sub list_all_by_hyphen_informixv6als_like {
Subroutine list_all_by_hyphen_informixv6als_like: called CC=19 SCAR=30.0
Pod undocumented
4707 3601 my($a, $b) = @_;
4708 3601 my @a = (undef, unpack 'C*', $a);
4709 3601 my @b = (undef, unpack 'C*', $b);
4710  
4711 3601 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 2761 840 3601
elsif (CORE::length $a == 2) { } 750 90 840
elsif (CORE::length $a == 3) { } 90 0 90
4712 elsif (CORE::length($a) == 1) {
4713 2761 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 1081 1680 2761
elsif (CORE::length $b == 2) { } 1200 480 1680
elsif (CORE::length $b == 3) { } 480 0 480
4714 elsif (CORE::length($b) == 1) {
4715 # the valid single octets in [$a[1],$b[1]]; the sweep excludes the
4716 # \xE0-\xFC two-octet leads and guards \xFD against being read as a
4717 # three-octet lead, so a range whose top reaches \xFD-\xFF cannot
4718 # wrongly match the lead byte of a \xFD-plane character.
4719 1081 my $body = _informixv6als_onebyte_sweep($a[1], $b[1]);
4720 1081 ▶ return ($body eq '') ? () : ($body);
Branch: 1 branch
BranchTrueFalseTotal
$body eq '' ? : 0 1081 1081
4721 }
4722 elsif (CORE::length($b) == 2) {
4723 return (
4724 1200 ▶ sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 720 480 1200
4725 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4726 # length 1: a .. the top of the one-octet universe (incl. \xFD-\xFF)
4727 _informixv6als_onebyte_sweep($a[1]),
4728 );
4729 }
4730 elsif (CORE::length($b) == 3) {
4731 return (
4732 # length 3: \xFD\xA1\x00 .. b
4733 480 ▶ sprintf(join('', qw( \xFD \x%02x [\x00-\x%02x] )), $b[2], $b[3]),
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[2] ? : 240 240 480
4734 0xA1 < $b[2] ? sprintf(join('', qw( \xFD [\xA1-\x%02x] [\x00-\xFF ] )), $b[2]-1 ) : (),
4735  
4736 # length 2: the full sjis-core two-octet universe
4737 sprintf(join('', qw( [\x81-\x9F\xE0-\xFC][\x00-\xFF] )), ),
4738  
4739 # length 1: a .. the top of the one-octet universe
4740 _informixv6als_onebyte_sweep($a[1]),
4741 );
4742 }
4743 }
4744 elsif (CORE::length($a) == 2) {
4745 750 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) { } 450 300 750
elsif (CORE::length $b == 3) { } 300 0 300
4746 elsif (CORE::length($b) == 2) {
4747 450 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 252 ? : 420 30 450
4748 $a[1] < 0xFC ? sprintf(join('', qw( [\x%02x-\xFC] [\x00-\xFF ] )), $a[1]+1 ) : (),
4749 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
4750 );
4751 450 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 360 90 450
4752 sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
4753 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4754 );
4755 450 return qq{(?=$lower_limit)(?=$upper_limit)};
4756 }
4757 elsif (CORE::length($b) == 3) {
4758 return (
4759 # length 3: \xFD\xA1\x00 .. b
4760 300 ▶ sprintf(join('', qw( \xFD \x%02x [\x00-\x%02x] )), $b[2], $b[3]),
Branch: 2 branches
BranchTrueFalseTotal
161 < $b[2] ? : 150 150 300
$a[1] < 252 ? : 240 60 300
4761 0xA1 < $b[2] ? sprintf(join('', qw( \xFD [\xA1-\x%02x] [\x00-\xFF ] )), $b[2]-1 ) : (),
4762 # length 2: a .. \xFC\xFF (top of the two-octet universe)
4763 $a[1] < 0xFC ? sprintf(join('', qw( [\x%02x-\xFC] [\x00-\xFF ] )), $a[1]+1 ) : (),
4764 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
4765 );
4766 }
4767 }
4768 elsif (CORE::length($a) == 3) {
4769 90 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 3 }) 90 0 90
4770 0 elsif (CORE::length($b) == 3) {
4771 90 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[2] < 254 ? : 60 30 90
4772 $a[2] < 0xFE ? sprintf(join('', qw( \xFD [\x%02x-\xFE] [\x00-\xFF ] )), $a[2]+1 ) : (),
4773 sprintf(join('', qw( \xFD \x%02x [\x%02x-\xFF] )), $a[2], $a[3]),
4774 );
4775 90 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[2] ? : 60 30 90
4776 sprintf(join('', qw( \xFD \x%02x [\x00-\x%02x] )), $b[2], $b[3]),
4777 0xA1 < $b[2] ? sprintf(join('', qw( \xFD [\xA1-\x%02x] [\x00-\xFF ] )), $b[2]-1 ) : (),
4778 );
4779 90 return qq{(?=$lower_limit)(?=$upper_limit)};
4780 }
4781 }
4782  
4783 # over range of codepoint
4784 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
4785 }
4786  
4787 #---------------------------------------------------------------------
4788 # qr/ [A-Z] / for EUC-JP-like encoding
4789 253 ▶sub list_all_by_hyphen_eucjp_like {
Subroutine list_all_by_hyphen_eucjp_like: called CC=10 SCAR=24.0
Pod undocumented
4790 253 my($a, $b) = @_;
4791 253 my @a = (undef, unpack 'C*', $a);
4792 253 my @b = (undef, unpack 'C*', $b);
4793  
4794 253 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 133 120 253
elsif (CORE::length $a == 2) { } 120 0 120
4795 elsif (CORE::length($a) == 1) {
4796 133 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 37 96 133
elsif (CORE::length $b == 2) { } 96 0 96
4797 elsif (CORE::length($b) == 1) {
4798 return (
4799 37 ▶$a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1],
Branch: 1 branch
BranchTrueFalseTotal
$a[1] <= $b[1] ? : 37 0 37
4800 $b[1]) : (),
4801 );
4802 }
4803 elsif (CORE::length($b) == 2) {
4804 return (
4805 96 ▶ sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[1] ? : 48 48 96
4806 0xA1 < $b[1] ? sprintf(join('', qw( [\xA1-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4807 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
4808 );
4809 }
4810 }
4811 elsif (CORE::length($a) == 2) {
4812 120 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) 120 0 120
4813 0 elsif (CORE::length($b) == 2) {
4814 120 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 254 ? : 84 36 120
4815 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [\x00-\xFF ] )), $a[1]+1 ) : (),
4816 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
4817 );
4818 120 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[1] ? : 84 36 120
4819 sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
4820 0xA1 < $b[1] ? sprintf(join('', qw( [\xA1-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4821 );
4822 120 return qq{(?=$lower_limit)(?=$upper_limit)};
4823 }
4824 }
4825  
4826 # over range of codepoint
4827 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
4828 }
4829  
4830 #---------------------------------------------------------------------
4831 # qr/ [A-Z] / for EUC-TW-like encoding
4832 #
4833 # EUC-TW codepoint structure (all in byte form):
4834 # 1 octet US-ASCII [\x00-\x7F]
4835 # 2 octets CNS 11643 plane 1 [\xA1-\xFE][\xA1-\xFE]
4836 # 4 octets SS2 planes 2..16 \x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]
4837 # (there is no 3-octet form). Range semantics follow the legacy Char-EUCTW
4838 # Eeuctw _charlist: ordering is length-first (every 1-octet char < every
4839 # 2-octet char < every 4-octet char), so [A-B] is the union, over each length
4840 # L in length(A)..length(B), of: A..max(L) for the shortest length, all of L
4841 # for an intermediate length, and min(L)..B for the longest length. The
4842 # non-existent 3-octet length is skipped (as the gb18030 helper skips it).
4843 # Every branch is consumed by the enclosing (?=...)$x / (?!...)$x wrapper, so a
4844 # branch only has to assert the in-range octets and $x consumes the character.
4845 1106 ▶sub list_all_by_hyphen_euctw_like {
Subroutine list_all_by_hyphen_euctw_like: called CC=23 SCAR=31.8
Pod undocumented
4846 1106 my($a, $b) = @_;
4847 1106 my @a = (undef, unpack 'C*', $a);
4848 1106 my @b = (undef, unpack 'C*', $b);
4849  
4850 1106 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 384 722 1106
elsif (CORE::length $a == 2) { } 521 201 722
elsif (CORE::length $a == 4) { } 201 0 201
4851 elsif (CORE::length($a) == 1) {
4852 384 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 61 323 384
elsif (CORE::length $b == 2) { } 160 163 323
elsif (CORE::length $b == 4) { } 163 0 163
4853 elsif (CORE::length($b) == 1) {
4854 return (
4855 61 ▶$a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1], $b[1]) : (),
Branch: 1 branch
BranchTrueFalseTotal
$a[1] <= $b[1] ? : 61 0 61
4856 );
4857 }
4858 elsif (CORE::length($b) == 2) {
4859 return (
4860 # length 2: \xA1\xA1 .. b
4861 160 ▶ sprintf(join('', qw( \x%02x [\xA1-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[1] ? : 80 80 160
4862 0xA1 < $b[1] ? sprintf(join('', qw( [\xA1-\x%02x] [\xA1-\xFE ] )), $b[1]-1 ) : (),
4863 # length 1: a .. \x7F
4864 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
4865 );
4866 }
4867 elsif (CORE::length($b) == 4) {
4868 return (
4869 # length 4: \x8E\xA1\xA1\x00 .. b (lead is always \x8E)
4870 163 ▶ sprintf(join('', qw( \x8E \x%02x \x%02x [\x00-\x%02x] )), $b[2], $b[3], $b[4]),
Branch: 2 branches
BranchTrueFalseTotal
161 < $b[3] ? : 82 81 163
161 < $b[2] ? : 82 81 163
4871 0xA1 < $b[3] ? sprintf(join('', qw( \x8E \x%02x [\xA1-\x%02x] [\x00-\xFF ] )), $b[2], $b[3]-1 ) : (),
4872 0xA1 < $b[2] ? sprintf(join('', qw( \x8E [\xA1-\x%02x] [\xA1-\xFE ] [\x00-\xFF ] )), $b[2]-1 ) : (),
4873 # length 2: all two-octet chars
4874 sprintf(join('', qw( [\xA1-\xFE] [\xA1-\xFE] )), ),
4875 # length 1: a .. \x7F
4876 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
4877 );
4878 }
4879 }
4880 elsif (CORE::length($a) == 2) {
4881 521 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) { } 200 321 521
elsif (CORE::length $b == 4) { } 321 0 321
4882 elsif (CORE::length($b) == 2) {
4883 200 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 254 ? : 140 60 200
4884 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [\xA1-\xFE ] )), $a[1]+1 ) : (),
4885 sprintf(join('', qw( \x%02x [\x%02x-\xFE] )), $a[1], $a[2]),
4886 );
4887 200 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
161 < $b[1] ? : 140 60 200
4888 sprintf(join('', qw( \x%02x [\xA1-\x%02x] )), $b[1], $b[2]),
4889 0xA1 < $b[1] ? sprintf(join('', qw( [\xA1-\x%02x] [\xA1-\xFE ] )), $b[1]-1 ) : (),
4890 );
4891 200 return qq{(?=$lower_limit)(?=$upper_limit)};
4892 }
4893 elsif (CORE::length($b) == 4) {
4894 return (
4895 # length 4: \x8E\xA1\xA1\x00 .. b
4896 321 ▶ sprintf(join('', qw( \x8E \x%02x \x%02x [\x00-\x%02x] )), $b[2], $b[3], $b[4]),
Branch: 3 branches
BranchTrueFalseTotal
161 < $b[3] ? : 161 160 321
161 < $b[2] ? : 161 160 321
$a[1] < 254 ? : 161 160 321
4897 0xA1 < $b[3] ? sprintf(join('', qw( \x8E \x%02x [\xA1-\x%02x] [\x00-\xFF ] )), $b[2], $b[3]-1 ) : (),
4898 0xA1 < $b[2] ? sprintf(join('', qw( \x8E [\xA1-\x%02x] [\xA1-\xFE ] [\x00-\xFF ] )), $b[2]-1 ) : (),
4899 # length 2: a .. \xFE\xFE
4900 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [\xA1-\xFE ] )), $a[1]+1 ) : (),
4901 sprintf(join('', qw( \x%02x [\x%02x-\xFE] )), $a[1], $a[2]),
4902 );
4903 }
4904 }
4905 elsif (CORE::length($a) == 4) {
4906 201 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 4 }) 201 0 201
4907 0 elsif (CORE::length($b) == 4) {
4908 201 ▶ my $lower_limit = join('|',
Branch: 2 branches
BranchTrueFalseTotal
$a[2] < 176 ? : 181 20 201
$a[3] < 254 ? : 181 20 201
4909 # >= a, lead is always \x8E
4910 $a[2] < 0xB0 ? sprintf(join('', qw( \x8E [\x%02x-\xB0] [\xA1-\xFE ] [\x00-\xFF ] )), $a[2]+1 ) : (),
4911 $a[3] < 0xFE ? sprintf(join('', qw( \x8E \x%02x [\x%02x-\xFE] [\x00-\xFF ] )), $a[2], $a[3]+1 ) : (),
4912 sprintf(join('', qw( \x8E \x%02x \x%02x [\x%02x-\xFF] )), $a[2], $a[3], $a[4]),
4913 );
4914 201 ▶ my $upper_limit = join('|',
Branch: 2 branches
BranchTrueFalseTotal
161 < $b[3] ? : 141 60 201
161 < $b[2] ? : 141 60 201
4915 sprintf(join('', qw( \x8E \x%02x \x%02x [\x00-\x%02x] )), $b[2], $b[3], $b[4]),
4916 0xA1 < $b[3] ? sprintf(join('', qw( \x8E \x%02x [\xA1-\x%02x] [\x00-\xFF ] )), $b[2], $b[3]-1 ) : (),
4917 0xA1 < $b[2] ? sprintf(join('', qw( \x8E [\xA1-\x%02x] [\xA1-\xFE ] [\x00-\xFF ] )), $b[2]-1 ) : (),
4918 );
4919 201 return qq{(?=$lower_limit)(?=$upper_limit)};
4920 }
4921 }
4922  
4923 # over range of codepoint
4924 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
4925 }
4926  
4927 #---------------------------------------------------------------------
4928 # qr/ [A-Z] / for Big5-like encoding
4929 256 ▶sub list_all_by_hyphen_big5_like {
Subroutine list_all_by_hyphen_big5_like: called CC=10 SCAR=24.0
Pod undocumented
4930 256 my($a, $b) = @_;
4931 256 my @a = (undef, unpack 'C*', $a);
4932 256 my @b = (undef, unpack 'C*', $b);
4933  
4934 256 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 136 120 256
elsif (CORE::length $a == 2) { } 120 0 120
4935 elsif (CORE::length($a) == 1) {
4936 136 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 40 96 136
elsif (CORE::length $b == 2) { } 96 0 96
4937 elsif (CORE::length($b) == 1) {
4938 return (
4939 40 ▶$a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1],
Branch: 1 branch
BranchTrueFalseTotal
$a[1] <= $b[1] ? : 40 0 40
4940 $b[1]) : (),
4941 );
4942 }
4943 elsif (CORE::length($b) == 2) {
4944 return (
4945 96 ▶ sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 48 48 96
4946 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4947 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
4948 );
4949 }
4950 }
4951 elsif (CORE::length($a) == 2) {
4952 120 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) 120 0 120
4953 0 elsif (CORE::length($b) == 2) {
4954 120 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 254 ? : 84 36 120
4955 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [\x00-\xFF ] )), $a[1]+1 ) : (),
4956 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
4957 );
4958 120 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 84 36 120
4959 sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
4960 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x00-\xFF ] )), $b[1]-1 ) : (),
4961 );
4962 120 return qq{(?=$lower_limit)(?=$upper_limit)};
4963 }
4964 }
4965  
4966 # over range of codepoint
4967 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
4968 }
4969  
4970 #---------------------------------------------------------------------
4971 # qr/ [A-Z] / for HP-15-like encoding
4972 #
4973 # HP-15 has a discontinuous two-octet lead [\x80-\xA0\xE0-\xFE] with the
4974 # single-octet JIS X 0201 katakana [\xA1-\xDF] sitting between the two lead
4975 # ranges and the single octet \xFF above them (verified against the legacy
4976 # Ehp15 %range_tr). So a codepoint-class range that touches the high bytes
4977 # must intersect [lo,hi] with the exact single-octet set and the exact lead
4978 # set rather than emit one contiguous class (as the contiguous-lead sjis/big5
4979 # helpers do). mb orders codepoints length-first (every one-octet unit sorts
4980 # before every two-octet unit), the same order list_all_by_hyphen_sjis_like
4981 # assumes.
4982 3601 ▶sub list_all_by_hyphen_hp15_like {
Subroutine list_all_by_hyphen_hp15_like: called CC=11 SCAR=24.1
Pod undocumented
4983 3601 my($a, $b) = @_;
4984 3601 my @a = (undef, unpack 'C*', $a);
4985 3601 my @b = (undef, unpack 'C*', $b);
4986  
4987 # HP-15 valid single-octet units and valid lead octets
4988 3601 my @single_ranges = ([0x00,0x7F],[0xA1,0xDF],[0xFF,0xFF]);
4989 3601 my @lead_ranges = ([0x80,0xA0],[0xE0,0xFE]);
4990  
4991 # class body for the intersection of [$lo,$hi] with @{$_[2]} ('' if empty)
4992 6751 ▶ my $isect = sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
4993 6751 my($lo, $hi, $ranges) = @_;
4994 6751 my $body = '';
4995 6751 for my $r (@{$ranges}) {
4996 15453 ▶ my $x = ($r->[0] > $lo) ? $r->[0] : $lo;
Branch: 1 branch
BranchTrueFalseTotal
$r->[0] > $lo ? : 6842 8611 15453
4997 15453 ▶ my $y = ($r->[1] < $hi) ? $r->[1] : $hi;
Branch: 1 branch
BranchTrueFalseTotal
$r->[1] < $hi ? : 7110 8343 15453
4998 15453 ▶ next if $x > $y;
Branch: 1 branch
BranchTrueFalseTotal
if $x > $y 5642 9811 15453
4999 9811 ▶ $body .= ($x == $y) ? sprintf('\x%02x', $x)
Branch: 1 branch
BranchTrueFalseTotal
$x == $y ? : 2550 7261 9811
5000 : sprintf('\x%02x-\x%02x', $x, $y);
5001 }
5002 6751 return $body;
5003 3601 };
5004  
5005 3601 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 1951 1650 3601
elsif (CORE::length $a == 2) { } 1650 0 1650
5006 elsif (CORE::length($a) == 1) {
5007 1951 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 451 1500 1951
elsif (CORE::length $b == 2) { } 1500 0 1500
5008 elsif (CORE::length($b) == 1) {
5009 451 my $body = $isect->($a[1], $b[1], \@single_ranges);
5010 451 ▶ return ($body eq '') ? () : ("[$body]");
Branch: 1 branch
BranchTrueFalseTotal
$body eq '' ? : 0 451 451
5011 }
5012 elsif (CORE::length($b) == 2) {
5013 1500 my @out = ();
5014  
5015 # every valid single octet >= $a[1] (all sort before any two-octet $b)
5016 1500 my $sbody = $isect->($a[1], 0xFF, \@single_ranges);
5017 1500 ▶ push @out, "[$sbody]" if $sbody ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $sbody ne "" 1500 0 1500
5018  
5019 # two-octet units whose lead is a valid lead below $b[1] (full trail)
5020 1500 my $lbody = $isect->(0x80, $b[1]-1, \@lead_ranges);
5021 1500 ▶ push @out, sprintf('[%s][\x00-\xFF]', $lbody) if $lbody ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $lbody ne "" 1050 450 1500
5022  
5023 # two-octet units with lead == $b[1] and trail <= $b[2]
5024 1500 push @out, sprintf('\x%02x[\x00-\x%02x]', $b[1], $b[2]);
5025 1500 return @out;
5026 }
5027 }
5028 elsif (CORE::length($a) == 2) {
5029 1650 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) 1650 0 1650
5030 0 elsif (CORE::length($b) == 2) {
5031 1650 my @lower = ();
5032 1650 push @lower, sprintf('\x%02x[\x%02x-\xFF]', $a[1], $a[2]);
5033 1650 my $lo_leads = $isect->($a[1]+1, 0xFE, \@lead_ranges);
5034 1650 ▶ push @lower, sprintf('[%s][\x00-\xFF]', $lo_leads) if $lo_leads ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $lo_leads ne "" 1560 90 1650
5035  
5036 1650 my @upper = ();
5037 1650 push @upper, sprintf('\x%02x[\x00-\x%02x]', $b[1], $b[2]);
5038 1650 my $up_leads = $isect->(0x80, $b[1]-1, \@lead_ranges);
5039 1650 ▶ push @upper, sprintf('[%s][\x00-\xFF]', $up_leads) if $up_leads ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $up_leads ne "" 1470 180 1650
5040  
5041 1650 my $lower_limit = join('|', @lower);
5042 1650 my $upper_limit = join('|', @upper);
5043 1650 return qq{(?=$lower_limit)(?=$upper_limit)};
5044 }
5045 }
5046  
5047 # over range of codepoint
5048 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
5049 }
5050  
5051 #---------------------------------------------------------------------
5052 # qr/ [A-Z] / for Johab-like encoding (code page 1361)
5053 #
5054 # Johab (KS X 1001:1992 annex 3, code page 1361) has a discontinuous two-octet
5055 # lead [\x81-\xD3\xD8-\xDE\xE0-\xF9] (hangul \x81-\xD3, symbols \xD8-\xDE, hanja
5056 # \xE0-\xF9, per Microsoft CRT mbctype.c), with NO single high octet: the only
5057 # single octet unit is US-ASCII [\x00-\x7F]. So a codepoint-class range that
5058 # touches the high bytes must intersect [lo,hi] with the exact single-octet set
5059 # and the exact discontinuous lead set rather than emit one contiguous class (as
5060 # the contiguous-lead sjis/big5 helpers do); the hp15 helper is reused verbatim
5061 # here with Johab's single/lead range tables (the same reason hp15 was made a
5062 # dedicated helper). mb orders codepoints length-first (every one-octet unit
5063 # sorts before every two-octet unit), the same order list_all_by_hyphen_sjis_like
5064 # assumes.
5065 3601 ▶sub list_all_by_hyphen_johab_like {
Subroutine list_all_by_hyphen_johab_like: called CC=11 SCAR=24.1
Pod undocumented
5066 3601 my($a, $b) = @_;
5067 3601 my @a = (undef, unpack 'C*', $a);
5068 3601 my @b = (undef, unpack 'C*', $b);
5069  
5070 # Johab valid single-octet units and valid lead octets (code page 1361)
5071 3601 my @single_ranges = ([0x00,0x7F]);
5072 3601 my @lead_ranges = ([0x81,0xD3],[0xD8,0xDE],[0xE0,0xF9]);
5073  
5074 # class body for the intersection of [$lo,$hi] with @{$_[2]} ('' if empty)
5075 7111 ▶ my $isect = sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
5076 7111 my($lo, $hi, $ranges) = @_;
5077 7111 my $body = '';
5078 7111 for my $r (@{$ranges}) {
5079 19591 ▶ my $x = ($r->[0] > $lo) ? $r->[0] : $lo;
Branch: 1 branch
BranchTrueFalseTotal
$r->[0] > $lo ? : 11100 8491 19591
5080 19591 ▶ my $y = ($r->[1] < $hi) ? $r->[1] : $hi;
Branch: 1 branch
BranchTrueFalseTotal
$r->[1] < $hi ? : 13350 6241 19591
5081 19591 ▶ next if $x > $y;
Branch: 1 branch
BranchTrueFalseTotal
if $x > $y 6630 12961 19591
5082 12961 ▶ $body .= ($x == $y) ? sprintf('\x%02x', $x)
Branch: 1 branch
BranchTrueFalseTotal
$x == $y ? : 450 12511 12961
5083 : sprintf('\x%02x-\x%02x', $x, $y);
5084 }
5085 7111 return $body;
5086 3601 };
5087  
5088 3601 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 871 2730 3601
elsif (CORE::length $a == 2) { } 2730 0 2730
5089 elsif (CORE::length($a) == 1) {
5090 871 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 91 780 871
elsif (CORE::length $b == 2) { } 780 0 780
5091 elsif (CORE::length($b) == 1) {
5092 91 my $body = $isect->($a[1], $b[1], \@single_ranges);
5093 91 ▶ return ($body eq '') ? () : ("[$body]");
Branch: 1 branch
BranchTrueFalseTotal
$body eq '' ? : 0 91 91
5094 }
5095 elsif (CORE::length($b) == 2) {
5096 780 my @out = ();
5097  
5098 # every valid single octet >= $a[1] (all sort before any two-octet $b)
5099 780 my $sbody = $isect->($a[1], 0xFF, \@single_ranges);
5100 780 ▶ push @out, "[$sbody]" if $sbody ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $sbody ne "" 780 0 780
5101  
5102 # two-octet units whose lead is a valid lead below $b[1] (full trail)
5103 780 my $lbody = $isect->(0x81, $b[1]-1, \@lead_ranges);
5104 780 ▶ push @out, sprintf('[%s][\x00-\xFF]', $lbody) if $lbody ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $lbody ne "" 600 180 780
5105  
5106 # two-octet units with lead == $b[1] and trail <= $b[2]
5107 780 push @out, sprintf('\x%02x[\x00-\x%02x]', $b[1], $b[2]);
5108 780 return @out;
5109 }
5110 }
5111 elsif (CORE::length($a) == 2) {
5112 2730 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) 2730 0 2730
5113 0 elsif (CORE::length($b) == 2) {
5114 2730 my @lower = ();
5115 2730 push @lower, sprintf('\x%02x[\x%02x-\xFF]', $a[1], $a[2]);
5116 2730 my $lo_leads = $isect->($a[1]+1, 0xFE, \@lead_ranges);
5117 2730 ▶ push @lower, sprintf('[%s][\x00-\xFF]', $lo_leads) if $lo_leads ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $lo_leads ne "" 2640 90 2730
5118  
5119 2730 my @upper = ();
5120 2730 push @upper, sprintf('\x%02x[\x00-\x%02x]', $b[1], $b[2]);
5121 2730 my $up_leads = $isect->(0x81, $b[1]-1, \@lead_ranges);
5122 2730 ▶ push @upper, sprintf('[%s][\x00-\xFF]', $up_leads) if $up_leads ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $up_leads ne "" 2550 180 2730
5123  
5124 2730 my $lower_limit = join('|', @lower);
5125 2730 my $upper_limit = join('|', @upper);
5126 2730 return qq{(?=$lower_limit)(?=$upper_limit)};
5127 }
5128 }
5129  
5130 # over range of codepoint
5131 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
5132 }
5133  
5134 #---------------------------------------------------------------------
5135 # qr/ [A-Z] / for GB18030-like encoding
5136 18253 ▶sub list_all_by_hyphen_gb18030_like {
Subroutine list_all_by_hyphen_gb18030_like: called CC=27 SCAR=33.3
Pod undocumented
5137 18253 my($a, $b) = @_;
5138 18253 my @a = (undef, unpack 'C*', $a);
5139 18253 my @b = (undef, unpack 'C*', $b);
5140  
5141 18253 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 2653 15600 18253
elsif (CORE::length $a == 2) { } 8528 7072 15600
elsif (CORE::length $a == 4) { } 7072 0 7072
5142 elsif (CORE::length($a) == 1) {
5143 2653 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 157 2496 2653
elsif (CORE::length $b == 2) { } 832 1664 2496
elsif (CORE::length $b == 4) { } 1664 0 1664
5144 elsif (CORE::length($b) == 1) {
5145 return (
5146 157 ▶$a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1],
Branch: 1 branch
BranchTrueFalseTotal
$a[1] <= $b[1] ? : 157 0 157
5147 $b[1]) : (),
5148 );
5149 }
5150 elsif (CORE::length($b) == 2) {
5151 return (
5152 832 ▶ sprintf(join('', qw( \x%02x [\x00-\x2F\x3A-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 416 416 832
5153 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [^\x30-\x39 ] )), $b[1]-1 ) : (),
5154 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
5155 );
5156 }
5157 elsif (CORE::length($b) == 4) {
5158 return (
5159 1664 ▶ sprintf(join('', qw( \x%02x \x%02x \x%02x [\x30-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
Branch: 3 branches
BranchTrueFalseTotal
129 < $b[3] ? : 832 832 1664
48 < $b[2] ? : 832 832 1664
129 < $b[1] ? : 832 832 1664
5160 0x81 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x81-\x%02x] [\x30-\x39 ] )), $b[1], $b[2], $b[3]-1 ) : (),
5161 0x30 < $b[2] ? sprintf(join('', qw( \x%02x [\x30-\x%02x] [\x81-\xFE ] [\x30-\x39 ] )), $b[1], $b[2]-1 ) : (),
5162 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x30-\x39 ] [\x81-\xFE ] [\x30-\x39 ] )), $b[1]-1 ) : (),
5163 sprintf(join('', qw( [\x81-\xFE ] [^\x30-\x39 ] )), ),
5164 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
5165 );
5166 }
5167 }
5168 elsif (CORE::length($a) == 2) {
5169 8528 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) { } 1872 6656 8528
elsif (CORE::length $b == 4) { } 6656 0 6656
5170 elsif (CORE::length($b) == 2) {
5171 1872 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 254 ? : 1352 520 1872
5172 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [^\x30-\x39 ] )), $a[1]+1 ) : (),
5173 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2]),
5174 );
5175 1872 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
129 < $b[1] ? : 1352 520 1872
5176 sprintf(join('', qw( \x%02x [\x00-\x%02x] )), $b[1], $b[2]),
5177 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [^\x30-\x39 ] )), $b[1]-1 ) : (),
5178 );
5179 1872 return qq{(?=$lower_limit)(?=$upper_limit)};
5180 }
5181 elsif (CORE::length($b) == 4) {
5182 return (
5183 6656 ▶ sprintf(join('', qw( \x%02x \x%02x \x%02x [\x30-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
Branch: 4 branches
BranchTrueFalseTotal
129 < $b[3] ? : 3328 3328 6656
48 < $b[2] ? : 3328 3328 6656
129 < $b[1] ? : 3328 3328 6656
$a[1] < 254 ? : 3328 3328 6656
5184 0x81 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x81-\x%02x] [\x30-\x39 ] )), $b[1], $b[2], $b[3]-1 ) : (),
5185 0x30 < $b[2] ? sprintf(join('', qw( \x%02x [\x30-\x%02x] [\x81-\xFE ] [\x30-\x39 ] )), $b[1], $b[2]-1 ) : (),
5186 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x30-\x39 ] [\x81-\xFE ] [\x30-\x39 ] )), $b[1]-1 ) : (),
5187 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [^\x30-\x39 ] )), $a[1]+1 ) : (),
5188 sprintf(join('', qw( \x%02x [\x%02x-\xFF] )), $a[1], $a[2] ),
5189 );
5190 }
5191 }
5192 elsif (CORE::length($a) == 4) {
5193 7072 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 4 }) 7072 0 7072
5194 0 elsif (CORE::length($b) == 4) {
5195 7072 ▶ my $lower_limit = join('|',
Branch: 3 branches
BranchTrueFalseTotal
$a[1] < 254 ? : 5200 1872 7072
$a[2] < 57 ? : 4368 2704 7072
$a[3] < 254 ? : 3952 3120 7072
5196 $a[1] < 0xFE ? sprintf(join('', qw( [\x%02x-\xFE] [\x30-\x39 ] [\x81-\xFE ] [\x30-\x39 ] )), $a[1]+1 ) : (),
5197 $a[2] < 0x39 ? sprintf(join('', qw( \x%02x [\x%02x-\x39] [\x81-\xFE ] [\x30-\x39 ] )), $a[1], $a[2]+1 ) : (),
5198 $a[3] < 0xFE ? sprintf(join('', qw( \x%02x \x%02x [\x%02x-\xFE] [\x30-\x39 ] )), $a[1], $a[2], $a[3]+1 ) : (),
5199 sprintf(join('', qw( \x%02x \x%02x \x%02x [\x%02x-\x39] )), $a[1], $a[2], $a[3], $a[4]),
5200 );
5201 7072 ▶ my $upper_limit = join('|',
Branch: 3 branches
BranchTrueFalseTotal
129 < $b[3] ? : 3952 3120 7072
48 < $b[2] ? : 4368 2704 7072
129 < $b[1] ? : 5200 1872 7072
5202 sprintf(join('', qw( \x%02x \x%02x \x%02x [\x30-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
5203 0x81 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x81-\x%02x] [\x30-\x39 ] )), $b[1], $b[2], $b[3]-1 ) : (),
5204 0x30 < $b[2] ? sprintf(join('', qw( \x%02x [\x30-\x%02x] [\x81-\xFE ] [\x30-\x39 ] )), $b[1], $b[2]-1 ) : (),
5205 0x81 < $b[1] ? sprintf(join('', qw( [\x81-\x%02x] [\x30-\x39 ] [\x81-\xFE ] [\x30-\x39 ] )), $b[1]-1 ) : (),
5206 );
5207 7072 return qq{(?=$lower_limit)(?=$upper_limit)};
5208 }
5209 }
5210  
5211 # over range of codepoint
5212 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
5213 }
5214  
5215 #---------------------------------------------------------------------
5216 # qr/ [A-Z] / for UTF-8-like encoding
5217 90127 ▶sub list_all_by_hyphen_utf8_like {
Subroutine list_all_by_hyphen_utf8_like: called CC=46 SCAR=38.5
Pod undocumented
5218 90127 my($a, $b) = @_;
5219 90127 my @a = (undef, unpack 'C*', $a);
5220 90127 my @b = (undef, unpack 'C*', $b);
5221  
5222 90127 ▶ if (0) { }
Branch: 4 branches
BranchTrueFalseTotal
if (do { CORE::length $a == 1 }) { } 9737 80390 90127
elsif (CORE::length $a == 2) { } 12692 67698 80390
elsif (CORE::length $a == 3) { } 27378 40320 67698
elsif (CORE::length $a == 4) { } 40320 0 40320
5223 elsif (CORE::length($a) == 1) {
5224 9737 ▶ if (0) { }
Branch: 4 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 1 }) { } 425 9312 9737
elsif (CORE::length $b == 2) { } 816 8496 9312
elsif (CORE::length $b == 3) { } 3376 5120 8496
elsif (CORE::length $b == 4) { } 5120 0 5120
5225 elsif (CORE::length($b) == 1) {
5226 return (
5227 425 ▶$a[1]<=$b[1] ? sprintf(join('', qw( [\x%02x-\x%02x] )), $a[1],
Branch: 1 branch
BranchTrueFalseTotal
$a[1] <= $b[1] ? : 425 0 425
5228 $b[1]) : (),
5229 );
5230 }
5231 elsif (CORE::length($b) == 2) {
5232 return (
5233 816 ▶ sprintf(join('', qw( \x%02x [\x80-\x%02x] )), $b[1], $b[2]),
Branch: 1 branch
BranchTrueFalseTotal
194 < $b[1] ? : 408 408 816
5234 0xC2 < $b[1] ? sprintf(join('', qw( [\xC2-\x%02x] [\x80-\xBF ] )), $b[1]-1 ) : (),
5235 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
5236 );
5237 }
5238 elsif (CORE::length($b) == 3) {
5239 return (
5240 3376 ▶ sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3]),
Branch: 2 branches
BranchTrueFalseTotal
128 < $b[2] ? : 2096 1280 3376
224 < $b[1] ? : 2712 664 3376
5241 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5242 0xE0 < $b[1] ? sprintf(join('', qw( [\xE0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5243 sprintf(join('', qw( [\xC2-\xDF ] [\x80-\xBF ] )), ),
5244 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
5245 );
5246 }
5247 elsif (CORE::length($b) == 4) {
5248 return (
5249 5120 ▶ sprintf(join('', qw( \x%02x \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
Branch: 3 branches
BranchTrueFalseTotal
128 < $b[3] ? : 2560 2560 5120
128 < $b[2] ? : 3296 1824 5120
240 < $b[1] ? : 3776 1344 5120
5250 0x80 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2], $b[3]-1 ) : (),
5251 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5252 0xF0 < $b[1] ? sprintf(join('', qw( [\xF0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5253 sprintf(join('', qw( [\xE0-\xEF ] [\x80-\xBF ] [\x80-\xBF ] )), ),
5254 sprintf(join('', qw( [\xC2-\xDF ] [\x80-\xBF ] )), ),
5255 sprintf(join('', qw( [\x%02x-\x7F] )), $a[1] ),
5256 );
5257 }
5258 }
5259 elsif (CORE::length($a) == 2) {
5260 12692 ▶ if (0) { }
Branch: 3 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 2 }) { } 868 11824 12692
elsif (CORE::length $b == 3) { } 6448 5376 11824
elsif (CORE::length $b == 4) { } 5376 0 5376
5261 elsif (CORE::length($b) == 2) {
5262 868 ▶ my $lower_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
$a[1] < 223 ? : 600 268 868
5263 $a[1] < 0xDF ? sprintf(join('', qw( [\x%02x-\xDF] [\x80-\xBF ] )), $a[1]+1 ) : (),
5264 sprintf(join('', qw( \x%02x [\x%02x-\xBF] )), $a[1], $a[2]),
5265 );
5266 868 ▶ my $upper_limit = join('|',
Branch: 1 branch
BranchTrueFalseTotal
194 < $b[1] ? : 600 268 868
5267 sprintf(join('', qw( \x%02x [\x80-\x%02x] )), $b[1], $b[2]),
5268 0xC2 < $b[1] ? sprintf(join('', qw( [\xC2-\x%02x] [\x80-\xBF ] )), $b[1]-1 ) : (),
5269 );
5270 868 return qq{(?=$lower_limit)(?=$upper_limit)};
5271 }
5272 elsif (CORE::length($b) == 3) {
5273 return (
5274 6448 ▶ sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3] ),
Branch: 3 branches
BranchTrueFalseTotal
128 < $b[2] ? : 3888 2560 6448
224 < $b[1] ? : 5272 1176 6448
$a[1] < 223 ? : 3224 3224 6448
5275 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5276 0xE0 < $b[1] ? sprintf(join('', qw( [\xE0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5277 $a[1] < 0xDF ? sprintf(join('', qw( [\x%02x-\xDF] [\x80-\xBF ] )), $a[1]+1 ) : (),
5278 sprintf(join('', qw( \x%02x [\x%02x-\xBF] )), $a[1], $a[2] ),
5279 );
5280 }
5281 elsif (CORE::length($b) == 4) {
5282 return (
5283 5376 ▶ sprintf(join('', qw( \x%02x \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
Branch: 4 branches
BranchTrueFalseTotal
128 < $b[3] ? : 2688 2688 5376
128 < $b[2] ? : 3552 1824 5376
240 < $b[1] ? : 3904 1472 5376
$a[1] < 223 ? : 2688 2688 5376
5284 0x80 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2], $b[3]-1 ) : (),
5285 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5286 0xF0 < $b[1] ? sprintf(join('', qw( [\xF0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5287 sprintf(join('', qw( [\xE0-\xEF ] [\x80-\xBF ] [\x80-\xBF ] )), ),
5288 $a[1] < 0xDF ? sprintf(join('', qw( [\x%02x-\xDF] [\x80-\xBF ] )), $a[1]+1 ) : (),
5289 sprintf(join('', qw( \x%02x [\x%02x-\xBF] )), $a[1], $a[2] ),
5290 );
5291 }
5292 }
5293 elsif (CORE::length($a) == 3) {
5294 27378 ▶ if (0) { }
Branch: 2 branches
BranchTrueFalseTotal
if (do { CORE::length $b == 3 }) { } 19442 7936 27378
elsif (CORE::length $b == 4) { } 7936 0 7936
5295 elsif (CORE::length($b) == 3) {
5296 19442 ▶ my $lower_limit = join('|',
Branch: 2 branches
BranchTrueFalseTotal
$a[1] < 239 ? : 18726 716 19442
$a[2] < 191 ? : 11750 7692 19442
5297 $a[1] < 0xEF ? sprintf(join('', qw( [\x%02x-\xEF] [\x80-\xBF ] [\x80-\xBF ] )), $a[1]+1 ) : (),
5298 $a[2] < 0xBF ? sprintf(join('', qw( \x%02x [\x%02x-\xBF] [\x80-\xBF ] )), $a[1], $a[2]+1 ) : (),
5299 sprintf(join('', qw( \x%02x \x%02x [\x%02x-\xBF] )), $a[1], $a[2], $a[3]),
5300 );
5301 19442 ▶ my $upper_limit = join('|',
Branch: 2 branches
BranchTrueFalseTotal
128 < $b[2] ? : 10802 8640 19442
224 < $b[1] ? : 18726 716 19442
5302 sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3]),
5303 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5304 0xE0 < $b[1] ? sprintf(join('', qw( [\xE0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5305 );
5306 19442 return qq{(?=$lower_limit)(?=$upper_limit)};
5307 }
5308 elsif (CORE::length($b) == 4) {
5309 return (
5310 7936 ▶ sprintf(join('', qw( \x%02x \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
Branch: 5 branches
BranchTrueFalseTotal
128 < $b[3] ? : 3968 3968 7936
128 < $b[2] ? : 6112 1824 7936
240 < $b[1] ? : 5184 2752 7936
$a[1] < 239 ? : 4992 2944 7936
$a[2] < 191 ? : 4224 3712 7936
5311 0x80 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2], $b[3]-1 ) : (),
5312 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5313 0xF0 < $b[1] ? sprintf(join('', qw( [\xF0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5314 $a[1] < 0xEF ? sprintf(join('', qw( [\x%02x-\xEF] [\x80-\xBF ] [\x80-\xBF ] )), $a[1]+1 ) : (),
5315 $a[2] < 0xBF ? sprintf(join('', qw( \x%02x [\x%02x-\xBF] [\x80-\xBF ] )), $a[1], $a[2]+1 ) : (),
5316 sprintf(join('', qw( \x%02x \x%02x [\x%02x-\xBF] )), $a[1], $a[2], $a[3] ),
5317 );
5318 }
5319 }
5320 elsif (CORE::length($a) == 4) {
5321 40320 ▶ if (0) { }
Branch: 1 branch
BranchTrueFalseTotal
if (do { CORE::length $b == 4 }) 40320 0 40320
5322 0 elsif (CORE::length($b) == 4) {
5323 40320 ▶ my $lower_limit = join('|',
Branch: 3 branches
BranchTrueFalseTotal
$a[1] < 244 ? : 37520 2800 40320
$a[2] < 191 ? : 23448 16872 40320
$a[3] < 191 ? : 21408 18912 40320
5324 $a[1] < 0xF4 ? sprintf(join('', qw( [\x%02x-\xF4] [\x80-\xBF ] [\x80-\xBF ] [\x80-\xBF ] )), $a[1]+1 ) : (),
5325 $a[2] < 0xBF ? sprintf(join('', qw( \x%02x [\x%02x-\xBF] [\x80-\xBF ] [\x80-\xBF ] )), $a[1], $a[2]+1 ) : (),
5326 $a[3] < 0xBF ? sprintf(join('', qw( \x%02x \x%02x [\x%02x-\xBF] [\x80-\xBF ] )), $a[1], $a[2], $a[3]+1 ) : (),
5327 sprintf(join('', qw( \x%02x \x%02x \x%02x [\x%02x-\xBF] )), $a[1], $a[2], $a[3], $a[4]),
5328 );
5329 40320 ▶ my $upper_limit = join('|',
Branch: 3 branches
BranchTrueFalseTotal
128 < $b[3] ? : 21408 18912 40320
128 < $b[2] ? : 23448 16872 40320
240 < $b[1] ? : 37520 2800 40320
5330 sprintf(join('', qw( \x%02x \x%02x \x%02x [\x80-\x%02x] )), $b[1], $b[2], $b[3], $b[4]),
5331 0x80 < $b[3] ? sprintf(join('', qw( \x%02x \x%02x [\x80-\x%02x] [\x80-\xBF ] )), $b[1], $b[2], $b[3]-1 ) : (),
5332 0x80 < $b[2] ? sprintf(join('', qw( \x%02x [\x80-\x%02x] [\x80-\xBF ] [\x80-\xBF ] )), $b[1], $b[2]-1 ) : (),
5333 0xF0 < $b[1] ? sprintf(join('', qw( [\xF0-\x%02x] [\x80-\xBF ] [\x80-\xBF ] [\x80-\xBF ] )), $b[1]-1 ) : (),
5334 );
5335 40320 return qq{(?=$lower_limit)(?=$upper_limit)};
5336 }
5337 }
5338  
5339 # over range of codepoint
5340 0 confess sprintf(qq{@{[__FILE__]}: codepoint class [$_[0]-$_[1]] is not 1 to 4 octets (%d-%d)}, CORE::length($a), CORE::length($b));
5341 }
5342 #---------------------------------------------------------------------
5343 # qr// for UTF-8 codepoint string at runtime (used by $mb{qr/.../})
5344 # ported from UTF8::R2::qr; uses mb::chr and list_all_by_hyphen_utf8_like
5345 45 ▶sub _r2_qr ($) {
Subroutine _r2_qr: called CC=93 SCAR=75.0
5346  
5347 # Local STRING form of the one-codepoint matcher, used throughout this
5348 # subroutine in place of the file-scoped qr// object $x.
5349 #
5350 # The file-scoped $x is a qr// object ($x = qr/(?>$over_ascii|...)/). On
5351 # perl 5.005_03 a qr// object loses its body when interpolated into
5352 # another pattern ("$qr" becomes "(?-xism:)" with the contents dropped),
5353 # so an embedded $x would silently degrade to a match-anything sub-pattern
5354 # in BOTH the parsing regexes below and the generated output. That makes
5355 # negative codepoint classes, hyphen-range boundaries, quantifier shortfall
5356 # and "." (without /s) over-match on old perl. A plain string interpolates
5357 # losslessly on every perl from 5.005_03 onward, so build one here.
5358 #
5359 # It is kept STRICT (ASCII tail is [\x00-\x7F], not [\x00-\xFF]): leniency
5360 # is deliberately not introduced. $over_ascii is itself a plain string.
5361 # The file-scoped qr// $x is left untouched for mb's transpile path.
5362 45 my $x = "(?>$over_ascii|[\\x00-\\x7F])";
5363  
5364 # Work on a stringified, writable copy of the argument. The caller passes
5365 # either a qr// object (from $mb{qr/.../}) or a plain string. On perl
5366 # 5.005_03 a destructive s/// applied directly to a qr// argument (or to a
5367 # read-only literal) fails ("Modification of a read-only value") or yields
5368 # an empty body, so copy "$_[0]" into a lexical first.
5369 45 my $source = "$_[0]";
5370  
5371 45 my $modifiers = '';
5372 45 ▶ if (my($m) = $source =~ /\A \( \? \^? (.*?) : /x) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($m) = $source =~ /\A \( \? \^? (.*?) : /x) 45 0 45
5373 45 $modifiers = $m;
5374 45 $modifiers =~ s/-.*//;
5375 }
5376  
5377 45 my @after = ();
5378 45 ▶ while ($source =~ s! \A (
Branch: 1 branch
BranchTrueFalseTotal
if ($source =~ s/ \A ( (?> \[ (?: \[:[^:]+?:\] | \\x\{[0123456789ABCDEFabcdef]+\} | \\c[\x00-\xFF] | (?>\\$x) | $x )+? \] ) | \\x\{[0123456789ABCDEFabcdef]+\} | \\c[\x00-\xFF] | (?>\\$x) | $x ) //x) 336 45 381
5379 (?> \[ (?: \[:[^:]+?:\] | \\x\{[0123456789ABCDEFabcdef]+\} | \\c[\x00-\xFF] | (?>\\$x) | $x )+? \] ) |
5380 \\x\{[0123456789ABCDEFabcdef]+\} | \\c[\x00-\xFF] | (?>\\$x) | $x
5381 ) !!x) {
5382 336 my $before = $1;
5383  
5384 # [^...] or [...]
5385 336 ▶ if (my($negative, $class) = $before =~ /\A \[ (\^?) ((?>\\$x|$x)+?) \] \z/x) {
Branch: 18 branches
BranchTrueFalseTotal
if (() = $before =~ /\A \[ (\^?) ((?>\\$x|$x)+?) \] \z/x) { } 12 324 336
elsif ($before eq '.') { } 4 320 324
elsif ($before eq '\\B') { } 0 320 320
elsif ($before eq '\\D') { } 0 320 320
elsif ($before eq '\\H') { } 0 320 320
elsif ($before eq '\\N') { } 0 320 320
elsif ($before eq '\\R') { } 0 320 320
elsif ($before eq '\\S') { } 0 320 320
elsif ($before eq '\\V') { } 0 320 320
elsif ($before eq '\\W') { } 0 320 320
elsif ($before eq '\\b') { } 0 320 320
elsif ($before eq '\\d') { } 1 319 320
elsif ($before eq '\\h') { } 0 319 319
elsif ($before eq '\\s') { } 1 318 319
elsif ($before eq '\\v') { } 0 318 318
elsif ($before eq '\\w') { } 1 317 318
elsif ($before =~ /\A[?+*{]\z/) { } 52 265 317
elsif ($before =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) { } 0 265 265
5386 12 my @classmate = $class =~ /\G (?: \[:.+?:\] | \\x\{[0123456789ABCDEFabcdef]+\} | (?>\\$x) | $x ) /xg;
5387 12 my @sbcs = ();
5388 12 my @xbcs = ();
5389  
5390 12 ▶ for (my $i=0; $i <= $#classmate; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#classmate) 15 12 27
5391 15 my $classmate = $classmate[$i];
5392  
5393 # hyphen of [A-Z] or [^A-Z]
5394 15 ▶ if (($i < $#classmate) and ($classmate[$i+1] eq '-')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#classmate and $classmate[$i + 1] eq '-') { } 13 2 15
Condition66%2/3
$i < $#classmate and $classmate[$i + 1] eq "-"
!ll&&!rl&&r
2013
MC/DC50%1/2
$i < $#classmate and $classmate[$i + 1] eq "-"
$i < $#classmate $classmate[$i + 1] eq "-"
Truth table66%2/3
A and B
A= $i < $#classmateB= $classmate[$i + 1] eq "-"
ABresult
0X0
100
111
5395 13 ▶ my $a = ($classmate[$i+0] =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) ? mb::chr(hex $1) : $classmate[$i+0];
Branch: 1 branch
BranchTrueFalseTotal
$classmate[$i + 0] =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x ? : 0 13 13
5396 13 ▶ my $b = ($classmate[$i+2] =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) ? mb::chr(hex $1) : $classmate[$i+2];
Branch: 1 branch
BranchTrueFalseTotal
$classmate[$i + 2] =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x ? : 0 13 13
5397 13 push @xbcs, list_all_by_hyphen_utf8_like($a, $b);
5398 13 $i += 3;
5399 }
5400  
5401 # any "one"
5402 else {
5403  
5404 # \x{UTF8hex}
5405 2 ▶ if ($classmate =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) {
Branch: 41 branches
BranchTrueFalseTotal
if ($classmate =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) { } 0 2 2
elsif ($classmate eq '\\D') { } 0 2 2
elsif ($classmate eq '\\H') { } 0 2 2
elsif ($classmate eq '\\S') { } 0 2 2
elsif ($classmate eq '\\V') { } 0 2 2
elsif ($classmate eq '\\W') { } 0 2 2
elsif ($classmate eq '\\b') { } 0 2 2
elsif ($classmate eq '\\d') { } 0 2 2
elsif ($classmate eq '\\h') { } 0 2 2
elsif ($classmate eq '\\s') { } 0 2 2
elsif ($classmate eq '\\v') { } 0 2 2
elsif ($classmate eq '\\w') { } 0 2 2
elsif ($classmate eq '[:alnum:]') { } 0 2 2
elsif ($classmate eq '[:alpha:]') { } 1 1 2
elsif ($classmate eq '[:ascii:]') { } 0 1 1
elsif ($classmate eq '[:blank:]') { } 0 1 1
elsif ($classmate eq '[:cntrl:]') { } 0 1 1
elsif ($classmate eq '[:digit:]') { } 1 0 1
elsif ($classmate eq '[:graph:]') { } 0 0 0
elsif ($classmate eq '[:lower:]') { } 0 0 0
elsif ($classmate eq '[:print:]') { } 0 0 0
elsif ($classmate eq '[:punct:]') { } 0 0 0
elsif ($classmate eq '[:space:]') { } 0 0 0
elsif ($classmate eq '[:upper:]') { } 0 0 0
elsif ($classmate eq '[:word:]') { } 0 0 0
elsif ($classmate eq '[:xdigit:]') { } 0 0 0
elsif ($classmate eq '[:^alnum:]') { } 0 0 0
elsif ($classmate eq '[:^alpha:]') { } 0 0 0
elsif ($classmate eq '[:^ascii:]') { } 0 0 0
elsif ($classmate eq '[:^blank:]') { } 0 0 0
elsif ($classmate eq '[:^cntrl:]') { } 0 0 0
elsif ($classmate eq '[:^digit:]') { } 0 0 0
elsif ($classmate eq '[:^graph:]') { } 0 0 0
elsif ($classmate eq '[:^lower:]') { } 0 0 0
elsif ($classmate eq '[:^print:]') { } 0 0 0
elsif ($classmate eq '[:^punct:]') { } 0 0 0
elsif ($classmate eq '[:^space:]') { } 0 0 0
elsif ($classmate eq '[:^upper:]') { } 0 0 0
elsif ($classmate eq '[:^word:]') { } 0 0 0
elsif ($classmate eq '[:^xdigit:]') { } 0 0 0
elsif (CORE::length $classmate == 1) { } 0 0 0
5406 0 push @xbcs, mb::chr(hex $1);
5407 }
5408  
5409 # \any
5410 0 elsif ($classmate eq '\D' ) { push @xbcs, "(?:(?![$bare_d])$x)" }
5411 0 elsif ($classmate eq '\H' ) { push @xbcs, "(?:(?![$bare_h])$x)" }
5412 # elsif ($classmate eq '\N' ) { push @xbcs, "(?:(?!\\n)$x)" } # \N in a character class must be a named character: \N{...} in regex
5413 # elsif ($classmate eq '\R' ) { push @xbcs, "(?>\\r\\n|[$bare_v])" } # Unrecognized escape \R in character class passed through in regex
5414 0 elsif ($classmate eq '\S' ) { push @xbcs, "(?:(?![$bare_s])$x)" }
5415 0 elsif ($classmate eq '\V' ) { push @xbcs, "(?:(?![$bare_v])$x)" }
5416 0 elsif ($classmate eq '\W' ) { push @xbcs, "(?:(?![$bare_w])$x)" }
5417 0 elsif ($classmate eq '\b' ) { push @sbcs, $bare_backspace }
5418 0 elsif ($classmate eq '\d' ) { push @sbcs, $bare_d }
5419 0 elsif ($classmate eq '\h' ) { push @sbcs, $bare_h }
5420 0 elsif ($classmate eq '\s' ) { push @sbcs, $bare_s }
5421 0 elsif ($classmate eq '\v' ) { push @sbcs, $bare_v }
5422 0 elsif ($classmate eq '\w' ) { push @sbcs, $bare_w }
5423  
5424 # [:POSIX:]
5425 0 elsif ($classmate eq '[:alnum:]' ) { push @sbcs, '\x30-\x39\x41-\x5A\x61-\x7A'; }
5426 1 elsif ($classmate eq '[:alpha:]' ) { push @sbcs, '\x41-\x5A\x61-\x7A'; }
5427 0 elsif ($classmate eq '[:ascii:]' ) { push @sbcs, '\x00-\x7F'; }
5428 0 elsif ($classmate eq '[:blank:]' ) { push @sbcs, '\x09\x20'; }
5429 0 elsif ($classmate eq '[:cntrl:]' ) { push @sbcs, '\x00-\x1F\x7F'; }
5430 1 elsif ($classmate eq '[:digit:]' ) { push @sbcs, '\x30-\x39'; }
5431 0 elsif ($classmate eq '[:graph:]' ) { push @sbcs, '\x21-\x7F'; }
5432 0 elsif ($classmate eq '[:lower:]' ) { push @sbcs, '\x61-\x7A'; } # /i modifier requires 'a' to 'z' literally
5433 0 elsif ($classmate eq '[:print:]' ) { push @sbcs, '\x20-\x7F'; }
5434 0 elsif ($classmate eq '[:punct:]' ) { push @sbcs, '\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E'; }
5435 0 elsif ($classmate eq '[:space:]' ) { push @sbcs, '\s\x0B'; } # "\s" and vertical tab ("\cK")
5436 0 elsif ($classmate eq '[:upper:]' ) { push @sbcs, '\x41-\x5A'; } # /i modifier requires 'A' to 'Z' literally
5437 0 elsif ($classmate eq '[:word:]' ) { push @sbcs, '\x30-\x39\x41-\x5A\x5F\x61-\x7A'; }
5438 0 elsif ($classmate eq '[:xdigit:]' ) { push @sbcs, '\x30-\x39\x41-\x46\x61-\x66'; }
5439  
5440 # [:^POSIX:]
5441 0 elsif ($classmate eq '[:^alnum:]' ) { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x5A\\x61-\\x7A])$x)"; }
5442 0 elsif ($classmate eq '[:^alpha:]' ) { push @xbcs, "(?:(?![\\x41-\\x5A\\x61-\\x7A])$x)"; }
5443 0 elsif ($classmate eq '[:^ascii:]' ) { push @xbcs, "(?:(?![\\x00-\\x7F])$x)"; }
5444 0 elsif ($classmate eq '[:^blank:]' ) { push @xbcs, "(?:(?![\\x09\\x20])$x)"; }
5445 0 elsif ($classmate eq '[:^cntrl:]' ) { push @xbcs, "(?:(?![\\x00-\\x1F\\x7F])$x)"; }
5446 0 elsif ($classmate eq '[:^digit:]' ) { push @xbcs, "(?:(?![\\x30-\\x39])$x)"; }
5447 0 elsif ($classmate eq '[:^graph:]' ) { push @xbcs, "(?:(?![\\x21-\\x7F])$x)"; }
5448 0 elsif ($classmate eq '[:^lower:]' ) { push @xbcs, "(?:(?![\\x61-\\x7A])$x)"; } # /i modifier requires 'a' to 'z' literally
5449 0 elsif ($classmate eq '[:^print:]' ) { push @xbcs, "(?:(?![\\x20-\\x7F])$x)"; }
5450 0 elsif ($classmate eq '[:^punct:]' ) { push @xbcs, "(?:(?![\\x21-\\x2F\\x3A-\\x3F\\x40\\x5B-\\x5F\\x60\\x7B-\\x7E])$x)"; }
5451 0 elsif ($classmate eq '[:^space:]' ) { push @xbcs, "(?:(?![\\s\\x0B])$x)"; } # "\s" and vertical tab ("\cK")
5452 0 elsif ($classmate eq '[:^upper:]' ) { push @xbcs, "(?:(?![\\x41-\\x5A])$x)"; } # /i modifier requires 'A' to 'Z' literally
5453 0 elsif ($classmate eq '[:^word:]' ) { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x5A\\x5F\\x61-\\x7A])$x)"; }
5454 0 elsif ($classmate eq '[:^xdigit:]') { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x46\\x61-\\x66])$x)"; }
5455  
5456 # other all
5457 0 elsif (CORE::length($classmate)==1) { push @sbcs, $classmate }
5458 0 else { push @xbcs, $classmate }
5459 2 $i += 1;
5460 }
5461 }
5462  
5463 # [^...]
5464 12 ▶ if ($negative eq q[^]) {
Branch: 2 branches
BranchTrueFalseTotal
if ($negative eq '^') { } 2 10 12
elsif ($] =~ /\A5\.006/) { } 0 10 10
5465 2 ▶ push @after,
Branch: 3 branches
BranchTrueFalseTotal
@sbcs && @xbcs ? : 0 2 2
!@sbcs && @xbcs ? : 2 0 2
@sbcs && !@xbcs ? : 0 0 0
Condition22%2/9
@sbcs and @xbcs
!ll&&!rl&&r
200
not @sbcs and @xbcs
!ll&&!rl&&r
002
@sbcs and not @xbcs
!ll&&!rl&&r
000
MC/DC0%0/2
@sbcs and @xbcs
@sbcs @xbcs
MC/DC0%0/2
not @sbcs and @xbcs
not @sbcs @xbcs
MC/DC0%0/2
@sbcs and not @xbcs
@sbcs not @xbcs
Truth table33%1/3
A and B
A= @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table33%1/3
not(A) and B
A= not @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= @sbcsB= not @xbcs
ABresult
0X0
100
111
5466 ( @sbcs and @xbcs) ? '(?:(?!' . join('|', @xbcs, '['.join('', @sbcs).']') . ")$x)" :
5467 (!@sbcs and @xbcs) ? '(?:(?!' . join('|', @xbcs ) . ")$x)" :
5468 ( @sbcs and !@xbcs) ? '(?:(?!' . '['.join('', @sbcs).']' . ")$x)" :
5469 '';
5470 }
5471  
5472 # [...] on Perl 5.006
5473 elsif ($] =~ /\A5\.006/) {
5474 0 ▶ push @after,
Branch: 3 branches
BranchTrueFalseTotal
@sbcs && @xbcs ? : 0 0 0
!@sbcs && @xbcs ? : 0 0 0
@sbcs && !@xbcs ? : 0 0 0
Condition0%0/9
@sbcs and @xbcs
!ll&&!rl&&r
000
not @sbcs and @xbcs
!ll&&!rl&&r
000
@sbcs and not @xbcs
!ll&&!rl&&r
000
MC/DC0%0/2
@sbcs and @xbcs
@sbcs @xbcs
MC/DC0%0/2
not @sbcs and @xbcs
not @sbcs @xbcs
MC/DC0%0/2
@sbcs and not @xbcs
@sbcs not @xbcs
Truth table0%0/3
A and B
A= @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table0%0/3
not(A) and B
A= not @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= @sbcsB= not @xbcs
ABresult
0X0
100
111
5475 ( @sbcs and @xbcs) ? '(?:' . join('|', @xbcs, '['.join('', @sbcs).']') . ')' :
5476 (!@sbcs and @xbcs) ? '(?:' . join('|', @xbcs ) . ')' :
5477 ( @sbcs and !@xbcs) ? '['.join('', @sbcs).']' :
5478 '';
5479 }
5480  
5481 # [...]
5482 else {
5483 10 ▶ push @after,
Branch: 3 branches
BranchTrueFalseTotal
@sbcs && @xbcs ? : 0 10 10
!@sbcs && @xbcs ? : 8 2 10
@sbcs && !@xbcs ? : 2 0 2
Condition55%5/9
@sbcs and @xbcs
!ll&&!rl&&r
820
not @sbcs and @xbcs
!ll&&!rl&&r
208
@sbcs and not @xbcs
!ll&&!rl&&r
002
MC/DC0%0/2
@sbcs and @xbcs
@sbcs @xbcs
MC/DC50%1/2
not @sbcs and @xbcs
not @sbcs @xbcs
MC/DC0%0/2
@sbcs and not @xbcs
@sbcs not @xbcs
Truth table66%2/3
A and B
A= @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table66%2/3
not(A) and B
A= not @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table33%1/3
A and not(B)
A= @sbcsB= not @xbcs
ABresult
0X0
100
111
5484 ( @sbcs and @xbcs) ? '(?:(?=' . join('|', @xbcs, '['.join('', @sbcs).']') . ")$x)" :
5485 (!@sbcs and @xbcs) ? '(?:(?=' . join('|', @xbcs ) . ")$x)" :
5486 ( @sbcs and !@xbcs) ? '['.join('', @sbcs).']' :
5487 '';
5488 }
5489 }
5490  
5491 # \any or /./
5492 4 ▶ elsif ($before eq '.' ) { push @after, ($modifiers =~ /s/) ? $x : "(?:(?!\\n)$x)" }
Branch: 1 branch
BranchTrueFalseTotal
$modifiers =~ /s/ ? : 1 3 4
5493 0 elsif ($before eq '\B') { push @after, "(?:(?<![$bare_w])(?![$bare_w])|(?<=[$bare_w])(?=[$bare_w]))" }
5494 0 elsif ($before eq '\D') { push @after, "(?:(?![$bare_d])$x)" }
5495 0 elsif ($before eq '\H') { push @after, "(?:(?![$bare_h])$x)" }
5496 0 elsif ($before eq '\N') { push @after, "(?:(?!\\n)$x)" }
5497 0 elsif ($before eq '\R') { push @after, "(?>\\r\\n|[$bare_v])" }
5498 0 elsif ($before eq '\S') { push @after, "(?:(?![$bare_s])$x)" }
5499 0 elsif ($before eq '\V') { push @after, "(?:(?![$bare_v])$x)" }
5500 0 elsif ($before eq '\W') { push @after, "(?:(?![$bare_w])$x)" }
5501 0 elsif ($before eq '\b') { push @after, "(?:(?<![$bare_w])(?=[$bare_w])|(?<=[$bare_w])(?![$bare_w]))" }
5502 1 elsif ($before eq '\d') { push @after, "[$bare_d]" }
5503 0 elsif ($before eq '\h') { push @after, "[$bare_h]" }
5504 1 elsif ($before eq '\s') { push @after, "[$bare_s]" }
5505 0 elsif ($before eq '\v') { push @after, "[$bare_v]" }
5506 1 elsif ($before eq '\w') { push @after, "[$bare_w]" }
5507  
5508 # quantifiers ? + * {n} {n,} {n,m}
5509 elsif ($before =~ /\A[?+*{]\z/) {
5510 52 ▶ if (0) { }
Branch: 4 branches
BranchTrueFalseTotal
if (do { $after[-1] =~ /\A \\c [\x00-\xFF] \z/x }) { } 0 52 52
elsif ($after[-1] =~ /\A \\ [\x00-\xFF] \z/x) { } 0 52 52
elsif ($after[-1] =~ /\A [\x00-\xFF] \z/x) { } 45 7 52
elsif ($after[-1] =~ / [\x00-\xFF] [)}\]] \z/x) { } 3 4 7
5511 elsif ($after[-1] =~ /\A \\c [\x00-\xFF] \z/x) { } # \c) \c} \c] \cX
5512 elsif ($after[-1] =~ /\A \\ [\x00-\xFF] \z/x) { } # \) \} \] \" \0 \1 \D \E \F \G \H \K \L \N \Q \R \S \U \V \W \\ \a \d \e \f \h \l \n \r \s \t \u \v \w
5513 elsif ($after[-1] =~ /\A [\x00-\xFF] \z/x) { } # (a) a{1} [a] a . \012 \x12 \o{12} \g{1}
5514 elsif ($after[-1] =~ / [\x00-\xFF] [)}\]] \z/x) { } # (any) any{1} [any]
5515 else { # XBCS
5516 4 $after[-1] = '(?:' . $after[-1] . ')';
5517 }
5518 52 push @after, $before;
5519 }
5520  
5521 # \x{UTF8hex}
5522 elsif ($before =~ /\A \\x \{ ([0123456789ABCDEFabcdef]+) \} \z/x) {
5523 0 push @after, mb::chr(hex $1);
5524 }
5525  
5526 # else
5527 else {
5528 265 push @after, $before;
5529 }
5530 }
5531  
5532 45 my $after = join '', @after;
5533  
5534 # Return a plain regular-expression STRING, not a qr// object.
5535 #
5536 # On perl 5.005_03 a qr// object, when interpolated into another pattern
5537 # (for example m<\G$mb{qr/.../}>g or s<$mb{qr/.../}><...> or even a
5538 # second =~ // after stringification) loses its body: "$qr" becomes
5539 # "(?-xism:)" with the contents dropped, so the pattern then matches
5540 # anything. A plain string interpolates losslessly on every perl from
5541 # 5.005_03 onward. The (?modifiers:...) wrapper preserves the i/m/s/x
5542 # flags that were present on the original qr/.../ token.
5543 45 ▶ if ($modifiers ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifiers ne '') { } 2 43 45
5544 2 return "(?$modifiers:$after)";
5545 }
5546 else {
5547 43 return "(?:$after)";
5548 }
5549 }
5550  
5551 #---------------------------------------------------------------------
5552 # mb::qr() - functional form of the runtime UTF-8 codepoint regex builder.
5553 # This is the same engine as $mb{qr/.../} (the tie FETCH), exposed as a
5554 # named subroutine for UTF8::R2 source compatibility:
5555 # $_ =~ mb::qr(qr/.../) is equivalent to $_ =~ $mb{qr/.../}
5556 # It returns a plain regular-expression string (see _r2_qr above for why a
5557 # string and not a qr// object, which matters on perl 5.005_03).
5558 18 ▶sub mb::qr ($) {
Subroutine qr: called CC=1 SCAR=0.0
Pod undocumented
5559 18 return _r2_qr($_[0]);
5560 }
5561  
5562 #---------------------------------------------------------------------
5563 # parse codepoint class
5564 130939 ▶sub parse_re_codepoint_class {
Subroutine parse_re_codepoint_class: called CC=70 SCAR=42.7
Pod undocumented
5565 130939 my($codepoint_class) = @_;
5566 130939 my @sbcs = ();
5567 130939 my @xbcs = (); # "xbcs" means DBCS, TBCS, QBCS, ...
5568  
5569 # get members from class
5570 130939 my @classmate = ();
5571 130939 ▶ while ($codepoint_class !~ /\G \z /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($codepoint_class =~ /\G \z /cgmsx) 390224 130939 521163
5572 390224 ▶ if (0) { }
Branch: 5 branches
BranchTrueFalseTotal
if (do { $codepoint_class =~ /\G\\o\{([01234567]+)\}/cgmsx }) { } 0 390224 390224
elsif ($codepoint_class =~ /\G\\x\{([0123456789ABCDEFabcdef]+)\}/cgmsx) { } 8 390216 390224
elsif ($codepoint_class =~ /\G(\[:.+?:\])/cgmsx) { } 492 389724 390216
elsif ($codepoint_class =~ /\G((?>\\$x))/cgmsx) { } 874 388850 389724
elsif ($codepoint_class =~ /\G($x)/cgmsx) { } 388850 0 388850
5573 elsif ($codepoint_class =~ /\G\\o\{([01234567]+)\}/xmsgc) {
5574 0 push @classmate, mb::chr(oct $1);
5575 }
5576 elsif ($codepoint_class =~ /\G\\x\{([0123456789ABCDEFabcdef]+)\}/xmsgc) {
5577 8 push @classmate, mb::chr(hex $1);
5578 }
5579 elsif ($codepoint_class =~ /\G(\[:.+?:\])/xmsgc) {
5580 492 push @classmate, $1;
5581 }
5582 elsif ($codepoint_class =~ /\G((?>\\$x))/xmsgc) {
5583 874 push @classmate, $1;
5584 }
5585 elsif ($codepoint_class =~ /\G($x)/xmsgc) {
5586 388850 push @classmate, $1;
5587 }
5588 else {
5589 0 confess qq{@{[__FILE__]}: codepoint_class=($codepoint_class), classmate=(@classmate)};
5590 }
5591 }
5592  
5593 # get regular expression for MBCS codepoint class
5594 130939 ▶ for (my $i=0; $i <= $#classmate; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#classmate) 131784 130939 262723
5595 131784 my $classmate = $classmate[$i];
5596  
5597 # hyphen of [A-Z] or [^A-Z]
5598 131784 ▶ if (($i < $#classmate) and ($classmate[$i+1] eq '-')) {
Branch: 42 branches
BranchTrueFalseTotal
if ($i < $#classmate and $classmate[$i + 1] eq '-') { } 129220 2564 131784
elsif ($classmate eq '\\D') { } 34 2530 2564
elsif ($classmate eq '\\H') { } 10 2520 2530
elsif ($classmate eq '\\S') { } 19 2501 2520
elsif ($classmate eq '\\V') { } 16 2485 2501
elsif ($classmate eq '\\W') { } 193 2292 2485
elsif ($classmate eq '\\b') { } 20 2272 2292
elsif ($classmate eq '\\d') { } 34 2238 2272
elsif ($classmate eq '\\h') { } 10 2228 2238
elsif ($classmate eq '\\s') { } 19 2209 2228
elsif ($classmate eq '\\v') { } 16 2193 2209
elsif ($classmate eq '\\w') { } 193 2000 2193
elsif ($classmate eq '[:alnum:]') { } 33 1967 2000
elsif ($classmate eq '[:alpha:]') { } 17 1950 1967
elsif ($classmate eq '[:ascii:]') { } 17 1933 1950
elsif ($classmate eq '[:blank:]') { } 17 1916 1933
elsif ($classmate eq '[:cntrl:]') { } 17 1899 1916
elsif ($classmate eq '[:digit:]') { } 17 1882 1899
elsif ($classmate eq '[:graph:]') { } 17 1865 1882
elsif ($classmate eq '[:lower:]') { } 17 1848 1865
elsif ($classmate eq '[:print:]') { } 17 1831 1848
elsif ($classmate eq '[:punct:]') { } 17 1814 1831
elsif ($classmate eq '[:space:]') { } 17 1797 1814
elsif ($classmate eq '[:upper:]') { } 17 1780 1797
elsif ($classmate eq '[:word:]') { } 17 1763 1780
elsif ($classmate eq '[:xdigit:]') { } 17 1746 1763
elsif ($classmate eq '[:^alnum:]') { } 17 1729 1746
elsif ($classmate eq '[:^alpha:]') { } 17 1712 1729
elsif ($classmate eq '[:^ascii:]') { } 17 1695 1712
elsif ($classmate eq '[:^blank:]') { } 17 1678 1695
elsif ($classmate eq '[:^cntrl:]') { } 17 1661 1678
elsif ($classmate eq '[:^digit:]') { } 17 1644 1661
elsif ($classmate eq '[:^graph:]') { } 17 1627 1644
elsif ($classmate eq '[:^lower:]') { } 17 1610 1627
elsif ($classmate eq '[:^print:]') { } 17 1593 1610
elsif ($classmate eq '[:^punct:]') { } 17 1576 1593
elsif ($classmate eq '[:^space:]') { } 17 1559 1576
elsif ($classmate eq '[:^upper:]') { } 17 1542 1559
elsif ($classmate eq '[:^word:]') { } 17 1525 1542
elsif ($classmate eq '[:^xdigit:]') { } 17 1508 1525
elsif ($classmate =~ /\G (\\) ($x) /cgmsx) { } 310 1198 1508
elsif ($classmate =~ /\G ($x) /cgmsx) { } 1198 0 1198
Condition100%3/3
$i < $#classmate and $classmate[$i + 1] eq "-"
!ll&&!rl&&r
1735829129220
MC/DC100%2/2
$i < $#classmate and $classmate[$i + 1] eq "-"
$i < $#classmate $classmate[$i + 1] eq "-"
Truth table100%3/3
A and B
A= $i < $#classmateB= $classmate[$i + 1] eq "-"
ABresult
0X0
100
111
5599 129220 my $a = $classmate[$i];
5600 129220 my $b = $classmate[$i+2];
5601 129220 ▶ if (0) { }
Branch: 9 branches
BranchTrueFalseTotal
if (do { $script_encoding =~ /\A (?: sjis ) \z/msx }) { } 8435 120785 129220
elsif ($script_encoding =~ /\A (?: informixv6als ) \z/msx) { } 3601 117184 120785
elsif ($script_encoding =~ /\A (?: eucjp ) \z/msx) { } 253 116931 117184
elsif ($script_encoding =~ /\A (?: euctw ) \z/msx) { } 1106 115825 116931
elsif ($script_encoding =~ /\A (?: hp15 ) \z/msx) { } 3601 112224 115825
elsif ($script_encoding =~ /\A (?: johab ) \z/msx) { } 3601 108623 112224
elsif ($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs ) \z/msx) { } 256 108367 108623
elsif ($script_encoding =~ /\A (?: gb18030 ) \z/msx) { } 18253 90114 108367
elsif ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/msx) { } 90114 0 90114
5602 elsif ($script_encoding =~ /\A (?: sjis ) \z/xms) {
5603 8435 push @xbcs, list_all_by_hyphen_sjis_like ($a, $b);
5604 }
5605 elsif ($script_encoding =~ /\A (?: informixv6als ) \z/xms) {
5606 3601 push @xbcs, list_all_by_hyphen_informixv6als_like($a, $b);
5607 }
5608 elsif ($script_encoding =~ /\A (?: eucjp ) \z/xms) {
5609 253 push @xbcs, list_all_by_hyphen_eucjp_like ($a, $b);
5610 }
5611 elsif ($script_encoding =~ /\A (?: euctw ) \z/xms) {
5612 1106 push @xbcs, list_all_by_hyphen_euctw_like ($a, $b);
5613 }
5614 elsif ($script_encoding =~ /\A (?: hp15 ) \z/xms) {
5615 3601 push @xbcs, list_all_by_hyphen_hp15_like ($a, $b);
5616 }
5617 elsif ($script_encoding =~ /\A (?: johab ) \z/xms) {
5618 3601 push @xbcs, list_all_by_hyphen_johab_like ($a, $b);
5619 }
5620 elsif ($script_encoding =~ /\A (?: gbk | uhc | big5 | big5hkscs ) \z/xms) {
5621 256 push @xbcs, list_all_by_hyphen_big5_like ($a, $b);
5622 }
5623 elsif ($script_encoding =~ /\A (?: gb18030 ) \z/xms) {
5624 18253 push @xbcs, list_all_by_hyphen_gb18030_like ($a, $b);
5625 }
5626 elsif ($script_encoding =~ /\A (?: rfc2279 | utf8 | wtf8 ) \z/xms) {
5627 90114 push @xbcs, list_all_by_hyphen_utf8_like ($a, $b);
5628 }
5629 else {
5630 0 push @sbcs, "$a-$b";
5631 }
5632 129220 $i += 2;
5633 }
5634  
5635 # classic perl codepoint class shortcuts
5636 34 elsif ($classmate eq '\\D') { push @xbcs, "(?:(?![$bare_d])$x)"; }
5637 10 elsif ($classmate eq '\\H') { push @xbcs, "(?:(?![$bare_h])$x)"; }
5638 # elsif ($classmate eq '\\N') { push @xbcs, "(?:(?!\\n)$x)"; } # \N in a codepoint class must be a named character: \N{...} in regex
5639 # elsif ($classmate eq '\\R') { push @xbcs, "(?>\\r\\n|[$bare_v])"; } # Unrecognized escape \R in codepoint class passed through in regex
5640 19 elsif ($classmate eq '\\S') { push @xbcs, "(?:(?![$bare_s])$x)"; }
5641 16 elsif ($classmate eq '\\V') { push @xbcs, "(?:(?![$bare_v])$x)"; }
5642 193 elsif ($classmate eq '\\W') { push @xbcs, "(?:(?![$bare_w])$x)"; }
5643 20 elsif ($classmate eq '\\b') { push @sbcs, $bare_backspace; }
5644 34 elsif ($classmate eq '\\d') { push @sbcs, $bare_d; }
5645 10 elsif ($classmate eq '\\h') { push @sbcs, $bare_h; }
5646 19 elsif ($classmate eq '\\s') { push @sbcs, $bare_s; }
5647 16 elsif ($classmate eq '\\v') { push @sbcs, $bare_v; }
5648 193 elsif ($classmate eq '\\w') { push @sbcs, $bare_w; }
5649  
5650 # [:POSIX:]
5651 33 elsif ($classmate eq '[:alnum:]' ) { push @sbcs, '\x30-\x39\x41-\x5A\x61-\x7A'; }
5652 17 elsif ($classmate eq '[:alpha:]' ) { push @sbcs, '\x41-\x5A\x61-\x7A'; }
5653 17 elsif ($classmate eq '[:ascii:]' ) { push @sbcs, '\x00-\x7F'; }
5654 17 elsif ($classmate eq '[:blank:]' ) { push @sbcs, '\x09\x20'; }
5655 17 elsif ($classmate eq '[:cntrl:]' ) { push @sbcs, '\x00-\x1F\x7F'; }
5656 17 elsif ($classmate eq '[:digit:]' ) { push @sbcs, '\x30-\x39'; }
5657 17 elsif ($classmate eq '[:graph:]' ) { push @sbcs, '\x21-\x7F'; }
5658 17 elsif ($classmate eq '[:lower:]' ) { push @sbcs, 'abcdefghijklmnopqrstuvwxyz'; } # /i modifier requires 'a' to 'z' literally
5659 17 elsif ($classmate eq '[:print:]' ) { push @sbcs, '\x20-\x7F'; }
5660 17 elsif ($classmate eq '[:punct:]' ) { push @sbcs, '\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E'; }
5661 17 elsif ($classmate eq '[:space:]' ) { push @sbcs, '\s\x0B'; } # "\s" and vertical tab ("\cK")
5662 17 elsif ($classmate eq '[:upper:]' ) { push @sbcs, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } # /i modifier requires 'A' to 'Z' literally
5663 17 elsif ($classmate eq '[:word:]' ) { push @sbcs, '\x30-\x39\x41-\x5A\x5F\x61-\x7A'; }
5664 17 elsif ($classmate eq '[:xdigit:]') { push @sbcs, '\x30-\x39\x41-\x46\x61-\x66'; }
5665  
5666 # [:^POSIX:]
5667 17 elsif ($classmate eq '[:^alnum:]' ) { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x5A\\x61-\\x7A])$x)"; }
5668 17 elsif ($classmate eq '[:^alpha:]' ) { push @xbcs, "(?:(?![\\x41-\\x5A\\x61-\\x7A])$x)"; }
5669 17 elsif ($classmate eq '[:^ascii:]' ) { push @xbcs, "(?:(?![\\x00-\\x7F])$x)"; }
5670 17 elsif ($classmate eq '[:^blank:]' ) { push @xbcs, "(?:(?![\\x09\\x20])$x)"; }
5671 17 elsif ($classmate eq '[:^cntrl:]' ) { push @xbcs, "(?:(?![\\x00-\\x1F\\x7F])$x)"; }
5672 17 elsif ($classmate eq '[:^digit:]' ) { push @xbcs, "(?:(?![\\x30-\\x39])$x)"; }
5673 17 elsif ($classmate eq '[:^graph:]' ) { push @xbcs, "(?:(?![\\x21-\\x7F])$x)"; }
5674 17 elsif ($classmate eq '[:^lower:]' ) { push @xbcs, "(?:(?![abcdefghijklmnopqrstuvwxyz])$x)"; } # /i modifier requires 'a' to 'z' literally
5675 17 elsif ($classmate eq '[:^print:]' ) { push @xbcs, "(?:(?![\\x20-\\x7F])$x)"; }
5676 17 elsif ($classmate eq '[:^punct:]' ) { push @xbcs, "(?:(?![\\x21-\\x2F\\x3A-\\x3F\\x40\\x5B-\\x5F\\x60\\x7B-\\x7E])$x)"; }
5677 17 elsif ($classmate eq '[:^space:]' ) { push @xbcs, "(?:(?![\\s\\x0B])$x)"; } # "\s" and vertical tab ("\cK")
5678 17 elsif ($classmate eq '[:^upper:]' ) { push @xbcs, "(?:(?![ABCDEFGHIJKLMNOPQRSTUVWXYZ])$x)"; } # /i modifier requires 'A' to 'Z' literally
5679 17 elsif ($classmate eq '[:^word:]' ) { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x5A\\x5F\\x61-\\x7A])$x)"; }
5680 17 elsif ($classmate eq '[:^xdigit:]') { push @xbcs, "(?:(?![\\x30-\\x39\\x41-\\x46\\x61-\\x66])$x)"; }
5681  
5682 # \any
5683 elsif ($classmate =~ /\G (\\) ($x) /xmsgc) {
5684 310 my($backslash, $escapee) = ($1, $2);
5685 310 ▶ if ($escapee =~ /\A [\x23\t\n\x0B\f\r\x20] \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($escapee =~ /\A [\x23\t\n\x0B\f\r\x20] \z/msx) { } 25 285 310
elsif (CORE::length $escapee == 1) { } 285 0 285
5686 25 push @sbcs, sprintf('\x%02X', CORE::ord($escapee));
5687 }
5688 elsif (CORE::length($escapee) == 1) {
5689 285 push @sbcs, ($backslash . $escapee);
5690 }
5691 else {
5692 0 push @xbcs, '(?:' . $backslash . escape_to_hex($escapee, ']') . ')';
5693 }
5694 }
5695  
5696 # any
5697 elsif ($classmate =~ /\G ($x) /xmsgc) {
5698 1198 my $octets = $1;
5699  
5700 # "#" and white space are written in hex, so that the generated
5701 # codepoint class means the same under /x, /xx, and /xx with
5702 # feature 'enhanced_xx' of Perl 5.44 (and makes no deprecation
5703 # warning of Perl 5.44)
5704 1198 ▶ if ($octets =~ /\A [\x23\t\n\x0B\f\r\x20] \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($octets =~ /\A [\x23\t\n\x0B\f\r\x20] \z/msx) { } 84 1114 1198
elsif (CORE::length $octets == 1) { } 749 365 1114
5705 84 push @sbcs, sprintf('\x%02X', CORE::ord($octets));
5706 }
5707 elsif (CORE::length($octets) == 1) {
5708 749 push @sbcs, $octets;
5709 }
5710 else {
5711 365 push @xbcs, '(?:' . escape_to_hex($octets, ']') . ')';
5712 }
5713 }
5714  
5715 # something wrong happened
5716 else {
5717 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
5718 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
5719 ------------------------------------------------------------------------------
5720 %s
5721 ------------------------------------------------------------------------------
5722 END
5723 }
5724 }
5725  
5726 # return codepoint class
5727 130939 ▶ my $parsed =
Branch: 3 branches
BranchTrueFalseTotal
@sbcs && @xbcs ? : 34 130905 130939
!@sbcs && @xbcs ? : 129966 939 130905
@sbcs && !@xbcs ? : 939 0 939
Condition66%6/9
@sbcs and @xbcs
!ll&&!rl&&r
12996693934
not @sbcs and @xbcs
!ll&&!rl&&r
9390129966
@sbcs and not @xbcs
!ll&&!rl&&r
00939
MC/DC100%2/2
@sbcs and @xbcs
@sbcs @xbcs
MC/DC50%1/2
not @sbcs and @xbcs
not @sbcs @xbcs
MC/DC0%0/2
@sbcs and not @xbcs
@sbcs not @xbcs
Truth table100%3/3
A and B
A= @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table66%2/3
not(A) and B
A= not @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table33%1/3
A and not(B)
A= @sbcsB= not @xbcs
ABresult
0X0
100
111
5728 ( @sbcs and @xbcs) ? join('|', @xbcs, '['.join('',@sbcs).']') :
5729 (!@sbcs and @xbcs) ? join('|', @xbcs ) :
5730 ( @sbcs and !@xbcs) ? '['.join('',@sbcs).']' :
5731 die;
5732 130939 return $parsed;
5733 }
5734  
5735 #---------------------------------------------------------------------
5736 # parse qr'regexp' as q-like
5737 1568 ▶sub parse_re_as_q_endswith {
Subroutine parse_re_as_q_endswith: called CC=45 SCAR=42.1
Pod undocumented
5738 1568 my($operator, $endswith) = @_;
5739 1568 my $parsed = $endswith;
5740 1568 local $mb::_re_x = _peek_re_x($operator, $endswith, $endswith);
5741 1568 local $mb::_re_open = $endswith;
5742 1568 local $mb::_re_close = $endswith;
5743 1568 ▶ my $enhanced_xx = ($mb::_enhanced_xx and ($mb::_re_x >= 2));
Condition66%2/3
$mb::_enhanced_xx && $mb::_re_x >= 2
!ll&&!rl&&r
156602
MC/DC50%1/2
$mb::_enhanced_xx && $mb::_re_x >= 2
$mb::_enhanced_xx $mb::_re_x >= 2
Truth table66%2/3
A && B
A= $mb::_enhanced_xxB= $mb::_re_x >= 2
ABresult
0X0
100
111
5744 1568 while (1) {
5745 3207 ▶ if (/\G (\Q$endswith\E) /xmsgc) {
Branch: 23 branches
BranchTrueFalseTotal
if (/\G (\Q$endswith\E) /cgmsx) { } 1567 1640 3207
elsif (/\G \[ /cgmsx) { } 976 664 1640
elsif (/\G \. /cgmsx) { } 16 648 664
elsif (/\G \\B /cgmsx) { } 16 632 648
elsif (/\G \\D /cgmsx) { } 26 606 632
elsif (/\G \\H /cgmsx) { } 18 588 606
elsif (/\G \\N /cgmsx) { } 16 572 588
elsif (/\G \\R /cgmsx) { } 16 556 572
elsif (/\G \\S /cgmsx) { } 21 535 556
elsif (/\G \\V /cgmsx) { } 20 515 535
elsif (/\G \\W /cgmsx) { } 79 436 515
elsif (/\G \\b /cgmsx) { } 16 420 436
elsif (/\G \\d /cgmsx) { } 26 394 420
elsif (/\G \\h /cgmsx) { } 18 376 394
elsif (/\G \\s /cgmsx) { } 21 355 376
elsif (/\G \\v /cgmsx) { } 20 335 355
elsif (/\G \\w /cgmsx) { } 79 256 335
elsif (/\G \\o\{ (.*?) \} /cgmsx) { } 0 256 256
elsif (/\G \\x\{ (.*?) \} /cgmsx) { } 0 256 256
elsif (/\G (\\ 0[1-7]*) /cgmsx) { } 0 256 256
elsif (/\G (\\ [1-3][0-7][0-7]) /cgmsx) { } 0 256 256
elsif (/\G (\\) ([1-9][0-9]*) /cgmsx) { } 0 256 256
elsif (/\G ($x) /cgmsx) { } 256 0 256
5746 1567 $parsed .= $1;
5747 1567 last;
5748 }
5749  
5750 # get codepoint class
5751 elsif (/\G \[ /xmsgc) {
5752 976 my $classmate = '';
5753 976 ▶ my $check_delimiter = ($enhanced_xx and ($mb::_re_close ne ']'));
Condition66%2/3
$enhanced_xx && $mb::_re_close ne ']'
!ll&&!rl&&r
97402
MC/DC50%1/2
$enhanced_xx && $mb::_re_close ne ']'
$enhanced_xx $mb::_re_close ne ']'
Truth table66%2/3
A && B
A= $enhanced_xxB= $mb::_re_close ne ']'
ABresult
0X0
100
111
5754 976 while (1) {
5755 2608 ▶ if (/\G \] /xmsgc) {
Branch: 12 branches
BranchTrueFalseTotal
if (/\G \] /cgmsx) { } 975 1633 2608
elsif ($check_delimiter and /\G (\\ \Q$mb::_re_close\E) /cgmsx) { } 0 1633 1633
elsif ($check_delimiter and /\G \Q$mb::_re_close\E /cgmsx) { } 1 1632 1633
elsif ($enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx) { } 1 1631 1632
elsif ($enhanced_xx and /\G \# /cgmsx) { } 2 1629 1631
elsif ($mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx) { } 4 1625 1629
elsif (/\G (\\\\) /cgmsx) { } 0 1625 1625
elsif (/\G (\\ [#\t\x20]) /cgmsx) { } 1 1624 1625
elsif (/\G (\[:\^[a-z]*:\]) /cgmsx) { } 224 1400 1624
elsif (/\G (\[:[a-z]*:\]) /cgmsx) { } 240 1160 1400
elsif (/\G ($x) /cgmsx) { } 1160 0 1160
elsif (/\G \z /cgmsx) { } 0 0 0
5756 975 last;
5757 }
5758  
5759 # use feature 'enhanced_xx'; m'[ ... ]'xx (Perl 5.44)
5760 # the close delimiter ends the regular expression even in a
5761 # codepoint class, as Perl tokenizer finds it first
5762 ▶ elsif ($check_delimiter and /\G (\\ \Q$mb::_re_close\E) /xmsgc) {
Condition66%2/3
$check_delimiter and /\G (\\ \Q$mb::_re_close\E) /cgmsx
!ll&&!rl&&r
162490
MC/DC0%0/2
$check_delimiter and /\G (\\ \Q$mb::_re_close\E) /cgmsx
$check_delimiter /\G (\\ \Q$mb::_re_close\E) /cgmsx
Truth table66%2/3
A and B
A= $check_delimiterB= /\G (\\ \Q$mb::_re_close\E) /cgmsx
ABresult
0X0
100
111
5763 0 $classmate .= $1;
5764 }
5765 ▶ elsif ($check_delimiter and /\G \Q$mb::_re_close\E /xmsgc) {
Condition100%3/3
$check_delimiter and /\G \Q$mb::_re_close\E /cgmsx
!ll&&!rl&&r
162481
MC/DC100%2/2
$check_delimiter and /\G \Q$mb::_re_close\E /cgmsx
$check_delimiter /\G \Q$mb::_re_close\E /cgmsx
Truth table100%3/3
A and B
A= $check_delimiterB= /\G \Q$mb::_re_close\E /cgmsx
ABresult
0X0
100
111
5766 1 _die_unmatched_class(pos($_) - 1);
5767 }
5768  
5769 # vertical space is ignored, and "#" starts a comment
5770 ▶ elsif ($enhanced_xx and /\G [\n\x0B\f\r]+ /xmsgc) {
Condition100%3/3
$enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx
!ll&&!rl&&r
162471
MC/DC100%2/2
$enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx
$enhanced_xx /\G [\n\x0B\f\r]+ /cgmsx
Truth table100%3/3
A and B
A= $enhanced_xxB= /\G [\n\x0B\f\r]+ /cgmsx
ABresult
0X0
100
111
5771 }
5772 ▶ elsif ($enhanced_xx and /\G \# /xmsgc) {
Condition100%3/3
$enhanced_xx and /\G \# /cgmsx
!ll&&!rl&&r
162452
MC/DC100%2/2
$enhanced_xx and /\G \# /cgmsx
$enhanced_xx /\G \# /cgmsx
Truth table100%3/3
A and B
A= $enhanced_xxB= /\G \# /cgmsx
ABresult
0X0
100
111
5773 2 _skip_re_comment(1);
5774 }
5775  
5776 # /xx ignores unescaped tab and space in codepoint class
5777 ▶ elsif (($mb::_re_x >= 2) and /\G [\t\x20]+ /xmsgc) {
Condition100%3/3
$mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx
!ll&&!rl&&r
162054
MC/DC100%2/2
$mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx
$mb::_re_x >= 2 /\G [\t\x20]+ /cgmsx
Truth table100%3/3
A and B
A= $mb::_re_x >= 2B= /\G [\t\x20]+ /cgmsx
ABresult
0X0
100
111
5778 }
5779  
5780 # \\, \#, "\ ", and "\<tab>" are kept as escaped
5781 elsif (/\G (\\\\) /xmsgc) {
5782 0 $classmate .= $1;
5783 }
5784 elsif (/\G (\\ [#\t\x20]) /xmsgc) {
5785 1 $classmate .= $1;
5786 }
5787  
5788 elsif (/\G (\[:\^[a-z]*:\]) /xmsgc) {
5789 224 $classmate .= $1;
5790 }
5791 elsif (/\G (\[:[a-z]*:\]) /xmsgc) {
5792 240 $classmate .= $1;
5793 }
5794 elsif (/\G ($x) /xmsgc) {
5795 1160 $classmate .= $1;
5796 }
5797  
5798 # end of script in a codepoint class
5799 elsif (/\G \z /xmsgc) {
5800 0 _die_unmatched_class(pos($_));
5801 }
5802  
5803 # something wrong happened
5804 else {
5805 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
5806 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
5807 ------------------------------------------------------------------------------
5808 %s
5809 ------------------------------------------------------------------------------
5810 END
5811 }
5812 }
5813  
5814 # parse codepoint class
5815 975 $parsed .= mb::_cc($classmate);
5816 }
5817  
5818 # /./ or \any
5819 16 elsif (/\G \. /xmsgc) { $parsed .= "(?:$over_ascii|.)"; } # after $over_ascii, /s modifier wants "." (not [\x00-\xFF])
5820 16 elsif (/\G \\B /xmsgc) { $parsed .= "(?:(?<![$bare_w])(?![$bare_w])|(?<=[$bare_w])(?=[$bare_w]))"; }
5821 26 elsif (/\G \\D /xmsgc) { $parsed .= "(?:(?![$bare_d])$x)"; }
5822 18 elsif (/\G \\H /xmsgc) { $parsed .= "(?:(?![$bare_h])$x)"; }
5823 16 elsif (/\G \\N /xmsgc) { $parsed .= "(?:(?!\\n)$x)"; }
5824 16 elsif (/\G \\R /xmsgc) { $parsed .= "(?>\\r\\n|[$bare_v])"; }
5825 21 elsif (/\G \\S /xmsgc) { $parsed .= "(?:(?![$bare_s])$x)"; }
5826 20 elsif (/\G \\V /xmsgc) { $parsed .= "(?:(?![$bare_v])$x)"; }
5827 79 elsif (/\G \\W /xmsgc) { $parsed .= "(?:(?![$bare_w])$x)"; }
5828 16 elsif (/\G \\b /xmsgc) { $parsed .= "(?:(?<![$bare_w])(?=[$bare_w])|(?<=[$bare_w])(?![$bare_w]))"; }
5829 26 elsif (/\G \\d /xmsgc) { $parsed .= "[$bare_d]"; }
5830 18 elsif (/\G \\h /xmsgc) { $parsed .= "[$bare_h]"; }
5831 21 elsif (/\G \\s /xmsgc) { $parsed .= "[$bare_s]"; }
5832 20 elsif (/\G \\v /xmsgc) { $parsed .= "[$bare_v]"; }
5833 79 elsif (/\G \\w /xmsgc) { $parsed .= "[$bare_w]"; }
5834  
5835 # \o{...}
5836 elsif (/\G \\o\{ (.*?) \} /xmsgc) {
5837 0 $parsed .= '(?:';
5838 0 $parsed .= escape_to_hex(mb::chr(oct $1), $endswith);
5839 0 $parsed .= ')';
5840 }
5841  
5842 # \x{...}
5843 elsif (/\G \\x\{ (.*?) \} /xmsgc) {
5844 0 $parsed .= '(?:';
5845 0 $parsed .= escape_to_hex(mb::chr(hex $1), $endswith);
5846 0 $parsed .= ')';
5847 }
5848  
5849 # \0... octal escape
5850 elsif (/\G (\\ 0[1-7]*) /xmsgc) {
5851 0 $parsed .= $1;
5852 }
5853  
5854 # \100...\x377 octal escape
5855 elsif (/\G (\\ [1-3][0-7][0-7]) /xmsgc) {
5856 0 $parsed .= $1;
5857 }
5858  
5859 # \1...\99, ... n-th previously captured string (decimal)
5860 elsif (/\G (\\) ([1-9][0-9]*) /xmsgc) {
5861 0 $parsed .= $1;
5862 0 ▶ if ($operator eq 's') {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq 's') { } 0 0 0
5863 0 $parsed .= ($2 + 1);
5864 }
5865 else {
5866 0 $parsed .= $2;
5867 }
5868 }
5869  
5870 # any
5871 elsif (/\G ($x) /xmsgc) {
5872 256 ▶ if (CORE::length($1) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $1 == 1) { } 111 145 256
5873 111 $parsed .= $1;
5874 }
5875 else {
5876 145 $parsed .= '(?:';
5877 145 $parsed .= escape_to_hex($1, $endswith);
5878 145 $parsed .= ')';
5879 }
5880 }
5881  
5882 # something wrong happened
5883 else {
5884 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
5885 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
5886 ------------------------------------------------------------------------------
5887 %s
5888 ------------------------------------------------------------------------------
5889 END
5890 }
5891 }
5892 1567 return $parsed;
5893 }
5894  
5895 #---------------------------------------------------------------------
5896 # parse qr{regexp} in balanced blackets
5897 628 ▶sub parse_re_balanced {
Subroutine parse_re_balanced: called CC=21 SCAR=36.9
Pod undocumented
5898 628 my($operator, $open_bracket) = @_;
5899 628 ▶ my $close_bracket = {qw| ( ) { } [ ] < > |}->{$open_bracket} || die;
Condition33%1/3
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
l!l
62800
MC/DC0%0/1
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket} || die()
{'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Truth table50%1/2
A
A= {'(', ')', '{', '}', '[', ']', '<', '>'}->{$open_bracket}
Aresult
11
00
5900 628 my $parsed = $open_bracket;
5901 628 my $nest_bracket = 1;
5902 628 my $nest_escape = 0;
5903 628 local $mb::_re_x = _peek_re_x($operator, $open_bracket, $close_bracket);
5904 628 local $mb::_re_open = $open_bracket;
5905 628 my $in_quotemeta = 0;
5906 628 local $mb::_re_close = $close_bracket;
5907 628 while (1) {
5908 1383 ▶ if (/\G (\Q$open_bracket\E) /xmsgc) {
Branch: 13 branches
BranchTrueFalseTotal
if (/\G (\Q$open_bracket\E) /cgmsx) { } 2 1381 1383
elsif (/\G (\Q$close_bracket\E) /cgmsx) { } 629 752 1381
elsif (/\G \\L \\u /cgmsx) { } 0 752 752
elsif (/\G \\U \\l /cgmsx) { } 0 752 752
elsif (/\G \\L /cgmsx) { } 0 752 752
elsif (/\G \\U /cgmsx) { } 0 752 752
elsif (/\G \\l /cgmsx) { } 0 752 752
elsif (/\G \\u /cgmsx) { } 0 752 752
elsif (/\G \\Q /cgmsx) { } 2 750 752
elsif (/\G \\E /cgmsx) { } 2 748 750
elsif ($in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx) { } 0 748 748
elsif ($in_quotemeta and /\G (\\) ($x) /cgmsx) { } 1 747 748
elsif ($in_quotemeta) { } 2 745 747
5909 2 $parsed .= $1;
5910 2 $nest_bracket++;
5911 }
5912 elsif (/\G (\Q$close_bracket\E) /xmsgc) {
5913 629 ▶ if (--$nest_bracket <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest_bracket <= 0) { } 627 2 629
5914 627 $parsed .= ('>)]}' x $nest_escape);
5915 627 $parsed .= $1;
5916 627 last;
5917 }
5918 else {
5919 2 $parsed .= $1;
5920 }
5921 }
5922  
5923 # \L\u --> \u\L
5924 elsif (/\G \\L \\u /xmsgc) {
5925 0 $parsed .= '@{[mb::ucfirst(qq<';
5926 0 $parsed .= '@{[mb::lc(qq<';
5927 0 $nest_escape++;
5928 0 $nest_escape++;
5929 }
5930  
5931 # \U\l --> \l\U
5932 elsif (/\G \\U \\l /xmsgc) {
5933 0 $parsed .= '@{[mb::lcfirst(qq<';
5934 0 $parsed .= '@{[mb::uc(qq<';
5935 0 $nest_escape++;
5936 0 $nest_escape++;
5937 }
5938  
5939 # \L
5940 elsif (/\G \\L /xmsgc) {
5941 0 $parsed .= '@{[mb::lc(qq<';
5942 0 $nest_escape++;
5943 }
5944  
5945 # \U
5946 elsif (/\G \\U /xmsgc) {
5947 0 $parsed .= '@{[mb::uc(qq<';
5948 0 $nest_escape++;
5949 }
5950  
5951 # \l
5952 elsif (/\G \\l /xmsgc) {
5953 0 $parsed .= '@{[mb::lcfirst(qq<';
5954 0 $nest_escape++;
5955 }
5956  
5957 # \u
5958 elsif (/\G \\u /xmsgc) {
5959 0 $parsed .= '@{[mb::ucfirst(qq<';
5960 0 $nest_escape++;
5961 }
5962  
5963 # \Q
5964 elsif (/\G \\Q /xmsgc) {
5965 2 $parsed .= '@{[quotemeta(qq<';
5966 2 $nest_escape++;
5967 2 $in_quotemeta = 1;
5968 }
5969  
5970 # \E
5971 elsif (/\G \\E /xmsgc) {
5972 2 $parsed .= ('>)]}' x $nest_escape);
5973 2 $nest_escape = 0;
5974 2 $in_quotemeta = 0;
5975 }
5976  
5977 # \Q...\E quotes a string, not a regular expression: "." and "["
5978 # in it are literal characters (mb 0.66 and older transpiled them
5979 # as a regular expression, then quoted the result)
5980 #
5981 # under /x, Perl tokenizer copies "#" up to the end of line as-is
5982 # (even "\E" in it is not recognized), and the copy is quoted
5983 ▶ elsif ($in_quotemeta and ($mb::_re_x >= 1) and /\G \# /xmsgc) {
Condition50%3/6
$in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx
!ll&&!rl&&r
74800
$in_quotemeta and $mb::_re_x >= 1
!ll&&!rl&&r
74530
MC/DC0%0/3
$in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx
$in_quotemeta $mb::_re_x >= 1 /\G \# /cgmsx
Truth table50%2/4
A and B and C
A= $in_quotemetaB= $mb::_re_x >= 1C= /\G \# /cgmsx
ABCresult
0XX0
10X0
1100
1111
5984 0 $parsed .= '#' . _quote_re_comment_as_qq();
5985 }
5986 # in \Q...\E of a regular expression, a backslash and the next
5987 # character are both literal (qr/\Q\n\E/ is qr/\\n/), except an
5988 # escaped delimiter of non-bracket, which is the delimiter itself
5989 ▶ elsif ($in_quotemeta and /\G (\\) ($x) /xmsgc) {
Condition100%3/3
$in_quotemeta and /\G (\\) ($x) /cgmsx
!ll&&!rl&&r
74521
MC/DC100%2/2
$in_quotemeta and /\G (\\) ($x) /cgmsx
$in_quotemeta /\G (\\) ($x) /cgmsx
Truth table100%3/3
A and B
A= $in_quotemetaB= /\G (\\) ($x) /cgmsx
ABresult
0X0
100
111
5990 1 my $escapee = $2;
5991 1 ▶ if (($mb::_re_open eq $mb::_re_close) and ($escapee eq $mb::_re_close)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close) { } 0 1 1
Condition33%1/3
$mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close
!ll&&!rl&&r
100
MC/DC0%0/2
$mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close
$mb::_re_open eq $mb::_re_close $escapee eq $mb::_re_close
Truth table33%1/3
A and B
A= $mb::_re_open eq $mb::_re_closeB= $escapee eq $mb::_re_close
ABresult
0X0
100
111
5992 0 $parsed .= _qq_literal($escapee);
5993 }
5994 else {
5995 1 $parsed .= '\\\\' . _qq_literal($escapee);
5996 }
5997 }
5998 elsif ($in_quotemeta) {
5999 2 my($as_qq) = parse_qq_like($close_bracket);
6000  
6001 2 $parsed .= $as_qq;
6002 }
6003  
6004 else {
6005 745 $parsed .= parse_re($operator, $open_bracket);
6006 }
6007 }
6008 627 return $parsed;
6009 }
6010  
6011 #---------------------------------------------------------------------
6012 # parse qr/regexp/ that ends with a character
6013 19591 ▶sub parse_re_endswith {
Subroutine parse_re_endswith: called CC=18 SCAR=32.4
Pod undocumented
6014 19591 my($operator, $endswith) = @_;
6015 19591 my $parsed = $endswith;
6016 19591 my $nest_escape = 0;
6017 19591 local $mb::_re_x = _peek_re_x($operator, $endswith, $endswith);
6018 19591 local $mb::_re_open = $endswith;
6019 19591 my $in_quotemeta = 0;
6020 19591 local $mb::_re_close = $endswith;
6021 19591 while (1) {
6022 40962 ▶ if (/\G (\Q$endswith\E) /xmsgc) {
Branch: 12 branches
BranchTrueFalseTotal
if (/\G (\Q$endswith\E) /cgmsx) { } 19587 21375 40962
elsif (/\G \\L \\u /cgmsx) { } 0 21375 21375
elsif (/\G \\U \\l /cgmsx) { } 0 21375 21375
elsif (/\G \\L /cgmsx) { } 0 21375 21375
elsif (/\G \\U /cgmsx) { } 0 21375 21375
elsif (/\G \\l /cgmsx) { } 0 21375 21375
elsif (/\G \\u /cgmsx) { } 0 21375 21375
elsif (/\G \\Q /cgmsx) { } 18 21357 21375
elsif (/\G \\E /cgmsx) { } 16 21341 21357
elsif ($in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx) { } 2 21339 21341
elsif ($in_quotemeta and /\G (\\) ($x) /cgmsx) { } 5 21334 21339
elsif ($in_quotemeta) { } 19 21315 21334
6023 19587 $parsed .= ('>)]}' x $nest_escape);
6024 19587 $parsed .= $1;
6025 19587 last;
6026 }
6027  
6028 # \L\u --> \u\L
6029 elsif (/\G \\L \\u /xmsgc) {
6030 0 $parsed .= '@{[mb::ucfirst(qq<';
6031 0 $parsed .= '@{[mb::lc(qq<';
6032 0 $nest_escape++;
6033 0 $nest_escape++;
6034 }
6035  
6036 # \U\l --> \l\U
6037 elsif (/\G \\U \\l /xmsgc) {
6038 0 $parsed .= '@{[mb::lcfirst(qq<';
6039 0 $parsed .= '@{[mb::uc(qq<';
6040 0 $nest_escape++;
6041 0 $nest_escape++;
6042 }
6043  
6044 # \L
6045 elsif (/\G \\L /xmsgc) {
6046 0 $parsed .= '@{[mb::lc(qq<';
6047 0 $nest_escape++;
6048 }
6049  
6050 # \U
6051 elsif (/\G \\U /xmsgc) {
6052 0 $parsed .= '@{[mb::uc(qq<';
6053 0 $nest_escape++;
6054 }
6055  
6056 # \l
6057 elsif (/\G \\l /xmsgc) {
6058 0 $parsed .= '@{[mb::lcfirst(qq<';
6059 0 $nest_escape++;
6060 }
6061  
6062 # \u
6063 elsif (/\G \\u /xmsgc) {
6064 0 $parsed .= '@{[mb::ucfirst(qq<';
6065 0 $nest_escape++;
6066 }
6067  
6068 # \Q
6069 elsif (/\G \\Q /xmsgc) {
6070 18 $parsed .= '@{[quotemeta(qq<';
6071 18 $nest_escape++;
6072 18 $in_quotemeta = 1;
6073 }
6074  
6075 # \E
6076 elsif (/\G \\E /xmsgc) {
6077 16 $parsed .= ('>)]}' x $nest_escape);
6078 16 $nest_escape = 0;
6079 16 $in_quotemeta = 0;
6080 }
6081  
6082 # \Q...\E quotes a string, not a regular expression: "." and "["
6083 # in it are literal characters (mb 0.66 and older transpiled them
6084 # as a regular expression, then quoted the result)
6085 #
6086 # under /x, Perl tokenizer copies "#" up to the end of line as-is
6087 # (even "\E" in it is not recognized), and the copy is quoted
6088 ▶ elsif ($in_quotemeta and ($mb::_re_x >= 1) and /\G \# /xmsgc) {
Condition100%6/6
$in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx
!ll&&!rl&&r
2133632
$in_quotemeta and $mb::_re_x >= 1
!ll&&!rl&&r
21315215
MC/DC100%3/3
$in_quotemeta and $mb::_re_x >= 1 and /\G \# /cgmsx
$in_quotemeta $mb::_re_x >= 1 /\G \# /cgmsx
Truth table100%4/4
A and B and C
A= $in_quotemetaB= $mb::_re_x >= 1C= /\G \# /cgmsx
ABCresult
0XX0
10X0
1100
1111
6089 2 $parsed .= '#' . _quote_re_comment_as_qq();
6090 }
6091 # in \Q...\E of a regular expression, a backslash and the next
6092 # character are both literal (qr/\Q\n\E/ is qr/\\n/), except an
6093 # escaped delimiter of non-bracket, which is the delimiter itself
6094 ▶ elsif ($in_quotemeta and /\G (\\) ($x) /xmsgc) {
Condition100%3/3
$in_quotemeta and /\G (\\) ($x) /cgmsx
!ll&&!rl&&r
21315195
MC/DC100%2/2
$in_quotemeta and /\G (\\) ($x) /cgmsx
$in_quotemeta /\G (\\) ($x) /cgmsx
Truth table100%3/3
A and B
A= $in_quotemetaB= /\G (\\) ($x) /cgmsx
ABresult
0X0
100
111
6095 5 my $escapee = $2;
6096 5 ▶ if (($mb::_re_open eq $mb::_re_close) and ($escapee eq $mb::_re_close)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close) { } 1 4 5
Condition66%2/3
$mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close
!ll&&!rl&&r
041
MC/DC50%1/2
$mb::_re_open eq $mb::_re_close and $escapee eq $mb::_re_close
$mb::_re_open eq $mb::_re_close $escapee eq $mb::_re_close
Truth table66%2/3
A and B
A= $mb::_re_open eq $mb::_re_closeB= $escapee eq $mb::_re_close
ABresult
0X0
100
111
6097 1 $parsed .= _qq_literal($escapee);
6098 }
6099 else {
6100 4 $parsed .= '\\\\' . _qq_literal($escapee);
6101 }
6102 }
6103 elsif ($in_quotemeta) {
6104 19 my($as_qq) = parse_qq_like($endswith);
6105  
6106 19 $parsed .= $as_qq;
6107 }
6108  
6109 else {
6110 21315 $parsed .= parse_re($operator, $endswith);
6111 }
6112 }
6113 19587 return $parsed;
6114 }
6115  
6116 #---------------------------------------------------------------------
6117 # parse qr/regexp/ common routine
6118 22060 ▶sub parse_re {
Subroutine parse_re: called CC=74 SCAR=47.5
Pod undocumented
6119 22060 my($operator, $closewith) = @_;
6120 22060 my $parsed = '';
6121  
6122 # codepoint class
6123 22060 ▶ if (/\G \[ /xmsgc) {
Branch: 36 branches
BranchTrueFalseTotal
if (/\G \[ /cgmsx) { } 17883 4177 22060
elsif (/\G \( \? \# /cgmsx) { } 2 4175 4177
elsif (/\G ( \\c [\x00-\x7F] ) /cgmsx) { } 1 4174 4175
elsif (/\G ( \$\# ) (?= [\{\$A-Za-z_:] ) /cgmsx) { } 2 4172 4174
elsif (CORE::substr($_, pos $_, 2) eq '$\\' and CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close) { } 3 4169 4172
elsif ($mb::_re_x >= 1 and /\G \# /cgmsx) { } 5 4164 4169
elsif (/\G \. /cgmsx) { } 48 4116 4164
elsif (/\G \\B /cgmsx) { } 8 4108 4116
elsif (/\G \\D /cgmsx) { } 19 4089 4108
elsif (/\G \\H /cgmsx) { } 11 4078 4089
elsif (/\G \\N /cgmsx) { } 9 4069 4078
elsif (/\G \\R /cgmsx) { } 13 4056 4069
elsif (/\G \\S /cgmsx) { } 15 4041 4056
elsif (/\G \\V /cgmsx) { } 13 4028 4041
elsif (/\G \\W /cgmsx) { } 72 3956 4028
elsif (/\G \\b /cgmsx) { } 8 3948 3956
elsif (/\G \\d /cgmsx) { } 18 3930 3948
elsif (/\G \\h /cgmsx) { } 11 3919 3930
elsif (/\G \\s /cgmsx) { } 19 3900 3919
elsif (/\G \\v /cgmsx) { } 15 3885 3900
elsif (/\G \\w /cgmsx) { } 71 3814 3885
elsif (/\G \\o\{ (.*?) \} /cgmsx) { } 0 3814 3814
elsif (/\G \\x\{ (.*?) \} /cgmsx) { } 0 3814 3814
elsif (/\G (\\ 0[1-7]*) /cgmsx) { } 0 3814 3814
elsif (/\G (\\ [1-3][0-7][0-7]) /cgmsx) { } 0 3814 3814
elsif (/\G (\\) ([1-9][0-9]*) /cgmsx) { } 24 3790 3814
elsif (/\G (\\) ($x) /cgmsx) { } 270 3520 3790
elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /cgmsx) { } 0 3520 3520
elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /cgmsx) { } 0 3520 3520
elsif (/\G \$ ([1-9][0-9]*) /cgmsx) { } 24 3496 3520
elsif (/\G \$\{\^CAPTURE\} \s* (\[) /cgmsx) { } 0 3496 3496
elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /cgmsx) { } 0 3496 3496
elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /cgmsx) { } 0 3496 3496
elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /cgmsx) { } 0 3496 3496
elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /cgmsx) { } 0 3496 3496
elsif (/\G ($x) /cgmsx) { } 3496 0 3496
6124 17883 my $classmate = '';
6125 17883 ▶ my $enhanced_xx = ($mb::_enhanced_xx and ($mb::_re_x >= 2));
Condition100%3/3
$mb::_enhanced_xx && $mb::_re_x >= 2
!ll&&!rl&&r
17841141
MC/DC100%2/2
$mb::_enhanced_xx && $mb::_re_x >= 2
$mb::_enhanced_xx $mb::_re_x >= 2
Truth table100%3/3
A && B
A= $mb::_enhanced_xxB= $mb::_re_x >= 2
ABresult
0X0
100
111
6126 17883 ▶ my $check_delimiter = ($enhanced_xx and ($mb::_re_close ne ']'));
Condition66%2/3
$enhanced_xx && $mb::_re_close ne ']'
!ll&&!rl&&r
17842041
MC/DC50%1/2
$enhanced_xx && $mb::_re_close ne ']'
$enhanced_xx $mb::_re_close ne ']'
Truth table66%2/3
A && B
A= $enhanced_xxB= $mb::_re_close ne ']'
ABresult
0X0
100
111
6127 17883 my $nest_delimiter = 0;
6128 17883 while (1) {
6129 78126 ▶ if (/\G \] /xmsgc) {
Branch: 16 branches
BranchTrueFalseTotal
if (/\G \] /cgmsx) { } 17878 60248 78126
elsif ($mb::_re_close ne '' and $mb::_re_close ne ']' and /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /cgmsx) { } 129 60119 60248
elsif ($check_delimiter and $mb::_re_open ne $mb::_re_close and /\G (\Q$mb::_re_open\E) /cgmsx) { } 2 60117 60119
elsif ($check_delimiter and /\G (\Q$mb::_re_close\E) /cgmsx) { } 5 60112 60117
elsif ($enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx) { } 34 60078 60112
elsif ($enhanced_xx and /\G \# /cgmsx) { } 35 60043 60078
elsif ($mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx) { } 137 59906 60043
elsif (/\G \\\\ /cgmsx) { } 7 59899 59906
elsif (/\G \\\# /cgmsx) { } 1 59898 59899
elsif (/\G \\ ([\[\]]) /cgmsx) { } 4 59894 59898
elsif (/\G \\ ([\t\x20]) /cgmsx) { } 2 59892 59894
elsif (/\G (\\) /cgmsx) { } 511 59381 59892
elsif (/\G (\[:\^[a-z]*:\]) /cgmsx) { } 112 59269 59381
elsif (/\G (\[:[a-z]*:\]) /cgmsx) { } 128 59141 59269
elsif (/\G ($x) /cgmsx) { } 59139 2 59141
elsif (/\G \z /cgmsx) { } 2 0 2
6130 17878 last;
6131 }
6132  
6133 # an escaped delimiter (\/ of m/.../, \} of m{...}, \# of m#...#)
6134 # is written as \\\x2F (etc.): qq[...] still gives "\/" to
6135 # mb::_cc, and the transpiled script has no delimiter octet
6136 # there to close the transpiled qr/.../ (mb 0.67 before this fix
6137 # wrote \\/, and the transpiled script of m/[^\/]/ was broken).
6138 # It is not written as \\\/ either: the transpiled qr{...} is
6139 # nested in m{...}, and Perl 5.005_03 removes the backslash of
6140 # \} at the outer level, so the inner qr{...} was closed early;
6141 # \[ and \] are written below
6142 ▶ elsif (($mb::_re_close ne '') and ($mb::_re_close ne ']') and /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /xmsgc) {
Condition50%3/6
$mb::_re_close ne "" and $mb::_re_close ne "]" and /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /cgmsx
!ll&&!rl&&r
060119129
$mb::_re_close ne "" and $mb::_re_close ne "]"
!ll&&!rl&&r
0060248
MC/DC33%1/3
$mb::_re_close ne "" and $mb::_re_close ne "]" and /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /cgmsx
$mb::_re_close ne "" $mb::_re_close ne "]" /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /cgmsx
Truth table50%2/4
A and B and C
A= $mb::_re_close ne ""B= $mb::_re_close ne "]"C= /\G \\ (\Q$mb::_re_open\E|\Q$mb::_re_close\E) /cgmsx
ABCresult
0XX0
10X0
1100
1111
6143 129 $classmate .= "\\\\" . CORE::sprintf('\\x%02X', CORE::ord($1));
6144 }
6145  
6146 # use feature 'enhanced_xx'; m/[ ... ]/xx (Perl 5.44)
6147 # the close delimiter ends the regular expression even in a
6148 # codepoint class, as Perl tokenizer finds it first (balanced
6149 # brackets nest); typically a comment absorbed the "]"
6150 ▶ elsif ($check_delimiter and ($mb::_re_open ne $mb::_re_close) and /\G (\Q$mb::_re_open\E) /xmsgc) {
Condition100%6/6
$check_delimiter and $mb::_re_open ne $mb::_re_close and /\G (\Q$mb::_re_open\E) /cgmsx
!ll&&!rl&&r
60088292
$check_delimiter and $mb::_re_open ne $mb::_re_close
!ll&&!rl&&r
5990917931
MC/DC100%3/3
$check_delimiter and $mb::_re_open ne $mb::_re_close and /\G (\Q$mb::_re_open\E) /cgmsx
$check_delimiter $mb::_re_open ne $mb::_re_close /\G (\Q$mb::_re_open\E) /cgmsx
Truth table100%4/4
A and B and C
A= $check_delimiterB= $mb::_re_open ne $mb::_re_closeC= /\G (\Q$mb::_re_open\E) /cgmsx
ABCresult
0XX0
10X0
1100
1111
6151 2 $nest_delimiter++;
6152 2 $classmate .= escape_qq($1, ']');
6153 }
6154 ▶ elsif ($check_delimiter and /\G (\Q$mb::_re_close\E) /xmsgc) {
Condition100%3/3
$check_delimiter and /\G (\Q$mb::_re_close\E) /cgmsx
!ll&&!rl&&r
599092035
MC/DC100%2/2
$check_delimiter and /\G (\Q$mb::_re_close\E) /cgmsx
$check_delimiter /\G (\Q$mb::_re_close\E) /cgmsx
Truth table100%3/3
A and B
A= $check_delimiterB= /\G (\Q$mb::_re_close\E) /cgmsx
ABresult
0X0
100
111
6155 5 ▶ if ($nest_delimiter <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nest_delimiter <= 0) 3 2 5
6156 3 _die_unmatched_class(pos($_) - 1);
6157 }
6158 2 $nest_delimiter--;
6159 2 $classmate .= escape_qq($1, ']');
6160 }
6161  
6162 # vertical space is ignored, and "#" starts a comment
6163 ▶ elsif ($enhanced_xx and /\G [\n\x0B\f\r]+ /xmsgc) {
Condition100%3/3
$enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx
!ll&&!rl&&r
5990916934
MC/DC100%2/2
$enhanced_xx and /\G [\n\x0B\f\r]+ /cgmsx
$enhanced_xx /\G [\n\x0B\f\r]+ /cgmsx
Truth table100%3/3
A and B
A= $enhanced_xxB= /\G [\n\x0B\f\r]+ /cgmsx
ABresult
0X0
100
111
6164 }
6165 ▶ elsif ($enhanced_xx and /\G \# /xmsgc) {
Condition100%3/3
$enhanced_xx and /\G \# /cgmsx
!ll&&!rl&&r
5990913435
MC/DC100%2/2
$enhanced_xx and /\G \# /cgmsx
$enhanced_xx /\G \# /cgmsx
Truth table100%3/3
A and B
A= $enhanced_xxB= /\G \# /cgmsx
ABresult
0X0
100
111
6166 35 _skip_re_comment(1);
6167 }
6168  
6169 # /xx ignores unescaped tab and space in codepoint class
6170 ▶ elsif (($mb::_re_x >= 2) and /\G [\t\x20]+ /xmsgc) {
Condition100%3/3
$mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx
!ll&&!rl&&r
59484422137
MC/DC100%2/2
$mb::_re_x >= 2 and /\G [\t\x20]+ /cgmsx
$mb::_re_x >= 2 /\G [\t\x20]+ /cgmsx
Truth table100%3/3
A and B
A= $mb::_re_x >= 2B= /\G [\t\x20]+ /cgmsx
ABresult
0X0
100
111
6171 }
6172  
6173 # \\ and \# (an escaped "#" never starts a comment)
6174 elsif (/\G \\\\ /xmsgc) {
6175 7 $classmate .= "\\\\\\\\";
6176 }
6177 elsif (/\G \\\# /xmsgc) {
6178 1 $classmate .= "\\\\#";
6179 }
6180  
6181 # \] and \[ (an escaped "]" never closes the class; they are
6182 # written as \\\] and \\\[ to keep qq[...] balanced)
6183 elsif (/\G \\ ([\[\]]) /xmsgc) {
6184 4 $classmate .= "\\\\\\$1";
6185 }
6186  
6187 # "\ " and "\<tab>" --> \x{20} and \x{09}, so that /xx never
6188 # removes them later
6189 elsif (/\G \\ ([\t\x20]) /xmsgc) {
6190 2 $classmate .= sprintf('\\\\x{%02X}', CORE::ord($1));
6191 }
6192  
6193 elsif (/\G (\\) /xmsgc) {
6194 511 $classmate .= "\\$1";
6195 }
6196 elsif (/\G (\[:\^[a-z]*:\]) /xmsgc) {
6197 112 $classmate .= $1;
6198 }
6199 elsif (/\G (\[:[a-z]*:\]) /xmsgc) {
6200 128 $classmate .= $1;
6201 }
6202 elsif (/\G ($x) /xmsgc) {
6203 59139 $classmate .= escape_qq($1, ']');
6204 }
6205  
6206 # end of script in a codepoint class
6207 elsif (/\G \z /xmsgc) {
6208 2 _die_unmatched_class(pos($_));
6209 }
6210  
6211 # something wrong happened
6212 else {
6213 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
6214 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
6215 ------------------------------------------------------------------------------
6216 %s
6217 ------------------------------------------------------------------------------
6218 END
6219 }
6220 }
6221  
6222 # quote by (?: ... ) to avoid syntax error: Can't coerce array into hash at ...
6223 #
6224 # [ABC]{3} --> @{[mb::_cc(qq[ABC])]}{3} # makes: Can't coerce array into hash at ...
6225 # [ABC]{3} --> (?:@{[mb::_cc(qq[ABC])]}){3} # ok
6226  
6227 17878 $parsed .= "(?:\@{[mb::_cc(qq[$classmate])]})";
6228 }
6229  
6230 # (?#comment) (dropped)
6231 # the comment ends at the first ")"; the close delimiter of the
6232 # regular expression is not skipped
6233 elsif (/\G \( \? \# /xmsgc) {
6234 2 while (1) {
6235 10 my $pos = pos($_);
6236 10 ▶ last if $pos >= CORE::length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= CORE::length $_ 0 10 10
6237 10 my $octet = CORE::substr($_, $pos, 1);
6238 10 ▶ if ($octet eq ')') {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet eq ")") 2 8 10
6239 2 pos($_) = $pos + 1;
6240 2 last;
6241 }
6242 8 ▶ last if ($octet eq $mb::_re_close) and ($mb::_re_open eq $mb::_re_close);
Branch: 1 branch
BranchTrueFalseTotal
if $octet eq $mb::_re_close and $mb::_re_open eq $mb::_re_close 0 8 8
Condition33%1/3
$octet eq $mb::_re_close and $mb::_re_open eq $mb::_re_close
!ll&&!rl&&r
800
MC/DC0%0/2
$octet eq $mb::_re_close and $mb::_re_open eq $mb::_re_close
$octet eq $mb::_re_close $mb::_re_open eq $mb::_re_close
Truth table33%1/3
A and B
A= $octet eq $mb::_re_closeB= $mb::_re_open eq $mb::_re_close
ABresult
0X0
100
111
6243 8 ▶ last if not /\G ($x) /xmsgc;
Branch: 1 branch
BranchTrueFalseTotal
unless /\G ($x) /cgmsx 0 8 8
6244 }
6245 }
6246  
6247 # \c# , \c[ , ... control character (never starts a comment nor a class)
6248 elsif (/\G ( \\c [\x00-\x7F] ) /xmsgc) {
6249 1 $parsed .= $1;
6250 }
6251  
6252 # $#array, $#{expr}, $#$aref (never starts a comment)
6253 elsif (/\G ( \$\# ) (?= [\{\$A-Za-z_:] ) /xmsgc) {
6254 2 $parsed .= $1;
6255 }
6256  
6257 # $\ (output record separator) is interpolated also in a regular
6258 # expression, and the next character is a literal character:
6259 # /a$\b/ is "a".$\."b", not "a" and \b (an escaped close delimiter
6260 # is not $\)
6261 ▶ elsif ((CORE::substr($_, pos($_), 2) eq '$\\') and (CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close)) {
Condition66%2/3
CORE::substr($_, pos $_, 2) eq "\$\\" and CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close
!ll&&!rl&&r
416903
MC/DC50%1/2
CORE::substr($_, pos $_, 2) eq "\$\\" and CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close
CORE::substr($_, pos $_, 2) eq "\$\\" CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close
Truth table66%2/3
A and B
A= CORE::substr($_, pos $_, 2) eq "\$\\"B= CORE::substr($_, pos($_) + 2, 1) ne $mb::_re_close
ABresult
0X0
100
111
6262 3 pos($_) += 2;
6263 3 $parsed .= '@{[$\\ ]}';
6264 }
6265  
6266 # comment of /x, /xx (dropped; the end of line is kept)
6267 ▶ elsif (($mb::_re_x >= 1) and /\G \# /xmsgc) {
Condition100%3/3
$mb::_re_x >= 1 and /\G \# /cgmsx
!ll&&!rl&&r
37653995
MC/DC100%2/2
$mb::_re_x >= 1 and /\G \# /cgmsx
$mb::_re_x >= 1 /\G \# /cgmsx
Truth table100%3/3
A and B
A= $mb::_re_x >= 1B= /\G \# /cgmsx
ABresult
0X0
100
111
6268 5 _skip_re_comment();
6269 }
6270  
6271 # /./ or \any
6272 48 elsif (/\G \. /xmsgc) { $parsed .= '(?:@{[@mb::_dot]})'; }
6273 8 elsif (/\G \\B /xmsgc) { $parsed .= '(?:@{[@mb::_B]})'; }
6274 19 elsif (/\G \\D /xmsgc) { $parsed .= '(?:@{[@mb::_D]})'; }
6275 11 elsif (/\G \\H /xmsgc) { $parsed .= '(?:@{[@mb::_H]})'; }
6276 9 elsif (/\G \\N /xmsgc) { $parsed .= '(?:@{[@mb::_N]})'; }
6277 13 elsif (/\G \\R /xmsgc) { $parsed .= '(?:@{[@mb::_R]})'; }
6278 15 elsif (/\G \\S /xmsgc) { $parsed .= '(?:@{[@mb::_S]})'; }
6279 13 elsif (/\G \\V /xmsgc) { $parsed .= '(?:@{[@mb::_V]})'; }
6280 72 elsif (/\G \\W /xmsgc) { $parsed .= '(?:@{[@mb::_W]})'; }
6281 8 elsif (/\G \\b /xmsgc) { $parsed .= '(?:@{[@mb::_b]})'; }
6282 18 elsif (/\G \\d /xmsgc) { $parsed .= '(?:@{[@mb::_d]})'; }
6283 11 elsif (/\G \\h /xmsgc) { $parsed .= '(?:@{[@mb::_h]})'; }
6284 19 elsif (/\G \\s /xmsgc) { $parsed .= '(?:@{[@mb::_s]})'; }
6285 15 elsif (/\G \\v /xmsgc) { $parsed .= '(?:@{[@mb::_v]})'; }
6286 71 elsif (/\G \\w /xmsgc) { $parsed .= '(?:@{[@mb::_w]})'; }
6287  
6288 # \o{...}
6289 elsif (/\G \\o\{ (.*?) \} /xmsgc) {
6290 0 $parsed .= '(?:';
6291 0 $parsed .= escape_to_hex(mb::chr(oct $1), $closewith);
6292 0 $parsed .= ')';
6293 }
6294  
6295 # \x{...}
6296 elsif (/\G \\x\{ (.*?) \} /xmsgc) {
6297 0 $parsed .= '(?:';
6298 0 $parsed .= escape_to_hex(mb::chr(hex $1), $closewith);
6299 0 $parsed .= ')';
6300 }
6301  
6302 # \0... octal escape
6303 elsif (/\G (\\ 0[1-7]*) /xmsgc) {
6304 0 $parsed .= $1;
6305 }
6306  
6307 # \100...\x377 octal escape
6308 elsif (/\G (\\ [1-3][0-7][0-7]) /xmsgc) {
6309 0 $parsed .= $1;
6310 }
6311  
6312 # \1...\99, ... n-th previously captured string (decimal)
6313 elsif (/\G (\\) ([1-9][0-9]*) /xmsgc) {
6314 24 $parsed .= $1;
6315 24 ▶ if ($operator eq 's') {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq 's') { } 0 24 24
6316 0 $parsed .= ($2 + 1);
6317 }
6318 else {
6319 24 $parsed .= $2;
6320 }
6321 }
6322  
6323 # \any
6324 elsif (/\G (\\) ($x) /xmsgc) {
6325 270 ▶ if (CORE::length($2) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $2 == 1) { } 270 0 270
6326 270 $parsed .= ($1 . $2);
6327 }
6328 else {
6329 0 $parsed .= ('(?:' . $1 . escape_qq($2, $closewith) . ')');
6330 }
6331 }
6332  
6333 # $` --> @{[mb::_clustered_codepoint(mb::_PREMATCH())]}
6334 # ${`} --> @{[mb::_clustered_codepoint(mb::_PREMATCH())]}
6335 # $PREMATCH --> @{[mb::_clustered_codepoint(mb::_PREMATCH())]}
6336 # ${PREMATCH} --> @{[mb::_clustered_codepoint(mb::_PREMATCH())]}
6337 # ${^PREMATCH} --> @{[mb::_clustered_codepoint(mb::_PREMATCH())]}
6338 elsif (/\G (?: \$` | \$\{`\} | \$PREMATCH | \$\{PREMATCH\} | \$\{\^PREMATCH\} ) /xmsgc) {
6339 0 $parsed .= '@{[mb::_clustered_codepoint(mb::_PREMATCH())]}';
6340 }
6341  
6342 # $& --> @{[mb::_clustered_codepoint(mb::_MATCH())]}
6343 # ${&} --> @{[mb::_clustered_codepoint(mb::_MATCH())]}
6344 # $MATCH --> @{[mb::_clustered_codepoint(mb::_MATCH())]}
6345 # ${MATCH} --> @{[mb::_clustered_codepoint(mb::_MATCH())]}
6346 # ${^MATCH} --> @{[mb::_clustered_codepoint(mb::_MATCH())]}
6347 elsif (/\G (?: \$& | \$\{&\} | \$MATCH | \$\{MATCH\} | \$\{\^MATCH\} ) /xmsgc) {
6348 0 $parsed .= '@{[mb::_clustered_codepoint(mb::_MATCH())]}';
6349 }
6350  
6351 # $1 --> @{[mb::_clustered_codepoint(mb::_CAPTURE(1))]}
6352 # $2 --> @{[mb::_clustered_codepoint(mb::_CAPTURE(2))]}
6353 # $3 --> @{[mb::_clustered_codepoint(mb::_CAPTURE(3))]}
6354 elsif (/\G \$ ([1-9][0-9]*) /xmsgc) {
6355 24 $parsed .= "\@{[mb::_clustered_codepoint(mb::_CAPTURE($1))]}";
6356 }
6357  
6358 # ${^CAPTURE}[0] --> @{[mb::_clustered_codepoint(mb::_CAPTURE(1))]}
6359 # ${^CAPTURE}[1] --> @{[mb::_clustered_codepoint(mb::_CAPTURE(2))]}
6360 # ${^CAPTURE}[2] --> @{[mb::_clustered_codepoint(mb::_CAPTURE(3))]}
6361 elsif (/\G \$\{\^CAPTURE\} \s* (\[) /xmsgc) {
6362 0 my $n_th = quotee_of(parse_expr_balanced($1));
6363 0 $parsed .= "\@{[mb::_clustered_codepoint(mb::_CAPTURE($n_th+1))]}";
6364 }
6365  
6366 # @- --> @{[mb::_LAST_MATCH_START()]}
6367 # @LAST_MATCH_START --> @{[mb::_LAST_MATCH_START()]}
6368 # @{LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
6369 # @{^LAST_MATCH_START} --> @{[mb::_LAST_MATCH_START()]}
6370 elsif (/\G (?: \@- | \@LAST_MATCH_START | \@\{LAST_MATCH_START\} | \@\{\^LAST_MATCH_START\} ) /xmsgc) {
6371 0 $parsed .= '@{[mb::_LAST_MATCH_START()]}';
6372 }
6373  
6374 # $-[1] --> @{[mb::_LAST_MATCH_START(1)]}
6375 # $LAST_MATCH_START[1] --> @{[mb::_LAST_MATCH_START(1)]}
6376 # ${LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
6377 # ${^LAST_MATCH_START}[1] --> @{[mb::_LAST_MATCH_START(1)]}
6378 elsif (/\G (?: \$- | \$LAST_MATCH_START | \$\{LAST_MATCH_START\} | \$\{\^LAST_MATCH_START\} ) \s* (\[) /xmsgc) {
6379 0 my $n_th = quotee_of(parse_expr_balanced($1));
6380 0 $parsed .= "\@{[mb::_LAST_MATCH_START($n_th)]}";
6381 }
6382  
6383 # @+ --> @{[mb::_LAST_MATCH_END()]}
6384 # @LAST_MATCH_END --> @{[mb::_LAST_MATCH_END()]}
6385 # @{LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
6386 # @{^LAST_MATCH_END} --> @{[mb::_LAST_MATCH_END()]}
6387 elsif (/\G (?: \@\+ | \@LAST_MATCH_END | \@\{LAST_MATCH_END\} | \@\{\^LAST_MATCH_END\} ) /xmsgc) {
6388 0 $parsed .= '@{[mb::_LAST_MATCH_END()]}';
6389 }
6390  
6391 # $+[1] --> @{[mb::_LAST_MATCH_END(1)]}
6392 # $LAST_MATCH_END[1] --> @{[mb::_LAST_MATCH_END(1)]}
6393 # ${LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
6394 # ${^LAST_MATCH_END}[1] --> @{[mb::_LAST_MATCH_END(1)]}
6395 elsif (/\G (?: \$\+ | \$LAST_MATCH_END | \$\{LAST_MATCH_END\} | \$\{\^LAST_MATCH_END\} ) \s* (\[) /xmsgc) {
6396 0 my $n_th = quotee_of(parse_expr_balanced($1));
6397 0 $parsed .= "\@{[mb::_LAST_MATCH_END($n_th)]}";
6398 }
6399  
6400 # any
6401 elsif (/\G ($x) /xmsgc) {
6402 3496 ▶ if (CORE::length($1) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $1 == 1) { } 2933 563 3496
6403 2933 $parsed .= $1;
6404 }
6405 else {
6406 563 $parsed .= ('(?:' . escape_qq($1, $closewith) . ')');
6407 }
6408 }
6409  
6410 # something wrong happened
6411 else {
6412 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
6413 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
6414 ------------------------------------------------------------------------------
6415 %s
6416 ------------------------------------------------------------------------------
6417 END
6418 }
6419 22055 return $parsed;
6420 }
6421  
6422 #---------------------------------------------------------------------
6423 # track "use feature" / "no feature" for 'enhanced_xx' (Perl 5.44)
6424 # called just after "use" or "no" keyword; pos($_) is not moved
6425 120 ▶sub mb::_track_feature {
Subroutine _track_feature: called CC=26 SCAR=33.8
6426 120 my($keyword) = @_;
6427 120 my $pos = pos($_);
6428 120 my $statement = '';
6429 120 ▶ if (/\G ([^;]*) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ([^;]*) /cgmsx) 120 0 120
6430 120 $statement = $1;
6431 }
6432 120 pos($_) = $pos;
6433  
6434 # use feature ...; no feature ...; use experimental ...; no experimental ...;
6435 120 ▶ if ($statement =~ /\A \s+ (?: feature | experimental ) \b (.*) \z/xms) {
Branch: 3 branches
BranchTrueFalseTotal
if ($statement =~ /\A \s+ (?: feature | experimental ) \b (.*) \z/msx) { } 58 62 120
elsif ($statement =~ /\A \s+ if \b (.*) \z/msx) { } 6 56 62
elsif ($keyword eq 'use') { } 48 8 56
6436 58 my $list = $1;
6437 58 ▶ if ($keyword eq 'use') {
Branch: 1 branch
BranchTrueFalseTotal
if ($keyword eq 'use') { } 56 2 58
6438 56 ▶ if ($list =~ /\b enhanced_xx \b/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list =~ /\b enhanced_xx \b/msx) { } 55 1 56
elsif ($list =~ /:all \b/msx) { } 0 1 1
6439 55 $mb::_enhanced_xx = 1;
6440 }
6441 elsif ($list =~ /:all \b/xms) {
6442 0 $mb::_enhanced_xx = 1;
6443 }
6444 }
6445 else {
6446 2 ▶ if ($list =~ /\b enhanced_xx \b/xms) {
Branch: 3 branches
BranchTrueFalseTotal
if ($list =~ /\b enhanced_xx \b/msx) { } 2 0 2
elsif ($list =~ /:all \b/msx) { } 0 0 0
elsif ($list =~ /\A \s* \z/msx) { } 0 0 0
6447 2 $mb::_enhanced_xx = 0;
6448 }
6449 elsif ($list =~ /:all \b/xms) {
6450 0 $mb::_enhanced_xx = 0;
6451 }
6452 elsif ($list =~ /\A \s* \z/xms) {
6453 0 $mb::_enhanced_xx = 0;
6454 }
6455 }
6456 }
6457  
6458 # use if COND, feature => 'enhanced_xx'; (also experimental, and no if)
6459 # COND is not evaluated at transpile time. 'enhanced_xx' exists only on
6460 # Perl 5.44 and later, so a script can enable it only when COND is
6461 # true there; mb follows the statement when it runs on Perl 5.44 and
6462 # later, and ignores it on older Perl, where COND must be false.
6463 elsif ($statement =~ /\A \s+ if \b (.*) \z/xms) {
6464 6 my $rest = $1;
6465 6 ▶ if (($mb::_perl_has_enhanced_xx) and ($rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::_perl_has_enhanced_xx and $rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/msx) 4 2 6
Condition100%3/3
$mb::_perl_has_enhanced_xx and $rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/msx
!ll&&!rl&&r
114
MC/DC100%2/2
$mb::_perl_has_enhanced_xx and $rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/msx
$mb::_perl_has_enhanced_xx $rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/msx
Truth table100%3/3
A and B
A= $mb::_perl_has_enhanced_xxB= $rest =~ /[,] \s* (?: (['"]?) (?: feature | experimental ) \1 ) \s* (?: => | , ) (.*) \z/msx
ABresult
0X0
100
111
6466 4 my $list = $2;
6467 4 ▶ if ($list =~ /\b enhanced_xx \b/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list =~ /\b enhanced_xx \b/msx) { } 3 1 4
elsif ($list =~ /:all \b/msx) { } 1 0 1
6468 3 ▶ $mb::_enhanced_xx = ($keyword eq 'use') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$keyword eq 'use' ? : 2 1 3
6469 }
6470 elsif ($list =~ /:all \b/xms) {
6471 1 ▶ $mb::_enhanced_xx = ($keyword eq 'use') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$keyword eq 'use' ? : 1 0 1
6472 }
6473 }
6474 }
6475  
6476 # "use VERSION" of any version (use v5.44; use 5.010; use 5.36.0;
6477 # use v5.8; use 5.006) lexically replaces the features with the
6478 # feature bundle of that version (perlfunc "use VERSION"), and no
6479 # bundle contains 'enhanced_xx'; "no VERSION" does not touch features
6480 # "use VERSION" of v5.35 and later also enables warnings
6481 elsif ($keyword eq 'use') {
6482 48 ▶ if ($statement =~ /\A \s+ (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* ) \s* \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($statement =~ /\A \s+ (?: v [0-9]+ (?: \. [0-9]+ )* | [0-9]+ (?: \. [0-9_]+ )* ) \s* \z/msx) 16 32 48
6483 16 $mb::_enhanced_xx = 0;
6484 16 my $minor = 0;
6485 16 ▶ if ($statement =~ /\A \s+ v? 5 \. ([0-9]+) \. /xms) {
Branch: 3 branches
BranchTrueFalseTotal
if ($statement =~ /\A \s+ v? 5 \. ([0-9]+) \. /msx) { } 2 14 16
elsif ($statement =~ /\A \s+ v 5 \. ([0-9]+) /msx) { } 9 5 14
elsif ($statement =~ /\A \s+ 5 \. ([0-9]{1,3}) /msx) { } 5 0 5
6486 2 $minor = $1;
6487 }
6488 elsif ($statement =~ /\A \s+ v 5 \. ([0-9]+) /xms) {
6489 9 $minor = $1;
6490 }
6491 elsif ($statement =~ /\A \s+ 5 \. ([0-9]{1,3}) /xms) {
6492 5 $minor = $1 . ('0' x (3 - CORE::length($1)));
6493 }
6494 16 ▶ if ($minor >= 35) {
Branch: 1 branch
BranchTrueFalseTotal
if ($minor >= 35) 9 7 16
6495 9 $mb::_warn_regexp = 1;
6496 }
6497 }
6498 }
6499  
6500 # use warnings; no warnings; (all or 'regexp') decide whether the
6501 # warnings of a comment under 'enhanced_xx' are given at transpile time
6502 120 ▶ if ($statement =~ /\A \s+ warnings \b (.*) \z/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($statement =~ /\A \s+ warnings \b (.*) \z/msx) 20 100 120
6503 20 my $list = $1;
6504 20 ▶ if (($list =~ /\A \s* \z/xms) or ($list =~ /\b (?: all | regexp ) \b/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list =~ /\A \s* \z/msx or $list =~ /\b (?: all | regexp ) \b/msx) 20 0 20
Condition66%2/3
$list =~ /\A \s* \z/msx or $list =~ /\b (?: all | regexp ) \b/msx
l!l&&r!l&&!r
1910
MC/DC0%0/2
$list =~ /\A \s* \z/msx or $list =~ /\b (?: all | regexp ) \b/msx
$list =~ /\A \s* \z/msx $list =~ /\b (?: all | regexp ) \b/msx
Truth table66%2/3
A or B
A= $list =~ /\A \s* \z/msxB= $list =~ /\b (?: all | regexp ) \b/msx
ABresult
1X1
011
000
6505 20 ▶ $mb::_warn_regexp = ($keyword eq 'use') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$keyword eq 'use' ? : 14 6 20
6506 }
6507 }
6508 }
6509  
6510 #---------------------------------------------------------------------
6511 # skip a quoted part like Perl tokenizer, from pos($_) to its close
6512 # delimiter; returns 1 if the close delimiter was found
6513 #
6514 # written with CORE::substr() and /\G ($x)/ only: on perl 5.005_03, a
6515 # pattern that interpolates the qr// object $x without parentheses (as
6516 # /\G $x/ or /\G \\ $x/) does not match, and then no modifier was looked
6517 # ahead at all
6518 23514 ▶sub _peek_skip_quoted {
Subroutine _peek_skip_quoted: called CC=9 SCAR=22.0
6519 23514 my($open, $close) = @_;
6520 23514 my $nest = 1;
6521 23514 while (1) {
6522 134977 my $pos = pos($_);
6523 134977 ▶ return 0 if $pos >= CORE::length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= CORE::length $_ 40 134937 134977
6524 134937 my $octet = CORE::substr($_, $pos, 1);
6525 134937 ▶ if ($octet eq '\\') {
Branch: 4 branches
BranchTrueFalseTotal
if ($octet eq '\\') { } 1982 132955 134937
elsif ($open ne $close and $octet eq $open) { } 6 132949 132955
elsif ($octet eq $close) { } 23480 109469 132949
elsif (not /\G ($x) /cgmsx) { } 0 109469 109469
6526 1982 pos($_) = $pos + 1;
6527 1982 ▶ return 0 if not /\G ($x) /xmsgc;
Branch: 1 branch
BranchTrueFalseTotal
unless /\G ($x) /cgmsx 0 1982 1982
6528 }
6529 ▶ elsif (($open ne $close) and ($octet eq $open)) {
Condition100%3/3
$open ne $close and $octet eq $open
!ll&&!rl&&r
13135515946
MC/DC100%2/2
$open ne $close and $octet eq $open
$open ne $close $octet eq $open
Truth table100%3/3
A and B
A= $open ne $closeB= $octet eq $open
ABresult
0X0
100
111
6530 6 pos($_) = $pos + 1;
6531 6 $nest++;
6532 }
6533 elsif ($octet eq $close) {
6534 23480 pos($_) = $pos + 1;
6535 23480 ▶ if (--$nest <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$nest <= 0) 23474 6 23480
6536 23474 return 1;
6537 }
6538 }
6539 elsif (not /\G ($x) /xmsgc) {
6540 0 return 0;
6541 }
6542 }
6543 }
6544  
6545 #---------------------------------------------------------------------
6546 # look ahead the modifiers of m/here/, qr/here/, s/here/.../ and returns
6547 # the number of 'x' in them; pos($_) is not moved
6548 # (comments of /x and comments in codepoint class of /xx with feature
6549 # 'enhanced_xx' must be known before parsing the regular expression)
6550 21787 ▶sub _peek_re_x {
Subroutine _peek_re_x: called CC=9 SCAR=22.0
6551 21787 my($operator, $open, $close) = @_;
6552 21787 my $pos = pos($_);
6553 21787 my $count = 0;
6554 21787 my $found = _peek_skip_quoted($open, $close);
6555 21787 ▶ if ($found and ($operator eq 's')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found and $operator eq "s") 1728 20059 21787
Condition100%3/3
$found and $operator eq "s"
!ll&&!rl&&r
24200351728
MC/DC100%2/2
$found and $operator eq "s"
$found $operator eq "s"
Truth table100%3/3
A and B
A= $foundB= $operator eq "s"
ABresult
0X0
100
111
6556 1728 ▶ if ($open eq $close) {
Branch: 1 branch
BranchTrueFalseTotal
if ($open eq $close) { } 1237 491 1728
6557 1237 $found = _peek_skip_quoted($open, $close);
6558 }
6559 else {
6560 491 ▶ while (/\G (?: \s+ | \# [^\n]* ) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G (?: \s+ | \# [^\n]* ) /cgmsx) 252 491 743
6561 }
6562 491 ▶ if (/\G ([\(\{\[\<]) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ([\(\{\[\<]) /cgmsx) { } 74 417 491
elsif (/\G ([\S]) /cgmsx) { } 416 1 417
6563 74 $found = _peek_skip_quoted($1, {qw| ( ) { } [ ] < > |}->{$1});
6564 }
6565 elsif (/\G ([\S]) /xmsgc) {
6566 416 $found = _peek_skip_quoted($1, $1);
6567 }
6568 else {
6569 1 $found = 0;
6570 }
6571 }
6572 }
6573 21787 ▶ if ($found and /\G ([a-z]*) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found and /\G ([a-z]*) /cgmsx) 21746 41 21787
Condition66%2/3
$found and /\G ([a-z]*) /cgmsx
!ll&&!rl&&r
41021746
MC/DC50%1/2
$found and /\G ([a-z]*) /cgmsx
$found /\G ([a-z]*) /cgmsx
Truth table66%2/3
A and B
A= $foundB= /\G ([a-z]*) /cgmsx
ABresult
0X0
100
111
6574 21746 my $modifier = $1;
6575 21746 $count = ($modifier =~ tr/x//);
6576 }
6577 21787 pos($_) = $pos;
6578 21787 return $count;
6579 }
6580  
6581 #---------------------------------------------------------------------
6582 # die for a codepoint class "[" that has no "]" before the end of the
6583 # regular expression (or of the script); under feature 'enhanced_xx' the
6584 # usual cause is a "#" in the class that started a comment and absorbed
6585 # the "]", as Perl 5.44 does ("Unmatched [ in regex")
6586 6 ▶sub _die_unmatched_class {
Subroutine _die_unmatched_class: called CC=3 SCAR=11.0
6587 6 my($pos) = @_;
6588 6 my $hint = '';
6589 6 ▶ if ($mb::_enhanced_xx and ($mb::_re_x >= 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::_enhanced_xx and $mb::_re_x >= 2) 4 2 6
Condition66%2/3
$mb::_enhanced_xx and $mb::_re_x >= 2
!ll&&!rl&&r
204
MC/DC50%1/2
$mb::_enhanced_xx and $mb::_re_x >= 2
$mb::_enhanced_xx $mb::_re_x >= 2
Truth table66%2/3
A and B
A= $mb::_enhanced_xxB= $mb::_re_x >= 2
ABresult
0X0
100
111
6590 4 $hint = qq{(under use feature 'enhanced_xx', "#" in a codepoint class of /xx starts a comment up to the end of line, and the comment absorbs "]"; write \\# for a literal "#")\n};
6591 }
6592 6 die sprintf(<<END, _script_line($pos), $pos, $hint, CORE::substr($_, $pos));
6593 $0: Unmatched [ in regex (codepoint class is not closed) at line %d (pos=%s)
6594 %s------------------------------------------------------------------------------
6595 %s
6596 ------------------------------------------------------------------------------
6597 END
6598 }
6599  
6600 #---------------------------------------------------------------------
6601 # line number of the position in the script being parsed
6602 14 ▶sub _script_line {
Subroutine _script_line: called CC=1 SCAR=0.0
6603 14 my($pos) = @_;
6604 14 my $before = CORE::substr($_, 0, $pos);
6605 14 return 1 + ($before =~ tr/\n//);
6606 }
6607  
6608 #---------------------------------------------------------------------
6609 # give the warnings of Perl 5.44 for a comment of /x under feature
6610 # 'enhanced_xx' (category 'regexp'), at transpile time: mb removes the
6611 # comment, so Perl never sees it and cannot warn. As S_reg_skipcomment()
6612 # of regcomp.c of Perl 5.44:
6613 # - a single "#" not surrounded by tab or space warns
6614 # "Did you mean this to be a comment?"
6615 # - an unescaped, unquoted "#" in the comment warns
6616 # "Did you mean to have a second '#' in your comment?"
6617 # - in a codepoint class, an unescaped, unquoted "]" in the comment warns
6618 # "Did you mean to have a ']' in your comment?"
6619 # A character just after a quote (' or ") or after an odd number of
6620 # backslashes is "escaped". At most one warning is given per comment.
6621 # called with pos($_) just after the first "#"; pos($_) is not moved
6622 39 ▶sub _warn_re_comment {
Subroutine _warn_re_comment: called CC=36 SCAR=39.5
6623 39 my($in_class) = @_;
6624 39 ▶ my $enabled = defined($mb::_warn_regexp) ? $mb::_warn_regexp : $^W;
Branch: 1 branch
BranchTrueFalseTotal
defined $mb::_warn_regexp ? : 15 24 39
6625 39 ▶ return if not $enabled;
Branch: 1 branch
BranchTrueFalseTotal
unless $enabled 26 13 39
6626  
6627 13 my $save = pos($_);
6628 13 my $hash = $save - 1;
6629 13 my $length = CORE::length($_);
6630  
6631 # some people like to string multiple "#"s together
6632 13 my $p = $save;
6633 13 ▶ while (($p < $length) and (CORE::substr($_, $p, 1) eq '#')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $length and CORE::substr($_, $p, 1) eq "#") 1 13 14
Condition66%2/3
$p < $length and CORE::substr($_, $p, 1) eq "#"
!ll&&!rl&&r
0131
MC/DC50%1/2
$p < $length and CORE::substr($_, $p, 1) eq "#"
$p < $length CORE::substr($_, $p, 1) eq "#"
Truth table66%2/3
A and B
A= $p < $lengthB= CORE::substr($_, $p, 1) eq "#"
ABresult
0X0
100
111
6634 1 $p++;
6635 }
6636 13 ▶ if ($p == $save) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p == $save) 12 1 13
6637 12 ▶ my $after = ($p < $length) ? CORE::substr($_, $p, 1) : '';
Branch: 1 branch
BranchTrueFalseTotal
$p < $length ? : 12 0 12
6638 12 ▶ my $before = ($hash > 0) ? CORE::substr($_, $hash - 1, 1) : '';
Branch: 1 branch
BranchTrueFalseTotal
$hash > 0 ? : 12 0 12
6639 12 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($after ne "" and $after ne "\n" and $after ne $mb::_re_close and $after ne "\t" and $after ne " " or $before ne "" and $before ne $mb::_re_open and $before ne "\t" and $before ne " ") 6 6 12
Condition50%12/24
$after ne "" and $after ne "\n" and $after ne $mb::_re_close and $after ne "\t" and $after ne " " or $before ne "" and $before ne $mb::_re_open and $before ne "\t" and $before ne " "
l!l&&r!l&&!r
516
$after ne "" and $after ne "\n" and $after ne $mb::_re_close and $after ne "\t" and $after ne " "
!ll&&!rl&&r
075
$after ne "" and $after ne "\n" and $after ne $mb::_re_close and $after ne "\t"
!ll&&!rl&&r
0012
$after ne "" and $after ne "\n" and $after ne $mb::_re_close
!ll&&!rl&&r
0012
$after ne "" and $after ne "\n"
!ll&&!rl&&r
0012
$before ne "" and $before ne $mb::_re_open and $before ne "\t" and $before ne " "
!ll&&!rl&&r
061
$before ne "" and $before ne $mb::_re_open and $before ne "\t"
!ll&&!rl&&r
007
$before ne "" and $before ne $mb::_re_open
!ll&&!rl&&r
007
MC/DC22%2/9
$after ne "" and $after ne "\n" and $after ne $mb::_re_close and $after ne "\t" and $after ne " " or $before ne "" and $before ne $mb::_re_open and $before ne "\t" and $before ne " "
$after ne "" $after ne "\n" $after ne $mb::_re_close $after ne "\t" $after ne " " $before ne "" $before ne $mb::_re_open $before ne "\t" $before ne " "
Truth table11%3/26
A and B and C and D and E or F and G and H and I
A= $after ne ""B= $after ne "\n"C= $after ne $mb::_re_closeD= $after ne "\t"E= $after ne " "F= $before ne ""G= $before ne $mb::_re_openH= $before ne "\t"I= $before ne " "
ABCDEFGHIresult
11111XXXX1
0XXXX11111
10XXX11111
110XX11111
1110X11111
1111011111
0XXXX0XXX0
0XXXX10XX0
0XXXX110X0
0XXXX11100
10XXX0XXX0
10XXX10XX0
10XXX110X0
10XXX11100
110XX0XXX0
110XX10XX0
110XX110X0
110XX11100
1110X0XXX0
1110X10XX0
1110X110X0
1110X11100
111100XXX0
1111010XX0
11110110X0
1111011100
6640 (($after ne '') and ($after ne "\n") and ($after ne $mb::_re_close) and ($after ne "\t") and ($after ne ' '))
6641 or
6642 (($before ne '') and ($before ne $mb::_re_open) and ($before ne "\t") and ($before ne ' '))
6643 ) {
6644 6 _warn_re(q{Did you mean this to be a comment? If so, to silence this message add blanks like so: " # "}, $hash);
6645 6 return;
6646 }
6647 }
6648  
6649 7 my $quoted = 0;
6650 7 my $backslash = 0;
6651 7 my $nest = 0;
6652 7 pos($_) = $p;
6653 7 while (1) {
6654 59 my $q = pos($_);
6655 59 ▶ last if $q >= $length;
Branch: 1 branch
BranchTrueFalseTotal
if $q >= $length 0 59 59
6656 59 my $octet = CORE::substr($_, $q, 1);
6657 59 ▶ last if $octet eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if $octet eq "\n" 5 54 59
6658 54 ▶ if (($octet eq $mb::_re_close) and (($backslash % 2) == 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($octet eq $mb::_re_close and $backslash % 2 == 0) { } 0 54 54
elsif ($mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open and $backslash % 2 == 0) { } 0 108 108
Condition33%1/3
$octet eq $mb::_re_close and $backslash % 2 == 0
!ll&&!rl&&r
5400
MC/DC0%0/2
$octet eq $mb::_re_close and $backslash % 2 == 0
$octet eq $mb::_re_close $backslash % 2 == 0
Truth table33%1/3
A and B
A= $octet eq $mb::_re_closeB= $backslash % 2 == 0
ABresult
0X0
100
111
6659 0 ▶ last if $nest <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $nest <= 0 0 0 0
6660 0 $nest--;
6661 }
6662 ▶ elsif (($mb::_re_open ne $mb::_re_close) and ($octet eq $mb::_re_open) and (($backslash % 2) == 0)) {
Condition33%2/6
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open and $backslash % 2 == 0
!ll&&!rl&&r
5400
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open
!ll&&!rl&&r
5400
MC/DC0%0/3
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open and $backslash % 2 == 0
$mb::_re_open ne $mb::_re_close $octet eq $mb::_re_open $backslash % 2 == 0
Truth table25%1/4
A and B and C
A= $mb::_re_open ne $mb::_re_closeB= $octet eq $mb::_re_openC= $backslash % 2 == 0
ABCresult
0XX0
10X0
1100
1111
6663 0 $nest++;
6664 }
6665 54 ▶ if ($octet eq '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet eq "\\") 2 52 54
6666 2 $backslash++;
6667 2 $quoted = 0;
6668 2 pos($_) = $q + 1;
6669 2 next;
6670 }
6671 52 ▶ if (($octet eq '"') or ($octet eq "'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($octet eq "\"" or $octet eq "'") 6 46 52
Condition100%3/3
$octet eq "\"" or $octet eq "'"
l!l&&r!l&&!r
4246
MC/DC100%2/2
$octet eq "\"" or $octet eq "'"
$octet eq "\"" $octet eq "'"
Truth table100%3/3
A or B
A= $octet eq "\""B= $octet eq "'"
ABresult
1X1
011
000
6672 6 ▶ $quoted = (($backslash % 2) == 0) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$backslash % 2 == 0 ? : 6 0 6
6673 6 $backslash = 0;
6674 6 pos($_) = $q + 1;
6675 6 next;
6676 }
6677 46 ▶ my $escaped = ((($backslash % 2) == 1) or $quoted) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$backslash % 2 == 1 || $quoted ? : 6 40 46
Condition100%3/3
$backslash % 2 == 1 or $quoted
l!l&&r!l&&!r
2440
MC/DC100%2/2
$backslash % 2 == 1 or $quoted
$backslash % 2 == 1 $quoted
Truth table100%3/3
A or B
A= $backslash % 2 == 1B= $quoted
ABresult
1X1
011
000
6678 46 $backslash = 0;
6679 46 $quoted = 0;
6680 46 ▶ if (not $escaped) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($escaped) 40 6 46
6681 40 ▶ if ($octet eq '#') {
Branch: 2 branches
BranchTrueFalseTotal
if ($octet eq '#') { } 1 39 40
elsif ($in_class and $octet eq ']') { } 1 44 45
6682 1 _warn_re(q{Did you mean to have a second '#' in your comment? If so, escape with '\\' or quote with " or ' to silence this message}, $q);
6683 1 last;
6684 }
6685 ▶ elsif ($in_class and ($octet eq ']')) {
Condition100%3/3
$in_class and $octet eq "]"
!ll&&!rl&&r
6321
MC/DC100%2/2
$in_class and $octet eq "]"
$in_class $octet eq "]"
Truth table100%3/3
A and B
A= $in_classB= $octet eq "]"
ABresult
0X0
100
111
6686 1 _warn_re(q{Did you mean to have a ']' in your comment? If so, escape with '\\' or quote with " or ' to silence this message}, $q);
6687 1 last;
6688 }
6689 }
6690 44 ▶ last if not /\G ($x) /xmsgc;
Branch: 1 branch
BranchTrueFalseTotal
unless /\G ($x) /cgmsx 0 44 44
6691 }
6692 7 pos($_) = $save;
6693 }
6694  
6695 # warn at the position in the script being parsed
6696 8 ▶sub _warn_re {
Subroutine _warn_re: called CC=1 SCAR=0.0
6697 8 my($message, $pos) = @_;
6698 8 warn sprintf("%s in regex at line %d of the script (found by mb at transpile time, under use feature 'enhanced_xx')\n", $message, _script_line($pos));
6699 }
6700  
6701 #---------------------------------------------------------------------
6702 # skip a comment of /x, or a comment in codepoint class of /xx with
6703 # feature 'enhanced_xx', from "#" to before the end of line.
6704 # the close delimiter of the regular expression is not skipped, because
6705 # Perl tokenizer finds it before the regular expression compiler sees
6706 # the comment.
6707 # $in_class is true for a comment in a codepoint class (for warnings).
6708 42 ▶sub _skip_re_comment {
Subroutine _skip_re_comment: called CC=12 SCAR=25.0
6709 42 my($in_class) = @_;
6710 42 ▶ if ($mb::_enhanced_xx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb::_enhanced_xx) 39 3 42
6711 39 _warn_re_comment($in_class);
6712 }
6713 42 my $nest = 0;
6714 42 while (1) {
6715 228 my $pos = pos($_);
6716 228 ▶ last if $pos >= CORE::length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= CORE::length $_ 0 228 228
6717 228 my $octet = CORE::substr($_, $pos, 1);
6718 228 ▶ last if $octet eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if $octet eq "\n" 37 191 228
6719 191 ▶ if ($octet eq $mb::_re_close) {
Branch: 4 branches
BranchTrueFalseTotal
if ($octet eq $mb::_re_close) { } 7 184 191
elsif ($mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open) { } 2 182 184
elsif ($octet eq '\\') { } 2 180 182
elsif (not /\G ($x) /cgmsx) { } 0 180 180
6720 7 ▶ last if $nest <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $nest <= 0 5 2 7
6721 2 $nest--;
6722 2 pos($_) = $pos + 1;
6723 }
6724 ▶ elsif (($mb::_re_open ne $mb::_re_close) and ($octet eq $mb::_re_open)) {
Condition100%3/3
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open
!ll&&!rl&&r
157252
MC/DC100%2/2
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open
$mb::_re_open ne $mb::_re_close $octet eq $mb::_re_open
Truth table100%3/3
A and B
A= $mb::_re_open ne $mb::_re_closeB= $octet eq $mb::_re_open
ABresult
0X0
100
111
6725 2 $nest++;
6726 2 pos($_) = $pos + 1;
6727 }
6728 elsif ($octet eq '\\') {
6729 2 pos($_) = $pos + 1;
6730 2 ▶ last if CORE::substr($_, $pos + 1, 1) eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if CORE::substr($_, $pos + 1, 1) eq "\n" 0 2 2
6731 2 ▶ last if not /\G ($x) /xmsgc;
Branch: 1 branch
BranchTrueFalseTotal
unless /\G ($x) /cgmsx 0 2 2
6732 }
6733 elsif (not /\G ($x) /xmsgc) {
6734 0 last;
6735 }
6736 }
6737 }
6738  
6739 #---------------------------------------------------------------------
6740 # under /x, "#" in \Q...\E of a regular expression: Perl tokenizer copies
6741 # it up to before the end of line (or the close delimiter) as-is, without
6742 # interpolation and without recognizing "\E", and the copy is quoted by
6743 # quotemeta. returns the copy written for the inside of qq<...>
6744 2 ▶sub _quote_re_comment_as_qq {
Subroutine _quote_re_comment_as_qq: called CC=8 SCAR=22.8
6745 2 my $parsed = '';
6746 2 my $nest = 0;
6747 2 while (1) {
6748 7 my $pos = pos($_);
6749 7 ▶ last if $pos >= CORE::length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= CORE::length $_ 0 7 7
6750 7 my $octet = CORE::substr($_, $pos, 1);
6751 7 ▶ last if $octet eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if $octet eq "\n" 1 6 7
6752 6 ▶ if ($octet eq $mb::_re_close) {
Branch: 2 branches
BranchTrueFalseTotal
if ($octet eq $mb::_re_close) { } 1 5 6
elsif ($mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open) { } 0 10 10
6753 1 ▶ last if $nest <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $nest <= 0 1 0 1
6754 0 $nest--;
6755 }
6756 ▶ elsif (($mb::_re_open ne $mb::_re_close) and ($octet eq $mb::_re_open)) {
Condition33%1/3
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open
!ll&&!rl&&r
500
MC/DC0%0/2
$mb::_re_open ne $mb::_re_close and $octet eq $mb::_re_open
$mb::_re_open ne $mb::_re_close $octet eq $mb::_re_open
Truth table33%1/3
A and B
A= $mb::_re_open ne $mb::_re_closeB= $octet eq $mb::_re_open
ABresult
0X0
100
111
6757 0 $nest++;
6758 }
6759 5 ▶ if (/\G ($x) /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\G ($x) /cgmsx) { } 5 0 5
6760 5 $parsed .= _qq_literal($1);
6761 }
6762 else {
6763 0 last;
6764 }
6765 }
6766 2 return $parsed;
6767 }
6768  
6769 #---------------------------------------------------------------------
6770 # a character written as a literal character in the inside of qq<...>
6771 11 ▶sub _qq_literal {
Subroutine _qq_literal: called CC=4 SCAR=13.9
6772 11 my($char) = @_;
6773 # the delimiter of the regular expression (the transpiled script uses
6774 # the same delimiter around qq<...>)
6775 11 ▶ if (($char eq $mb::_re_open) or ($char eq $mb::_re_close)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($char eq $mb::_re_open or $char eq $mb::_re_close) { } 2 9 11
elsif ($char =~ /\A [\\\$\@<>] \z/msx) { } 3 6 9
Condition100%3/3
$char eq $mb::_re_open or $char eq $mb::_re_close
l!l&&r!l&&!r
119
MC/DC100%2/2
$char eq $mb::_re_open or $char eq $mb::_re_close
$char eq $mb::_re_open $char eq $mb::_re_close
Truth table100%3/3
A or B
A= $char eq $mb::_re_openB= $char eq $mb::_re_close
ABresult
1X1
011
000
6776 2 return sprintf('\\x%02X', CORE::ord($char));
6777 }
6778 elsif ($char =~ /\A [\\\$\@<>] \z/xms) {
6779 3 return "\\$char";
6780 }
6781 else {
6782 6 return escape_qq($char, '>');
6783 }
6784 }
6785  
6786 #---------------------------------------------------------------------
6787 # parse modifiers of qr///here
6788 21781 ▶sub parse_re_modifier {
Subroutine parse_re_modifier: called CC=5 SCAR=16.1
Pod undocumented
6789 21781 my $modifier_i = '';
6790 21781 my $modifier_not_cegir = '';
6791 21781 my $modifier_cegr = '';
6792 21781 while (1) {
6793 22374 ▶ if (/\G [adlpu] /xmsgc) {
Branch: 4 branches
BranchTrueFalseTotal
if (/\G [adlpu] /cgmsx) { } 0 22374 22374
elsif (/\G ([i]) /cgmsx) { } 100 22274 22374
elsif (/\G ([cegr]) /cgmsx) { } 89 22185 22274
elsif (/\G ([a-z]) /cgmsx) { } 404 21781 22185
6794 # drop modifiers
6795 }
6796 elsif (/\G ([i]) /xmsgc) {
6797 100 $modifier_i .= $1;
6798 }
6799 elsif (/\G ([cegr]) /xmsgc) {
6800 89 $modifier_cegr .= $1;
6801 }
6802 elsif (/\G ([a-z]) /xmsgc) {
6803 404 $modifier_not_cegir .= $1;
6804 }
6805 else {
6806 21781 last;
6807 }
6808 }
6809 21781 return ($modifier_i, $modifier_not_cegir, $modifier_cegr);
6810 }
6811  
6812 #---------------------------------------------------------------------
6813 # parse modifiers of tr///here
6814 2159 ▶sub parse_tr_modifier {
Subroutine parse_tr_modifier: called CC=3 SCAR=11.1
Pod undocumented
6815 2159 my $modifier_not_r = '';
6816 2159 my $modifier_r = '';
6817 2159 while (1) {
6818 2247 ▶ if (/\G ([r]) /xmsgc) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\G ([r]) /cgmsx) { } 0 2247 2247
elsif (/\G ([a-z]) /cgmsx) { } 88 2159 2247
6819 0 $modifier_r .= $1;
6820 }
6821 elsif (/\G ([a-z]) /xmsgc) {
6822 88 $modifier_not_r .= $1;
6823 }
6824 else {
6825 2159 last;
6826 }
6827 }
6828 2159 return ($modifier_not_r, $modifier_r);
6829 }
6830  
6831 #---------------------------------------------------------------------
6832 # makes codepoint class from string
6833 2131 ▶sub codepoint_tr {
Subroutine codepoint_tr: called CC=13 SCAR=26.3
Pod undocumented
6834 2131 my $searchlist = quotee_of($_[0]);
6835  
6836 2131 my @sbcs = ();
6837 2131 my @xbcs = (); # "xbcs" means DBCS, TBCS, QBCS, ...
6838 2131 ▶ while ($searchlist !~ /\G \z /xmsgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($searchlist =~ /\G \z /cgmsx) 3267 2131 5398
6839  
6840 # \-
6841 3267 ▶ if ($searchlist =~ /\G (\\-) /xmsgc) {
Branch: 4 branches
BranchTrueFalseTotal
if ($searchlist =~ /\G (\\-) /cgmsx) { } 9 3258 3267
elsif ($searchlist =~ /\G (-) /cgmsx) { } 31 3227 3258
elsif ($searchlist =~ /\G ([$escapee_in_qq_like]) /cgmsx) { } 1036 2191 3227
elsif ($searchlist =~ /\G ($x) /cgmsx) { } 2191 0 2191
6842 9 push @sbcs, $1;
6843 }
6844  
6845 # -
6846 elsif ($searchlist =~ /\G (-) /xmsgc) {
6847 31 push @sbcs, $1;
6848 }
6849  
6850 # any qq escapee
6851 elsif ($searchlist =~ /\G ([$escapee_in_qq_like]) /xmsgc) {
6852 1036 push @sbcs, "\\$1";
6853 }
6854  
6855 # any
6856 elsif ($searchlist =~ /\G ($x) /xmsgc) {
6857 2191 ▶ if (CORE::length($1) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $1 == 1) { } 1160 1031 2191
6858 1160 push @sbcs, $1;
6859 }
6860 else {
6861 1031 push @xbcs, escape_qq($1, '\\');
6862 }
6863 }
6864  
6865 # something wrong happened
6866 else {
6867 0 die sprintf(<<END, pos($_), CORE::substr($_,pos($_)));
6868 0 $0(@{[__LINE__]}): something wrong happened in script at pos=%s
6869 ------------------------------------------------------------------------------
6870 %s
6871 ------------------------------------------------------------------------------
6872 END
6873 }
6874 }
6875  
6876 # return codepoint class
6877 return
6878 2131 ▶ ( @sbcs and @xbcs) ? join('|', @xbcs, '['.join('',@sbcs).']') :
Branch: 3 branches
BranchTrueFalseTotal
@sbcs && @xbcs ? : 994 1137 2131
!@sbcs && @xbcs ? : 21 1116 1137
@sbcs && !@xbcs ? : 1116 0 1116
Condition66%6/9
@sbcs and @xbcs
!ll&&!rl&&r
211116994
not @sbcs and @xbcs
!ll&&!rl&&r
1116021
@sbcs and not @xbcs
!ll&&!rl&&r
001116
MC/DC100%2/2
@sbcs and @xbcs
@sbcs @xbcs
MC/DC50%1/2
not @sbcs and @xbcs
not @sbcs @xbcs
MC/DC0%0/2
@sbcs and not @xbcs
@sbcs not @xbcs
Truth table100%3/3
A and B
A= @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table66%2/3
not(A) and B
A= not @sbcsB= @xbcs
ABresult
0X0
100
111
Truth table33%1/3
A and not(B)
A= @sbcsB= not @xbcs
ABresult
0X0
100
111
6879 (!@sbcs and @xbcs) ? join('|', @xbcs ) :
6880 ( @sbcs and !@xbcs) ? '['.join('',@sbcs).']' :
6881 die;
6882 }
6883  
6884 #---------------------------------------------------------------------
6885 # get quotee from quoted "quotee"
6886 3266 ▶sub quotee_of {
Subroutine quotee_of: called CC=2 SCAR=8.1
Pod undocumented
6887 3266 ▶ if (CORE::length($_[0]) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $_[0] >= 2) { } 3266 0 3266
6888 3266 return CORE::substr($_[0],1,-1);
6889 }
6890 else {
6891 0 die;
6892 }
6893 }
6894  
6895 #---------------------------------------------------------------------
6896 # escape q/string/ as q-like quote
6897 174785 ▶sub escape_q {
Subroutine escape_q: called CC=3 SCAR=11.3
Pod undocumented
6898 174785 my($codepoint, $endswith) = @_;
6899 174785 ▶ if ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/msx) { } 0 174785 174785
elsif ($codepoint =~ /\A ([^\x00-\x7F]) ($escapee_in_q__like) \z/msx) { } 3444 171341 174785
6900 0 return "$1\\$2";
6901 }
6902 elsif ($codepoint =~ /\A ([^\x00-\x7F]) ($escapee_in_q__like) \z/xms) {
6903 3444 return "$1\\$2";
6904 }
6905 else {
6906 171341 return $codepoint;
6907 }
6908 }
6909  
6910 #---------------------------------------------------------------------
6911 # escape qq/string/ as qq-like quote
6912 225669 ▶sub escape_qq {
Subroutine escape_qq: called CC=4 SCAR=14.0
Pod undocumented
6913 225669 my($codepoint, $endswith) = @_;
6914  
6915 # m@`@ --> m`\x60`
6916 # qr@`@ --> qr`\x60`
6917 # s@`@``@ --> s`\x60`\x60\x60`
6918 # m:`: --> m`\x60`
6919 # qr:`: --> qr`\x60`
6920 # s:`:``: --> s`\x60`\x60\x60`
6921 225669 ▶ if ($codepoint eq '`') {
Branch: 3 branches
BranchTrueFalseTotal
if ($codepoint eq '`') { } 0 225669 225669
elsif ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/msx) { } 1032 224637 225669
elsif ($codepoint =~ /\A ([^\x00-\x7F]) ([$escapee_in_qq_like]) \z/msx) { } 5939 218698 224637
6922 0 return '\\x60';
6923 }
6924 elsif ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/xms) {
6925 1032 return "$1\\$2";
6926 }
6927 elsif ($codepoint =~ /\A ([^\x00-\x7F]) ([$escapee_in_qq_like]) \z/xms) {
6928 5939 return "$1\\$2";
6929 }
6930 else {
6931 218698 return $codepoint;
6932 }
6933 }
6934  
6935 #---------------------------------------------------------------------
6936 # escape tr/here/here/ as tr-like quote
6937 4608 ▶sub escape_tr {
Subroutine escape_tr: called CC=4 SCAR=15.2
Pod undocumented
6938 4608 my($codepoint, $endswith) = @_;
6939 4608 ▶ if ($codepoint =~ /\A (\Q$endswith\E) \z/xms) {
Branch: 3 branches
BranchTrueFalseTotal
if ($codepoint =~ /\A (\Q$endswith\E) \z/msx) { } 0 4608 4608
elsif ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/msx) { } 0 4608 4608
elsif ($codepoint =~ /\A ([^\x00-\x7F]) ($escapee_in_q__like) \z/msx) { } 1988 2620 4608
6940 0 return "\\$1";
6941 }
6942 elsif ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/xms) {
6943 0 return "$1\\$2";
6944 }
6945 elsif ($codepoint =~ /\A ([^\x00-\x7F]) ($escapee_in_q__like) \z/xms) {
6946 1988 return "$1\\$2";
6947 }
6948 else {
6949 2620 return $codepoint;
6950 }
6951 }
6952  
6953 #---------------------------------------------------------------------
6954 # escape qq/string/ or qr/regexp/ to hex
6955 511 ▶sub escape_to_hex {
Subroutine escape_to_hex: called CC=3 SCAR=11.0
Pod undocumented
6956 511 my($codepoint, $endswith) = @_;
6957 511 ▶ if ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/xms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($codepoint =~ /\A ([^\x00-\x7F]) (\Q$endswith\E) \z/msx) { } 28 483 511
elsif ($codepoint =~ /\A ([^\x00-\x7F]) ([$escapee_in_qq_like]) \z/msx) { } 96 387 483
6958 28 return sprintf('\x%02X\x%02X', CORE::ord($1), CORE::ord($2));
6959 }
6960  
6961 # in qr'...', $escapee_in_qq_like is right, not $escapee_in_q__like
6962 elsif ($codepoint =~ /\A ([^\x00-\x7F]) ([$escapee_in_qq_like]) \z/xms) {
6963 96 return sprintf('\x%02X\x%02X', CORE::ord($1), CORE::ord($2));
6964 }
6965 else {
6966 387 return $codepoint;
6967 }
6968 }
6969  
6970 #---------------------------------------------------------------------
6971 # compatible routines for %mb of UTF8::R2 module
6972 #
6973 # tie my %mb, 'mb';
6974 # $result = $_ =~ $mb{qr/$utf8regex/imsxo}
6975 # $result = $_ =~ m<\G$mb{qr/$utf8regex/imsxo}>gc
6976 # $result = $_ =~ s<$mb{qr/before/imsxo}><after>egr
6977  
6978 156 ▶sub TIEHASH { bless { }, $_[0] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
6979 27 ▶sub FETCH { _r2_qr($_[1]) }
Subroutine FETCH: called CC=1 SCAR=0.0
6980 0 ▶sub STORE { }
Subroutine STORE: not called CC=1 SCAR=0.0
6981 155 ▶sub FIRSTKEY { }
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
6982 0 ▶sub NEXTKEY { }
Subroutine NEXTKEY: not called CC=1 SCAR=0.0
6983 0 ▶sub EXISTS { }
Subroutine EXISTS: not called CC=1 SCAR=0.0
6984 0 ▶sub DELETE { }
Subroutine DELETE: not called CC=1 SCAR=0.0
6985 0 ▶sub CLEAR { }
Subroutine CLEAR: not called CC=1 SCAR=0.0
6986 0 ▶sub UNTIE { }
Subroutine UNTIE: not called CC=1 SCAR=0.0
6987 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
6988 0 ▶sub SCALAR { }
Subroutine SCALAR: not called CC=1 SCAR=0.0
6989  
6990 #---------------------------------------------------------------------
6991  
6992 181 1;
6993  
6994 __END__
↑ Summary eg/bm/mb_length.pl »