Multibyte/ShiftJIS.pm

filter: Statementstmt 92.3% 12 / 13 Branchbran 88.8% 16 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 82.0% 32 / 39 CC 11 SCAR 20.3
CC
11
Cov
85%
__ANON__
10.7
__ANON__
2.0
BEGIN
1.0
CRAP 7.6
« Multibyte/EUC_JP.pm ↑ Summary Multibyte/EUC.pm »
1 package String::Multibyte::ShiftJIS;
2  
3 18 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 $VERSION = '1.12';
5  
6 +{
7 charset => 'Shift-JIS',
8  
9 regexp => '(?:[\x00-\x7F\xA1-\xDF]|' .
10 '[\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC])',
11  
12 97 ▶ cmpchar => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
13 97 ▶ length($_[0]) <=> length($_[1]) || $_[0] cmp $_[1];
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] <=> length $_[1] or $_[0] cmp $_[1] 1 95 96
14 },
15  
16 3407 ▶ nextchar => sub {
Subroutine __ANON__: called CC=10 SCAR=23.7
17 3408 my $ch = shift;
18 3408 my $len = length $ch;
19 3407 ▶ if ($len < 1 || 2 < $len) {
Branch: 2 branches
BranchTrueFalseTotal
if ($len < 1 or 2 < $len) { } 0 3407 3407
elsif ($len == 1) { } 610 2797 3407
Condition33%1/3
$len < 1 or 2 < $len
l!l&&r!l&&!r
003407
MC/DC0%0/2
$len < 1 or 2 < $len
$len < 1 2 < $len
Truth table33%1/3
A or B
A= $len < 1B= 2 < $len
ABresult
1X1
011
000
20 0 return undef;
21 }
22 elsif ($len == 1) {
23 610 ▶ return $ch eq "\x7F"
Branch: 2 branches
BranchTrueFalseTotal
$ch eq "\177" ? : 1 609 610
$ch eq "\337" ? : 1 608 609
24 ? "\xA1"
25 : $ch eq "\xDF"
26 ? "\x81\x40"
27 : chr(ord($ch)+1);
28 }
29 else {
30 2797 my($c,$d) = unpack('CC',$ch);
31 2797 ▶ return $ch eq "\x9F\xFC"
Branch: 4 branches
BranchTrueFalseTotal
$ch eq "\237\374" ? : 1 2796 2797
$ch eq "\374\374" ? : 0 2796 2796
$d == 252 ? : 1 2795 2796
$d == 126 ? : 14 2781 2795
32 ? "\xE0\x40"
33 : $ch eq "\xFC\xFC"
34 ? undef
35 : $d == 0xFC
36 ? chr($c+1)."\x40"
37 : $d == 0x7E
38 ? chr($c) ."\x80"
39 : pack('CC', $c, $d+1);
40 }
41 },
42 15 };
43  
44 __END__
« Multibyte/EUC_JP.pm ↑ Summary Multibyte/EUC.pm »