blib/lib/ShiftJIS/String.pm

filter: Statementstmt 98.3% 347 / 353 Branchbran 90.1% 321 / 356 Conditioncond 90.0% 63 / 70 MC/DCmcdc 84.4% 38 / 45 Subroutinesub 96.0% 49 / 51 Podpod 95.0% 38 / 40 totaltotal 93.5% 856 / 915 CC 205 SCAR 26.3
CC
205
Cov
94%
__expand
27.1
strsplit
26.0
trclosure
25.4
CRAP 13.8
↑ Summary
1 package ShiftJIS::String;
2  
3 25 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use vars qw($VERSION $PACKAGE @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 25 $VERSION = '1.11';
8 25 $PACKAGE = 'ShiftJIS::String'; # __PACKAGE__
9  
10 25 require Exporter;
11 25 @ISA = qw(Exporter);
12  
13 25 %EXPORT_TAGS = (
14 issjis => [qw/issjis/],
15 string => [qw/length index rindex strspn strcspn strrev substr strsplit/],
16 'span' => [qw/strspn strcspn rspan rcspan/],
17 'trim' => [qw/trim ltrim rtrim/],
18 'cmp' => [qw/strcmp strEQ strNE strLT strLE strGT strGE strxfrm/],
19 ctype => [qw/toupper tolower/],
20 'tr' => [qw/mkrange strtr trclosure/],
21 'kana' => [qw/hi2ka ka2hi hiXka/],
22 'H2Z' => [qw/kataH2Z kanaH2Z hiraH2Z spaceH2Z/],
23 'Z2H' => [qw/kataZ2H kanaZ2H hiraZ2H spaceZ2H/],
24 );
25  
26 25 $EXPORT_TAGS{all} = [ map @$_, values %EXPORT_TAGS ];
27 25 $EXPORT_TAGS{core} = [ map @$_, @EXPORT_TAGS{qw/issjis string cmp ctype tr/} ];
28  
29 25 @EXPORT_OK = @{ $EXPORT_TAGS{all} };
30 25 @EXPORT = ();
31  
32 25 my $Char = '(?:[\x81-\x9F\xE0-\xFC][\x00-\xFF]|[\x00-\xFF])';
33 25 my $White = "\t\n\r\f\x20\x81\x40";
34  
35 ##
36 ## issjis(LIST)
37 ##
38 18 ▶sub issjis {
Subroutine issjis: called CC=3 SCAR=11.0
Pod documented
39 18 for (@_) {
40 23 my $str = $_;
41 23 $str =~ s/[\x00-\x7F\xA1-\xDF]|
42 [\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC]//gx;
43 23 ▶ return '' if CORE::length($str);
Branch: 1 branch
BranchTrueFalseTotal
if CORE::length $str 7 16 23
44 }
45 11 return 1;
46 }
47  
48 ##
49 ## length(STRING)
50 ##
51 1467 ▶sub length ($) {
Subroutine length: called CC=1 SCAR=0.0
Pod documented
52 1467 my $str = shift;
53 1467 return 0 + $str =~ s/$Char//go;
54 }
55  
56 ##
57 ## strrev(STRING)
58 ##
59 23 ▶sub strrev ($) {
Subroutine strrev: called CC=1 SCAR=0.0
Pod documented
60 23 my $str = shift;
61 23 join '', reverse $str =~ /$Char/go;
62 }
63  
64 ##
65 ## index(STRING, SUBSTR; POSITION)
66 ##
67 97 ▶sub index($$;$) {
Subroutine index: called CC=13 SCAR=25.7
Pod documented
68 97 my $cnt = 0;
69 97 my($str, $sub) = @_;
70 97 my $len = &length($str);
71 97 ▶ my $pos = @_ == 3 ? $_[2] : 0;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 ? : 81 16 97
72 97 ▶ if ($sub eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "") 11 86 97
73 11 ▶ return $pos <= 0 ? 0 : $len <= $pos ? $len : $pos;
Branch: 2 branches
BranchTrueFalseTotal
$pos <= 0 ? : 6 5 11
$len <= $pos ? : 4 1 5
74 }
75 86 ▶ return -1 if $len < $pos;
Branch: 1 branch
BranchTrueFalseTotal
if $len < $pos 13 73 86
76  
77 73 my $sublen = CORE::length($sub);
78 73 ▶ $str =~ s/^$Char//o ? $cnt++ : croak "${PACKAGE}::index"
Branch: 2 branches
BranchTrueFalseTotal
CORE::length $str and $cnt < $pos and do { $str =~ s/^$Char//o ? ++$cnt : croak("$ShiftJIS::String::PACKAGE::index") } 230 73 303
$str =~ s/^$Char//o ? : 230 0 230
Condition100%3/3
CORE::length $str and $cnt < $pos
!ll&&!rl&&r
667230
MC/DC100%2/2
CORE::length $str and $cnt < $pos
CORE::length $str $cnt < $pos
Truth table100%3/3
A and B
A= CORE::length $strB= $cnt < $pos
ABresult
0X0
100
111
79 while CORE::length($str) && $cnt < $pos;
80 73 ▶ $str =~ s/^$Char//o ? $cnt++ : croak "${PACKAGE}::index"
Branch: 2 branches
BranchTrueFalseTotal
CORE::length $str and substr($str, 0, $sublen) ne $sub and do { $str =~ s/^$Char//o ? ++$cnt : croak("$ShiftJIS::String::PACKAGE::index") } 100116 73 100189
$str =~ s/^$Char//o ? : 100116 0 100116
Condition100%3/3
CORE::length $str and substr($str, 0, $sublen) ne $sub
!ll&&!rl&&r
1558100116
MC/DC100%2/2
CORE::length $str and substr($str, 0, $sublen) ne $sub
CORE::length $str substr($str, 0, $sublen) ne $sub
Truth table100%3/3
A and B
A= CORE::length $strB= substr($str, 0, $sublen) ne $sub
ABresult
0X0
100
111
81 while CORE::length($str) && CORE::substr($str,0,$sublen) ne $sub;
82 73 ▶ return CORE::length($str) ? $cnt : -1;
Branch: 1 branch
BranchTrueFalseTotal
CORE::length $str ? : 58 15 73
83 }
84  
85 ##
86 ## rindex(STRING, SUBSTR; POSITION)
87 ##
88 92 ▶sub rindex($$;$) {
Subroutine rindex: called CC=10 SCAR=23.0
Pod documented
89 92 my $cnt = 0;
90 92 my($str, $sub) = @_;
91 92 my $len = &length($str);
92 92 ▶ my $pos = @_ == 3 ? $_[2] : $len;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 ? : 77 15 92
93 92 ▶ if ($sub eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "") 11 81 92
94 11 ▶ return $pos <= 0 ? 0 : $len <= $pos ? $len : $pos;
Branch: 2 branches
BranchTrueFalseTotal
$pos <= 0 ? : 5 6 11
$len <= $pos ? : 5 1 6
95 }
96 81 ▶ return -1 if $pos < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 23 58 81
97  
98 58 my $sublen = CORE::length($sub);
99 58 my $ret = -1;
100 58 ▶ while ($cnt <= $pos && CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cnt <= $pos and CORE::length $str) 100367 58 100425
Condition100%3/3
$cnt <= $pos and CORE::length $str
!ll&&!rl&&r
3028100367
MC/DC100%2/2
$cnt <= $pos and CORE::length $str
$cnt <= $pos CORE::length $str
Truth table100%3/3
A and B
A= $cnt <= $posB= CORE::length $str
ABresult
0X0
100
111
101 100367 ▶ $ret = $cnt if CORE::substr($str,0,$sublen) eq $sub;
Branch: 1 branch
BranchTrueFalseTotal
if substr($str, 0, $sublen) eq $sub 5170 95197 100367
102 100367 ▶ $str =~ s/^$Char//o ? $cnt++ : croak "${PACKAGE}::rindex";
Branch: 1 branch
BranchTrueFalseTotal
$str =~ s/^$Char//o ? : 100367 0 100367
103 }
104 58 return $ret;
105 }
106  
107 ##
108 ## strspn(STRING, SEARCHLIST)
109 ##
110 19 ▶sub strspn($$) {
Subroutine strspn: called CC=3 SCAR=11.0
Pod documented
111 19 my($str, $lst) = @_;
112 19 my $ret = 0;
113 19 my(%lst);
114 19 @lst{ $lst =~ /$Char/go } = ();
115 19 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 50060 4 50064
116 50060 ▶ last if ! exists $lst{$1};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $lst{$1} 15 50045 50060
117 50045 $ret++;
118 }
119 19 return $ret;
120 }
121  
122 ##
123 ## strcspn(STRING, SEARCHLIST)
124 ##
125 8 ▶sub strcspn($$) {
Subroutine strcspn: called CC=3 SCAR=11.0
Pod documented
126 8 my($str, $lst) = @_;
127 8 my $ret = 0;
128 8 my(%lst);
129 8 @lst{ $lst=~ /$Char/go } = ();
130 8 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 50017 4 50021
131 50017 ▶ last if exists $lst{$1};
Branch: 1 branch
BranchTrueFalseTotal
if exists $lst{$1} 4 50013 50017
132 50013 $ret++;
133 }
134 8 return $ret;
135 }
136  
137 ##
138 ## rspan(STRING, SEARCHLIST)
139 ##
140 23 ▶sub rspan($$) {
Subroutine rspan: called CC=5 SCAR=16.1
Pod documented
141 23 my($str, $lst) = @_;
142 23 my $ret = 0;
143 23 my $cnt = 0;
144 23 my($found, %lst);
145 23 @lst{ $lst =~ /$Char/go } = ();
146 23 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 100264 23 100287
147 100264 ▶ $ret = $cnt if exists $lst{$1} && !$found;
Branch: 1 branch
BranchTrueFalseTotal
if exists $lst{$1} and not $found 46 100218 100264
Condition100%3/3
exists $lst{$1} and not $found
!ll&&!rl&&r
501515006746
MC/DC100%2/2
exists $lst{$1} and not $found
exists $lst{$1} not $found
Truth table100%3/3
A and not(B)
A= exists $lst{$1}B= not $found
ABresult
0X0
100
111
148 100264 $found = exists $lst{$1};
149 100264 $cnt++;
150 }
151 23 ▶ return $found ? $ret : $cnt;
Branch: 1 branch
BranchTrueFalseTotal
$found ? : 12 11 23
152 }
153  
154 ##
155 ## rcspan(STRING, SEARCHLIST)
156 ##
157 10 ▶sub rcspan($$) {
Subroutine rcspan: called CC=5 SCAR=16.1
Pod documented
158 10 my($str, $lst) = @_;
159 10 my $ret = 0;
160 10 my $cnt = 0;
161 10 my($found, %lst);
162 10 @lst{ $lst =~ /$Char/go } = ();
163 10 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 50059 10 50069
164 50059 ▶ $ret = $cnt if !exists $lst{$1} && $found;
Branch: 1 branch
BranchTrueFalseTotal
if not exists $lst{$1} and $found 4 50055 50059
Condition100%3/3
not exists $lst{$1} and $found
!ll&&!rl&&r
21500344
MC/DC100%2/2
not exists $lst{$1} and $found
not exists $lst{$1} $found
Truth table100%3/3
not(A) and B
A= not exists $lst{$1}B= $found
ABresult
0X0
100
111
165 50059 $found = exists $lst{$1};
166 50059 $cnt++;
167 }
168 10 ▶ return !$found ? $ret : $cnt;
Branch: 1 branch
BranchTrueFalseTotal
!$found ? : 8 2 10
169 }
170  
171 ##
172 ## ltrim(STRING; SEARCHLIST; USE_COMPLEMENT)
173 ##
174 44 ▶sub ltrim($;$$) {
Subroutine ltrim: called CC=5 SCAR=16.1
Pod documented
175 44 my($str, $lst, $c) = @_;
176 44 ▶ $lst = $White if ! defined $lst;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lst 8 36 44
177 44 my $pos = 0;
178 44 my(%lst);
179 44 @lst{ $lst =~ /$Char/go } = ();
180 44 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 100212 22 100234
181 100212 ▶ last if $c ? exists $lst{$1} : ! exists $lst{$1};
Branch: 2 branches
BranchTrueFalseTotal
if $c ? exists $lst{$1} : !exists $lst{$1} 22 100190 100212
$c ? : 36 100176 100212
182 100190 $pos += CORE::length($1);
183 }
184 44 return CORE::substr($str,$pos);
185 }
186  
187 ##
188 ## rtrim(STRING; SEARCHLIST; USE_COMPLEMENT)
189 ##
190 44 ▶sub rtrim($;$$) {
Subroutine rtrim: called CC=7 SCAR=19.5
Pod documented
191 44 my($str, $lst, $c) = @_;
192 44 ▶ $lst = $White if ! defined $lst;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lst 8 36 44
193 44 my $ret = 0;
194 44 my $pos = 0;
195 44 my($prefound, $curfound, %lst);
196 44 @lst{ $lst=~ /$Char/go } = ();
197 44 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 50307 44 50351
198 50307 ▶ $curfound = $c ? ! exists $lst{$1} : exists $lst{$1};
Branch: 1 branch
BranchTrueFalseTotal
$c ? : 70 50237 50307
199 50307 ▶ $ret = $pos if $curfound && !$prefound;
Branch: 1 branch
BranchTrueFalseTotal
if $curfound and not $prefound 52 50255 50307
Condition100%3/3
$curfound and not $prefound
!ll&&!rl&&r
1265012952
MC/DC100%2/2
$curfound and not $prefound
$curfound not $prefound
Truth table100%3/3
A and not(B)
A= $curfoundB= not $prefound
ABresult
0X0
100
111
200 50307 $prefound = $curfound;
201 50307 $pos += CORE::length($1);
202 }
203 44 ▶ return CORE::substr($str, 0, $prefound ? $ret : $pos);
Branch: 1 branch
BranchTrueFalseTotal
$prefound ? : 22 22 44
204 }
205  
206 ##
207 ## trim(STRING; SEARCHLIST; USE_COMPLEMENT)
208 ##
209 22 ▶sub trim($;$$) {
Subroutine trim: called CC=1 SCAR=0.0
Pod documented
210 22 my($str, $lst, $c) = @_;
211 22 rtrim(ltrim($str, $lst, $c), $lst, $c);
212 }
213  
214  
215 ##
216 ## substr(STRING or SCALAR REF, OFFSET; LENGTH)
217 ## substr(SCALAR, OFFSET, LENGTH, REPLACEMENT)
218 ##
219 1258 ▶sub substr($$;$$) {
Subroutine substr: called CC=21 SCAR=30.5
Pod documented
220 1258 my($ini, $fin, $except);
221 1258 my($arg, $off, $len, $rep) = @_;
222 1258 ▶ my $str = ref $arg ? $$arg : $arg;
Branch: 1 branch
BranchTrueFalseTotal
ref $arg ? : 393 865 1258
223  
224 1258 my $slen = &length($str);
225 1258 ▶ $except = 1 if $slen < $off;
Branch: 1 branch
BranchTrueFalseTotal
if $slen < $off 46 1212 1258
226 1258 ▶ if (@_ == 2) {$len = $slen - $off }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 50 1208 1258
227 else {
228 1208 ▶ $except = 1 if $off + $slen < 0 && $len + $slen < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $off + $slen < 0 and $len + $slen < 0 4 1204 1208
Condition100%3/3
$off + $slen < 0 and $len + $slen < 0
!ll&&!rl&&r
1164404
MC/DC100%2/2
$off + $slen < 0 and $len + $slen < 0
$off + $slen < 0 $len + $slen < 0
Truth table100%3/3
A and B
A= $off + $slen < 0B= $len + $slen < 0
ABresult
0X0
100
111
229 1208 ▶ $except = 1 if 0 <= $len && $off + $len + $slen < 0;
Branch: 1 branch
BranchTrueFalseTotal
if 0 <= $len and $off + $len + $slen < 0 5 1203 1208
Condition100%3/3
0 <= $len and $off + $len + $slen < 0
!ll&&!rl&&r
5506535
MC/DC100%2/2
0 <= $len and $off + $len + $slen < 0
0 <= $len $off + $len + $slen < 0
Truth table100%3/3
A and B
A= 0 <= $lenB= $off + $len + $slen < 0
ABresult
0X0
100
111
230 }
231 1258 ▶ if ($except) {
Branch: 1 branch
BranchTrueFalseTotal
if ($except) 55 1203 1258
232 55 ▶ if (@_ > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 3) { } 0 55 55
233 0 croak "$PACKAGE outside of string in substr";
234 55 } else { return }
235 }
236 1203 ▶ $ini = $off < 0 ? $slen + $off : $off;
Branch: 1 branch
BranchTrueFalseTotal
$off < 0 ? : 575 628 1203
237 1203 ▶ $fin = $len < 0 ? $slen + $len : $ini + $len;
Branch: 1 branch
BranchTrueFalseTotal
$len < 0 ? : 526 677 1203
238 1203 ▶ $ini = 0 if $ini < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $ini < 0 37 1166 1203
239 1203 ▶ $fin = $ini if $ini > $fin;
Branch: 1 branch
BranchTrueFalseTotal
if $ini > $fin 294 909 1203
240 1203 ▶ $ini = $slen if $slen < $ini;
Branch: 1 branch
BranchTrueFalseTotal
if $slen < $ini 0 1203 1203
241 1203 ▶ $fin = $slen if $slen < $fin;
Branch: 1 branch
BranchTrueFalseTotal
if $slen < $fin 315 888 1203
242  
243 1203 my $cnt = 0;
244 1203 my $plen = 0;
245 1203 my $clen = 0;
246 1203 ▶ while ($str =~ /($Char)/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /($Char)/go) 87799 431 88230
247 87799 ▶ if ($cnt < $ini) { $plen += CORE::length($1) }
Branch: 2 branches
BranchTrueFalseTotal
if ($cnt < $ini) { } 64381 23418 87799
elsif ($cnt < $fin) { } 22646 772 23418
248 22646 elsif($cnt < $fin) { $clen += CORE::length($1) }
249 772 else { last }
250 87027 $cnt++;
251 }
252 1203 ▶ if (@_ > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 3) 357 846 1203
253 357 $_[0] = CORE::substr($str, 0, $plen) .
254 $rep. CORE::substr($str, $plen + $clen);
255 }
256 1203 ▶ return ref $arg
Branch: 1 branch
BranchTrueFalseTotal
ref $arg ? : 393 810 1203
257 ? \ CORE::substr($$arg, $plen, $clen)
258 : CORE::substr($str, $plen, $clen);
259 }
260  
261 ##
262 ## strtr(STRING or SCALAR REF, SEARCHLIST, REPLACEMENTLIST;
263 ## MODIFIER, PATTERN, TOPATTERN)
264 ##
265 25 my %Cache;
266  
267 0 ▶sub getStrtrCache { wantarray ? %Cache : \%Cache }
Subroutine getStrtrCache: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
268  
269 619 ▶sub strtr($$$;$$$) {
Subroutine strtr: called CC=4 SCAR=17.1
Pod documented
270 619 my $str = shift;
271 my $coderef = (defined $_[2] && $_[2] =~ /o/)
272 619 ▶ ? ( $Cache{ join "\xFF", @_ } ||= trclosure(@_) )
Branch: 1 branch
BranchTrueFalseTotal
defined $_[2] && $_[2] =~ /o/ ? : 0 619 619
Condition33%2/6
defined $_[2] and $_[2] =~ /o/
!ll&&!rl&&r
215980
$Cache{join "\377", @_} ||= &trclosure(@_)
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $_[2] and $_[2] =~ /o/
defined $_[2] $_[2] =~ /o/
MC/DC0%0/2
$Cache{join "\377", @_} ||= &trclosure(@_)
$Cache{join "\377", @_} &trclosure(@_)
Truth table66%2/3
A and B
A= defined $_[2]B= $_[2] =~ /o/
ABresult
0X0
100
111
Truth table0%0/3
A ||= B
A= $Cache{join "\377", @_}B= &trclosure(@_)
ABresult
1X1
011
000
273 : trclosure(@_);
274 619 &$coderef($str);
275 }
276  
277  
278 ##
279 ## trclosure(SEARCHLIST, REPLACEMENTLIST; MODIFIER, PATTERN, TOPATTERN)
280 ##
281 sub trclosure($$;$$$)
282 907 ▶{
Subroutine trclosure: called CC=25 SCAR=32.4
Pod documented
283 907 my(@fr, @to, $noxs, $r, $R, $c, $d, $s, $h, $i, %hash);
284 907 my($fr, $to, $mod, $re, $tore) = @_;
285 907 ▶ $mod ||= ''; # '0' is not supposed.
Condition100%2/2
$mod ||= ""
l!l
760147
MC/DC100%1/1
$mod ||= ""
$mod
Truth table100%2/2
A
A= $mod
Aresult
11
00
286  
287 907 $noxs = $[ <= CORE::index($mod, 'n'); # no-op in the Non-XS version.
288 907 $h = $[ <= CORE::index($mod, 'h');
289 907 $r = $[ <= CORE::index($mod, 'r');
290 907 $R = $[ <= CORE::index($mod, 'R');
291  
292 907 ▶ if (ref $fr) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fr) { } 1 906 907
293 1 @fr = @$fr;
294 1 ▶ $re = defined $re
Branch: 1 branch
BranchTrueFalseTotal
defined $re ? : 0 1 1
295 ? "$re|$Char"
296 : join('|', map(quotemeta($_), @$fr), $Char);
297 } else {
298 906 ▶ $fr = mkrange($fr, $r) unless $R;
Branch: 1 branch
BranchTrueFalseTotal
unless $R 704 202 906
299 906 ▶ $re = defined $re ? "$re|$Char" : $Char;
Branch: 1 branch
BranchTrueFalseTotal
defined $re ? : 204 702 906
300 906 @fr = $fr =~ /\G$re/g;
301 }
302 907 ▶ if (ref $to) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $to) { } 1 906 907
303 1 @to = @$to;
304 1 ▶ $tore = defined $tore
Branch: 1 branch
BranchTrueFalseTotal
defined $tore ? : 0 1 1
305 ? "$tore|$Char"
306 : join('|', map(quotemeta($_), @$to), $Char);
307 } else {
308 906 ▶ $to = mkrange($to, $r) unless $R;
Branch: 1 branch
BranchTrueFalseTotal
unless $R 704 202 906
309 906 ▶ $tore = defined $tore ? "$tore|$Char" : $re;
Branch: 1 branch
BranchTrueFalseTotal
defined $tore ? : 3 903 906
310 906 @to = $to =~ /\G$tore/g;
311 }
312  
313 907 $c = $[ <= CORE::index($mod, 'c');
314 907 $d = $[ <= CORE::index($mod, 'd');
315 907 $s = $[ <= CORE::index($mod, 's');
316 907 my $modes = $s * 4 + $d * 2 + $c;
317  
318 907 ▶ for ($i = 0; $i < @fr; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @fr) 27894 907 28801
319 27894 ▶ next if exists $hash{ $fr[$i] };
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash{$fr[$i]} 844 27050 27894
320 27050 ▶ $hash{ $fr[$i] } = @to
Branch: 4 branches
BranchTrueFalseTotal
@to ? : 25952 1098 27050
defined $to[$i] ? : 25524 428 25952
$d ? : 93 335 428
$d && !$c ? : 212 886 1098
Condition100%3/3
$d and not $c
!ll&&!rl&&r
622264212
MC/DC100%2/2
$d and not $c
$d not $c
Truth table100%3/3
A and not(B)
A= $dB= not $c
ABresult
0X0
100
111
321 ? defined $to[$i] ? $to[$i] : $d ? '' : $to[-1]
322 : $d && !$c ? '' : $fr[$i];
323 }
324  
325 return
326 $modes == 0 || $modes == 2 ?
327 2186 ▶ sub { # $c: false, $d: true/false, $s: false, $mod: 0 or 2
Subroutine __ANON__: called CC=7 SCAR=19.5
328 2186 my $str = shift;
329 2186 my $cnt = 0; my %cnt = ();
330 2186 ▶ (ref $str ? $$str : $str) =~ s{($re)}{
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 243 1943 2186
331 exists $hash{$1}
332 551744 ▶ ? ($h ? ++$cnt{$1} : ++$cnt, $hash{$1})
Branch: 2 branches
BranchTrueFalseTotal
exists $hash{$1} ? : 284068 267676 551744
$h ? : 38 284030 284068
333 : $1;
334 }ge;
335 2186 ▶ return $h
Branch: 3 branches
BranchTrueFalseTotal
$h ? : 6 2180 2186
wantarray ? : 5 1 6
ref $str ? : 241 1939 2180
336 ? wantarray ? %cnt : \%cnt
337 : ref $str ? $cnt : $str;
338 } :
339  
340 $modes == 1 ?
341 74 ▶ sub { # $c: true, $d: false, $s: false, $mod: 1
Subroutine __ANON__: called CC=8 SCAR=21.1
342 74 my $str = shift;
343 74 my $cnt = 0; my %cnt = ();
344 74 ▶ (ref $str ? $$str : $str) =~ s{($re)}{
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 74 0 74
345 exists $hash{$1} ? $1
346 2327 ▶ : ($h ? ++$cnt{$1} : ++$cnt, @to) ? $to[-1] : $1;
Branch: 3 branches
BranchTrueFalseTotal
exists $hash{$1} ? : 421 1906 2327
($h ? ++$cnt{$1} : ++$cnt, @to) ? : 1586 320 1906
$h ? : 10 1896 1906
347 }ge;
348 74 ▶ return $h
Branch: 3 branches
BranchTrueFalseTotal
$h ? : 2 72 74
wantarray ? : 2 0 2
ref $str ? : 72 0 72
349 ? wantarray ? %cnt : \%cnt
350 : ref $str ? $cnt : $str;
351 } :
352  
353 $modes == 3 || $modes == 7 ?
354 147 ▶ sub { # $c: true, $d: true, $s: true/false, $mod: 3 or 7
Subroutine __ANON__: called CC=7 SCAR=19.5
355 147 my $str = shift;
356 147 my $cnt = 0; my %cnt = ();
357 147 ▶ (ref $str ? $$str : $str) =~ s{($re)}{
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 146 1 147
358 4663 ▶ exists $hash{$1} ? $1 : ($h ? ++$cnt{$1} : ++$cnt, '');
Branch: 2 branches
BranchTrueFalseTotal
exists $hash{$1} ? : 858 3805 4663
$h ? : 4 3801 3805
359 }ge;
360 147 ▶ return $h
Branch: 3 branches
BranchTrueFalseTotal
$h ? : 1 146 147
wantarray ? : 1 0 1
ref $str ? : 145 1 146
361 ? wantarray ? %cnt : \%cnt
362 : ref $str ? $cnt : $str;
363 } :
364  
365 $modes == 4 || $modes == 6 ?
366 147 ▶ sub { # $c: false, $d: true/false, $s: true, $mod: 4 or 6
Subroutine __ANON__: called CC=9 SCAR=22.4
367 147 my $str = shift;
368 147 my $cnt = 0; my %cnt = ();
369 147 my $pre = '';
370 147 ▶ (ref $str ? $$str : $str) =~ s{($re)}{
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 146 1 147
371 exists $hash{$1} ? ($h ? ++$cnt{$1} : ++$cnt,
372 $hash{$1} eq '' || $hash{$1} eq $pre
373 4659 ▶ ? '' : ($pre = $hash{$1})
Branch: 3 branches
BranchTrueFalseTotal
exists $hash{$1} ? : 841 3818 4659
$h ? : 0 841 841
$hash{$1} eq '' || $hash{$1} eq $pre ? : 174 667 841
Condition100%3/3
$hash{$1} eq "" or $hash{$1} eq $pre
l!l&&r!l&&!r
12252667
MC/DC100%2/2
$hash{$1} eq "" or $hash{$1} eq $pre
$hash{$1} eq "" $hash{$1} eq $pre
Truth table100%3/3
A or B
A= $hash{$1} eq ""B= $hash{$1} eq $pre
ABresult
1X1
011
000
374 ) : ($pre = '', $1);
375 }ge;
376 147 ▶ return $h
Branch: 3 branches
BranchTrueFalseTotal
$h ? : 0 147 147
wantarray ? : 0 0 0
ref $str ? : 146 1 147
377 ? wantarray ? %cnt : \%cnt
378 : ref $str ? $cnt : $str;
379 } :
380  
381 $modes == 5 ?
382 73 ▶ sub { # $c: true, $d: false, $s: true, $mod: 5
Subroutine __ANON__: called CC=9 SCAR=22.4
383 73 my $str = shift;
384 73 my $cnt = 0; my %cnt = ();
385 73 my $pre = '';
386 73 my $tmp;
387 73 ▶ (ref $str ? $$str : $str) =~ s{($re)}{
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 72 1 73
388 exists $hash{$1}
389 ? ($pre = '', $1)
390 2319 ▶ : ($h ? ++$cnt{$1} : ++$cnt,
Branch: 4 branches
BranchTrueFalseTotal
exists $hash{$1} ? : 415 1904 2319
$h ? : 0 1904 1904
@to ? : 1588 316 1904
$tmp eq $pre ? : 1265 639 1904
391 $tmp = @to ? $to[-1] : $1,
392 $tmp eq $pre ? '' : ($pre = $tmp)
393 );
394 }ge;
395 73 ▶ return $h
Branch: 3 branches
BranchTrueFalseTotal
$h ? : 0 73 73
wantarray ? : 0 0 0
ref $str ? : 72 1 73
396 ? wantarray ? %cnt : \%cnt
397 : ref $str ? $cnt : $str;
398 } :
399 0 ▶ sub { croak "$PACKAGE Panic! Invalid closure in trclosure!\n" }
Subroutine __ANON__: not called CC=1 SCAR=6.9
400 907 ▶}
Branch: 5 branches
BranchTrueFalseTotal
$modes == 0 || $modes == 2 ? : 466 441 907
$modes == 1 ? : 74 367 441
$modes == 3 || $modes == 7 ? : 147 220 367
$modes == 4 || $modes == 6 ? : 147 73 220
$modes == 5 ? : 73 0 73
Condition100%9/9
$modes == 0 or $modes == 2
l!l&&r!l&&!r
39076441
$modes == 3 or $modes == 7
l!l&&r!l&&!r
7572220
$modes == 4 or $modes == 6
l!l&&r!l&&!r
757273
MC/DC100%2/2
$modes == 0 or $modes == 2
$modes == 0 $modes == 2
MC/DC100%2/2
$modes == 3 or $modes == 7
$modes == 3 $modes == 7
MC/DC100%2/2
$modes == 4 or $modes == 6
$modes == 4 $modes == 6
Truth table100%3/3
A or B
A= $modes == 0B= $modes == 2
ABresult
1X1
011
000
Truth table100%3/3
A or B
A= $modes == 3B= $modes == 7
ABresult
1X1
011
000
Truth table100%3/3
A or B
A= $modes == 4B= $modes == 6
ABresult
1X1
011
000
401  
402  
403 4 ▶sub sjis_display ($) { # for err-msg
Subroutine sjis_display: called CC=5 SCAR=18.2
Pod undocumented
404 4 my $c = shift;
405 4 ▶ $c == 0 ? '\0' :
Branch: 3 branches
BranchTrueFalseTotal
$c == 0 ? : 0 4 4
$c < 32 || $c == 127 ? : 0 4 4
$c > 255 ? : 2 2 4
Condition33%1/3
$c < 32 or $c == 127
l!l&&r!l&&!r
004
MC/DC0%0/2
$c < 32 or $c == 127
$c < 32 $c == 127
Truth table33%1/3
A or B
A= $c < 32B= $c == 127
ABresult
1X1
011
000
406 $c < 0x20 || $c == 0x7F ? sprintf("\\x%02x", $c) :
407 $c > 0xFF ? pack('n', $c) : chr($c);
408 }
409  
410 428 ▶sub __ord ($) { CORE::length($_[0]) > 1 ? unpack('n', $_[0]) : ord($_[0]) }
Subroutine __ord: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
CORE::length $_[0] > 1 ? : 120 308 428
411  
412 214 ▶sub __expand {
Subroutine __expand: called CC=27 SCAR=33.0
413 214 my($ini, $fin, $i, $ch, @retv);
414 214 my($fin_f,$fin_t,$ini_f,$ini_t);
415 214 my($fr, $to, $rev) = @_;
416 214 ▶ if ($fr > $to) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr > $to) { } 14 200 214
417 14 ▶ if($rev){ ($fr,$to) = ($to,$fr) }
Branch: 1 branch
BranchTrueFalseTotal
if ($rev) { } 12 2 14
418 else {
419 2 croak sprintf "$PACKAGE Invalid character range %s-%s",
420 sjis_display($fr), sjis_display($to);
421 }
422 200 } else { $rev = 0 }
423 212 ▶ if ($fr <= 0x7F) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= 127) 152 60 212
424 152 ▶ $ini = $fr < 0x00 ? 0x00 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 0 ? : 0 152 152
425 152 ▶ $fin = $to > 0x7F ? 0x7F : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 127 ? : 4 148 152
426 152 ▶ for ($i = $ini; $i <= $fin; $i++) { push @retv, chr($i) }
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fin) 4063 152 4215
427 }
428 212 ▶ if ($fr <= 0xDF) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= 223) 155 57 212
429 155 ▶ $ini = $fr < 0xA1 ? 0xA1 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 161 ? : 152 3 155
430 155 ▶ $fin = $to > 0xDF ? 0xDF : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 223 ? : 4 151 155
431 155 ▶ for ($i = $ini; $i <= $fin; $i++) { push @retv, chr($i) }
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fin) 400 155 555
432 }
433 212 ▶ $ini = $fr < 0x8140 ? 0x8140 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 33088 ? : 155 57 212
434 212 ▶ $fin = $to > 0xFCFC ? 0xFCFC : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 64764 ? : 0 212 212
435 212 ▶ if ($ini <= $fin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini <= $fin) 61 151 212
436 61 ($ini_f,$ini_t) = unpack 'C*', pack 'n', $ini;
437 61 ($fin_f,$fin_t) = unpack 'C*', pack 'n', $fin;
438 61 ▶ $ini_t = 0x40 if $ini_t < 0x40;
Branch: 1 branch
BranchTrueFalseTotal
if $ini_t < 64 0 61 61
439 61 ▶ $fin_t = 0xFC if $fin_t > 0xFC;
Branch: 1 branch
BranchTrueFalseTotal
if $fin_t > 252 0 61 61
440 61 ▶ if ($ini_f == $fin_f) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini_f == $fin_f) { } 55 6 61
441 55 $ch = chr $ini_f;
442 55 ▶ for ($i = $ini_t; $i <= $fin_t; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fin_t) 2820 55 2875
443 2820 ▶ next if $i == 0x7F;
Branch: 1 branch
BranchTrueFalseTotal
if $i == 127 13 2807 2820
444 2807 push @retv, $ch.chr($i);
445 }
446 } else {
447 6 $ch = chr($ini_f);
448 6 ▶ for ($i = $ini_t; $i <= 0xFC; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 252) 690 6 696
449 690 ▶ next if $i == 0x7F;
Branch: 1 branch
BranchTrueFalseTotal
if $i == 127 2 688 690
450 688 push @retv, $ch.chr($i);
451 }
452 6 ▶ for ($i = $ini_f+1; $i < $fin_f; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $fin_f) 280 6 286
453 280 ▶ next if 0xA0 <= $i && $i <= 0xDF;
Branch: 1 branch
BranchTrueFalseTotal
if 160 <= $i and $i <= 223 128 152 280
Condition100%3/3
160 <= $i and $i <= 223
!ll&&!rl&&r
9656128
MC/DC100%2/2
160 <= $i and $i <= 223
160 <= $i $i <= 223
Truth table100%3/3
A and B
A= 160 <= $iB= $i <= 223
ABresult
0X0
100
111
454 152 $ch = chr($i);
455 152 push @retv, map $ch.chr, 0x40..0x7E, 0x80..0xFC;
456 }
457 6 $ch = chr($fin_f);
458 6 ▶ for ($i = 0x40; $i <= $fin_t; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fin_t) 662 6 668
459 662 ▶ next if $i == 0x7F;
Branch: 1 branch
BranchTrueFalseTotal
if $i == 127 4 658 662
460 658 push @retv, $ch.chr($i);
461 }
462 }
463 }
464 212 ▶ return $rev ? reverse(@retv) : @retv;
Branch: 1 branch
BranchTrueFalseTotal
$rev ? : 12 200 212
465 }
466  
467  
468 ##
469 ## mkrange(STRING, BOOL)
470 ##
471 1456 ▶sub mkrange($;$) {
Subroutine mkrange: called CC=12 SCAR=25.5
Pod documented
472 1456 my($s, @retv, $range, $min, $max);
473 1456 my($self,$rev) = @_;
474 1456 $self =~ s/^-/\\-/;
475 1456 $range = 0;
476 1456 foreach $s ($self =~ /\G(?:\\\\|\\-|$Char)/go) {
477 4205 ▶ if ($range) {
Branch: 1 branch
BranchTrueFalseTotal
if ($range) { } 214 3991 4205
478 0 ▶ if ($s eq '\\-') { $s = '-' }
Branch: 2 branches
BranchTrueFalseTotal
if ($s eq '\\-') { } 0 214 214
elsif ($s eq '\\\\') { } 0 214 214
479 0 elsif ($s eq '\\\\') { $s = '\\' }
480  
481 214 ▶ $min = @retv ? __ord(pop(@retv)) : 1;
Branch: 1 branch
BranchTrueFalseTotal
@retv ? : 214 0 214
482 214 $max = __ord($s);
483 214 push @retv, __expand($min,$max,$rev);
484 212 $range = 0;
485 } else {
486 3991 ▶ if ($s eq '-') { $range = 1 }
Branch: 3 branches
BranchTrueFalseTotal
if ($s eq '-') { } 219 3772 3991
elsif ($s eq '\\-') { } 8 3764 3772
elsif ($s eq '\\\\') { } 0 3764 3764
487 8 elsif ($s eq '\\-') { push @retv, '-' }
488 0 elsif ($s eq '\\\\') { push @retv, '\\'}
489 3764 else { push @retv, $s }
490 }
491 }
492 1454 ▶ push @retv, '-' if $range;
Branch: 1 branch
BranchTrueFalseTotal
if $range 5 1449 1454
493 1454 ▶ wantarray ? @retv : @retv ? join('', @retv) : '';
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 3 1451 1454
@retv ? : 1244 207 1451
494 }
495  
496  
497 ##
498 ## spaceH2Z(STRING)
499 ##
500 17 ▶sub spaceH2Z($) {
Subroutine spaceH2Z: called CC=4 SCAR=13.9
Pod documented
501 17 my $str = shift;
502 17 ▶ my $len = CORE::length(ref $str ? $$str : $str);
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 5 12 17
503 17 ▶ (ref $str ? $$str : $str) =~ s/ /\x81\x40/g;
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 5 12 17
504 17 ▶ ref $str ? abs($len - CORE::length $$str) : $str;
Branch: 1 branch
BranchTrueFalseTotal
ref $str ? : 5 12 17
505 };
506  
507 ##
508 ## spaceZ2H(STRING)
509 ##
510 ## tolower(STRING) and toupper(STRING)
511 ##
512 25 my $spaceZ2H = trclosure('@', ' ');
513 25 my $toupper = trclosure('a-z', 'A-Z');
514 25 my $tolower = trclosure('A-Z', 'a-z');
515  
516 29 ▶sub spaceZ2H($) { &$spaceZ2H(@_) }
Subroutine spaceZ2H: called CC=1 SCAR=0.0
Pod documented
517 31 ▶sub toupper($) { &$toupper(@_) }
Subroutine toupper: called CC=1 SCAR=0.0
Pod documented
518 27 ▶sub tolower($) { &$tolower(@_) }
Subroutine tolower: called CC=1 SCAR=0.0
Pod documented
519  
520 ##
521 ## Kana Letters
522 ##
523 25 my $kataTRE = '(?:[\xB3\xB6-\xC4\xCA-\xCE]\xDE|[\xCA-\xCE]\xDF)';
524 25 my $hiraTRE = '(?:\x82\xA4\x81\x4A)'; # '‚¤J'
525 25 my $kanaTRE = "(?:$hiraTRE|$kataTRE)";
526  
527 25 my $kataH
528 = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿À'
529 . 'ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß'
530 . '¶Þ·Þ¸Þ¹ÞºÞ»Þ¼Þ½Þ¾Þ¿ÞÀÞÁÞÂÞÃÞÄÞÊÞËÞÌÞÍÞÎÞÊßËßÌßÍßÎß'
531 . '³Þ²´Ü¶¹';
532  
533 25 my $kataZH
534 = 'BuvAEƒ’ƒ@ƒBƒDƒFƒHƒƒƒ…ƒ‡ƒb[ƒAƒCƒEƒGƒIƒJƒLƒNƒPƒRƒTƒVƒXƒZƒ\ƒ^'
535 . 'ƒ`ƒcƒeƒgƒiƒjƒkƒlƒmƒnƒqƒtƒwƒzƒ}ƒ~ƒ€ƒƒ‚ƒ„ƒ†ƒˆƒ‰ƒŠƒ‹ƒŒƒƒƒ“JK'
536 . 'ƒKƒMƒOƒQƒSƒUƒWƒYƒ[ƒ]ƒ_ƒaƒdƒfƒhƒoƒrƒuƒxƒ{ƒpƒsƒvƒyƒ|'
537 . 'ƒ”ƒƒ‘ƒŽƒ•ƒ–';
538  
539 25 my $hiraZH
540 = 'BuvAE‚ð‚Ÿ‚¡‚£‚¥‚§‚á‚ã‚å‚Á[‚ ‚¢‚¤‚¦‚¨‚©‚«‚­‚¯‚±‚³‚µ‚·‚¹‚»‚½'
541 . '‚¿‚‚ĂƂȂɂʂ˂̂͂Ђӂւق܂݂ނ߂à‚â‚䂿‚ç‚è‚é‚ê‚ë‚í‚ñJK'
542 . '‚ª‚¬‚®‚°‚²‚´‚¶‚¸‚º‚¼‚¾‚À‚Âłǂ΂тԂׂڂς҂Ղ؂Û'
543 . '‚¤J‚î‚ï‚ì‚©‚¯';
544  
545 25 my $kataH2Z = trclosure($kataH, $kataZH, 'R', $kanaTRE);
546 25 my $hiraH2Z = trclosure($kataH, $hiraZH, 'R', $kanaTRE);
547 25 my $kataZ2H = trclosure($kataZH, $kataH, 'R', $kanaTRE);
548 25 my $kanaZ2H = trclosure($hiraZH.$kataZH, $kataH.$kataH, 'R', $kanaTRE);
549 25 my $hiraZ2H = trclosure($hiraZH, $kataH, 'R', $kanaTRE);
550  
551 25 my $kataZ
552 = 'ƒ’ƒ@ƒBƒDƒFƒHƒƒƒ…ƒ‡ƒbƒAƒCƒEƒGƒIƒJƒLƒNƒPƒRƒTƒVƒXƒZƒ\ƒ^'
553 . 'ƒ`ƒcƒeƒgƒiƒjƒkƒlƒmƒnƒqƒtƒwƒzƒ}ƒ~ƒ€ƒƒ‚ƒ„ƒ†ƒˆƒ‰ƒŠƒ‹ƒŒƒƒƒ“'
554 . 'ƒKƒMƒOƒQƒSƒUƒWƒYƒ[ƒ]ƒ_ƒaƒdƒfƒhƒoƒrƒuƒxƒ{ƒpƒsƒvƒyƒ|'
555 . 'ƒ”ƒƒ‘ƒŽƒ•ƒ–RS';
556  
557 25 my $hiraZ
558 = '‚ð‚Ÿ‚¡‚£‚¥‚§‚á‚ã‚å‚Á‚ ‚¢‚¤‚¦‚¨‚©‚«‚­‚¯‚±‚³‚µ‚·‚¹‚»‚½'
559 . '‚¿‚‚ĂƂȂɂʂ˂̂͂Ђӂւق܂݂ނ߂à‚â‚䂿‚ç‚è‚é‚ê‚ë‚í‚ñ'
560 . '‚ª‚¬‚®‚°‚²‚´‚¶‚¸‚º‚¼‚¾‚À‚Âłǂ΂тԂׂڂς҂Ղ؂Û'
561 . '‚¤J‚î‚ï‚ì‚©‚¯TU';
562  
563 25 my $hiXka = trclosure($kataZ.$hiraZ, $hiraZ.$kataZ, 'R', $hiraTRE);
564 25 my $hi2ka = trclosure($hiraZ, $kataZ, 'R', $hiraTRE);
565 25 my $ka2hi = trclosure($kataZ, $hiraZ, 'R', $hiraTRE);
566  
567 23 ▶sub kataH2Z ($) { &$kataH2Z(@_) }
Subroutine kataH2Z: called CC=1 SCAR=0.0
Pod documented
568 38 ▶sub kanaH2Z ($) { &$kataH2Z(@_) }
Subroutine kanaH2Z: called CC=1 SCAR=0.0
Pod documented
569 21 ▶sub hiraH2Z ($) { &$hiraH2Z(@_) }
Subroutine hiraH2Z: called CC=1 SCAR=0.0
Pod documented
570 22 ▶sub kataZ2H ($) { &$kataZ2H(@_) }
Subroutine kataZ2H: called CC=1 SCAR=0.0
Pod documented
571 29 ▶sub kanaZ2H ($) { &$kanaZ2H(@_) }
Subroutine kanaZ2H: called CC=1 SCAR=0.0
Pod documented
572 19 ▶sub hiraZ2H ($) { &$hiraZ2H(@_) }
Subroutine hiraZ2H: called CC=1 SCAR=0.0
Pod documented
573 24 ▶sub hiXka ($) { &$hiXka(@_) }
Subroutine hiXka: called CC=1 SCAR=0.0
Pod documented
574 19 ▶sub hi2ka ($) { &$hi2ka(@_) }
Subroutine hi2ka: called CC=1 SCAR=0.0
Pod documented
575 19 ▶sub ka2hi ($) { &$ka2hi(@_) }
Subroutine ka2hi: called CC=1 SCAR=0.0
Pod documented
576  
577  
578 ##
579 ## strsplit
580 ##
581 255 ▶sub strsplit ($$;$) {
Subroutine strsplit: called CC=26 SCAR=32.6
Pod documented
582 255 my $strpat = shift;
583 255 my $str = shift;
584 255 ▶ my $lim = shift || 0;
Condition100%2/2
shift() || 0
l!l
20946
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
585  
586 255 ▶ return wantarray ? () : 0 if $str eq '';
Branch: 2 branches
BranchTrueFalseTotal
if $str eq "" 102 153 255
wantarray ? : 51 51 102
587  
588 153 my($pat);
589 153 ▶ if (!defined $strpat) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $strpat) { } 34 119 153
590 34 ▶ if ($lim <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lim <= 0) 12 22 34
591 12 return @{ [ split ' ', spaceZ2H($str), $lim ] };
592 }
593 22 $str =~ s/^(?:[ \n\r\t\f]|\x81\x40)+//;
594 22 $pat = '(?:(?:[ \n\r\t\f]|\x81\x40)+)';
595 } else {
596 119 ▶ if ($strpat eq '' && $lim <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strpat eq "" and $lim <= 0) 4 115 119
Condition100%3/3
$strpat eq "" and $lim <= 0
!ll&&!rl&&r
75404
MC/DC100%2/2
$strpat eq "" and $lim <= 0
$strpat eq "" $lim <= 0
Truth table100%3/3
A and B
A= $strpat eq ""B= $lim <= 0
ABresult
0X0
100
111
597 return wantarray
598 4 ▶ ? ($str =~ /$Char/go, $lim < 0 ? '' : ())
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 2 2 4
$lim < 0 ? : 1 1 2
599 : ($lim < 0) + &length($str);
600 }
601 115 $pat = quotemeta $strpat;
602 }
603  
604 137 ▶ return wantarray ? ($str) : 1 if $lim == 1;
Branch: 2 branches
BranchTrueFalseTotal
if $lim == 1 8 129 137
wantarray ? : 4 4 8
605  
606 129 my $cnt = 0;
607 129 ▶ my @ret = CORE::length $pat ? ('') : ();
Branch: 1 branch
BranchTrueFalseTotal
CORE::length $pat ? : 91 38 129
608  
609 129 ▶ if (CORE::length $pat) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $pat) { } 91 38 129
610 91 ▶ while (($lim <= 0 || $cnt < $lim) && CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lim <= 0 || $cnt < $lim and CORE::length $str) 646 91 737
Condition100%6/6
$lim <= 0 || $cnt < $lim and CORE::length $str
!ll&&!rl&&r
3556646
$lim <= 0 or $cnt < $lim
l!l&&r!l&&!r
41528735
MC/DC100%3/3
$lim <= 0 || $cnt < $lim and CORE::length $str
$lim <= 0 $cnt < $lim CORE::length $str
Truth table100%5/5
A or B and C
A= $lim <= 0B= $cnt < $limC= CORE::length $str
ABCresult
00X0
1X00
0100
1X11
0111
611 646 ▶ if ($str =~ s/^$pat//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ s/^$pat//) { } 228 418 646
612 228 $cnt = push @ret, '';
613 } else {
614 418 ▶ croak("$PACKAGE Panic in strsplit") if $str !~ s/^($Char)//o;
Branch: 1 branch
BranchTrueFalseTotal
unless $str =~ s/^($Char)//o 0 418 418
615 418 $ret[-1] .= $1;
616 }
617 }
618 } else {
619 38 ▶ while ($cnt < $lim && CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cnt < $lim and CORE::length $str) 418 38 456
Condition66%2/3
$cnt < $lim and CORE::length $str
!ll&&!rl&&r
380418
MC/DC50%1/2
$cnt < $lim and CORE::length $str
$cnt < $lim CORE::length $str
Truth table66%2/3
A and B
A= $cnt < $limB= CORE::length $str
ABresult
0X0
100
111
620 418 ▶ croak("$PACKAGE Panic in strsplit") unless $str =~ s/^($Char)//o;
Branch: 1 branch
BranchTrueFalseTotal
unless $str =~ s/^($Char)//o 0 418 418
621 418 $cnt = push @ret, $1;
622 }
623 }
624 129 ▶ $ret[-1] .= $str if $str ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $str ne "" 69 60 129
625 129 ▶ if ($lim == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lim == 0) 31 98 129
626 31 ▶ pop @ret while defined $ret[-1] && $ret[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
defined $ret[-1] and $ret[-1] eq "" and do { pop @ret } 34 31 65
Condition100%3/3
defined $ret[-1] and $ret[-1] eq ""
!ll&&!rl&&r
82334
MC/DC100%2/2
defined $ret[-1] and $ret[-1] eq ""
defined $ret[-1] $ret[-1] eq ""
Truth table100%3/3
A and B
A= defined $ret[-1]B= $ret[-1] eq ""
ABresult
0X0
100
111
627 }
628 129 return @ret;
629 }
630  
631 ##
632 ## strxfrm
633 ##
634 91938 ▶sub strxfrm ($) {
Subroutine strxfrm: called CC=2 SCAR=6.9
Pod documented
635 91938 my $str = shift;
636 91938 ▶ $str =~ s/($Char)/ CORE::length $1 > 1 ? $1 : "\0".$1 /ge;
Branch: 1 branch
BranchTrueFalseTotal
CORE::length $1 > 1 ? : 90322 1664 91986
637 91938 return $str;
638 }
639  
640 11491 ▶sub strcmp($$) { $_[0] eq $_[1] ? 0 : strxfrm($_[0]) cmp strxfrm($_[1]) }
Subroutine strcmp: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq $_[1] ? : 3 11488 11491
641 7 ▶sub strEQ ($$) { $_[0] eq $_[1] }
Subroutine strEQ: called CC=1 SCAR=0.0
Pod documented
642 7 ▶sub strNE ($$) { $_[0] ne $_[1] }
Subroutine strNE: called CC=1 SCAR=0.0
Pod documented
643 7 ▶sub strLT ($$) { $_[0] eq $_[1] ? '' : strxfrm($_[0]) lt strxfrm($_[1]) }
Subroutine strLT: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq $_[1] ? : 2 5 7
644 11475 ▶sub strLE ($$) { $_[0] eq $_[1] ? 1 : strxfrm($_[0]) le strxfrm($_[1]) }
Subroutine strLE: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq $_[1] ? : 2 11473 11475
645 6 ▶sub strGT ($$) { $_[0] eq $_[1] ? '' : strxfrm($_[0]) gt strxfrm($_[1]) }
Subroutine strGT: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq $_[1] ? : 2 4 6
646 4 ▶sub strGE ($$) { $_[0] eq $_[1] ? 1 : strxfrm($_[0]) ge strxfrm($_[1]) }
Subroutine strGE: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq $_[1] ? : 2 2 4
647  
648 25 1;
649  
650 __END__
↑ Summary