Regexp/Class.pm

filter: Statementstmt 84.2% 209 / 248 Branchbran 74.2% 199 / 268 Conditioncond 69.1% 56 / 81 MC/DCmcdc 50.9% 27 / 53 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 8 totaltotal 75.2% 507 / 674 CC 170 SCAR 40.2
CC
170
Cov
78%
expand
100.3
rechar
55.0
parse_class
37.5
CRAP 55.7
↑ Summary Regexp.pm »
1 package ShiftJIS::Regexp::Class;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 $VERSION = '1.03';
7  
8 6 require Exporter;
9 6 @ISA = qw(Exporter);
10 6 @EXPORT = qw(parse_class parse_prop parse_regex rechar);
11 6 @EXPORT_OK = qw();
12  
13 6 ▶use vars qw(%AbbrevProp %Re %Eq %Err $Char $Trail);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use ShiftJIS::Regexp::Const qw(%AbbrevProp %Re %Err $Char $Trail);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use ShiftJIS::Regexp::Equiv qw(%Eq);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 6 ▶my $Open = 5.005 > $] ? '(?:' : '(?-i:';
Branch: 1 branch
BranchTrueFalseTotal
5.005 > $] ? : 0 6 6
18 6 my $OpenRe = quotemeta $Open;
19 6 my $Close = ')';
20 6 my $InClassRe = '[\-0-9A-Za-z\\\\]';
21  
22 478 ▶sub __ord ($) {
Subroutine __ord: called CC=2 SCAR=6.9
23 478 ▶ length($_[0]) > 1 ? unpack('n', $_[0]) : ord($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] > 1 ? : 326 152 478
24 }
25  
26 362 ▶sub __ord2($) {
Subroutine __ord2: called CC=2 SCAR=7.6
27 362 ▶ 0xFF < $_[0] ? unpack('C*', pack 'n', $_[0]) : chr($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
255 < $_[0] ? : 362 0 362
28 }
29  
30 sub rechar ($;$)
31 628 ▶{
Subroutine rechar: called CC=36 SCAR=40.1
Pod undocumented
32 628 my $c = shift;
33 628 ▶ my $mod = shift || '';
Condition100%2/2
shift() || ''
l!l
120508
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
34 628 ▶ if (1 == length $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (1 == length $c) 412 216 628
35 412 my $o = ord $c;
36 412 ▶ return $mod =~ /i/
Branch: 3 branches
BranchTrueFalseTotal
$mod =~ /i/ ? : 35 377 412
65 <= $o && $o <= 90 ? : 0 35 35
97 <= $o && $o <= 122 ? : 34 1 35
Condition50%3/6
65 <= $o and $o <= 90
!ll&&!rl&&r
0350
97 <= $o and $o <= 122
!ll&&!rl&&r
1034
MC/DC0%0/2
65 <= $o and $o <= 90
65 <= $o $o <= 90
MC/DC50%1/2
97 <= $o and $o <= 122
97 <= $o $o <= 122
Truth table33%1/3
A and B
A= 65 <= $oB= $o <= 90
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= 97 <= $oB= $o <= 122
ABresult
0X0
100
111
37 ? 0x41 <= $o && $o <= 0x5A
38 ? sprintf('[\\x%02x\\x%02x]', $o, $o + 0x20)
39 : 0x61 <= $o && $o <= 0x7A
40 ? sprintf('[\\x%02x\\x%02x]', $o, $o - 0x20)
41 : sprintf('\\x%02x', $o)
42 : sprintf('\\x%02x', $o)
43 }
44 216 my $d = ord substr($c,1,1); # the trail byte
45 216 ▶ my $rechar =
Branch: 14 branches
BranchTrueFalseTotal
$c =~ /^\x82([\x60-\x79])$/ && $mod =~ /I/ ? : 1 215 216
$c =~ /^\x82([\x81-\x9A])$/ && $mod =~ /I/ ? : 5 210 215
$c =~ /^\x83([\x9F-\xB6])$/ && $mod =~ /I/ ? : 0 210 210
$c =~ /^\x83([\xBF-\xD6])$/ && $mod =~ /I/ ? : 8 202 210
$c =~ /^\x84([\x40-\x4E])$/ && $mod =~ /I/ ? : 0 202 202
$c =~ /^\x84([\x4F-\x60])$/ && $mod =~ /I/ ? : 0 202 202
$c =~ /^\x84([\x70-\x7E])$/ && $mod =~ /I/ ? : 0 202 202
$c =~ /^\x84([\x80-\x91])$/ && $mod =~ /I/ ? : 0 202 202
$c =~ /^\x82([\x9F-\xDD])$/ && $mod =~ /j/ ? : 18 184 202
$c =~ /^\x82([\xDE-\xF1])$/ && $mod =~ /j/ ? : 2 182 184
$c =~ /^\x83([\x40-\x7E])$/ && $mod =~ /j/ ? : 4 178 182
$c =~ /^\x83([\x80-\x93])$/ && $mod =~ /j/ ? : 6 172 178
$c =~ /^\x81([\x52-\x53])$/ && $mod =~ /j/ ? : 2 170 172
$c =~ /^\x81([\x54-\x55])$/ && $mod =~ /j/ ? : 0 170 170
Condition69%29/42
$c =~ /^\x82([\x60-\x79])$/ and $mod =~ /I/
!ll&&!rl&&r
21411
$c =~ /^\x82([\x81-\x9A])$/ and $mod =~ /I/
!ll&&!rl&&r
20915
$c =~ /^\x83([\x9F-\xB6])$/ and $mod =~ /I/
!ll&&!rl&&r
21000
$c =~ /^\x83([\xBF-\xD6])$/ and $mod =~ /I/
!ll&&!rl&&r
20208
$c =~ /^\x84([\x40-\x4E])$/ and $mod =~ /I/
!ll&&!rl&&r
20200
$c =~ /^\x84([\x4F-\x60])$/ and $mod =~ /I/
!ll&&!rl&&r
20200
$c =~ /^\x84([\x70-\x7E])$/ and $mod =~ /I/
!ll&&!rl&&r
20200
$c =~ /^\x84([\x80-\x91])$/ and $mod =~ /I/
!ll&&!rl&&r
20200
$c =~ /^\x82([\x9F-\xDD])$/ and $mod =~ /j/
!ll&&!rl&&r
175918
$c =~ /^\x82([\xDE-\xF1])$/ and $mod =~ /j/
!ll&&!rl&&r
18022
$c =~ /^\x83([\x40-\x7E])$/ and $mod =~ /j/
!ll&&!rl&&r
156224
$c =~ /^\x83([\x80-\x93])$/ and $mod =~ /j/
!ll&&!rl&&r
17206
$c =~ /^\x81([\x52-\x53])$/ and $mod =~ /j/
!ll&&!rl&&r
16642
$c =~ /^\x81([\x54-\x55])$/ and $mod =~ /j/
!ll&&!rl&&r
16640
MC/DC100%2/2
$c =~ /^\x82([\x60-\x79])$/ and $mod =~ /I/
$c =~ /^\x82([\x60-\x79])$/ $mod =~ /I/
MC/DC100%2/2
$c =~ /^\x82([\x81-\x9A])$/ and $mod =~ /I/
$c =~ /^\x82([\x81-\x9A])$/ $mod =~ /I/
MC/DC0%0/2
$c =~ /^\x83([\x9F-\xB6])$/ and $mod =~ /I/
$c =~ /^\x83([\x9F-\xB6])$/ $mod =~ /I/
MC/DC50%1/2
$c =~ /^\x83([\xBF-\xD6])$/ and $mod =~ /I/
$c =~ /^\x83([\xBF-\xD6])$/ $mod =~ /I/
MC/DC0%0/2
$c =~ /^\x84([\x40-\x4E])$/ and $mod =~ /I/
$c =~ /^\x84([\x40-\x4E])$/ $mod =~ /I/
MC/DC0%0/2
$c =~ /^\x84([\x4F-\x60])$/ and $mod =~ /I/
$c =~ /^\x84([\x4F-\x60])$/ $mod =~ /I/
MC/DC0%0/2
$c =~ /^\x84([\x70-\x7E])$/ and $mod =~ /I/
$c =~ /^\x84([\x70-\x7E])$/ $mod =~ /I/
MC/DC0%0/2
$c =~ /^\x84([\x80-\x91])$/ and $mod =~ /I/
$c =~ /^\x84([\x80-\x91])$/ $mod =~ /I/
MC/DC100%2/2
$c =~ /^\x82([\x9F-\xDD])$/ and $mod =~ /j/
$c =~ /^\x82([\x9F-\xDD])$/ $mod =~ /j/
MC/DC100%2/2
$c =~ /^\x82([\xDE-\xF1])$/ and $mod =~ /j/
$c =~ /^\x82([\xDE-\xF1])$/ $mod =~ /j/
MC/DC100%2/2
$c =~ /^\x83([\x40-\x7E])$/ and $mod =~ /j/
$c =~ /^\x83([\x40-\x7E])$/ $mod =~ /j/
MC/DC50%1/2
$c =~ /^\x83([\x80-\x93])$/ and $mod =~ /j/
$c =~ /^\x83([\x80-\x93])$/ $mod =~ /j/
MC/DC100%2/2
$c =~ /^\x81([\x52-\x53])$/ and $mod =~ /j/
$c =~ /^\x81([\x52-\x53])$/ $mod =~ /j/
MC/DC0%0/2
$c =~ /^\x81([\x54-\x55])$/ and $mod =~ /j/
$c =~ /^\x81([\x54-\x55])$/ $mod =~ /j/
Truth table100%3/3
A and B
A= $c =~ /^\x82([\x60-\x79])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $c =~ /^\x82([\x81-\x9A])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $c =~ /^\x83([\x9F-\xB6])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= $c =~ /^\x83([\xBF-\xD6])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $c =~ /^\x84([\x40-\x4E])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $c =~ /^\x84([\x4F-\x60])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $c =~ /^\x84([\x70-\x7E])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $c =~ /^\x84([\x80-\x91])$/B= $mod =~ /I/
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $c =~ /^\x82([\x9F-\xDD])$/B= $mod =~ /j/
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $c =~ /^\x82([\xDE-\xF1])$/B= $mod =~ /j/
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $c =~ /^\x83([\x40-\x7E])$/B= $mod =~ /j/
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= $c =~ /^\x83([\x80-\x93])$/B= $mod =~ /j/
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $c =~ /^\x81([\x52-\x53])$/B= $mod =~ /j/
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= $c =~ /^\x81([\x54-\x55])$/B= $mod =~ /j/
ABresult
0X0
100
111
46 $c =~ /^\x82([\x60-\x79])$/ && $mod =~ /I/
47 ? sprintf('\x82[\x%02x\x%02x]', $d, $d + 33)
48 : $c =~ /^\x82([\x81-\x9A])$/ && $mod =~ /I/
49 ? sprintf('\x82[\x%02x\x%02x]', $d, $d - 33)
50 : $c =~ /^\x83([\x9F-\xB6])$/ && $mod =~ /I/
51 ? sprintf('\x83[\x%02x\x%02x]', $d, $d + 32)
52 : $c =~ /^\x83([\xBF-\xD6])$/ && $mod =~ /I/
53 ? sprintf('\x83[\x%02x\x%02x]', $d, $d - 32)
54 : $c =~ /^\x84([\x40-\x4E])$/ && $mod =~ /I/
55 ? sprintf('\x84[\x%02x\x%02x]', $d, $d + 48)
56 : $c =~ /^\x84([\x4F-\x60])$/ && $mod =~ /I/
57 ? sprintf('\x84[\x%02x\x%02x]', $d, $d + 49)
58 : $c =~ /^\x84([\x70-\x7E])$/ && $mod =~ /I/
59 ? sprintf('\x84[\x%02x\x%02x]', $d, $d - 48)
60 : $c =~ /^\x84([\x80-\x91])$/ && $mod =~ /I/
61 ? sprintf('\x84[\x%02x\x%02x]', $d, $d - 49)
62 : $c =~ /^\x82([\x9F-\xDD])$/ && $mod =~ /j/
63 ? sprintf('\x82\x%02x|\x83\x%02x', $d, $d - 0x5F)
64 : $c =~ /^\x82([\xDE-\xF1])$/ && $mod =~ /j/
65 ? sprintf('\x82\x%02x|\x83\x%02x', $d, $d - 0x5E)
66 : $c =~ /^\x83([\x40-\x7E])$/ && $mod =~ /j/
67 ? sprintf('\x83\x%02x|\x82\x%02x', $d, $d + 0x5F)
68 : $c =~ /^\x83([\x80-\x93])$/ && $mod =~ /j/
69 ? sprintf('\x83\x%02x|\x82\x%02x', $d, $d + 0x5E)
70 : $c =~ /^\x81([\x52-\x53])$/ && $mod =~ /j/
71 ? sprintf('\x81[\x%02x\x%02x]', $d, $d + 2)
72 : $c =~ /^\x81([\x54-\x55])$/ && $mod =~ /j/
73 ? sprintf('\x81[\x%02x\x%02x]', $d, $d - 2)
74 : sprintf('\x%02x\x%02x', unpack 'C2', $c);
75 216 return "$Open$rechar$Close";
76 }
77  
78  
79 #
80 # parse_regex('R', ref to string)
81 # returning '\R{padA}' etc.
82 #
83 1 ▶sub parse_regex ($$) {
Subroutine parse_regex: called CC=5 SCAR=19.1
Pod undocumented
84 1 my($key, $rev);
85 1 my $r = shift;
86 1 for (${ $_[0] }) {
87 1 ▶ if (s/^\{//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\{//) { } 1 0 1
88 1 ▶ if (s/^([0-9A-Za-z]+)\}//) {
Branch: 2 branches
BranchTrueFalseTotal
if (s/^([0-9A-Za-z]+)\}//) { } 1 0 1
elsif (s/^([0-9A-Za-z]*(?![0-9A-Za-z])$ShiftJIS::Regexp::Class::Char)//o) { } 0 0 0
89 1 $key = lc $1;
90 }
91 elsif (s/^([0-9A-Za-z]*(?![0-9A-Za-z])$Char)//o) {
92 0 croak sprintf($Err{notAlnum}, "\\R\{$1");
93 }
94 else {
95 0 croak sprintf($Err{notTermin}, "\\R\{$_}", '}');
96 }
97 } else {
98 0 croak sprintf($Err{notBrace}, '\R');
99 }
100 }
101 1 return "\\R\{$key\}";
102 }
103  
104  
105 #
106 # parse_prop('p' or 'P', ref to string)
107 # returning '\p{digit}' etc.
108 #
109 432 ▶sub parse_prop ($$) {
Subroutine parse_prop: called CC=12 SCAR=27.7
Pod undocumented
110 432 my($key, $rev);
111 432 my $p = shift;
112 432 for (${ $_[0] }) {
113 432 ▶ if (s/^\{//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\{//) { } 206 226 432
114 206 ▶ $rev = s/^\^// ? '^' : '';
Branch: 1 branch
BranchTrueFalseTotal
s/^\^// ? : 2 204 206
115 206 s/^I[sn]//; # XXX, deprecated
116 206 ▶ if (s/^([0-9A-Za-z]+)\}//) {
Branch: 2 branches
BranchTrueFalseTotal
if (s/^([0-9A-Za-z]+)\}//) { } 206 0 206
elsif (s/^([0-9A-Za-z]*(?![0-9A-Za-z])$ShiftJIS::Regexp::Class::Char)//o) { } 0 0 0
117 206 $key = lc $1;
118 }
119 elsif (s/^([0-9A-Za-z]*(?![0-9A-Za-z])$Char)//o) {
120 0 croak sprintf($Err{notAlnum}, "\\$p\{$rev$1");
121 }
122 else {
123 0 croak sprintf($Err{notTermin}, "\\$p\{$_}", '}');
124 }
125 } else {
126 226 ▶ $rev = s/^\^// ? '^' : '';
Branch: 1 branch
BranchTrueFalseTotal
s/^\^// ? : 4 222 226
127 226 ▶ if (s/^([\x21-\x7e])//) {
Branch: 2 branches
BranchTrueFalseTotal
if (s/^([\x21-\x7e])//) { } 226 0 226
elsif (s/^($ShiftJIS::Regexp::Class::Char)//o) { } 0 0 0
128 226 ▶ $key = $AbbrevProp{uc $1} || $1;
Condition33%1/3
$ShiftJIS::Regexp::Class::AbbrevProp{uc $1} || $1
l!l&&r!l&&!r
22600
MC/DC0%0/2
$ShiftJIS::Regexp::Class::AbbrevProp{uc $1} || $1
$ShiftJIS::Regexp::Class::AbbrevProp{uc $1} $1
Truth table33%1/3
A || B
A= $ShiftJIS::Regexp::Class::AbbrevProp{uc $1}B= $1
ABresult
1X1
011
000
129 }
130 elsif (s/^($Char)//o) {
131 0 croak sprintf($Err{notASCII}, "\\$p$rev$1");
132 }
133 else {
134 0 croak sprintf($Err{notTermin}, "\\$p^", '');
135 }
136 }
137 }
138 432 ▶ if ($rev) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rev) 6 426 432
139 6 ▶ $p = $p eq 'p' ? 'P' : 'p';
Branch: 1 branch
BranchTrueFalseTotal
$p eq 'p' ? : 3 3 6
140 }
141 432 return "\\$p\{$key\}";
142 }
143  
144  
145 #
146 # parse_posix(ref to string)
147 # called after "[:" in a character class.
148 # returning '\p{digit}' etc.
149 #
150 86 ▶sub parse_posix ($) {
Subroutine parse_posix: called CC=6 SCAR=19.3
Pod undocumented
151 86 my($key, $rev);
152  
153 86 for(${ $_[0] }) {
154 86 ▶ $rev = s/^\^// ? '^' : '';
Branch: 1 branch
BranchTrueFalseTotal
s/^\^// ? : 43 43 86
155 86 ▶ if (s/^([0-9A-Za-z]+)\:\]//) {
Branch: 2 branches
BranchTrueFalseTotal
if (s/^([0-9A-Za-z]+)\:\]//) { } 86 0 86
elsif (s/^([0-9A-Za-z]*(?![:])$ShiftJIS::Regexp::Class::Char)//o) { } 0 0 0
156 86 $key = lc $1;
157 }
158 elsif (s/^([0-9A-Za-z]*(?![:])$Char)//o) {
159 0 croak sprintf($Err{notAlnum}, "[:$rev$1");
160 }
161 else {
162 0 croak sprintf($Err{notTermin}, "[:$rev$_", ":]");
163 }
164 }
165 86 ▶ return $rev ? "\\P\{$key\}" : "\\p\{$key\}";
Branch: 1 branch
BranchTrueFalseTotal
$rev ? : 43 43 86
166 }
167  
168  
169 #
170 # parse_char(ref to string)
171 # returning a single- or double-byte char.
172 #
173 1138 ▶sub parse_char ($) {
Subroutine parse_char: called CC=21 SCAR=33.4
Pod undocumented
174 1138 for (${ $_[0] }) {
175 1138 ▶ if ($_ eq '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "\\") 0 1138 1138
176 0 croak sprintf($Err{backtips});
177 }
178 1138 ▶ if (s/^\\([0-7][0-7][0-7])//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\([0-7][0-7][0-7])//) 0 1138 1138
179 0 return chr(oct $1);
180 }
181 1138 ▶ if (s/^\\x//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\x//) 499 639 1138
182 499 ▶ if (s/^([0-9A-Fa-f][0-9A-Fa-f])//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^([0-9A-Fa-f][0-9A-Fa-f])//) 179 320 499
183 179 return chr(hex $1);
184 }
185 320 ▶ if (s/^\{([0-9A-Fa-f]{4})\}//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\{([0-9A-Fa-f]{4})\}//) 320 0 320
186 320 return pack('n', hex $1);
187 }
188 0 ▶ if (length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_) { } 0 0 0
189 0 croak sprintf($Err{invalHex}, $_);
190 } else {
191 0 croak sprintf($Err{notTermin}, '\x{$_', '}');
192 }
193 }
194 639 ▶ if (s/^\\c//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\c//) 62 577 639
195 62 ▶ if (s/([\x00-\x7F])//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/([\x00-\x7F])//) 62 0 62
196 62 return chr(ord(uc $1) ^ 64);
197 }
198 0 ▶ if (length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_) { } 0 0 0
199 0 croak sprintf($Err{invalFlw}, ord, '\c', '[\x00-\x7F]');
200 } else {
201 0 croak sprintf($Err{notTermin}, '\c');
202 }
203 }
204 577 ▶ if (s/^\\a//) { return "\a" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\a//) 5 572 577
205 572 ▶ if (s/^\\b//) { return "\b" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\b//) 3 569 572
206 569 ▶ if (s/^\\e//) { return "\e" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\e//) 3 566 569
207 566 ▶ if (s/^\\f//) { return "\f" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\f//) 5 561 566
208 561 ▶ if (s/^\\n//) { return "\n" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\n//) 5 556 561
209 556 ▶ if (s/^\\r//) { return "\r" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\r//) 5 551 556
210 551 ▶ if (s/^\\t//) { return "\t" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\t//) 5 546 551
211 546 ▶ if (s/^\\0//) { return "\0" }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\0//) 14 532 546
212 532 ▶ if (s/^\\([0-9A-Za-z])//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\([0-9A-Za-z])//) 0 532 532
213 0 croak sprintf($Err{invalMch}, "\\$1");
214 }
215 532 ▶ if (s/^\\?($Char)//o) { return $1 }
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\\?($ShiftJIS::Regexp::Class::Char)//o) 532 0 532
216 0 croak sprintf($Err{oddTrail}, ord);
217 }
218 }
219  
220 #
221 # parse_literal(string)
222 # returning a literal.
223 #
224 393 ▶sub parse_literal ($) {
Subroutine parse_literal: called CC=2 SCAR=6.9
Pod undocumented
225 393 my $str = shift;
226 393 my $ret = '';
227 393 ▶ $ret .= parse_char(\$str) while length $str;
Branch: 1 branch
BranchTrueFalseTotal
length $str and do { $ret .= &parse_char(\$str) } 393 393 786
228 393 return $ret;
229 }
230  
231  
232 sub expand ($$;$)
233 239 ▶{
Subroutine expand: called CC=63 SCAR=46.1
Pod undocumented
234 239 my($fr, $to, $mod) = @_;
235 239 ▶ $mod ||= '';
Condition100%2/2
$mod ||= ""
l!l
39200
MC/DC100%1/1
$mod ||= ""
$mod
Truth table100%2/2
A
A= $mod
Aresult
11
00
236 239 my($ini, $fin, $i, $ch, @retv, @retd, $add);
237 239 my($ini_f, $fin_f, $ini_t, $fin_t, $ini_c, $fin_c);
238  
239 0 ▶ if ($fr > $to) { croak sprintf($Err{revRange}, $fr, $to) }
Branch: 1 branch
BranchTrueFalseTotal
if ($fr > $to) 0 239 239
240  
241 239 ▶ if ($fr <= 0x7F) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= 127) 66 173 239
242 66 ▶ $ini = $fr < 0x00 ? 0x00 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 0 ? : 0 66 66
243 66 ▶ $fin = $to > 0x7F ? 0x7F : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 127 ? : 6 60 66
244 66 ▶ if ($ini == $fin) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ini == $fin) { } 2 64 66
elsif ($ini < $fin) { } 64 0 64
245 2 push @retv, rechar(chr($ini),$mod);
246 } elsif ($ini < $fin) {
247 64 ▶ if ($mod =~ /i/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod =~ /i/) { } 12 52 64
248 12 ▶ for ($i=$ini; $i<=$fin; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fin) 283 12 295
249 283 ▶ $add .= lc(chr $i) if 0x41 <= $i && $i <= 0x5A;
Branch: 1 branch
BranchTrueFalseTotal
if 65 <= $i and $i <= 90 131 152 283
Condition100%3/3
65 <= $i and $i <= 90
!ll&&!rl&&r
34118131
MC/DC100%2/2
65 <= $i and $i <= 90
65 <= $i $i <= 90
Truth table100%3/3
A and B
A= 65 <= $iB= $i <= 90
ABresult
0X0
100
111
250 283 ▶ $add .= uc(chr $i) if 0x61 <= $i && $i <= 0x7A;
Branch: 1 branch
BranchTrueFalseTotal
if 97 <= $i and $i <= 122 112 171 283
Condition66%2/3
97 <= $i and $i <= 122
!ll&&!rl&&r
1710112
MC/DC50%1/2
97 <= $i and $i <= 122
97 <= $i $i <= 122
Truth table66%2/3
A and B
A= 97 <= $iB= $i <= 122
ABresult
0X0
100
111
251 }
252 52 } else { $add = '' }
253 64 push @retv, sprintf "[\\x%02x-\\x%02x$add]", $ini, $fin;
254 }
255 }
256  
257 239 ▶ if ($fr <= 0xDF) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= 223) 78 161 239
258 78 ▶ $ini = $fr < 0xA1 ? 0xA1 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 161 ? : 66 12 78
259 78 ▶ $fin = $to > 0xDF ? 0xDF : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 223 ? : 4 74 78
260 78 ▶ if ($ini == $fin) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ini == $fin) { } 0 78 78
elsif ($ini < $fin) { } 18 60 78
261 0 push @retd, sprintf('\\x%2x', $ini);
262 } elsif ($ini < $fin) {
263 18 push @retd, sprintf('[\\x%2x-\\x%2x]', $ini, $fin);
264 }
265 }
266  
267 239 ▶ $ini = $fr < 0x8140 ? 0x8140 : $fr;
Branch: 1 branch
BranchTrueFalseTotal
$fr < 33088 ? : 78 161 239
268 239 ▶ $fin = $to > 0xFCFC ? 0xFCFC : $to;
Branch: 1 branch
BranchTrueFalseTotal
$to > 64764 ? : 0 239 239
269 239 ▶ if ($ini <= $fin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini <= $fin) 165 74 239
270 165 ($ini_f,$ini_t) = __ord2($ini);
271 165 ($fin_f,$fin_t) = __ord2($fin);
272 165 ▶ if ($ini_f == $fin_f) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini_f == $fin_f) { } 111 54 165
273 111 ▶ push @retd,
Branch: 5 branches
BranchTrueFalseTotal
$ini_t == $fin_t ? : 0 111 111
$fin_t <= 126 || 128 <= $ini_t ? : 98 13 111
$ini_t == 126 && $fin_t == 128 ? : 0 13 13
$ini_t == 126 ? : 5 8 13
$fin_t == 128 ? : 0 8 8
Condition83%5/6
$fin_t <= 126 or 128 <= $ini_t
l!l&&r!l&&!r
455313
$ini_t == 126 and $fin_t == 128
!ll&&!rl&&r
850
MC/DC100%2/2
$fin_t <= 126 or 128 <= $ini_t
$fin_t <= 126 128 <= $ini_t
MC/DC0%0/2
$ini_t == 126 and $fin_t == 128
$ini_t == 126 $fin_t == 128
Truth table100%3/3
A or B
A= $fin_t <= 126B= 128 <= $ini_t
ABresult
1X1
011
000
Truth table66%2/3
A and B
A= $ini_t == 126B= $fin_t == 128
ABresult
0X0
100
111
274 $ini_t == $fin_t ?
275 sprintf('\x%2x\x%2x', $ini_f, $ini_t) :
276 $fin_t <= 0x7E || 0x80 <= $ini_t ?
277 sprintf('\x%2x[\x%2x-\x%2x]', $ini_f, $ini_t, $fin_t) :
278 $ini_t == 0x7E && $fin_t == 0x80 ?
279 sprintf('\x%2x[\x7e\x80]', $ini_f) :
280 $ini_t == 0x7E ?
281 sprintf('\x%2x[\x7e\x80-\x%2x]', $ini_f, $fin_t) :
282 $fin_t == 0x80 ?
283 sprintf('\x%2x[\x%2x-\x7e\x80]', $ini_f, $ini_t) :
284 sprintf('\x%2x[\x%2x-\x7e\x80-\x%2x]',$ini_f, $ini_t, $fin_t);
285 } else {
286 54 ▶ $ini_c = $ini_t == 0x40 ? $ini_f :
Branch: 2 branches
BranchTrueFalseTotal
$ini_t == 64 ? : 25 29 54
$ini_f == 159 ? : 0 29 29
287 $ini_f == 0x9F ? 0xE0 : $ini_f + 1;
288 54 ▶ $fin_c = $fin_t == 0xFC ? $fin_f :
Branch: 2 branches
BranchTrueFalseTotal
$fin_t == 252 ? : 13 41 54
$fin_f == 224 ? : 0 41 41
289 $fin_f == 0xE0 ? 0x9F : $fin_f - 1;
290  
291 54 ▶ if ($ini_t != 0x40) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini_t != 64) 29 25 54
292 29 ▶ push @retd,
Branch: 3 branches
BranchTrueFalseTotal
$ini_t == 252 ? : 1 28 29
128 <= $ini_t ? : 20 8 28
$ini_t == 126 ? : 0 8 8
293 $ini_t == 0xFC ?
294 sprintf('\x%2x\xfc', $ini_f) :
295 0x80 <= $ini_t ?
296 sprintf('\x%2x[\x%2x-\xfc]', $ini_f, $ini_t) :
297 $ini_t == 0x7E ?
298 sprintf('\x%2x[\x7e\x80-\xfc]', $ini_f) :
299 sprintf('\x%2x[\x%2x-\x7e\x80-\xfc]', $ini_f, $ini_t);
300 }
301 54 ▶ if ($ini_c <= $fin_c) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ini_c <= $fin_c) 45 9 54
302 45 ▶ my $lead =
Branch: 5 branches
BranchTrueFalseTotal
$ini_c == $fin_c ? : 14 31 45
$fin_c <= 159 || 224 <= $ini_c ? : 13 18 31
$ini_c == 159 && $fin_c == 224 ? : 0 18 18
$ini_c == 159 ? : 0 18 18
$fin_c == 224 ? : 0 18 18
Condition66%4/6
$fin_c <= 159 or 224 <= $ini_c
l!l&&r!l&&!r
6718
$ini_c == 159 and $fin_c == 224
!ll&&!rl&&r
1800
MC/DC100%2/2
$fin_c <= 159 or 224 <= $ini_c
$fin_c <= 159 224 <= $ini_c
MC/DC0%0/2
$ini_c == 159 and $fin_c == 224
$ini_c == 159 $fin_c == 224
Truth table100%3/3
A or B
A= $fin_c <= 159B= 224 <= $ini_c
ABresult
1X1
011
000
Truth table33%1/3
A and B
A= $ini_c == 159B= $fin_c == 224
ABresult
0X0
100
111
303 $ini_c == $fin_c
304 ? sprintf('\x%2x', $ini_c) :
305 $fin_c <= 0x9F || 0xE0 <= $ini_c
306 ? sprintf('[\x%2x-\x%2x]', $ini_c, $fin_c) :
307 $ini_c == 0x9F && $fin_c == 0xE0
308 ? '[\x9f\xe0]' :
309 $ini_c == 0x9F
310 ? sprintf('[\x9f\xe0-\x%2x]', $fin_c) :
311 $fin_c == 0xE0
312 ? sprintf('[\x%2x-\x9f\xe0]', $ini_c)
313 : sprintf('[\x%2x-\x9f\xe0-\x%2x]', $ini_c, $fin_c);
314 45 push @retd, $lead.$Trail;
315 }
316 54 ▶ if ($fin_t != 0xFC) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fin_t != 252) 41 13 54
317 41 ▶ push @retd,
Branch: 3 branches
BranchTrueFalseTotal
$fin_t == 64 ? : 1 40 41
$fin_t <= 126 ? : 19 21 40
$fin_t == 128 ? : 0 21 21
318 $fin_t == 0x40 ?
319 sprintf('\x%2x\x40', $fin_f) :
320 $fin_t <= 0x7E ?
321 sprintf('\x%2x[\x40-\x%2x]', $fin_f, $fin_t) :
322 $fin_t == 0x80 ?
323 sprintf('\x%2x[\x40-\x7e\x80]', $fin_f) :
324 sprintf('\x%2x[\x40-\x7e\x80-\x%2x]', $fin_f, $fin_t);
325 }
326 }
327 }
328 239 ▶ if ($mod =~ /I/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod =~ /I/) 12 227 239
329 12 foreach (
330 [0x8260, 0x8279, +33], # Full A to Z
331 [0x8281, 0x829A, -33], # Full a to z
332 [0x839F, 0x83B6, +32], # Greek Alpha to Omega
333 [0x83BF, 0x83D6, -32], # Greek alpha to omega
334 [0x8440, 0x844E, +48], # Cyrillic A to N
335 [0x8470, 0x847E, -48], # Cyrillic a to n
336 [0x844F, 0x8460, +49], # Cyrillic O to Ya
337 [0x8480, 0x8491, -49], # Cyrillic o to ya
338 ) {
339 96 ▶ if ($fr <= $_->[1] && $_->[0] <= $to) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= $_->[1] and $_->[0] <= $to) 16 80 96
Condition100%3/3
$fr <= $_->[1] and $_->[0] <= $to
!ll&&!rl&&r
324816
MC/DC100%2/2
$fr <= $_->[1] and $_->[0] <= $to
$fr <= $_->[1] $_->[0] <= $to
Truth table100%3/3
A and B
A= $fr <= $_->[1]B= $_->[0] <= $to
ABresult
0X0
100
111
340 16 ▶ ($ini_f,$ini_t) = __ord2($fr <= $_->[0] ? $_->[0] : $fr);
Branch: 1 branch
BranchTrueFalseTotal
$fr <= $_->[0] ? : 16 0 16
341 16 ▶ ($fin_f,$fin_t) = __ord2($_->[1] <= $to ? $_->[1] : $to);
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] <= $to ? : 16 0 16
342 16 push @retd, sprintf('\x%02x[\x%02x-\x%02x]',
343 $ini_f, $ini_t + $_->[2], $fin_t + $_->[2]);
344 }
345 }
346 }
347 239 ▶ if ($mod =~ /j/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod =~ /j/) 0 239 239
348 0 foreach (
349 [0x829F, 0x82DD, -0x5F, 0x83], # Hiragana Small A to Mi
350 [0x82DE, 0x82F1, -0x5E, 0x83], # Hiragana Mu to N
351 [0x8340, 0x837E, +0x5F, 0x82], # Katakana Small A to Mi
352 [0x8380, 0x8393, +0x5E, 0x82], # Katakana Mu to N
353 [0x8152, 0x8153, +2, 0x81], # Katakana Iteration Marks
354 [0x8154, 0x8155, -2, 0x81], # Hiragana Iteration Marks
355 ) {
356 0 ▶ if ($fr <= $_->[1] && $_->[0] <= $to) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fr <= $_->[1] and $_->[0] <= $to) 0 0 0
Condition0%0/3
$fr <= $_->[1] and $_->[0] <= $to
!ll&&!rl&&r
000
MC/DC0%0/2
$fr <= $_->[1] and $_->[0] <= $to
$fr <= $_->[1] $_->[0] <= $to
Truth table0%0/3
A and B
A= $fr <= $_->[1]B= $_->[0] <= $to
ABresult
0X0
100
111
357 0 ▶ ($ini_f,$ini_t) = __ord2($fr <= $_->[0] ? $_->[0] : $fr);
Branch: 1 branch
BranchTrueFalseTotal
$fr <= $_->[0] ? : 0 0 0
358 0 ▶ ($fin_f,$fin_t) = __ord2($_->[1] <= $to ? $_->[1] : $to);
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] <= $to ? : 0 0 0
359 0 push @retd, sprintf('\x%02x[\x%02x-\x%02x]',
360 $_->[3], $ini_t + $_->[2], $fin_t + $_->[2]);
361 }
362 }
363 }
364 239 ▶ return(@retv, @retd ? $Open.join('|',@retd).$Close : ());
Branch: 1 branch
BranchTrueFalseTotal
@retd ? : 179 60 239
365 }
366  
367  
368  
369 #
370 # parse_class(ref to string, mode)
371 # called after "[" at the beginning of a character class.
372 # returning a byte-oriented regexp.
373 #
374 874 ▶sub parse_class ($;$) {
Subroutine parse_class: called CC=30 SCAR=36.3
Pod undocumented
375 874 my(@re, $subclass);
376 874 ▶ my $mod = $_[1] || '';
Condition100%2/2
$_[1] || ''
l!l
46828
MC/DC100%1/1
$_[1] || ''
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
377 874 my $state = 0; # enum: initial, char, range, subclass, last;
378  
379 874 for (${ $_[0] }) {
380 874 ▶ while (length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_) 2564 0 2564
381 2564 ▶ if (s/^\]//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\]//) 874 1690 2564
382 874 ▶ if (@re) {
Branch: 1 branch
BranchTrueFalseTotal
if (@re) { } 874 0 874
383 874 ▶ if ($state == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state == 1) { } 106 768 874
elsif ($state == 2) { } 0 768 768
384 106 push @re, rechar(pop(@re), $mod);
385 } elsif ($state == 2) {
386 0 push @re, rechar(pop(@re), $mod);
387 0 push @re, rechar('-', $mod);
388 }
389 } else {
390 0 push(@re, ']');
391 0 $state = 1;
392 0 next;
393 }
394 874 $state = 4;
395 874 last;
396 }
397 1690 ▶ if (s/^\-//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^\-//) 239 1451 1690
398 239 ▶ if ($state == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($state == 0) { } 0 239 239
elsif ($state == 1) { } 239 0 239
elsif ($state == 2) { } 0 0 0
399 0 push(@re, '-');
400 0 $state = 1;
401 } elsif ($state == 1) {
402 239 $state = 2;
403 } elsif ($state == 2) {
404 0 push @re, expand(__ord(pop(@re)), __ord('-'), $mod);
405 0 $state = 0;
406 } else {
407 0 croak sprintf($Err{invalRng}, "-$_");
408 }
409 239 next;
410 }
411  
412 1451 $subclass = undef;
413 1451 ▶ if (s/^\[\://) {
Branch: 5 branches
BranchTrueFalseTotal
if (s/^\[\://) { } 86 1365 1451
elsif (s/^\\([pP])//) { } 205 1160 1365
elsif (s/^(\\[dwsDWS])//) { } 18 1142 1160
elsif (s/^\[=\\?([\\=])=\]//) { } 4 1138 1142
elsif (s/^\[=([^=]+)=\]//) { } 393 745 1138
414 86 my $key = parse_posix(\$_);
415 $subclass = defined $Re{$key} ? $Re{$key}
416 86 ▶ : croak sprintf($Err{Undef}, $key);
Branch: 1 branch
BranchTrueFalseTotal
defined $ShiftJIS::Regexp::Class::Re{$key} ? : 86 0 86
417 } elsif(s/^\\([pP])//) { # prop
418 205 my $key = parse_prop($1, \$_);
419 $subclass = defined $Re{$key} ? $Re{$key}
420 205 ▶ : croak sprintf($Err{Undef}, $key);
Branch: 1 branch
BranchTrueFalseTotal
defined $ShiftJIS::Regexp::Class::Re{$key} ? : 205 0 205
421 } elsif(s/^(\\[dwsDWS])//) {
422 18 $subclass = $Re{ $1 };
423 } elsif(s/^\[=\\?([\\=])=\]//) {
424 4 ▶ $subclass = defined $Eq{$1} ? $Eq{$1} : rechar($1,$mod);
Branch: 1 branch
BranchTrueFalseTotal
defined $ShiftJIS::Regexp::Class::Eq{$1} ? : 4 0 4
425 } elsif(s/^\[=([^=]+)=\]//) {
426 393 my $lit = parse_literal($1);
427 393 ▶ $subclass = defined $Eq{$lit} ? $Eq{$lit} : rechar($lit,$mod);
Branch: 1 branch
BranchTrueFalseTotal
defined $ShiftJIS::Regexp::Class::Eq{$lit} ? : 280 113 393
428 }
429  
430 1451 ▶ if (defined $subclass) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subclass) 706 745 1451
431 706 ▶ if ($state == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state == 1) { } 0 706 706
elsif ($state == 2) { } 0 706 706
432 0 push @re, rechar(pop(@re), $mod);
433 } elsif($state == 2) {
434 0 croak sprintf($Err{invalRng}, "-$_");
435 }
436 706 push @re, $subclass;
437 706 $state = 3;
438 706 next;
439 }
440  
441 745 my $char = parse_char(\$_);
442 745 ▶ if ($state == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state == 1) { } 161 584 745
elsif ($state == 2) { } 239 345 584
443 161 push @re, rechar(pop(@re), $mod);
444 161 push @re, $char;
445 161 $state = 1;
446 } elsif ($state == 2) {
447 239 push @re, expand(__ord(pop(@re)), __ord($char), $mod);
448 239 $state = 0;
449 } else {
450 345 push @re, $char;
451 345 $state = 1;
452 }
453 }
454 }
455  
456 874 ▶ if ($state != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state != 4) 0 874 874
457 0 croak sprintf($Err{notTermin}, "character class", ']');
458 }
459  
460 # contract: e.g. ('\x81\x40', '\x81[\x44-\x48]') to ('\x81[\x40\x44-\x48]').
461  
462 874 my ($pre, @retv, $r);
463 874 push @retv, shift @re;
464 874 $retv[0] =~ s/^(?:$OpenRe)? \[ ($InClassRe+) \] \)? $/[$1]/xo;
465 874 $retv[0] =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2}) \)? $/[$1]/xo;
466 874 $retv[0] =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2}) \[ ($InClassRe+) \] \)? $/${1}[$2]/xo;
467 874 $retv[0] =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2}) (\\x[0-9A-Fa-f]{2}) \)? $/${1}[$2]/xo;
468  
469 874 foreach $r (@re) {
470 344 $r =~ s/^(?:$OpenRe)? \[ ($InClassRe+) \] \)? $/[$1]/xo;
471 344 $r =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2}) \)? $/[$1]/xo;
472 344 $r =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2})
473 \[ ($InClassRe+) \] \)? $/${1}[$2]/xo;
474 344 $r =~ s/^(?:$OpenRe)? (\\x[0-9A-Fa-f]{2})
475 (\\x[0-9A-Fa-f]{2}) \)? $/${1}[$2]/xo;
476  
477 344 ▶ if ("$retv[-1]|$r" =~ /^ \[($InClassRe+)\] \| \[($InClassRe+)\] $/xo) {
Branch: 2 branches
BranchTrueFalseTotal
if (("$retv[-1]|$r") =~ /^ \[($InClassRe+)\] \| \[($InClassRe+)\] $/ox) { } 80 264 344
elsif (("$retv[-1]|$r") =~ /^ (\\x[0-9A-Fa-f]{2}) \[($InClassRe+)\] \| \1 \[($InClassRe+)\] $/ox) { } 109 155 264
478 80 $retv[-1] = "[$1$2]";
479 }
480 elsif ("$retv[-1]|$r" =~ /^
481 (\\x[0-9A-Fa-f]{2}) \[($InClassRe+)\] \| \1 \[($InClassRe+)\] $/xo)
482 {
483 109 $retv[-1] = "$1\[$2$3\]";
484 }
485 else {
486 155 $retv[-1] =~ s/^\[(\\x[0-9A-Fa-f]{2})\]$/$1/x;
487 155 $retv[-1] =~ s/^(\\x[0-9A-Fa-f]{2})\[(\\x[0-9A-Fa-f]{2})\]$/$1$2/x;
488 155 push(@retv, $r);
489 }
490 }
491  
492 874 $retv[-1] =~ s/^\[(\\x[0-9A-Fa-f]{2})\]$/$1/x;
493 874 $retv[-1] =~ s/^(\\x[0-9A-Fa-f]{2})\[(\\x[0-9A-Fa-f]{2})\]$/$1$2/x;
494  
495 874 return $Open.join('|', @retv).$Close;
496 }
497  
498 6 1;
499 __END__
↑ Summary Regexp.pm »