| 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
| |||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$len < 1 or 2 < $len
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
| |||||||||||||||||||||||||||||||||
| 20 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||
| 22 | elsif ($len == 1) { | ||||||||||||||||||||||||||||||||
| 23 | 610 | ▶ | return $ch eq "\x7F" | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||