line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eeuctw; |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Eeuctw - Run-time routines for EUCTW.pm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Char-EUCTW/ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 INABA Hitoshi |
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
325
|
|
|
325
|
|
4458
|
use 5.00503; # Galapagos Consensus 1998 for primetools |
|
325
|
|
|
|
|
771
|
|
12
|
|
|
|
|
|
|
# use 5.008001; # Lancaster Consensus 2013 for toolchains |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# 12.3. Delaying use Until Runtime |
15
|
|
|
|
|
|
|
# in Chapter 12. Packages, Libraries, and Modules |
16
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
17
|
|
|
|
|
|
|
# (and so on) |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Version numbers should be boring |
20
|
|
|
|
|
|
|
# http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/ |
21
|
|
|
|
|
|
|
# For the impatient, the disinterested or those who just want to follow |
22
|
|
|
|
|
|
|
# a recipe, my advice for all modules is this: |
23
|
|
|
|
|
|
|
# our $VERSION = "0.001"; # or "0.001_001" for a dev release |
24
|
|
|
|
|
|
|
# $VERSION = eval $VERSION; |
25
|
|
|
|
|
|
|
|
26
|
325
|
|
|
325
|
|
16625
|
BEGIN { CORE::eval q{ use vars qw($VERSION) } } |
|
325
|
|
|
325
|
|
1357
|
|
|
325
|
|
|
|
|
407
|
|
|
325
|
|
|
|
|
37691
|
|
27
|
|
|
|
|
|
|
$VERSION = '1.08'; |
28
|
|
|
|
|
|
|
$VERSION = CORE::eval $VERSION; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
BEGIN { |
31
|
325
|
50
|
|
325
|
|
1540
|
if ($^X =~ / jperl /oxmsi) { |
32
|
0
|
|
|
|
|
0
|
die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n"; |
33
|
|
|
|
|
|
|
} |
34
|
325
|
|
|
|
|
347
|
if (CORE::ord('A') == 193) { |
35
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n"; |
36
|
|
|
|
|
|
|
} |
37
|
325
|
|
|
|
|
32940
|
if (CORE::ord('A') != 0x41) { |
38
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
BEGIN { |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# instead of utf8.pm |
45
|
325
|
|
|
325
|
|
16581
|
CORE::eval q{ |
|
325
|
|
|
325
|
|
1330
|
|
|
325
|
|
|
105
|
|
388
|
|
|
325
|
|
|
|
|
29092
|
|
|
75
|
|
|
|
|
5504
|
|
|
81
|
|
|
|
|
5990
|
|
|
73
|
|
|
|
|
5340
|
|
|
96
|
|
|
|
|
6807
|
|
46
|
|
|
|
|
|
|
no warnings qw(redefine); |
47
|
|
|
|
|
|
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
48
|
|
|
|
|
|
|
*utf8::downgrade = sub { 1 }; |
49
|
|
|
|
|
|
|
*utf8::encode = sub { }; |
50
|
|
|
|
|
|
|
*utf8::decode = sub { 1 }; |
51
|
|
|
|
|
|
|
*utf8::is_utf8 = sub { }; |
52
|
|
|
|
|
|
|
*utf8::valid = sub { 1 }; |
53
|
|
|
|
|
|
|
}; |
54
|
325
|
50
|
|
|
|
131057
|
if ($@) { |
55
|
0
|
|
|
|
|
0
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
*utf8::downgrade = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
*utf8::encode = sub { }; |
58
|
0
|
|
|
|
|
0
|
*utf8::decode = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
59
|
0
|
|
|
|
|
0
|
*utf8::is_utf8 = sub { }; |
60
|
0
|
|
|
|
|
0
|
*utf8::valid = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# instead of Symbol.pm |
65
|
0
|
|
|
|
|
0
|
BEGIN { |
66
|
325
|
|
|
325
|
|
630
|
my $genpkg = "Symbol::"; |
67
|
325
|
|
|
|
|
10762
|
my $genseq = 0; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub gensym () { |
70
|
0
|
|
|
0
|
0
|
0
|
my $name = "GEN" . $genseq++; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# here, no strict qw(refs); if strict.pm exists |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
my $ref = \*{$genpkg . $name}; |
|
0
|
|
|
|
|
0
|
|
75
|
0
|
|
|
|
|
0
|
delete $$genpkg{$name}; |
76
|
0
|
|
|
|
|
0
|
return $ref; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub qualify ($;$) { |
80
|
0
|
|
|
0
|
0
|
0
|
my ($name) = @_; |
81
|
0
|
0
|
0
|
|
|
0
|
if (!ref($name) && (Eeuctw::index($name, '::') == -1) && (Eeuctw::index($name, "'") == -1)) { |
|
|
|
0
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
my $pkg; |
83
|
0
|
|
|
|
|
0
|
my %global = map {$_ => 1} qw(ARGV ARGVOUT ENV INC SIG STDERR STDIN STDOUT DATA); |
|
0
|
|
|
|
|
0
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Global names: special character, "^xyz", or other. |
86
|
0
|
0
|
0
|
|
|
0
|
if ($name =~ /^(([^\x8E\xA1-\xFEa-z])|(\^[a-z_]+))\z/i || $global{$name}) { |
87
|
|
|
|
|
|
|
# RGS 2001-11-05 : translate leading ^X to control-char |
88
|
0
|
|
|
|
|
0
|
$name =~ s/^\^([a-z_])/'qq(\c'.$1.')'/eei; |
|
0
|
|
|
|
|
0
|
|
89
|
0
|
|
|
|
|
0
|
$pkg = "main"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
0
|
|
|
|
0
|
$pkg = (@_ > 1) ? $_[1] : caller; |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
0
|
$name = $pkg . "::" . $name; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
0
|
return $name; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub qualify_to_ref ($;$) { |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# here, no strict qw(refs); if strict.pm exists |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
0
|
0
|
0
|
return \*{ qualify $_[0], @_ > 1 ? $_[1] : caller }; |
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Column: local $@ |
108
|
|
|
|
|
|
|
# in Chapter 9. Osaete okitai Perl no kiso |
109
|
|
|
|
|
|
|
# of ISBN 10: 4798119172 | ISBN 13: 978-4798119175 MODAN Perl NYUMON |
110
|
|
|
|
|
|
|
# (and so on) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# use strict; if strict.pm exists |
113
|
|
|
|
|
|
|
BEGIN { |
114
|
325
|
50
|
|
325
|
|
464
|
if (CORE::eval { local $@; CORE::require strict }) { |
|
325
|
|
|
|
|
470
|
|
|
325
|
|
|
|
|
2583
|
|
115
|
325
|
|
|
|
|
27174
|
strict::->import; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# P.714 29.2.39. flock |
120
|
|
|
|
|
|
|
# in Chapter 29: Functions |
121
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# P.863 flock |
124
|
|
|
|
|
|
|
# in Chapter 27: Functions |
125
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub LOCK_SH() {1} |
128
|
|
|
|
|
|
|
sub LOCK_EX() {2} |
129
|
|
|
|
|
|
|
sub LOCK_UN() {8} |
130
|
|
|
|
|
|
|
sub LOCK_NB() {4} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# instead of Carp.pm |
133
|
|
|
|
|
|
|
sub carp; |
134
|
|
|
|
|
|
|
sub croak; |
135
|
|
|
|
|
|
|
sub cluck; |
136
|
|
|
|
|
|
|
sub confess; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# 6.18. Matching Multiple-Byte Characters |
139
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
140
|
|
|
|
|
|
|
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook. |
141
|
|
|
|
|
|
|
# (and so on) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# regexp of character |
144
|
325
|
|
|
325
|
|
17822
|
BEGIN { CORE::eval q{ use vars qw($your_char) } } $your_char = q{[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|[\x00-\xFF]}; |
|
325
|
|
|
325
|
|
1279
|
|
|
325
|
|
|
|
|
397
|
|
|
325
|
|
|
|
|
15278
|
|
145
|
325
|
|
|
325
|
|
15204
|
BEGIN { CORE::eval q{ use vars qw($qq_char ) } } $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms; |
|
325
|
|
|
325
|
|
1208
|
|
|
325
|
|
|
|
|
381
|
|
|
325
|
|
|
|
|
15455
|
|
146
|
325
|
|
|
325
|
|
14710
|
BEGIN { CORE::eval q{ use vars qw($q_char ) } } $q_char = qr/$your_char/oxms; |
|
325
|
|
|
325
|
|
1188
|
|
|
325
|
|
|
|
|
379
|
|
|
325
|
|
|
|
|
17024
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# EUC-TW character range per length |
150
|
|
|
|
|
|
|
# |
151
|
|
|
|
|
|
|
my %range_tr = (); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
# alias of encoding name |
155
|
|
|
|
|
|
|
# |
156
|
325
|
|
|
325
|
|
15054
|
BEGIN { CORE::eval q{ use vars qw($encoding_alias) } } |
|
325
|
|
|
325
|
|
1192
|
|
|
325
|
|
|
|
|
385
|
|
|
325
|
|
|
|
|
235129
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
# EUC-TW case conversion |
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
my %lc = (); |
162
|
|
|
|
|
|
|
@lc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} = |
163
|
|
|
|
|
|
|
qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); |
164
|
|
|
|
|
|
|
my %uc = (); |
165
|
|
|
|
|
|
|
@uc{qw(a b c d e f g h i j k l m n o p q r s t u v w x y z)} = |
166
|
|
|
|
|
|
|
qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); |
167
|
|
|
|
|
|
|
my %fc = (); |
168
|
|
|
|
|
|
|
@fc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} = |
169
|
|
|
|
|
|
|
qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
if (0) { |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b Eeuctw \z/oxms) { |
175
|
|
|
|
|
|
|
%range_tr = ( |
176
|
|
|
|
|
|
|
1 => [ [0x00..0x8D], |
177
|
|
|
|
|
|
|
[0x8F..0xA0], |
178
|
|
|
|
|
|
|
[0xFF..0xFF], |
179
|
|
|
|
|
|
|
], |
180
|
|
|
|
|
|
|
2 => [ [0xA1..0xFE],[0xA1..0xFE], |
181
|
|
|
|
|
|
|
], |
182
|
|
|
|
|
|
|
4 => [ [0x8E..0x8E],[0xA1..0xB0],[0xA1..0xFE],[0xA1..0xFE], |
183
|
|
|
|
|
|
|
], |
184
|
|
|
|
|
|
|
); |
185
|
|
|
|
|
|
|
$encoding_alias = qr/ \b (?: euc.*tw | tw.*euc ) \b /oxmsi; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
else { |
189
|
|
|
|
|
|
|
croak "Don't know my package name '@{[__PACKAGE__]}'"; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# |
193
|
|
|
|
|
|
|
# @ARGV wildcard globbing |
194
|
|
|
|
|
|
|
# |
195
|
|
|
|
|
|
|
sub import { |
196
|
|
|
|
|
|
|
|
197
|
0
|
0
|
|
0
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
198
|
0
|
|
|
|
|
0
|
my @argv = (); |
199
|
0
|
|
|
|
|
0
|
for (@ARGV) { |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# has space |
202
|
0
|
0
|
|
|
|
0
|
if (/\A (?:$q_char)*? [ ] /oxms) { |
|
|
0
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
0
|
if (my @glob = Eeuctw::glob(qq{"$_"})) { |
204
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
else { |
207
|
0
|
|
|
|
|
0
|
push @argv, $_; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# has wildcard metachar |
212
|
|
|
|
|
|
|
elsif (/\A (?:$q_char)*? [*?] /oxms) { |
213
|
0
|
0
|
|
|
|
0
|
if (my @glob = Eeuctw::glob($_)) { |
214
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
else { |
217
|
0
|
|
|
|
|
0
|
push @argv, $_; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# no wildcard globbing |
222
|
|
|
|
|
|
|
else { |
223
|
0
|
|
|
|
|
0
|
push @argv, $_; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
0
|
|
|
|
|
0
|
@ARGV = @argv; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
0
|
*Char::ord = \&EUCTW::ord; |
230
|
0
|
|
|
|
|
0
|
*Char::ord_ = \&EUCTW::ord_; |
231
|
0
|
|
|
|
|
0
|
*Char::reverse = \&EUCTW::reverse; |
232
|
0
|
|
|
|
|
0
|
*Char::getc = \&EUCTW::getc; |
233
|
0
|
|
|
|
|
0
|
*Char::length = \&EUCTW::length; |
234
|
0
|
|
|
|
|
0
|
*Char::substr = \&EUCTW::substr; |
235
|
0
|
|
|
|
|
0
|
*Char::index = \&EUCTW::index; |
236
|
0
|
|
|
|
|
0
|
*Char::rindex = \&EUCTW::rindex; |
237
|
0
|
|
|
|
|
0
|
*Char::eval = \&EUCTW::eval; |
238
|
0
|
|
|
|
|
0
|
*Char::escape = \&EUCTW::escape; |
239
|
0
|
|
|
|
|
0
|
*Char::escape_token = \&EUCTW::escape_token; |
240
|
0
|
|
|
|
|
0
|
*Char::escape_script = \&EUCTW::escape_script; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# P.230 Care with Prototypes |
244
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
245
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
246
|
|
|
|
|
|
|
# |
247
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
248
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
249
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
250
|
|
|
|
|
|
|
# the world a better place. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# P.332 Care with Prototypes |
253
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
254
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
255
|
|
|
|
|
|
|
# |
256
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
257
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
258
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
259
|
|
|
|
|
|
|
# the world a better place. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# |
262
|
|
|
|
|
|
|
# Prototypes of subroutines |
263
|
|
|
|
|
|
|
# |
264
|
|
|
|
0
|
|
|
sub unimport {} |
265
|
|
|
|
|
|
|
sub Eeuctw::split(;$$$); |
266
|
|
|
|
|
|
|
sub Eeuctw::tr($$$$;$); |
267
|
|
|
|
|
|
|
sub Eeuctw::chop(@); |
268
|
|
|
|
|
|
|
sub Eeuctw::index($$;$); |
269
|
|
|
|
|
|
|
sub Eeuctw::rindex($$;$); |
270
|
|
|
|
|
|
|
sub Eeuctw::lcfirst(@); |
271
|
|
|
|
|
|
|
sub Eeuctw::lcfirst_(); |
272
|
|
|
|
|
|
|
sub Eeuctw::lc(@); |
273
|
|
|
|
|
|
|
sub Eeuctw::lc_(); |
274
|
|
|
|
|
|
|
sub Eeuctw::ucfirst(@); |
275
|
|
|
|
|
|
|
sub Eeuctw::ucfirst_(); |
276
|
|
|
|
|
|
|
sub Eeuctw::uc(@); |
277
|
|
|
|
|
|
|
sub Eeuctw::uc_(); |
278
|
|
|
|
|
|
|
sub Eeuctw::fc(@); |
279
|
|
|
|
|
|
|
sub Eeuctw::fc_(); |
280
|
|
|
|
|
|
|
sub Eeuctw::ignorecase; |
281
|
|
|
|
|
|
|
sub Eeuctw::classic_character_class; |
282
|
|
|
|
|
|
|
sub Eeuctw::capture; |
283
|
|
|
|
|
|
|
sub Eeuctw::chr(;$); |
284
|
|
|
|
|
|
|
sub Eeuctw::chr_(); |
285
|
|
|
|
|
|
|
sub Eeuctw::glob($); |
286
|
|
|
|
|
|
|
sub Eeuctw::glob_(); |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub EUCTW::ord(;$); |
289
|
|
|
|
|
|
|
sub EUCTW::ord_(); |
290
|
|
|
|
|
|
|
sub EUCTW::reverse(@); |
291
|
|
|
|
|
|
|
sub EUCTW::getc(;*@); |
292
|
|
|
|
|
|
|
sub EUCTW::length(;$); |
293
|
|
|
|
|
|
|
sub EUCTW::substr($$;$$); |
294
|
|
|
|
|
|
|
sub EUCTW::index($$;$); |
295
|
|
|
|
|
|
|
sub EUCTW::rindex($$;$); |
296
|
|
|
|
|
|
|
sub EUCTW::escape(;$); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# |
299
|
|
|
|
|
|
|
# Regexp work |
300
|
|
|
|
|
|
|
# |
301
|
325
|
|
|
325
|
|
18264
|
BEGIN { CORE::eval q{ use vars qw( |
|
325
|
|
|
325
|
|
1374
|
|
|
325
|
|
|
|
|
391
|
|
|
325
|
|
|
|
|
95923
|
|
302
|
|
|
|
|
|
|
$EUCTW::re_a |
303
|
|
|
|
|
|
|
$EUCTW::re_t |
304
|
|
|
|
|
|
|
$EUCTW::re_n |
305
|
|
|
|
|
|
|
$EUCTW::re_r |
306
|
|
|
|
|
|
|
) } } |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# |
309
|
|
|
|
|
|
|
# Character class |
310
|
|
|
|
|
|
|
# |
311
|
325
|
|
|
325
|
|
19546
|
BEGIN { CORE::eval q{ use vars qw( |
|
325
|
|
|
325
|
|
1281
|
|
|
325
|
|
|
|
|
377
|
|
|
325
|
|
|
|
|
49216
|
|
312
|
|
|
|
|
|
|
$dot |
313
|
|
|
|
|
|
|
$dot_s |
314
|
|
|
|
|
|
|
$eD |
315
|
|
|
|
|
|
|
$eS |
316
|
|
|
|
|
|
|
$eW |
317
|
|
|
|
|
|
|
$eH |
318
|
|
|
|
|
|
|
$eV |
319
|
|
|
|
|
|
|
$eR |
320
|
|
|
|
|
|
|
$eN |
321
|
|
|
|
|
|
|
$not_alnum |
322
|
|
|
|
|
|
|
$not_alpha |
323
|
|
|
|
|
|
|
$not_ascii |
324
|
|
|
|
|
|
|
$not_blank |
325
|
|
|
|
|
|
|
$not_cntrl |
326
|
|
|
|
|
|
|
$not_digit |
327
|
|
|
|
|
|
|
$not_graph |
328
|
|
|
|
|
|
|
$not_lower |
329
|
|
|
|
|
|
|
$not_lower_i |
330
|
|
|
|
|
|
|
$not_print |
331
|
|
|
|
|
|
|
$not_punct |
332
|
|
|
|
|
|
|
$not_space |
333
|
|
|
|
|
|
|
$not_upper |
334
|
|
|
|
|
|
|
$not_upper_i |
335
|
|
|
|
|
|
|
$not_word |
336
|
|
|
|
|
|
|
$not_xdigit |
337
|
|
|
|
|
|
|
$eb |
338
|
|
|
|
|
|
|
$eB |
339
|
|
|
|
|
|
|
) } } |
340
|
|
|
|
|
|
|
|
341
|
325
|
|
|
325
|
|
15270
|
BEGIN { CORE::eval q{ use vars qw( |
|
325
|
|
|
325
|
|
1242
|
|
|
325
|
|
|
|
|
393
|
|
|
325
|
|
|
|
|
30460
|
|
342
|
|
|
|
|
|
|
$anchor |
343
|
|
|
|
|
|
|
$matched |
344
|
|
|
|
|
|
|
) } } |
345
|
|
|
|
|
|
|
${Eeuctw::anchor} = qr{\G(?>[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])*?}oxms; |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
# unless LONG_STRING_FOR_RE |
348
|
|
|
|
|
|
|
if (1) { |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
325
|
|
|
325
|
|
15512
|
BEGIN { CORE::eval q{ use vars qw( |
|
325
|
|
|
325
|
|
1284
|
|
|
325
|
|
|
|
|
466
|
|
|
325
|
|
|
|
|
3727219
|
|
352
|
|
|
|
|
|
|
$q_char_SADAHIRO_Tomoyuki_2002_01_17 |
353
|
|
|
|
|
|
|
) } } |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# Quantifiers |
356
|
|
|
|
|
|
|
# {n,m} --- Match at least n but not more than m times |
357
|
|
|
|
|
|
|
# |
358
|
|
|
|
|
|
|
# n and m are limited to non-negative integral values less than a |
359
|
|
|
|
|
|
|
# preset limit defined when perl is built. This is usually 32766 on |
360
|
|
|
|
|
|
|
# the most common platforms. |
361
|
|
|
|
|
|
|
# |
362
|
|
|
|
|
|
|
# The following code is an attempt to solve the above limitations |
363
|
|
|
|
|
|
|
# in a multi-byte anchoring. |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# avoid "Segmentation fault" and "Error: Parse exception" |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
# perl5101delta |
368
|
|
|
|
|
|
|
# http://perldoc.perl.org/perl5101delta.html |
369
|
|
|
|
|
|
|
# In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767} |
370
|
|
|
|
|
|
|
# [RT #60034, #60464]. For example, this match would fail: |
371
|
|
|
|
|
|
|
# ("ab" x 32768) =~ /^(ab)*$/ |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# SEE ALSO |
374
|
|
|
|
|
|
|
# |
375
|
|
|
|
|
|
|
# Complex regular subexpression recursion limit |
376
|
|
|
|
|
|
|
# http://www.perlmonks.org/?node_id=810857 |
377
|
|
|
|
|
|
|
# |
378
|
|
|
|
|
|
|
# regexp iteration limits |
379
|
|
|
|
|
|
|
# http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html |
380
|
|
|
|
|
|
|
# |
381
|
|
|
|
|
|
|
# latest Perl won't match certain regexes more than 32768 characters long |
382
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long |
383
|
|
|
|
|
|
|
# |
384
|
|
|
|
|
|
|
# Break through the limitations of regular expressions of Perl |
385
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20110212/1297512479 |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
if (($] >= 5.010001) or |
388
|
|
|
|
|
|
|
# ActivePerl 5.6 or later (include 5.10.0) |
389
|
|
|
|
|
|
|
(defined($ActivePerl::VERSION) and ($ActivePerl::VERSION > 800)) or |
390
|
|
|
|
|
|
|
(($^O eq 'MSWin32') and ($] =~ /\A 5\.006/oxms)) |
391
|
|
|
|
|
|
|
) { |
392
|
|
|
|
|
|
|
my $sbcs = ''; # Single Byte Character Set |
393
|
|
|
|
|
|
|
for my $range (@{ $range_tr{1} }) { |
394
|
|
|
|
|
|
|
$sbcs .= sprintf('\\x%02X-\\x%02X', $range->[0], $range->[-1]); |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
if (0) { |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# EUC-TW encoding |
401
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b Eeuctw \z/oxms) { |
402
|
|
|
|
|
|
|
${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[^\x8E\xA1-\xFE] (?> [\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\xA1-\xFE] )*?}oxms; |
403
|
|
|
|
|
|
|
# **************** octets not in multiple octet char (always char boundary) |
404
|
|
|
|
|
|
|
# ********************** 2 octet chars |
405
|
|
|
|
|
|
|
# ************************************* 4 octet chars |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# other encoding |
409
|
|
|
|
|
|
|
else { |
410
|
|
|
|
|
|
|
${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[$sbcs](?:[^$sbcs][^$sbcs])*?}oxms; |
411
|
|
|
|
|
|
|
# ******* octets not in multiple octet char (always char boundary) |
412
|
|
|
|
|
|
|
# **************** 2 octet chars |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
${Eeuctw::anchor_SADAHIRO_Tomoyuki_2002_01_17} = |
416
|
|
|
|
|
|
|
qr{\G(?(?=.{0,32766}\z)(?:[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])*?|(?(?=[$sbcs]+\z).*?|(?:${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17})))}oxms; |
417
|
|
|
|
|
|
|
# qr{ |
418
|
|
|
|
|
|
|
# \G # (1), (2) |
419
|
|
|
|
|
|
|
# (? # (3) |
420
|
|
|
|
|
|
|
# (?=.{0,32766}\z) # (4) |
421
|
|
|
|
|
|
|
# (?:[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])*?| # (5) |
422
|
|
|
|
|
|
|
# (?(?=[$sbcs]+\z) # (6) |
423
|
|
|
|
|
|
|
# .*?| #(7) |
424
|
|
|
|
|
|
|
# (?:${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17}) # (8) |
425
|
|
|
|
|
|
|
# ))}oxms; |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# avoid: Complex regular subexpression recursion limit (32766) exceeded at here. |
428
|
|
|
|
|
|
|
local $^W = 0; |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
if (((('A' x 32768).'B') !~ / ${Eeuctw::anchor} B /oxms) and |
431
|
|
|
|
|
|
|
((('A' x 32768).'B') =~ / ${Eeuctw::anchor_SADAHIRO_Tomoyuki_2002_01_17} B /oxms) |
432
|
|
|
|
|
|
|
) { |
433
|
|
|
|
|
|
|
${Eeuctw::anchor} = ${Eeuctw::anchor_SADAHIRO_Tomoyuki_2002_01_17}; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
else { |
436
|
|
|
|
|
|
|
undef ${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
# (1) |
441
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
442
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
443
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
444
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
# (2) |
447
|
|
|
|
|
|
|
# P.255 Use leading anchors |
448
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front of expressions |
449
|
|
|
|
|
|
|
# in Chapter6: Crafting an Efficient Expression |
450
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
# (3) |
453
|
|
|
|
|
|
|
# P.138 Conditional: (? if then| else) |
454
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
455
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# (4) |
458
|
|
|
|
|
|
|
# perlre |
459
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
460
|
|
|
|
|
|
|
# The "*" quantifier is equivalent to {0,} , the "+" quantifier to {1,} , |
461
|
|
|
|
|
|
|
# and the "?" quantifier to {0,1}, ., n, and m are limited to non-negative |
462
|
|
|
|
|
|
|
# integral values less than a preset limit defined when perl is built. |
463
|
|
|
|
|
|
|
# This is usually 32766 on the most common platforms. The actual limit |
464
|
|
|
|
|
|
|
# can be seen in the error message generated by code such as this: |
465
|
|
|
|
|
|
|
# $_ **= $_ , / {$_} / for 2 .. 42; |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# (5) |
468
|
|
|
|
|
|
|
# P.1023 Multiple-Byte Anchoring |
469
|
|
|
|
|
|
|
# in Appendix W Perl Code Examples |
470
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
# (6) |
473
|
|
|
|
|
|
|
# if string has only SBCS (Single Byte Character Set) |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
# (7) |
476
|
|
|
|
|
|
|
# then .*? (isn't limited to 32766) |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
# (8) |
479
|
|
|
|
|
|
|
# else EUC-TW::Regexp::Const (SADAHIRO Tomoyuki) |
480
|
|
|
|
|
|
|
# http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#long |
481
|
|
|
|
|
|
|
# http://search.cpan.org/~sadahiro/EUC-TW-Regexp/ |
482
|
|
|
|
|
|
|
# $PadA = ' (?:\A| [\x00-\x80\xA0-\xDF])(?:[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE]{2})*?'; |
483
|
|
|
|
|
|
|
# $PadG = '\G(?: |[\x00-\xFF]*?[\x00-\x80\xA0-\xDF])(?:[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE]{2})*?'; |
484
|
|
|
|
|
|
|
# $PadGA = '\G(?:\A|(?:[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE]{2})+?|[\x00-\xFF]*?[\x00-\x80\xA0-\xDF] (?:[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE]{2})*?)'; |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
${Eeuctw::dot} = qr{(?>[^\x8E\xA1-\xFE\x0A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
487
|
|
|
|
|
|
|
${Eeuctw::dot_s} = qr{(?>[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
488
|
|
|
|
|
|
|
${Eeuctw::eD} = qr{(?>[^\x8E\xA1-\xFE0-9]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
491
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
492
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
493
|
|
|
|
|
|
|
# ${Eeuctw::eS} = qr{(?>[^\x8E\xA1-\xFE\x09\x0A \x0C\x0D\x20]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
494
|
|
|
|
|
|
|
# ${Eeuctw::eS} = qr{(?>[^\x8E\xA1-\xFE\x09\x0A\x0B\x0C\x0D\x20]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
495
|
|
|
|
|
|
|
${Eeuctw::eS} = qr{(?>[^\x8E\xA1-\xFE\s]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
${Eeuctw::eW} = qr{(?>[^\x8E\xA1-\xFE0-9A-Z_a-z]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
498
|
|
|
|
|
|
|
${Eeuctw::eH} = qr{(?>[^\x8E\xA1-\xFE\x09\x20]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
499
|
|
|
|
|
|
|
${Eeuctw::eV} = qr{(?>[^\x8E\xA1-\xFE\x0A\x0B\x0C\x0D]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
500
|
|
|
|
|
|
|
${Eeuctw::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])}; |
501
|
|
|
|
|
|
|
${Eeuctw::eN} = qr{(?>[^\x8E\xA1-\xFE\x0A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
502
|
|
|
|
|
|
|
${Eeuctw::not_alnum} = qr{(?>[^\x8E\xA1-\xFE\x30-\x39\x41-\x5A\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
503
|
|
|
|
|
|
|
${Eeuctw::not_alpha} = qr{(?>[^\x8E\xA1-\xFE\x41-\x5A\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
504
|
|
|
|
|
|
|
${Eeuctw::not_ascii} = qr{(?>[^\x8E\xA1-\xFE\x00-\x7F]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
505
|
|
|
|
|
|
|
${Eeuctw::not_blank} = qr{(?>[^\x8E\xA1-\xFE\x09\x20]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
506
|
|
|
|
|
|
|
${Eeuctw::not_cntrl} = qr{(?>[^\x8E\xA1-\xFE\x00-\x1F\x7F]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
507
|
|
|
|
|
|
|
${Eeuctw::not_digit} = qr{(?>[^\x8E\xA1-\xFE\x30-\x39]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
508
|
|
|
|
|
|
|
${Eeuctw::not_graph} = qr{(?>[^\x8E\xA1-\xFE\x21-\x7F]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
509
|
|
|
|
|
|
|
${Eeuctw::not_lower} = qr{(?>[^\x8E\xA1-\xFE\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
510
|
|
|
|
|
|
|
${Eeuctw::not_lower_i} = qr{(?>[^\x8E\xA1-\xFE\x41-\x5A\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
511
|
|
|
|
|
|
|
# ${Eeuctw::not_lower_i} = qr{(?>[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; # older Perl compatible |
512
|
|
|
|
|
|
|
${Eeuctw::not_print} = qr{(?>[^\x8E\xA1-\xFE\x20-\x7F]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
513
|
|
|
|
|
|
|
${Eeuctw::not_punct} = qr{(?>[^\x8E\xA1-\xFE\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
514
|
|
|
|
|
|
|
${Eeuctw::not_space} = qr{(?>[^\x8E\xA1-\xFE\s\x0B]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
515
|
|
|
|
|
|
|
${Eeuctw::not_upper} = qr{(?>[^\x8E\xA1-\xFE\x41-\x5A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
516
|
|
|
|
|
|
|
${Eeuctw::not_upper_i} = qr{(?>[^\x8E\xA1-\xFE\x41-\x5A\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
517
|
|
|
|
|
|
|
# ${Eeuctw::not_upper_i} = qr{(?>[^\x8E\xA1-\xFE]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; # older Perl compatible |
518
|
|
|
|
|
|
|
${Eeuctw::not_word} = qr{(?>[^\x8E\xA1-\xFE\x30-\x39\x41-\x5A\x5F\x61-\x7A]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
519
|
|
|
|
|
|
|
${Eeuctw::not_xdigit} = qr{(?>[^\x8E\xA1-\xFE\x30-\x39\x41-\x46\x61-\x66]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])}; |
520
|
|
|
|
|
|
|
${Eeuctw::eb} = qr{(?:\A(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[0-9A-Z_a-z])|(?<=[0-9A-Z_a-z])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]|\z))}; |
521
|
|
|
|
|
|
|
${Eeuctw::eB} = qr{(?:(?<=[0-9A-Z_a-z])(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]))}; |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
# avoid: Name "Eeuctw::foo" used only once: possible typo at here. |
524
|
|
|
|
|
|
|
${Eeuctw::dot} = ${Eeuctw::dot}; |
525
|
|
|
|
|
|
|
${Eeuctw::dot_s} = ${Eeuctw::dot_s}; |
526
|
|
|
|
|
|
|
${Eeuctw::eD} = ${Eeuctw::eD}; |
527
|
|
|
|
|
|
|
${Eeuctw::eS} = ${Eeuctw::eS}; |
528
|
|
|
|
|
|
|
${Eeuctw::eW} = ${Eeuctw::eW}; |
529
|
|
|
|
|
|
|
${Eeuctw::eH} = ${Eeuctw::eH}; |
530
|
|
|
|
|
|
|
${Eeuctw::eV} = ${Eeuctw::eV}; |
531
|
|
|
|
|
|
|
${Eeuctw::eR} = ${Eeuctw::eR}; |
532
|
|
|
|
|
|
|
${Eeuctw::eN} = ${Eeuctw::eN}; |
533
|
|
|
|
|
|
|
${Eeuctw::not_alnum} = ${Eeuctw::not_alnum}; |
534
|
|
|
|
|
|
|
${Eeuctw::not_alpha} = ${Eeuctw::not_alpha}; |
535
|
|
|
|
|
|
|
${Eeuctw::not_ascii} = ${Eeuctw::not_ascii}; |
536
|
|
|
|
|
|
|
${Eeuctw::not_blank} = ${Eeuctw::not_blank}; |
537
|
|
|
|
|
|
|
${Eeuctw::not_cntrl} = ${Eeuctw::not_cntrl}; |
538
|
|
|
|
|
|
|
${Eeuctw::not_digit} = ${Eeuctw::not_digit}; |
539
|
|
|
|
|
|
|
${Eeuctw::not_graph} = ${Eeuctw::not_graph}; |
540
|
|
|
|
|
|
|
${Eeuctw::not_lower} = ${Eeuctw::not_lower}; |
541
|
|
|
|
|
|
|
${Eeuctw::not_lower_i} = ${Eeuctw::not_lower_i}; |
542
|
|
|
|
|
|
|
${Eeuctw::not_print} = ${Eeuctw::not_print}; |
543
|
|
|
|
|
|
|
${Eeuctw::not_punct} = ${Eeuctw::not_punct}; |
544
|
|
|
|
|
|
|
${Eeuctw::not_space} = ${Eeuctw::not_space}; |
545
|
|
|
|
|
|
|
${Eeuctw::not_upper} = ${Eeuctw::not_upper}; |
546
|
|
|
|
|
|
|
${Eeuctw::not_upper_i} = ${Eeuctw::not_upper_i}; |
547
|
|
|
|
|
|
|
${Eeuctw::not_word} = ${Eeuctw::not_word}; |
548
|
|
|
|
|
|
|
${Eeuctw::not_xdigit} = ${Eeuctw::not_xdigit}; |
549
|
|
|
|
|
|
|
${Eeuctw::eb} = ${Eeuctw::eb}; |
550
|
|
|
|
|
|
|
${Eeuctw::eB} = ${Eeuctw::eB}; |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
# |
553
|
|
|
|
|
|
|
# EUC-TW split |
554
|
|
|
|
|
|
|
# |
555
|
|
|
|
|
|
|
sub Eeuctw::split(;$$$) { |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
# P.794 29.2.161. split |
558
|
|
|
|
|
|
|
# in Chapter 29: Functions |
559
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
# P.951 split |
562
|
|
|
|
|
|
|
# in Chapter 27: Functions |
563
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
564
|
|
|
|
|
|
|
|
565
|
0
|
|
|
0
|
0
|
0
|
my $pattern = $_[0]; |
566
|
0
|
|
|
|
|
0
|
my $string = $_[1]; |
567
|
0
|
|
|
|
|
0
|
my $limit = $_[2]; |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " " |
570
|
0
|
0
|
|
|
|
0
|
if (not defined $pattern) { |
571
|
0
|
|
|
|
|
0
|
$pattern = ' '; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
# if $string is omitted, the function splits the $_ string |
575
|
0
|
0
|
|
|
|
0
|
if (not defined $string) { |
576
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
577
|
0
|
|
|
|
|
0
|
$string = $_; |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
else { |
580
|
0
|
|
|
|
|
0
|
$string = ''; |
581
|
|
|
|
|
|
|
} |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
0
|
my @split = (); |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
# when string is empty |
587
|
0
|
0
|
|
|
|
0
|
if ($string eq '') { |
|
|
0
|
|
|
|
|
|
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
# resulting list value in list context |
590
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
591
|
0
|
|
|
|
|
0
|
return @split; |
592
|
|
|
|
|
|
|
} |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
# count of substrings in scalar context |
595
|
|
|
|
|
|
|
else { |
596
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
597
|
0
|
|
|
|
|
0
|
@_ = @split; |
598
|
0
|
|
|
|
|
0
|
return scalar @_; |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
# split's first argument is more consistently interpreted |
603
|
|
|
|
|
|
|
# |
604
|
|
|
|
|
|
|
# After some changes earlier in v5.17, split's behavior has been simplified: |
605
|
|
|
|
|
|
|
# if the PATTERN argument evaluates to a string containing one space, it is |
606
|
|
|
|
|
|
|
# treated the way that a literal string containing one space once was. |
607
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " ", the function splits |
610
|
|
|
|
|
|
|
# on whitespace, /\s+/, after skipping any leading whitespace |
611
|
|
|
|
|
|
|
# (and so on) |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
elsif ($pattern eq ' ') { |
614
|
0
|
0
|
|
|
|
0
|
if (not defined $limit) { |
615
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string); |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
else { |
618
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string, $limit); |
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
0
|
local $q_char = $q_char; |
623
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 32766) { |
624
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\A [\x00-\x7F]+ \z/oxms) { |
|
|
0
|
|
|
|
|
|
625
|
0
|
|
|
|
|
0
|
$q_char = qr{.}s; |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
elsif (defined ${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17}) { |
628
|
0
|
|
|
|
|
0
|
$q_char = ${Eeuctw::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
# if $limit is negative, it is treated as if an arbitrarily large $limit has been specified |
633
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $limit) or ($limit <= 0)) { |
|
|
0
|
|
|
|
|
|
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
# a pattern capable of matching either the null string or something longer than the |
636
|
|
|
|
|
|
|
# null string will split the value of $string into separate characters wherever it |
637
|
|
|
|
|
|
|
# matches the null string between characters |
638
|
|
|
|
|
|
|
# (and so on) |
639
|
|
|
|
|
|
|
|
640
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
641
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
642
|
0
|
|
|
|
|
0
|
my $limit = scalar(() = $string =~ /($pattern)/oxmsg); |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
645
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
646
|
|
|
|
|
|
|
# (and so on) |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
# the //m modifier is assumed when you split on the pattern /^/ |
649
|
|
|
|
|
|
|
# (and so on) |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
# V |
652
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) { |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# if the $pattern contains parentheses, then the substring matched by each pair of parentheses |
655
|
|
|
|
|
|
|
# is included in the resulting list, interspersed with the fields that are ordinarily returned |
656
|
|
|
|
|
|
|
# (and so on) |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
0
|
local $@; |
659
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
660
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
661
|
|
|
|
|
|
|
} |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
} |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
else { |
666
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
# V |
669
|
0
|
|
|
|
|
0
|
while ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
670
|
0
|
|
|
|
|
0
|
local $@; |
671
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
672
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
elsif ($limit > 0) { |
679
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
680
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
681
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
# V |
684
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)+?)$pattern//m) { |
685
|
0
|
|
|
|
|
0
|
local $@; |
686
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
687
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
} |
692
|
|
|
|
|
|
|
else { |
693
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
694
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
# V |
697
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
698
|
0
|
|
|
|
|
0
|
local $@; |
699
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
700
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
701
|
|
|
|
|
|
|
} |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
} |
706
|
|
|
|
|
|
|
|
707
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 0) { |
708
|
0
|
|
|
|
|
0
|
push @split, $string; |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
# if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result |
712
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $_[2]) or ($_[2] == 0)) { |
713
|
0
|
|
0
|
|
|
0
|
while ((scalar(@split) >= 1) and ($split[-1] eq '')) { |
714
|
0
|
|
|
|
|
0
|
pop @split; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
# resulting list value in list context |
719
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
720
|
0
|
|
|
|
|
0
|
return @split; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
# count of substrings in scalar context |
724
|
|
|
|
|
|
|
else { |
725
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
726
|
0
|
|
|
|
|
0
|
@_ = @split; |
727
|
0
|
|
|
|
|
0
|
return scalar @_; |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
} |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
# |
732
|
|
|
|
|
|
|
# get last subexpression offsets |
733
|
|
|
|
|
|
|
# |
734
|
|
|
|
|
|
|
sub _last_subexpression_offsets { |
735
|
0
|
|
|
0
|
|
0
|
my $pattern = $_[0]; |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
# remove comment |
738
|
0
|
|
|
|
|
0
|
$pattern =~ s/\(\?\# .*? \)//oxmsg; |
739
|
|
|
|
|
|
|
|
740
|
0
|
|
|
|
|
0
|
my $modifier = ''; |
741
|
0
|
0
|
|
|
|
0
|
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) { |
742
|
0
|
|
|
|
|
0
|
$modifier = $1; |
743
|
0
|
|
|
|
|
0
|
$modifier =~ s/-[A-Za-z]*//; |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
# with /x modifier |
747
|
0
|
|
|
|
|
0
|
my @char = (); |
748
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /x/oxms) { |
749
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
750
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\#\[\(]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
751
|
|
|
|
|
|
|
\\ $q_char | |
752
|
|
|
|
|
|
|
\# (?>[^\n]*) $ | |
753
|
|
|
|
|
|
|
\[ (?>(?:[^\x8E\xA1-\xFE\\\]]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
754
|
|
|
|
|
|
|
\(\? | |
755
|
|
|
|
|
|
|
$q_char |
756
|
|
|
|
|
|
|
))/oxmsg; |
757
|
|
|
|
|
|
|
} |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
# without /x modifier |
760
|
|
|
|
|
|
|
else { |
761
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
762
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\[\(]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
763
|
|
|
|
|
|
|
\\ $q_char | |
764
|
|
|
|
|
|
|
\[ (?>(?:[^\x8E\xA1-\xFE\\\]]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
765
|
|
|
|
|
|
|
\(\? | |
766
|
|
|
|
|
|
|
$q_char |
767
|
|
|
|
|
|
|
))/oxmsg; |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
|
770
|
0
|
|
|
|
|
0
|
return scalar grep { $_ eq '(' } @char; |
|
0
|
|
|
|
|
0
|
|
771
|
|
|
|
|
|
|
} |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
# |
774
|
|
|
|
|
|
|
# EUC-TW transliteration (tr///) |
775
|
|
|
|
|
|
|
# |
776
|
|
|
|
|
|
|
sub Eeuctw::tr($$$$;$) { |
777
|
|
|
|
|
|
|
|
778
|
0
|
|
|
0
|
0
|
0
|
my $bind_operator = $_[1]; |
779
|
0
|
|
|
|
|
0
|
my $searchlist = $_[2]; |
780
|
0
|
|
|
|
|
0
|
my $replacementlist = $_[3]; |
781
|
0
|
|
0
|
|
|
0
|
my $modifier = $_[4] || ''; |
782
|
|
|
|
|
|
|
|
783
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
784
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
785
|
0
|
|
|
|
|
0
|
croak "Using !~ with tr///r doesn't make sense"; |
786
|
|
|
|
|
|
|
} |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
|
789
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
790
|
0
|
|
|
|
|
0
|
my @searchlist = _charlist_tr($searchlist); |
791
|
0
|
|
|
|
|
0
|
my @replacementlist = _charlist_tr($replacementlist); |
792
|
|
|
|
|
|
|
|
793
|
0
|
|
|
|
|
0
|
my %tr = (); |
794
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#searchlist; $i++) { |
795
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$searchlist[$i]}) { |
796
|
0
|
0
|
0
|
|
|
0
|
if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
797
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[$i]; |
798
|
|
|
|
|
|
|
} |
799
|
|
|
|
|
|
|
elsif ($modifier =~ /d/oxms) { |
800
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = ''; |
801
|
|
|
|
|
|
|
} |
802
|
|
|
|
|
|
|
elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) { |
803
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[-1]; |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
else { |
806
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $searchlist[$i]; |
807
|
|
|
|
|
|
|
} |
808
|
|
|
|
|
|
|
} |
809
|
|
|
|
|
|
|
} |
810
|
|
|
|
|
|
|
|
811
|
0
|
|
|
|
|
0
|
my $tr = 0; |
812
|
0
|
|
|
|
|
0
|
my $replaced = ''; |
813
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /c/oxms) { |
814
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
815
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$char}) { |
816
|
0
|
0
|
|
|
|
0
|
if (defined $replacementlist[0]) { |
817
|
0
|
|
|
|
|
0
|
$replaced .= $replacementlist[0]; |
818
|
|
|
|
|
|
|
} |
819
|
0
|
|
|
|
|
0
|
$tr++; |
820
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
821
|
0
|
|
0
|
|
|
0
|
while (@char and (not exists $tr{$char[0]})) { |
822
|
0
|
|
|
|
|
0
|
shift @char; |
823
|
0
|
|
|
|
|
0
|
$tr++; |
824
|
|
|
|
|
|
|
} |
825
|
|
|
|
|
|
|
} |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
else { |
828
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
829
|
|
|
|
|
|
|
} |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
else { |
833
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
834
|
0
|
0
|
|
|
|
0
|
if (exists $tr{$char}) { |
835
|
0
|
|
|
|
|
0
|
$replaced .= $tr{$char}; |
836
|
0
|
|
|
|
|
0
|
$tr++; |
837
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
838
|
0
|
|
0
|
|
|
0
|
while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) { |
|
|
|
0
|
|
|
|
|
839
|
0
|
|
|
|
|
0
|
shift @char; |
840
|
0
|
|
|
|
|
0
|
$tr++; |
841
|
|
|
|
|
|
|
} |
842
|
|
|
|
|
|
|
} |
843
|
|
|
|
|
|
|
} |
844
|
|
|
|
|
|
|
else { |
845
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
846
|
|
|
|
|
|
|
} |
847
|
|
|
|
|
|
|
} |
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
|
850
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
851
|
0
|
|
|
|
|
0
|
return $replaced; |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
else { |
854
|
0
|
|
|
|
|
0
|
$_[0] = $replaced; |
855
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
856
|
0
|
|
|
|
|
0
|
return not $tr; |
857
|
|
|
|
|
|
|
} |
858
|
|
|
|
|
|
|
else { |
859
|
0
|
|
|
|
|
0
|
return $tr; |
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
} |
862
|
|
|
|
|
|
|
} |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
# |
865
|
|
|
|
|
|
|
# EUC-TW chop |
866
|
|
|
|
|
|
|
# |
867
|
|
|
|
|
|
|
sub Eeuctw::chop(@) { |
868
|
|
|
|
|
|
|
|
869
|
0
|
|
|
0
|
0
|
0
|
my $chop; |
870
|
0
|
0
|
|
|
|
0
|
if (@_ == 0) { |
871
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
872
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
873
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
874
|
|
|
|
|
|
|
} |
875
|
|
|
|
|
|
|
else { |
876
|
0
|
|
|
|
|
0
|
for (@_) { |
877
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
878
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
879
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
880
|
|
|
|
|
|
|
} |
881
|
|
|
|
|
|
|
} |
882
|
0
|
|
|
|
|
0
|
return $chop; |
883
|
|
|
|
|
|
|
} |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
# |
886
|
|
|
|
|
|
|
# EUC-TW index by octet |
887
|
|
|
|
|
|
|
# |
888
|
|
|
|
|
|
|
sub Eeuctw::index($$;$) { |
889
|
|
|
|
|
|
|
|
890
|
0
|
|
|
0
|
1
|
0
|
my($str,$substr,$position) = @_; |
891
|
0
|
|
0
|
|
|
0
|
$position ||= 0; |
892
|
0
|
|
|
|
|
0
|
my $pos = 0; |
893
|
|
|
|
|
|
|
|
894
|
0
|
|
|
|
|
0
|
while ($pos < CORE::length($str)) { |
895
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
896
|
0
|
0
|
|
|
|
0
|
if ($pos >= $position) { |
897
|
0
|
|
|
|
|
0
|
return $pos; |
898
|
|
|
|
|
|
|
} |
899
|
|
|
|
|
|
|
} |
900
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
901
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
902
|
|
|
|
|
|
|
} |
903
|
|
|
|
|
|
|
else { |
904
|
0
|
|
|
|
|
0
|
$pos += 1; |
905
|
|
|
|
|
|
|
} |
906
|
|
|
|
|
|
|
} |
907
|
0
|
|
|
|
|
0
|
return -1; |
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
# |
911
|
|
|
|
|
|
|
# EUC-TW reverse index |
912
|
|
|
|
|
|
|
# |
913
|
|
|
|
|
|
|
sub Eeuctw::rindex($$;$) { |
914
|
|
|
|
|
|
|
|
915
|
0
|
|
|
0
|
0
|
0
|
my($str,$substr,$position) = @_; |
916
|
0
|
|
0
|
|
|
0
|
$position ||= CORE::length($str) - 1; |
917
|
0
|
|
|
|
|
0
|
my $pos = 0; |
918
|
0
|
|
|
|
|
0
|
my $rindex = -1; |
919
|
|
|
|
|
|
|
|
920
|
0
|
|
0
|
|
|
0
|
while (($pos < CORE::length($str)) and ($pos <= $position)) { |
921
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
922
|
0
|
|
|
|
|
0
|
$rindex = $pos; |
923
|
|
|
|
|
|
|
} |
924
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
925
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
926
|
|
|
|
|
|
|
} |
927
|
|
|
|
|
|
|
else { |
928
|
0
|
|
|
|
|
0
|
$pos += 1; |
929
|
|
|
|
|
|
|
} |
930
|
|
|
|
|
|
|
} |
931
|
0
|
|
|
|
|
0
|
return $rindex; |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
# |
935
|
|
|
|
|
|
|
# EUC-TW lower case first with parameter |
936
|
|
|
|
|
|
|
# |
937
|
|
|
|
|
|
|
sub Eeuctw::lcfirst(@) { |
938
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
939
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
940
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
941
|
0
|
|
|
|
|
0
|
return Eeuctw::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
942
|
|
|
|
|
|
|
} |
943
|
|
|
|
|
|
|
else { |
944
|
0
|
|
|
|
|
0
|
return Eeuctw::lc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
945
|
|
|
|
|
|
|
} |
946
|
|
|
|
|
|
|
} |
947
|
|
|
|
|
|
|
else { |
948
|
0
|
|
|
|
|
0
|
return Eeuctw::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
949
|
|
|
|
|
|
|
} |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
# |
953
|
|
|
|
|
|
|
# EUC-TW lower case first without parameter |
954
|
|
|
|
|
|
|
# |
955
|
|
|
|
|
|
|
sub Eeuctw::lcfirst_() { |
956
|
0
|
|
|
0
|
0
|
0
|
return Eeuctw::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
957
|
|
|
|
|
|
|
} |
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
# |
960
|
|
|
|
|
|
|
# EUC-TW lower case with parameter |
961
|
|
|
|
|
|
|
# |
962
|
|
|
|
|
|
|
sub Eeuctw::lc(@) { |
963
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
964
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
965
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
966
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
967
|
|
|
|
|
|
|
} |
968
|
|
|
|
|
|
|
else { |
969
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
0
|
|
|
|
|
0
|
|
970
|
|
|
|
|
|
|
} |
971
|
|
|
|
|
|
|
} |
972
|
|
|
|
|
|
|
else { |
973
|
0
|
|
|
|
|
0
|
return Eeuctw::lc_(); |
974
|
|
|
|
|
|
|
} |
975
|
|
|
|
|
|
|
} |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
# |
978
|
|
|
|
|
|
|
# EUC-TW lower case without parameter |
979
|
|
|
|
|
|
|
# |
980
|
|
|
|
|
|
|
sub Eeuctw::lc_() { |
981
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
982
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
# |
986
|
|
|
|
|
|
|
# EUC-TW upper case first with parameter |
987
|
|
|
|
|
|
|
# |
988
|
|
|
|
|
|
|
sub Eeuctw::ucfirst(@) { |
989
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
990
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
991
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
992
|
0
|
|
|
|
|
0
|
return Eeuctw::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
993
|
|
|
|
|
|
|
} |
994
|
|
|
|
|
|
|
else { |
995
|
0
|
|
|
|
|
0
|
return Eeuctw::uc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
else { |
999
|
0
|
|
|
|
|
0
|
return Eeuctw::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1000
|
|
|
|
|
|
|
} |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
# |
1004
|
|
|
|
|
|
|
# EUC-TW upper case first without parameter |
1005
|
|
|
|
|
|
|
# |
1006
|
|
|
|
|
|
|
sub Eeuctw::ucfirst_() { |
1007
|
0
|
|
|
0
|
0
|
0
|
return Eeuctw::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1008
|
|
|
|
|
|
|
} |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
# |
1011
|
|
|
|
|
|
|
# EUC-TW upper case with parameter |
1012
|
|
|
|
|
|
|
# |
1013
|
|
|
|
|
|
|
sub Eeuctw::uc(@) { |
1014
|
2790
|
50
|
|
2790
|
0
|
3043
|
if (@_) { |
1015
|
2790
|
|
|
|
|
2097
|
my $s = shift @_; |
1016
|
2790
|
50
|
33
|
|
|
4421
|
if (@_ and wantarray) { |
1017
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1018
|
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
else { |
1020
|
2790
|
100
|
|
|
|
5836
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
2790
|
|
|
|
|
6534
|
|
1021
|
|
|
|
|
|
|
} |
1022
|
|
|
|
|
|
|
} |
1023
|
|
|
|
|
|
|
else { |
1024
|
0
|
|
|
|
|
0
|
return Eeuctw::uc_(); |
1025
|
|
|
|
|
|
|
} |
1026
|
|
|
|
|
|
|
} |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
# |
1029
|
|
|
|
|
|
|
# EUC-TW upper case without parameter |
1030
|
|
|
|
|
|
|
# |
1031
|
|
|
|
|
|
|
sub Eeuctw::uc_() { |
1032
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1033
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
# |
1037
|
|
|
|
|
|
|
# EUC-TW fold case with parameter |
1038
|
|
|
|
|
|
|
# |
1039
|
|
|
|
|
|
|
sub Eeuctw::fc(@) { |
1040
|
2865
|
50
|
|
2865
|
0
|
3049
|
if (@_) { |
1041
|
2865
|
|
|
|
|
2154
|
my $s = shift @_; |
1042
|
2865
|
50
|
33
|
|
|
4533
|
if (@_ and wantarray) { |
1043
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1044
|
|
|
|
|
|
|
} |
1045
|
|
|
|
|
|
|
else { |
1046
|
2865
|
100
|
|
|
|
5273
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
2865
|
|
|
|
|
8111
|
|
1047
|
|
|
|
|
|
|
} |
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
else { |
1050
|
0
|
|
|
|
|
0
|
return Eeuctw::fc_(); |
1051
|
|
|
|
|
|
|
} |
1052
|
|
|
|
|
|
|
} |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
# |
1055
|
|
|
|
|
|
|
# EUC-TW fold case without parameter |
1056
|
|
|
|
|
|
|
# |
1057
|
|
|
|
|
|
|
sub Eeuctw::fc_() { |
1058
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1059
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
# |
1063
|
|
|
|
|
|
|
# EUC-TW regexp capture |
1064
|
|
|
|
|
|
|
# |
1065
|
|
|
|
|
|
|
{ |
1066
|
|
|
|
|
|
|
# 10.3. Creating Persistent Private Variables |
1067
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
1068
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
my $last_s_matched = 0; |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
sub Eeuctw::capture { |
1073
|
0
|
0
|
0
|
0
|
1
|
0
|
if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) { |
1074
|
0
|
|
|
|
|
0
|
return $_[0] + 1; |
1075
|
|
|
|
|
|
|
} |
1076
|
0
|
|
|
|
|
0
|
return $_[0]; |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
# EUC-TW mark last regexp matched |
1080
|
|
|
|
|
|
|
sub Eeuctw::matched() { |
1081
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 0; |
1082
|
|
|
|
|
|
|
} |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
# EUC-TW mark last s/// matched |
1085
|
|
|
|
|
|
|
sub Eeuctw::s_matched() { |
1086
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 1; |
1087
|
|
|
|
|
|
|
} |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
# P.854 31.17. use re |
1090
|
|
|
|
|
|
|
# in Chapter 31. Pragmatic Modules |
1091
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
# P.1026 re |
1094
|
|
|
|
|
|
|
# in Chapter 29. Pragmatic Modules |
1095
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
$Eeuctw::matched = qr/(?{Eeuctw::matched})/; |
1098
|
|
|
|
|
|
|
} |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
# |
1101
|
|
|
|
|
|
|
# EUC-TW regexp ignore case modifier |
1102
|
|
|
|
|
|
|
# |
1103
|
|
|
|
|
|
|
sub Eeuctw::ignorecase { |
1104
|
|
|
|
|
|
|
|
1105
|
0
|
|
|
0
|
0
|
0
|
my @string = @_; |
1106
|
0
|
|
|
|
|
0
|
my $metachar = qr/[\@\\|[\]{]/oxms; |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
# ignore case of $scalar or @array |
1109
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
# split regexp |
1112
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg; |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
# unescape character |
1115
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1116
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
# open character class [...] |
1119
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '[') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1120
|
0
|
|
|
|
|
0
|
my $left = $i; |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
# [] make die "unmatched [] in regexp ...\n" |
1123
|
|
|
|
|
|
|
|
1124
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1125
|
0
|
|
|
|
|
0
|
$i++; |
1126
|
|
|
|
|
|
|
} |
1127
|
|
|
|
|
|
|
|
1128
|
0
|
|
|
|
|
0
|
while (1) { |
1129
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1130
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1131
|
|
|
|
|
|
|
} |
1132
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1133
|
0
|
|
|
|
|
0
|
my $right = $i; |
1134
|
0
|
|
|
|
|
0
|
my @charlist = charlist_qr(@char[$left+1..$right-1], 'i'); |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
# escape character |
1137
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1138
|
0
|
0
|
|
|
|
0
|
if (0) { |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1142
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1143
|
|
|
|
|
|
|
} |
1144
|
|
|
|
|
|
|
} |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
# [...] |
1147
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')'; |
1148
|
|
|
|
|
|
|
|
1149
|
0
|
|
|
|
|
0
|
$i = $left; |
1150
|
0
|
|
|
|
|
0
|
last; |
1151
|
|
|
|
|
|
|
} |
1152
|
|
|
|
|
|
|
} |
1153
|
|
|
|
|
|
|
} |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
# open character class [^...] |
1156
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
1157
|
0
|
|
|
|
|
0
|
my $left = $i; |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
# [^] make die "unmatched [] in regexp ...\n" |
1160
|
|
|
|
|
|
|
|
1161
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1162
|
0
|
|
|
|
|
0
|
$i++; |
1163
|
|
|
|
|
|
|
} |
1164
|
|
|
|
|
|
|
|
1165
|
0
|
|
|
|
|
0
|
while (1) { |
1166
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1167
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1168
|
|
|
|
|
|
|
} |
1169
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1170
|
0
|
|
|
|
|
0
|
my $right = $i; |
1171
|
0
|
|
|
|
|
0
|
my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i'); |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
# escape character |
1174
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1175
|
0
|
0
|
|
|
|
0
|
if (0) { |
1176
|
|
|
|
|
|
|
} |
1177
|
|
|
|
|
|
|
|
1178
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1179
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1180
|
|
|
|
|
|
|
} |
1181
|
|
|
|
|
|
|
} |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
# [^...] |
1184
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)"; |
1185
|
|
|
|
|
|
|
|
1186
|
0
|
|
|
|
|
0
|
$i = $left; |
1187
|
0
|
|
|
|
|
0
|
last; |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
} |
1190
|
|
|
|
|
|
|
} |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
# rewrite classic character class or escape character |
1193
|
|
|
|
|
|
|
elsif (my $char = classic_character_class($char[$i])) { |
1194
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
1195
|
|
|
|
|
|
|
} |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
# with /i modifier |
1198
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
1199
|
0
|
|
|
|
|
0
|
my $uc = Eeuctw::uc($char[$i]); |
1200
|
0
|
|
|
|
|
0
|
my $fc = Eeuctw::fc($char[$i]); |
1201
|
0
|
0
|
|
|
|
0
|
if ($uc ne $fc) { |
1202
|
0
|
0
|
|
|
|
0
|
if (CORE::length($fc) == 1) { |
1203
|
0
|
|
|
|
|
0
|
$char[$i] = '[' . $uc . $fc . ']'; |
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
else { |
1206
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . $uc . '|' . $fc . ')'; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
} |
1210
|
|
|
|
|
|
|
} |
1211
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
# characterize |
1213
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1214
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1215
|
|
|
|
|
|
|
|
1216
|
0
|
0
|
|
|
|
0
|
if (0) { |
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
# quote character before ? + * { |
1220
|
0
|
0
|
|
|
|
0
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
1221
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) { |
1222
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
} |
1225
|
|
|
|
|
|
|
} |
1226
|
|
|
|
|
|
|
|
1227
|
0
|
|
|
|
|
0
|
$string = join '', @char; |
1228
|
|
|
|
|
|
|
} |
1229
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
# make regexp string |
1231
|
0
|
|
|
|
|
0
|
return @string; |
1232
|
|
|
|
|
|
|
} |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
# |
1235
|
|
|
|
|
|
|
# classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B ) |
1236
|
|
|
|
|
|
|
# |
1237
|
|
|
|
|
|
|
sub Eeuctw::classic_character_class { |
1238
|
2945
|
|
|
2945
|
0
|
2423
|
my($char) = @_; |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
return { |
1241
|
|
|
|
|
|
|
'\D' => '${Eeuctw::eD}', |
1242
|
|
|
|
|
|
|
'\S' => '${Eeuctw::eS}', |
1243
|
|
|
|
|
|
|
'\W' => '${Eeuctw::eW}', |
1244
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
# Before Perl 5.6, \s only matched the five whitespace characters |
1247
|
|
|
|
|
|
|
# tab, newline, form-feed, carriage return, and the space character |
1248
|
|
|
|
|
|
|
# itself, which, taken together, is the character class [\t\n\f\r ]. |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1251
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1252
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1253
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1254
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1255
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1256
|
|
|
|
|
|
|
'\s' => '\s', |
1257
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1259
|
|
|
|
|
|
|
'\C' => '[\x00-\xFF]', |
1260
|
|
|
|
|
|
|
'\X' => 'X', |
1261
|
|
|
|
|
|
|
|
1262
|
|
|
|
|
|
|
# \h \v \H \V |
1263
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
# P.114 Character Class Shortcuts |
1265
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
1266
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
1267
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
# P.357 13.2.3 Whitespace |
1269
|
|
|
|
|
|
|
# in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes |
1270
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1271
|
|
|
|
|
|
|
# |
1272
|
|
|
|
|
|
|
# 0x00009 CHARACTER TABULATION h s |
1273
|
|
|
|
|
|
|
# 0x0000a LINE FEED (LF) vs |
1274
|
|
|
|
|
|
|
# 0x0000b LINE TABULATION v |
1275
|
|
|
|
|
|
|
# 0x0000c FORM FEED (FF) vs |
1276
|
|
|
|
|
|
|
# 0x0000d CARRIAGE RETURN (CR) vs |
1277
|
|
|
|
|
|
|
# 0x00020 SPACE h s |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
# P.196 Table 5-9. Alphanumeric regex metasymbols |
1280
|
|
|
|
|
|
|
# in Chapter 5. Pattern Matching |
1281
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
# (and so on) |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
'\H' => '${Eeuctw::eH}', |
1286
|
|
|
|
|
|
|
'\V' => '${Eeuctw::eV}', |
1287
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1288
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1289
|
|
|
|
|
|
|
'\R' => '${Eeuctw::eR}', |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
# \N |
1292
|
|
|
|
|
|
|
# |
1293
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
1294
|
|
|
|
|
|
|
# Character Classes and other Special Escapes |
1295
|
|
|
|
|
|
|
# Any character but \n (experimental). Not affected by /s modifier |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
'\N' => '${Eeuctw::eN}', |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
# \b \B |
1300
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
# P.180 Boundaries: The \b and \B Assertions |
1302
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1303
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
# P.219 Boundaries: The \b and \B Assertions |
1306
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1307
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
# \b really means (?:(?<=\w)(?!\w)|(?
|
1310
|
|
|
|
|
|
|
# or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z)) |
1311
|
|
|
|
|
|
|
'\b' => '${Eeuctw::eb}', |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
# \B really means (?:(?<=\w)(?=\w)|(?
|
1314
|
|
|
|
|
|
|
# or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W)) |
1315
|
|
|
|
|
|
|
'\B' => '${Eeuctw::eB}', |
1316
|
|
|
|
|
|
|
|
1317
|
2945
|
|
100
|
|
|
117665
|
}->{$char} || ''; |
1318
|
|
|
|
|
|
|
} |
1319
|
|
|
|
|
|
|
|
1320
|
|
|
|
|
|
|
# |
1321
|
|
|
|
|
|
|
# prepare EUC-TW characters per length |
1322
|
|
|
|
|
|
|
# |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
# 1 octet characters |
1325
|
|
|
|
|
|
|
my @chars1 = (); |
1326
|
|
|
|
|
|
|
sub chars1 { |
1327
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars1) { |
1328
|
0
|
|
|
|
|
0
|
return @chars1; |
1329
|
|
|
|
|
|
|
} |
1330
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{1}) { |
1331
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{1} }; |
|
0
|
|
|
|
|
0
|
|
1332
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,1)) { |
1333
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1334
|
0
|
|
|
|
|
0
|
push @chars1, pack 'C', $oct0; |
1335
|
|
|
|
|
|
|
} |
1336
|
|
|
|
|
|
|
} |
1337
|
|
|
|
|
|
|
} |
1338
|
0
|
|
|
|
|
0
|
return @chars1; |
1339
|
|
|
|
|
|
|
} |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
# 2 octets characters |
1342
|
|
|
|
|
|
|
my @chars2 = (); |
1343
|
|
|
|
|
|
|
sub chars2 { |
1344
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars2) { |
1345
|
0
|
|
|
|
|
0
|
return @chars2; |
1346
|
|
|
|
|
|
|
} |
1347
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{2}) { |
1348
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{2} }; |
|
0
|
|
|
|
|
0
|
|
1349
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,2)) { |
1350
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1351
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1352
|
0
|
|
|
|
|
0
|
push @chars2, pack 'CC', $oct0,$oct1; |
1353
|
|
|
|
|
|
|
} |
1354
|
|
|
|
|
|
|
} |
1355
|
|
|
|
|
|
|
} |
1356
|
|
|
|
|
|
|
} |
1357
|
0
|
|
|
|
|
0
|
return @chars2; |
1358
|
|
|
|
|
|
|
} |
1359
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
# 3 octets characters |
1361
|
|
|
|
|
|
|
my @chars3 = (); |
1362
|
|
|
|
|
|
|
sub chars3 { |
1363
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars3) { |
1364
|
0
|
|
|
|
|
0
|
return @chars3; |
1365
|
|
|
|
|
|
|
} |
1366
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{3}) { |
1367
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{3} }; |
|
0
|
|
|
|
|
0
|
|
1368
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,3)) { |
1369
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1370
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1371
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1372
|
0
|
|
|
|
|
0
|
push @chars3, pack 'CCC', $oct0,$oct1,$oct2; |
1373
|
|
|
|
|
|
|
} |
1374
|
|
|
|
|
|
|
} |
1375
|
|
|
|
|
|
|
} |
1376
|
|
|
|
|
|
|
} |
1377
|
|
|
|
|
|
|
} |
1378
|
0
|
|
|
|
|
0
|
return @chars3; |
1379
|
|
|
|
|
|
|
} |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
# 4 octets characters |
1382
|
|
|
|
|
|
|
my @chars4 = (); |
1383
|
|
|
|
|
|
|
sub chars4 { |
1384
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars4) { |
1385
|
0
|
|
|
|
|
0
|
return @chars4; |
1386
|
|
|
|
|
|
|
} |
1387
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{4}) { |
1388
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{4} }; |
|
0
|
|
|
|
|
0
|
|
1389
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,4)) { |
1390
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1391
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1392
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1393
|
0
|
|
|
|
|
0
|
for my $oct3 (@{$range[3]}) { |
|
0
|
|
|
|
|
0
|
|
1394
|
0
|
|
|
|
|
0
|
push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3; |
1395
|
|
|
|
|
|
|
} |
1396
|
|
|
|
|
|
|
} |
1397
|
|
|
|
|
|
|
} |
1398
|
|
|
|
|
|
|
} |
1399
|
|
|
|
|
|
|
} |
1400
|
|
|
|
|
|
|
} |
1401
|
0
|
|
|
|
|
0
|
return @chars4; |
1402
|
|
|
|
|
|
|
} |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
# |
1405
|
|
|
|
|
|
|
# EUC-TW open character list for tr |
1406
|
|
|
|
|
|
|
# |
1407
|
|
|
|
|
|
|
sub _charlist_tr { |
1408
|
|
|
|
|
|
|
|
1409
|
0
|
|
|
0
|
|
0
|
local $_ = shift @_; |
1410
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
# unescape character |
1412
|
0
|
|
|
|
|
0
|
my @char = (); |
1413
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxmsgc) { |
1414
|
0
|
0
|
|
|
|
0
|
if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1415
|
0
|
|
|
|
|
0
|
push @char, '\-'; |
1416
|
|
|
|
|
|
|
} |
1417
|
|
|
|
|
|
|
elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) { |
1418
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(oct $1); |
1419
|
|
|
|
|
|
|
} |
1420
|
|
|
|
|
|
|
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) { |
1421
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(hex $1); |
1422
|
|
|
|
|
|
|
} |
1423
|
|
|
|
|
|
|
elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) { |
1424
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(CORE::ord($1) & 0x1F); |
1425
|
|
|
|
|
|
|
} |
1426
|
|
|
|
|
|
|
elsif (/\G (\\ [0nrtfbae]) /oxmsgc) { |
1427
|
|
|
|
|
|
|
push @char, { |
1428
|
|
|
|
|
|
|
'\0' => "\0", |
1429
|
|
|
|
|
|
|
'\n' => "\n", |
1430
|
|
|
|
|
|
|
'\r' => "\r", |
1431
|
|
|
|
|
|
|
'\t' => "\t", |
1432
|
|
|
|
|
|
|
'\f' => "\f", |
1433
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1434
|
|
|
|
|
|
|
'\a' => "\a", |
1435
|
|
|
|
|
|
|
'\e' => "\e", |
1436
|
0
|
|
|
|
|
0
|
}->{$1}; |
1437
|
|
|
|
|
|
|
} |
1438
|
|
|
|
|
|
|
elsif (/\G \\ ($q_char) /oxmsgc) { |
1439
|
0
|
|
|
|
|
0
|
push @char, $1; |
1440
|
|
|
|
|
|
|
} |
1441
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxmsgc) { |
1442
|
0
|
|
|
|
|
0
|
push @char, $1; |
1443
|
|
|
|
|
|
|
} |
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
# join separated multiple-octet |
1447
|
0
|
|
|
|
|
0
|
@char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg; |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
# unescape '-' |
1450
|
0
|
|
|
|
|
0
|
my @i = (); |
1451
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#char) { |
1452
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\-') { |
|
|
0
|
|
|
|
|
|
1453
|
0
|
|
|
|
|
0
|
$char[$i] = '-'; |
1454
|
|
|
|
|
|
|
} |
1455
|
|
|
|
|
|
|
elsif ($char[$i] eq '-') { |
1456
|
0
|
0
|
0
|
|
|
0
|
if ((0 < $i) and ($i < $#char)) { |
1457
|
0
|
|
|
|
|
0
|
push @i, $i; |
1458
|
|
|
|
|
|
|
} |
1459
|
|
|
|
|
|
|
} |
1460
|
|
|
|
|
|
|
} |
1461
|
|
|
|
|
|
|
|
1462
|
|
|
|
|
|
|
# open character list (reverse for splice) |
1463
|
0
|
|
|
|
|
0
|
for my $i (CORE::reverse @i) { |
1464
|
0
|
|
|
|
|
0
|
my @range = (); |
1465
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
# range error |
1467
|
0
|
0
|
0
|
|
|
0
|
if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) { |
1468
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1469
|
|
|
|
|
|
|
} |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
# range of multiple-octet code |
1472
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i-1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1473
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1474
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1(); |
|
0
|
|
|
|
|
0
|
|
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 2) { |
1477
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1478
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars2(); |
|
0
|
|
|
|
|
0
|
|
1479
|
|
|
|
|
|
|
} |
1480
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1481
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1482
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1483
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1484
|
|
|
|
|
|
|
} |
1485
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1486
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1487
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1488
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1489
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1490
|
|
|
|
|
|
|
} |
1491
|
|
|
|
|
|
|
else { |
1492
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1493
|
|
|
|
|
|
|
} |
1494
|
|
|
|
|
|
|
} |
1495
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 2) { |
1496
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 2) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1497
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2(); |
|
0
|
|
|
|
|
0
|
|
1498
|
|
|
|
|
|
|
} |
1499
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1500
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1501
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1502
|
|
|
|
|
|
|
} |
1503
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1504
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1505
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1506
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1507
|
|
|
|
|
|
|
} |
1508
|
|
|
|
|
|
|
else { |
1509
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1510
|
|
|
|
|
|
|
} |
1511
|
|
|
|
|
|
|
} |
1512
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 3) { |
1513
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 3) { |
|
|
0
|
|
|
|
|
|
1514
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars3(); |
|
0
|
|
|
|
|
0
|
|
1515
|
|
|
|
|
|
|
} |
1516
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1517
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars3(); |
|
0
|
|
|
|
|
0
|
|
1518
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1519
|
|
|
|
|
|
|
} |
1520
|
|
|
|
|
|
|
else { |
1521
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1522
|
|
|
|
|
|
|
} |
1523
|
|
|
|
|
|
|
} |
1524
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 4) { |
1525
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 4) { |
1526
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4(); |
|
0
|
|
|
|
|
0
|
|
1527
|
|
|
|
|
|
|
} |
1528
|
|
|
|
|
|
|
else { |
1529
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1530
|
|
|
|
|
|
|
} |
1531
|
|
|
|
|
|
|
} |
1532
|
|
|
|
|
|
|
else { |
1533
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1534
|
|
|
|
|
|
|
} |
1535
|
|
|
|
|
|
|
|
1536
|
0
|
|
|
|
|
0
|
splice @char, $i-1, 3, @range; |
1537
|
|
|
|
|
|
|
} |
1538
|
|
|
|
|
|
|
|
1539
|
0
|
|
|
|
|
0
|
return @char; |
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
# |
1543
|
|
|
|
|
|
|
# EUC-TW open character class |
1544
|
|
|
|
|
|
|
# |
1545
|
|
|
|
|
|
|
sub _cc { |
1546
|
342
|
50
|
|
342
|
|
838
|
if (scalar(@_) == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1547
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine cc got no parameter.\n"; |
1548
|
|
|
|
|
|
|
} |
1549
|
|
|
|
|
|
|
elsif (scalar(@_) == 1) { |
1550
|
151
|
|
|
|
|
538
|
return sprintf('\x%02X',$_[0]); |
1551
|
|
|
|
|
|
|
} |
1552
|
|
|
|
|
|
|
elsif (scalar(@_) == 2) { |
1553
|
191
|
50
|
|
|
|
608
|
if ($_[0] > $_[1]) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1554
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n"; |
1555
|
|
|
|
|
|
|
} |
1556
|
|
|
|
|
|
|
elsif ($_[0] == $_[1]) { |
1557
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
elsif (($_[0]+1) == $_[1]) { |
1560
|
20
|
|
|
|
|
46
|
return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]); |
1561
|
|
|
|
|
|
|
} |
1562
|
|
|
|
|
|
|
else { |
1563
|
171
|
|
|
|
|
797
|
return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]); |
1564
|
|
|
|
|
|
|
} |
1565
|
|
|
|
|
|
|
} |
1566
|
|
|
|
|
|
|
else { |
1567
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n"; |
|
0
|
|
|
|
|
0
|
|
1568
|
|
|
|
|
|
|
} |
1569
|
|
|
|
|
|
|
} |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
# |
1572
|
|
|
|
|
|
|
# EUC-TW octet range |
1573
|
|
|
|
|
|
|
# |
1574
|
|
|
|
|
|
|
sub _octets { |
1575
|
557
|
|
|
557
|
|
740
|
my $length = shift @_; |
1576
|
|
|
|
|
|
|
|
1577
|
557
|
100
|
|
|
|
1004
|
if ($length == 1) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1578
|
426
|
|
|
|
|
1191
|
my($a1) = unpack 'C', $_[0]; |
1579
|
426
|
|
|
|
|
695
|
my($z1) = unpack 'C', $_[1]; |
1580
|
|
|
|
|
|
|
|
1581
|
426
|
50
|
|
|
|
783
|
if ($a1 > $z1) { |
1582
|
0
|
|
|
|
|
0
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1); |
1583
|
|
|
|
|
|
|
} |
1584
|
|
|
|
|
|
|
|
1585
|
426
|
100
|
|
|
|
1184
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1586
|
20
|
|
|
|
|
70
|
return sprintf('\x%02X',$a1); |
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1589
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X\x%02X',$a1,$z1); |
1590
|
|
|
|
|
|
|
} |
1591
|
|
|
|
|
|
|
else { |
1592
|
406
|
|
|
|
|
2562
|
return sprintf('\x%02X-\x%02X',$a1,$z1); |
1593
|
|
|
|
|
|
|
} |
1594
|
|
|
|
|
|
|
} |
1595
|
|
|
|
|
|
|
elsif ($length == 2) { |
1596
|
131
|
|
|
|
|
324
|
my($a1,$a2) = unpack 'CC', $_[0]; |
1597
|
131
|
|
|
|
|
182
|
my($z1,$z2) = unpack 'CC', $_[1]; |
1598
|
131
|
|
|
|
|
179
|
my($A1,$A2) = unpack 'CC', $_[2]; |
1599
|
131
|
|
|
|
|
192
|
my($Z1,$Z2) = unpack 'CC', $_[3]; |
1600
|
|
|
|
|
|
|
|
1601
|
131
|
100
|
|
|
|
247
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
return ( |
1603
|
|
|
|
|
|
|
# 11111111 222222222222 |
1604
|
|
|
|
|
|
|
# A A Z |
1605
|
111
|
|
|
|
|
231
|
_cc($a1) . _cc($a2,$z2), # a2-z2 |
1606
|
|
|
|
|
|
|
); |
1607
|
|
|
|
|
|
|
} |
1608
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1609
|
|
|
|
|
|
|
return ( |
1610
|
|
|
|
|
|
|
# 11111111111 222222222222 |
1611
|
|
|
|
|
|
|
# A Z A Z |
1612
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1613
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1614
|
|
|
|
|
|
|
); |
1615
|
|
|
|
|
|
|
} |
1616
|
|
|
|
|
|
|
else { |
1617
|
|
|
|
|
|
|
return ( |
1618
|
|
|
|
|
|
|
# 1111111111111111 222222222222 |
1619
|
|
|
|
|
|
|
# A Z A Z |
1620
|
20
|
|
|
|
|
55
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1621
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2), # - |
1622
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1623
|
|
|
|
|
|
|
); |
1624
|
|
|
|
|
|
|
} |
1625
|
|
|
|
|
|
|
} |
1626
|
|
|
|
|
|
|
elsif ($length == 3) { |
1627
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3) = unpack 'CCC', $_[0]; |
1628
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3) = unpack 'CCC', $_[1]; |
1629
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3) = unpack 'CCC', $_[2]; |
1630
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3) = unpack 'CCC', $_[3]; |
1631
|
|
|
|
|
|
|
|
1632
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1633
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
return ( |
1635
|
|
|
|
|
|
|
# 11111111 22222222 333333333333 |
1636
|
|
|
|
|
|
|
# A A A Z |
1637
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$z3), # a3-z3 |
1638
|
|
|
|
|
|
|
); |
1639
|
|
|
|
|
|
|
} |
1640
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1641
|
|
|
|
|
|
|
return ( |
1642
|
|
|
|
|
|
|
# 11111111 22222222222 333333333333 |
1643
|
|
|
|
|
|
|
# A A Z A Z |
1644
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1645
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1646
|
|
|
|
|
|
|
); |
1647
|
|
|
|
|
|
|
} |
1648
|
|
|
|
|
|
|
else { |
1649
|
|
|
|
|
|
|
return ( |
1650
|
|
|
|
|
|
|
# 11111111 2222222222222222 333333333333 |
1651
|
|
|
|
|
|
|
# A A Z A Z |
1652
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1653
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3), # - |
1654
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1655
|
|
|
|
|
|
|
); |
1656
|
|
|
|
|
|
|
} |
1657
|
|
|
|
|
|
|
} |
1658
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1659
|
|
|
|
|
|
|
return ( |
1660
|
|
|
|
|
|
|
# 11111111111 22222222222222 333333333333 |
1661
|
|
|
|
|
|
|
# A Z A Z A Z |
1662
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1663
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1664
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1665
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1666
|
|
|
|
|
|
|
); |
1667
|
|
|
|
|
|
|
} |
1668
|
|
|
|
|
|
|
else { |
1669
|
|
|
|
|
|
|
return ( |
1670
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 333333333333 |
1671
|
|
|
|
|
|
|
# A Z A Z A Z |
1672
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1673
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1674
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3), # - |
1675
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1676
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1677
|
|
|
|
|
|
|
); |
1678
|
|
|
|
|
|
|
} |
1679
|
|
|
|
|
|
|
} |
1680
|
|
|
|
|
|
|
elsif ($length == 4) { |
1681
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3,$a4) = unpack 'CCCC', $_[0]; |
1682
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3,$z4) = unpack 'CCCC', $_[1]; |
1683
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3,$A4) = unpack 'CCCC', $_[0]; |
1684
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3,$Z4) = unpack 'CCCC', $_[1]; |
1685
|
|
|
|
|
|
|
|
1686
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1687
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1688
|
0
|
0
|
|
|
|
0
|
if ($a3 == $z3) { |
|
|
0
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
return ( |
1690
|
|
|
|
|
|
|
# 11111111 22222222 33333333 444444444444 |
1691
|
|
|
|
|
|
|
# A A A A Z |
1692
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$z4), # a4-z4 |
1693
|
|
|
|
|
|
|
); |
1694
|
|
|
|
|
|
|
} |
1695
|
|
|
|
|
|
|
elsif (($a3+1) == $z3) { |
1696
|
|
|
|
|
|
|
return ( |
1697
|
|
|
|
|
|
|
# 11111111 22222222 33333333333 444444444444 |
1698
|
|
|
|
|
|
|
# A A A Z A Z |
1699
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1700
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1701
|
|
|
|
|
|
|
); |
1702
|
|
|
|
|
|
|
} |
1703
|
|
|
|
|
|
|
else { |
1704
|
|
|
|
|
|
|
return ( |
1705
|
|
|
|
|
|
|
# 11111111 22222222 3333333333333333 444444444444 |
1706
|
|
|
|
|
|
|
# A A A Z A Z |
1707
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1708
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$z3-1) . _cc($A4,$Z4), # - |
1709
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1710
|
|
|
|
|
|
|
); |
1711
|
|
|
|
|
|
|
} |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1714
|
|
|
|
|
|
|
return ( |
1715
|
|
|
|
|
|
|
# 11111111 22222222222 33333333333333 444444444444 |
1716
|
|
|
|
|
|
|
# A A Z A Z A Z |
1717
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1718
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1719
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1720
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1721
|
|
|
|
|
|
|
); |
1722
|
|
|
|
|
|
|
} |
1723
|
|
|
|
|
|
|
else { |
1724
|
|
|
|
|
|
|
return ( |
1725
|
|
|
|
|
|
|
# 11111111 2222222222222222 33333333333333 444444444444 |
1726
|
|
|
|
|
|
|
# A A Z A Z A Z |
1727
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1728
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1729
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1730
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1731
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1732
|
|
|
|
|
|
|
); |
1733
|
|
|
|
|
|
|
} |
1734
|
|
|
|
|
|
|
} |
1735
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1736
|
|
|
|
|
|
|
return ( |
1737
|
|
|
|
|
|
|
# 11111111111 22222222222222 33333333333333 444444444444 |
1738
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1739
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1740
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1741
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1742
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1743
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1744
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1745
|
|
|
|
|
|
|
); |
1746
|
|
|
|
|
|
|
} |
1747
|
|
|
|
|
|
|
else { |
1748
|
|
|
|
|
|
|
return ( |
1749
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 33333333333333 444444444444 |
1750
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1751
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1752
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1753
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1754
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1755
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1756
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1757
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1758
|
|
|
|
|
|
|
); |
1759
|
|
|
|
|
|
|
} |
1760
|
|
|
|
|
|
|
} |
1761
|
|
|
|
|
|
|
else { |
1762
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _octets got invalid length ($length).\n"; |
1763
|
|
|
|
|
|
|
} |
1764
|
|
|
|
|
|
|
} |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
# |
1767
|
|
|
|
|
|
|
# EUC-TW range regexp |
1768
|
|
|
|
|
|
|
# |
1769
|
|
|
|
|
|
|
sub _range_regexp { |
1770
|
517
|
|
|
517
|
|
820
|
my($length,$first,$last) = @_; |
1771
|
|
|
|
|
|
|
|
1772
|
517
|
|
|
|
|
571
|
my @range_regexp = (); |
1773
|
517
|
50
|
|
|
|
1219
|
if (not exists $range_tr{$length}) { |
1774
|
0
|
|
|
|
|
0
|
return @range_regexp; |
1775
|
|
|
|
|
|
|
} |
1776
|
|
|
|
|
|
|
|
1777
|
517
|
|
|
|
|
460
|
my @ranges = @{ $range_tr{$length} }; |
|
517
|
|
|
|
|
1195
|
|
1778
|
517
|
|
|
|
|
1641
|
while (my @range = splice(@ranges,0,$length)) { |
1779
|
1289
|
|
|
|
|
1074
|
my $min = ''; |
1780
|
1289
|
|
|
|
|
931
|
my $max = ''; |
1781
|
1289
|
|
|
|
|
2129
|
for (my $i=0; $i < $length; $i++) { |
1782
|
1420
|
|
|
|
|
2744
|
$min .= pack 'C', $range[$i][0]; |
1783
|
1420
|
|
|
|
|
2636
|
$max .= pack 'C', $range[$i][-1]; |
1784
|
|
|
|
|
|
|
} |
1785
|
|
|
|
|
|
|
|
1786
|
|
|
|
|
|
|
# min___max |
1787
|
|
|
|
|
|
|
# FIRST_____________LAST |
1788
|
|
|
|
|
|
|
# (nothing) |
1789
|
|
|
|
|
|
|
|
1790
|
1289
|
50
|
66
|
|
|
13705
|
if ($max lt $first) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
1791
|
|
|
|
|
|
|
} |
1792
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
# ********** |
1794
|
|
|
|
|
|
|
# min_________max |
1795
|
|
|
|
|
|
|
# FIRST_____________LAST |
1796
|
|
|
|
|
|
|
# ********** |
1797
|
|
|
|
|
|
|
|
1798
|
|
|
|
|
|
|
elsif (($min le $first) and ($first le $max) and ($max le $last)) { |
1799
|
20
|
|
|
|
|
40
|
push @range_regexp, _octets($length,$first,$max,$min,$max); |
1800
|
|
|
|
|
|
|
} |
1801
|
|
|
|
|
|
|
|
1802
|
|
|
|
|
|
|
# ********************** |
1803
|
|
|
|
|
|
|
# min________________max |
1804
|
|
|
|
|
|
|
# FIRST_____________LAST |
1805
|
|
|
|
|
|
|
# ********************** |
1806
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
elsif (($min eq $first) and ($max eq $last)) { |
1808
|
0
|
|
|
|
|
0
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1809
|
|
|
|
|
|
|
} |
1810
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
# ********* |
1812
|
|
|
|
|
|
|
# min___max |
1813
|
|
|
|
|
|
|
# FIRST_____________LAST |
1814
|
|
|
|
|
|
|
# ********* |
1815
|
|
|
|
|
|
|
|
1816
|
|
|
|
|
|
|
elsif (($first le $min) and ($max le $last)) { |
1817
|
40
|
|
|
|
|
50
|
push @range_regexp, _octets($length,$min,$max,$min,$max); |
1818
|
|
|
|
|
|
|
} |
1819
|
|
|
|
|
|
|
|
1820
|
|
|
|
|
|
|
# ********************** |
1821
|
|
|
|
|
|
|
# min__________________________max |
1822
|
|
|
|
|
|
|
# FIRST_____________LAST |
1823
|
|
|
|
|
|
|
# ********************** |
1824
|
|
|
|
|
|
|
|
1825
|
|
|
|
|
|
|
elsif (($min le $first) and ($last le $max)) { |
1826
|
477
|
|
|
|
|
996
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1827
|
|
|
|
|
|
|
} |
1828
|
|
|
|
|
|
|
|
1829
|
|
|
|
|
|
|
# ********* |
1830
|
|
|
|
|
|
|
# min________max |
1831
|
|
|
|
|
|
|
# FIRST_____________LAST |
1832
|
|
|
|
|
|
|
# ********* |
1833
|
|
|
|
|
|
|
|
1834
|
|
|
|
|
|
|
elsif (($first le $min) and ($min le $last) and ($last le $max)) { |
1835
|
20
|
|
|
|
|
25
|
push @range_regexp, _octets($length,$min,$last,$min,$max); |
1836
|
|
|
|
|
|
|
} |
1837
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
# min___max |
1839
|
|
|
|
|
|
|
# FIRST_____________LAST |
1840
|
|
|
|
|
|
|
# (nothing) |
1841
|
|
|
|
|
|
|
|
1842
|
|
|
|
|
|
|
elsif ($last lt $min) { |
1843
|
|
|
|
|
|
|
} |
1844
|
|
|
|
|
|
|
|
1845
|
|
|
|
|
|
|
else { |
1846
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _range_regexp panic.\n"; |
1847
|
|
|
|
|
|
|
} |
1848
|
|
|
|
|
|
|
} |
1849
|
|
|
|
|
|
|
|
1850
|
517
|
|
|
|
|
1002
|
return @range_regexp; |
1851
|
|
|
|
|
|
|
} |
1852
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
# |
1854
|
|
|
|
|
|
|
# EUC-TW open character list for qr and not qr |
1855
|
|
|
|
|
|
|
# |
1856
|
|
|
|
|
|
|
sub _charlist { |
1857
|
|
|
|
|
|
|
|
1858
|
758
|
|
|
758
|
|
1006
|
my $modifier = pop @_; |
1859
|
758
|
|
|
|
|
1284
|
my @char = @_; |
1860
|
|
|
|
|
|
|
|
1861
|
758
|
100
|
|
|
|
1622
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
1862
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
# unescape character |
1864
|
758
|
|
|
|
|
1999
|
for (my $i=0; $i <= $#char; $i++) { |
1865
|
|
|
|
|
|
|
|
1866
|
|
|
|
|
|
|
# escape - to ... |
1867
|
2648
|
100
|
100
|
|
|
21109
|
if ($char[$i] eq '-') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1868
|
522
|
100
|
100
|
|
|
2217
|
if ((0 < $i) and ($i < $#char)) { |
1869
|
497
|
|
|
|
|
1001
|
$char[$i] = '...'; |
1870
|
|
|
|
|
|
|
} |
1871
|
|
|
|
|
|
|
} |
1872
|
|
|
|
|
|
|
|
1873
|
|
|
|
|
|
|
# octal escape sequence |
1874
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
1875
|
0
|
|
|
|
|
0
|
$char[$i] = octchr($1); |
1876
|
|
|
|
|
|
|
} |
1877
|
|
|
|
|
|
|
|
1878
|
|
|
|
|
|
|
# hexadecimal escape sequence |
1879
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
1880
|
0
|
|
|
|
|
0
|
$char[$i] = hexchr($1); |
1881
|
|
|
|
|
|
|
} |
1882
|
|
|
|
|
|
|
|
1883
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
1884
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
1885
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
1886
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
1887
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
1888
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
1889
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1890
|
|
|
|
|
|
|
} |
1891
|
|
|
|
|
|
|
|
1892
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
1893
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
1894
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
1895
|
|
|
|
|
|
|
} |
1896
|
|
|
|
|
|
|
|
1897
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) { |
1898
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr oct $1; |
1899
|
|
|
|
|
|
|
} |
1900
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) { |
1901
|
206
|
|
|
|
|
899
|
$char[$i] = CORE::chr hex $1; |
1902
|
|
|
|
|
|
|
} |
1903
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) { |
1904
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr(CORE::ord($1) & 0x1F); |
1905
|
|
|
|
|
|
|
} |
1906
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) { |
1907
|
|
|
|
|
|
|
$char[$i] = { |
1908
|
|
|
|
|
|
|
'\0' => "\0", |
1909
|
|
|
|
|
|
|
'\n' => "\n", |
1910
|
|
|
|
|
|
|
'\r' => "\r", |
1911
|
|
|
|
|
|
|
'\t' => "\t", |
1912
|
|
|
|
|
|
|
'\f' => "\f", |
1913
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1914
|
|
|
|
|
|
|
'\a' => "\a", |
1915
|
|
|
|
|
|
|
'\e' => "\e", |
1916
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1919
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1920
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1921
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1922
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1923
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1924
|
|
|
|
|
|
|
'\s' => '\s', |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1927
|
|
|
|
|
|
|
'\D' => '${Eeuctw::eD}', |
1928
|
|
|
|
|
|
|
'\S' => '${Eeuctw::eS}', |
1929
|
|
|
|
|
|
|
'\W' => '${Eeuctw::eW}', |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
'\H' => '${Eeuctw::eH}', |
1932
|
|
|
|
|
|
|
'\V' => '${Eeuctw::eV}', |
1933
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1934
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1935
|
|
|
|
|
|
|
'\R' => '${Eeuctw::eR}', |
1936
|
|
|
|
|
|
|
|
1937
|
33
|
|
|
|
|
508
|
}->{$1}; |
1938
|
|
|
|
|
|
|
} |
1939
|
|
|
|
|
|
|
|
1940
|
|
|
|
|
|
|
# POSIX-style character classes |
1941
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) { |
1942
|
|
|
|
|
|
|
$char[$i] = { |
1943
|
|
|
|
|
|
|
|
1944
|
|
|
|
|
|
|
'[:lower:]' => '[\x41-\x5A\x61-\x7A]', |
1945
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A\x61-\x7A]', |
1946
|
|
|
|
|
|
|
'[:^lower:]' => '${Eeuctw::not_lower_i}', |
1947
|
|
|
|
|
|
|
'[:^upper:]' => '${Eeuctw::not_upper_i}', |
1948
|
|
|
|
|
|
|
|
1949
|
8
|
|
|
|
|
67
|
}->{$1}; |
1950
|
|
|
|
|
|
|
} |
1951
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) { |
1952
|
|
|
|
|
|
|
$char[$i] = { |
1953
|
|
|
|
|
|
|
|
1954
|
|
|
|
|
|
|
'[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]', |
1955
|
|
|
|
|
|
|
'[:alpha:]' => '[\x41-\x5A\x61-\x7A]', |
1956
|
|
|
|
|
|
|
'[:ascii:]' => '[\x00-\x7F]', |
1957
|
|
|
|
|
|
|
'[:blank:]' => '[\x09\x20]', |
1958
|
|
|
|
|
|
|
'[:cntrl:]' => '[\x00-\x1F\x7F]', |
1959
|
|
|
|
|
|
|
'[:digit:]' => '[\x30-\x39]', |
1960
|
|
|
|
|
|
|
'[:graph:]' => '[\x21-\x7F]', |
1961
|
|
|
|
|
|
|
'[:lower:]' => '[\x61-\x7A]', |
1962
|
|
|
|
|
|
|
'[:print:]' => '[\x20-\x7F]', |
1963
|
|
|
|
|
|
|
'[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]', |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
# P.174 POSIX-Style Character Classes |
1966
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1967
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1968
|
|
|
|
|
|
|
|
1969
|
|
|
|
|
|
|
# P.311 11.2.4 Character Classes and other Special Escapes |
1970
|
|
|
|
|
|
|
# in Chapter 11: perlre: Perl regular expressions |
1971
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1972
|
|
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
# P.210 POSIX-Style Character Classes |
1974
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1975
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
'[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK") |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A]', |
1980
|
|
|
|
|
|
|
'[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]', |
1981
|
|
|
|
|
|
|
'[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]', |
1982
|
|
|
|
|
|
|
'[:^alnum:]' => '${Eeuctw::not_alnum}', |
1983
|
|
|
|
|
|
|
'[:^alpha:]' => '${Eeuctw::not_alpha}', |
1984
|
|
|
|
|
|
|
'[:^ascii:]' => '${Eeuctw::not_ascii}', |
1985
|
|
|
|
|
|
|
'[:^blank:]' => '${Eeuctw::not_blank}', |
1986
|
|
|
|
|
|
|
'[:^cntrl:]' => '${Eeuctw::not_cntrl}', |
1987
|
|
|
|
|
|
|
'[:^digit:]' => '${Eeuctw::not_digit}', |
1988
|
|
|
|
|
|
|
'[:^graph:]' => '${Eeuctw::not_graph}', |
1989
|
|
|
|
|
|
|
'[:^lower:]' => '${Eeuctw::not_lower}', |
1990
|
|
|
|
|
|
|
'[:^print:]' => '${Eeuctw::not_print}', |
1991
|
|
|
|
|
|
|
'[:^punct:]' => '${Eeuctw::not_punct}', |
1992
|
|
|
|
|
|
|
'[:^space:]' => '${Eeuctw::not_space}', |
1993
|
|
|
|
|
|
|
'[:^upper:]' => '${Eeuctw::not_upper}', |
1994
|
|
|
|
|
|
|
'[:^word:]' => '${Eeuctw::not_word}', |
1995
|
|
|
|
|
|
|
'[:^xdigit:]' => '${Eeuctw::not_xdigit}', |
1996
|
|
|
|
|
|
|
|
1997
|
70
|
|
|
|
|
1170
|
}->{$1}; |
1998
|
|
|
|
|
|
|
} |
1999
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) { |
2000
|
7
|
|
|
|
|
27
|
$char[$i] = $1; |
2001
|
|
|
|
|
|
|
} |
2002
|
|
|
|
|
|
|
} |
2003
|
|
|
|
|
|
|
|
2004
|
|
|
|
|
|
|
# open character list |
2005
|
758
|
|
|
|
|
986
|
my @singleoctet = (); |
2006
|
758
|
|
|
|
|
809
|
my @multipleoctet = (); |
2007
|
758
|
|
|
|
|
1618
|
for (my $i=0; $i <= $#char; ) { |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
# escaped - |
2010
|
2151
|
100
|
100
|
|
|
9544
|
if (defined($char[$i+1]) and ($char[$i+1] eq '...')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2011
|
497
|
|
|
|
|
394
|
$i += 1; |
2012
|
497
|
|
|
|
|
929
|
next; |
2013
|
|
|
|
|
|
|
} |
2014
|
|
|
|
|
|
|
|
2015
|
|
|
|
|
|
|
# make range regexp |
2016
|
|
|
|
|
|
|
elsif ($char[$i] eq '...') { |
2017
|
|
|
|
|
|
|
|
2018
|
|
|
|
|
|
|
# range error |
2019
|
497
|
50
|
|
|
|
1907
|
if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) { |
|
|
100
|
|
|
|
|
|
2020
|
0
|
|
|
|
|
0
|
croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2021
|
|
|
|
|
|
|
} |
2022
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) { |
2023
|
477
|
50
|
|
|
|
1101
|
if ($char[$i-1] gt $char[$i+1]) { |
2024
|
0
|
|
|
|
|
0
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2025
|
|
|
|
|
|
|
} |
2026
|
|
|
|
|
|
|
} |
2027
|
|
|
|
|
|
|
|
2028
|
|
|
|
|
|
|
# make range regexp per length |
2029
|
497
|
|
|
|
|
1440
|
for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) { |
2030
|
517
|
|
|
|
|
598
|
my @regexp = (); |
2031
|
|
|
|
|
|
|
|
2032
|
|
|
|
|
|
|
# is first and last |
2033
|
517
|
100
|
100
|
|
|
2054
|
if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2034
|
477
|
|
|
|
|
1222
|
push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]); |
2035
|
|
|
|
|
|
|
} |
2036
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
# is first |
2038
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i-1])) { |
2039
|
20
|
|
|
|
|
58
|
push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length); |
2040
|
|
|
|
|
|
|
} |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
# is inside in first and last |
2043
|
|
|
|
|
|
|
elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) { |
2044
|
0
|
|
|
|
|
0
|
push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length); |
2045
|
|
|
|
|
|
|
} |
2046
|
|
|
|
|
|
|
|
2047
|
|
|
|
|
|
|
# is last |
2048
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i+1])) { |
2049
|
20
|
|
|
|
|
41
|
push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]); |
2050
|
|
|
|
|
|
|
} |
2051
|
|
|
|
|
|
|
|
2052
|
|
|
|
|
|
|
else { |
2053
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine make_regexp panic.\n"; |
2054
|
|
|
|
|
|
|
} |
2055
|
|
|
|
|
|
|
|
2056
|
517
|
100
|
|
|
|
878
|
if ($length == 1) { |
2057
|
386
|
|
|
|
|
783
|
push @singleoctet, @regexp; |
2058
|
|
|
|
|
|
|
} |
2059
|
|
|
|
|
|
|
else { |
2060
|
131
|
|
|
|
|
232
|
push @multipleoctet, @regexp; |
2061
|
|
|
|
|
|
|
} |
2062
|
|
|
|
|
|
|
} |
2063
|
|
|
|
|
|
|
|
2064
|
497
|
|
|
|
|
936
|
$i += 2; |
2065
|
|
|
|
|
|
|
} |
2066
|
|
|
|
|
|
|
|
2067
|
|
|
|
|
|
|
# with /i modifier |
2068
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
2069
|
764
|
100
|
|
|
|
909
|
if ($modifier =~ /i/oxms) { |
2070
|
192
|
|
|
|
|
316
|
my $uc = Eeuctw::uc($char[$i]); |
2071
|
192
|
|
|
|
|
414
|
my $fc = Eeuctw::fc($char[$i]); |
2072
|
192
|
50
|
|
|
|
286
|
if ($uc ne $fc) { |
2073
|
192
|
50
|
|
|
|
246
|
if (CORE::length($fc) == 1) { |
2074
|
192
|
|
|
|
|
344
|
push @singleoctet, $uc, $fc; |
2075
|
|
|
|
|
|
|
} |
2076
|
|
|
|
|
|
|
else { |
2077
|
0
|
|
|
|
|
0
|
push @singleoctet, $uc; |
2078
|
0
|
|
|
|
|
0
|
push @multipleoctet, $fc; |
2079
|
|
|
|
|
|
|
} |
2080
|
|
|
|
|
|
|
} |
2081
|
|
|
|
|
|
|
else { |
2082
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2083
|
|
|
|
|
|
|
} |
2084
|
|
|
|
|
|
|
} |
2085
|
|
|
|
|
|
|
else { |
2086
|
572
|
|
|
|
|
633
|
push @singleoctet, $char[$i]; |
2087
|
|
|
|
|
|
|
} |
2088
|
764
|
|
|
|
|
1139
|
$i += 1; |
2089
|
|
|
|
|
|
|
} |
2090
|
|
|
|
|
|
|
|
2091
|
|
|
|
|
|
|
# single character of single octet code |
2092
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) { |
2093
|
0
|
|
|
|
|
0
|
push @singleoctet, "\t", "\x20"; |
2094
|
0
|
|
|
|
|
0
|
$i += 1; |
2095
|
|
|
|
|
|
|
} |
2096
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) { |
2097
|
0
|
|
|
|
|
0
|
push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D"; |
2098
|
0
|
|
|
|
|
0
|
$i += 1; |
2099
|
|
|
|
|
|
|
} |
2100
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) { |
2101
|
2
|
|
|
|
|
5
|
push @singleoctet, $char[$i]; |
2102
|
2
|
|
|
|
|
6
|
$i += 1; |
2103
|
|
|
|
|
|
|
} |
2104
|
|
|
|
|
|
|
|
2105
|
|
|
|
|
|
|
# single character of multiple-octet code |
2106
|
|
|
|
|
|
|
else { |
2107
|
391
|
|
|
|
|
468
|
push @multipleoctet, $char[$i]; |
2108
|
391
|
|
|
|
|
610
|
$i += 1; |
2109
|
|
|
|
|
|
|
} |
2110
|
|
|
|
|
|
|
} |
2111
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
# quote metachar |
2113
|
758
|
|
|
|
|
1336
|
for (@singleoctet) { |
2114
|
1384
|
50
|
|
|
|
6200
|
if ($_ eq '...') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2115
|
0
|
|
|
|
|
0
|
$_ = '-'; |
2116
|
|
|
|
|
|
|
} |
2117
|
|
|
|
|
|
|
elsif (/\A \n \z/oxms) { |
2118
|
8
|
|
|
|
|
18
|
$_ = '\n'; |
2119
|
|
|
|
|
|
|
} |
2120
|
|
|
|
|
|
|
elsif (/\A \r \z/oxms) { |
2121
|
8
|
|
|
|
|
17
|
$_ = '\r'; |
2122
|
|
|
|
|
|
|
} |
2123
|
|
|
|
|
|
|
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) { |
2124
|
1
|
|
|
|
|
4
|
$_ = sprintf('\x%02X', CORE::ord $1); |
2125
|
|
|
|
|
|
|
} |
2126
|
|
|
|
|
|
|
elsif (/\A [\x00-\xFF] \z/oxms) { |
2127
|
939
|
|
|
|
|
1084
|
$_ = quotemeta $_; |
2128
|
|
|
|
|
|
|
} |
2129
|
|
|
|
|
|
|
} |
2130
|
|
|
|
|
|
|
|
2131
|
|
|
|
|
|
|
# return character list |
2132
|
758
|
|
|
|
|
2017
|
return \@singleoctet, \@multipleoctet; |
2133
|
|
|
|
|
|
|
} |
2134
|
|
|
|
|
|
|
|
2135
|
|
|
|
|
|
|
# |
2136
|
|
|
|
|
|
|
# EUC-TW octal escape sequence |
2137
|
|
|
|
|
|
|
# |
2138
|
|
|
|
|
|
|
sub octchr { |
2139
|
5
|
|
|
5
|
0
|
8
|
my($octdigit) = @_; |
2140
|
|
|
|
|
|
|
|
2141
|
5
|
|
|
|
|
7
|
my @binary = (); |
2142
|
5
|
|
|
|
|
16
|
for my $octal (split(//,$octdigit)) { |
2143
|
|
|
|
|
|
|
push @binary, { |
2144
|
|
|
|
|
|
|
'0' => '000', |
2145
|
|
|
|
|
|
|
'1' => '001', |
2146
|
|
|
|
|
|
|
'2' => '010', |
2147
|
|
|
|
|
|
|
'3' => '011', |
2148
|
|
|
|
|
|
|
'4' => '100', |
2149
|
|
|
|
|
|
|
'5' => '101', |
2150
|
|
|
|
|
|
|
'6' => '110', |
2151
|
|
|
|
|
|
|
'7' => '111', |
2152
|
50
|
|
|
|
|
168
|
}->{$octal}; |
2153
|
|
|
|
|
|
|
} |
2154
|
5
|
|
|
|
|
14
|
my $binary = join '', @binary; |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
my $octchr = { |
2157
|
|
|
|
|
|
|
# 1234567 |
2158
|
|
|
|
|
|
|
1 => pack('B*', "0000000$binary"), |
2159
|
|
|
|
|
|
|
2 => pack('B*', "000000$binary"), |
2160
|
|
|
|
|
|
|
3 => pack('B*', "00000$binary"), |
2161
|
|
|
|
|
|
|
4 => pack('B*', "0000$binary"), |
2162
|
|
|
|
|
|
|
5 => pack('B*', "000$binary"), |
2163
|
|
|
|
|
|
|
6 => pack('B*', "00$binary"), |
2164
|
|
|
|
|
|
|
7 => pack('B*', "0$binary"), |
2165
|
|
|
|
|
|
|
0 => pack('B*', "$binary"), |
2166
|
|
|
|
|
|
|
|
2167
|
5
|
|
|
|
|
58
|
}->{CORE::length($binary) % 8}; |
2168
|
|
|
|
|
|
|
|
2169
|
5
|
|
|
|
|
18
|
return $octchr; |
2170
|
|
|
|
|
|
|
} |
2171
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
# |
2173
|
|
|
|
|
|
|
# EUC-TW hexadecimal escape sequence |
2174
|
|
|
|
|
|
|
# |
2175
|
|
|
|
|
|
|
sub hexchr { |
2176
|
5
|
|
|
5
|
0
|
16
|
my($hexdigit) = @_; |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
my $hexchr = { |
2179
|
|
|
|
|
|
|
1 => pack('H*', "0$hexdigit"), |
2180
|
|
|
|
|
|
|
0 => pack('H*', "$hexdigit"), |
2181
|
|
|
|
|
|
|
|
2182
|
5
|
|
|
|
|
78
|
}->{CORE::length($_[0]) % 2}; |
2183
|
|
|
|
|
|
|
|
2184
|
5
|
|
|
|
|
26
|
return $hexchr; |
2185
|
|
|
|
|
|
|
} |
2186
|
|
|
|
|
|
|
|
2187
|
|
|
|
|
|
|
# |
2188
|
|
|
|
|
|
|
# EUC-TW open character list for qr |
2189
|
|
|
|
|
|
|
# |
2190
|
|
|
|
|
|
|
sub charlist_qr { |
2191
|
|
|
|
|
|
|
|
2192
|
519
|
|
|
519
|
0
|
825
|
my $modifier = pop @_; |
2193
|
519
|
|
|
|
|
1120
|
my @char = @_; |
2194
|
|
|
|
|
|
|
|
2195
|
519
|
|
|
|
|
1375
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2196
|
519
|
|
|
|
|
937
|
my @singleoctet = @$singleoctet; |
2197
|
519
|
|
|
|
|
669
|
my @multipleoctet = @$multipleoctet; |
2198
|
|
|
|
|
|
|
|
2199
|
|
|
|
|
|
|
# return character list |
2200
|
519
|
100
|
|
|
|
1142
|
if (scalar(@singleoctet) >= 1) { |
2201
|
|
|
|
|
|
|
|
2202
|
|
|
|
|
|
|
# with /i modifier |
2203
|
384
|
100
|
|
|
|
875
|
if ($modifier =~ m/i/oxms) { |
2204
|
107
|
|
|
|
|
272
|
my %singleoctet_ignorecase = (); |
2205
|
107
|
|
|
|
|
183
|
for (@singleoctet) { |
2206
|
277
|
|
100
|
|
|
1011
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2207
|
85
|
|
|
|
|
328
|
for my $ord (hex($1) .. hex($2)) { |
2208
|
1201
|
|
|
|
|
941
|
my $char = CORE::chr($ord); |
2209
|
1201
|
|
|
|
|
1151
|
my $uc = Eeuctw::uc($char); |
2210
|
1201
|
|
|
|
|
1288
|
my $fc = Eeuctw::fc($char); |
2211
|
1201
|
100
|
|
|
|
1364
|
if ($uc eq $fc) { |
2212
|
612
|
|
|
|
|
1171
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2213
|
|
|
|
|
|
|
} |
2214
|
|
|
|
|
|
|
else { |
2215
|
589
|
50
|
|
|
|
613
|
if (CORE::length($fc) == 1) { |
2216
|
589
|
|
|
|
|
945
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2217
|
589
|
|
|
|
|
1222
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2218
|
|
|
|
|
|
|
} |
2219
|
|
|
|
|
|
|
else { |
2220
|
0
|
|
|
|
|
0
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2221
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2222
|
|
|
|
|
|
|
} |
2223
|
|
|
|
|
|
|
} |
2224
|
|
|
|
|
|
|
} |
2225
|
|
|
|
|
|
|
} |
2226
|
277
|
100
|
|
|
|
460
|
if ($_ ne '') { |
2227
|
192
|
|
|
|
|
437
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2228
|
|
|
|
|
|
|
} |
2229
|
|
|
|
|
|
|
} |
2230
|
107
|
|
|
|
|
113
|
my $i = 0; |
2231
|
107
|
|
|
|
|
137
|
my @singleoctet_ignorecase = (); |
2232
|
107
|
|
|
|
|
219
|
for my $ord (0 .. 255) { |
2233
|
27392
|
100
|
|
|
|
23516
|
if (exists $singleoctet_ignorecase{$ord}) { |
2234
|
1732
|
|
|
|
|
940
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1732
|
|
|
|
|
1955
|
|
2235
|
|
|
|
|
|
|
} |
2236
|
|
|
|
|
|
|
else { |
2237
|
25660
|
|
|
|
|
16011
|
$i++; |
2238
|
|
|
|
|
|
|
} |
2239
|
|
|
|
|
|
|
} |
2240
|
107
|
|
|
|
|
217
|
@singleoctet = (); |
2241
|
107
|
|
|
|
|
249
|
for my $range (@singleoctet_ignorecase) { |
2242
|
11257
|
100
|
|
|
|
15077
|
if (ref $range) { |
2243
|
219
|
100
|
|
|
|
182
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
336
|
|
2244
|
5
|
|
|
|
|
4
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
79
|
|
2245
|
|
|
|
|
|
|
} |
2246
|
214
|
|
|
|
|
273
|
elsif (scalar(@{$range}) == 2) { |
2247
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2248
|
|
|
|
|
|
|
} |
2249
|
|
|
|
|
|
|
else { |
2250
|
214
|
|
|
|
|
195
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
214
|
|
|
|
|
215
|
|
|
214
|
|
|
|
|
922
|
|
2251
|
|
|
|
|
|
|
} |
2252
|
|
|
|
|
|
|
} |
2253
|
|
|
|
|
|
|
} |
2254
|
|
|
|
|
|
|
} |
2255
|
|
|
|
|
|
|
|
2256
|
384
|
|
|
|
|
501
|
my $not_anchor = ''; |
2257
|
384
|
|
|
|
|
457
|
$not_anchor = '(?![\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE])'; |
2258
|
|
|
|
|
|
|
|
2259
|
384
|
|
|
|
|
929
|
push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' ); |
2260
|
|
|
|
|
|
|
} |
2261
|
519
|
100
|
|
|
|
985
|
if (scalar(@multipleoctet) >= 2) { |
2262
|
102
|
|
|
|
|
623
|
return '(?:' . join('|', @multipleoctet) . ')'; |
2263
|
|
|
|
|
|
|
} |
2264
|
|
|
|
|
|
|
else { |
2265
|
417
|
|
|
|
|
1594
|
return $multipleoctet[0]; |
2266
|
|
|
|
|
|
|
} |
2267
|
|
|
|
|
|
|
} |
2268
|
|
|
|
|
|
|
|
2269
|
|
|
|
|
|
|
# |
2270
|
|
|
|
|
|
|
# EUC-TW open character list for not qr |
2271
|
|
|
|
|
|
|
# |
2272
|
|
|
|
|
|
|
sub charlist_not_qr { |
2273
|
|
|
|
|
|
|
|
2274
|
239
|
|
|
239
|
0
|
370
|
my $modifier = pop @_; |
2275
|
239
|
|
|
|
|
465
|
my @char = @_; |
2276
|
|
|
|
|
|
|
|
2277
|
239
|
|
|
|
|
547
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2278
|
239
|
|
|
|
|
417
|
my @singleoctet = @$singleoctet; |
2279
|
239
|
|
|
|
|
276
|
my @multipleoctet = @$multipleoctet; |
2280
|
|
|
|
|
|
|
|
2281
|
|
|
|
|
|
|
# with /i modifier |
2282
|
239
|
100
|
|
|
|
512
|
if ($modifier =~ m/i/oxms) { |
2283
|
128
|
|
|
|
|
240
|
my %singleoctet_ignorecase = (); |
2284
|
128
|
|
|
|
|
165
|
for (@singleoctet) { |
2285
|
277
|
|
100
|
|
|
914
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2286
|
85
|
|
|
|
|
258
|
for my $ord (hex($1) .. hex($2)) { |
2287
|
1201
|
|
|
|
|
924
|
my $char = CORE::chr($ord); |
2288
|
1201
|
|
|
|
|
1073
|
my $uc = Eeuctw::uc($char); |
2289
|
1201
|
|
|
|
|
1223
|
my $fc = Eeuctw::fc($char); |
2290
|
1201
|
100
|
|
|
|
1337
|
if ($uc eq $fc) { |
2291
|
612
|
|
|
|
|
1107
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2292
|
|
|
|
|
|
|
} |
2293
|
|
|
|
|
|
|
else { |
2294
|
589
|
50
|
|
|
|
604
|
if (CORE::length($fc) == 1) { |
2295
|
589
|
|
|
|
|
868
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2296
|
589
|
|
|
|
|
1123
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2297
|
|
|
|
|
|
|
} |
2298
|
|
|
|
|
|
|
else { |
2299
|
0
|
|
|
|
|
0
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2300
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2301
|
|
|
|
|
|
|
} |
2302
|
|
|
|
|
|
|
} |
2303
|
|
|
|
|
|
|
} |
2304
|
|
|
|
|
|
|
} |
2305
|
277
|
100
|
|
|
|
397
|
if ($_ ne '') { |
2306
|
192
|
|
|
|
|
357
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2307
|
|
|
|
|
|
|
} |
2308
|
|
|
|
|
|
|
} |
2309
|
128
|
|
|
|
|
112
|
my $i = 0; |
2310
|
128
|
|
|
|
|
150
|
my @singleoctet_ignorecase = (); |
2311
|
128
|
|
|
|
|
194
|
for my $ord (0 .. 255) { |
2312
|
32768
|
100
|
|
|
|
27953
|
if (exists $singleoctet_ignorecase{$ord}) { |
2313
|
1732
|
|
|
|
|
964
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1732
|
|
|
|
|
1902
|
|
2314
|
|
|
|
|
|
|
} |
2315
|
|
|
|
|
|
|
else { |
2316
|
31036
|
|
|
|
|
19630
|
$i++; |
2317
|
|
|
|
|
|
|
} |
2318
|
|
|
|
|
|
|
} |
2319
|
128
|
|
|
|
|
201
|
@singleoctet = (); |
2320
|
128
|
|
|
|
|
253
|
for my $range (@singleoctet_ignorecase) { |
2321
|
11257
|
100
|
|
|
|
14999
|
if (ref $range) { |
2322
|
219
|
100
|
|
|
|
127
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
346
|
|
2323
|
5
|
|
|
|
|
4
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
77
|
|
2324
|
|
|
|
|
|
|
} |
2325
|
214
|
|
|
|
|
240
|
elsif (scalar(@{$range}) == 2) { |
2326
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2327
|
|
|
|
|
|
|
} |
2328
|
|
|
|
|
|
|
else { |
2329
|
214
|
|
|
|
|
161
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
214
|
|
|
|
|
176
|
|
|
214
|
|
|
|
|
827
|
|
2330
|
|
|
|
|
|
|
} |
2331
|
|
|
|
|
|
|
} |
2332
|
|
|
|
|
|
|
} |
2333
|
|
|
|
|
|
|
} |
2334
|
|
|
|
|
|
|
|
2335
|
|
|
|
|
|
|
# return character list |
2336
|
239
|
100
|
|
|
|
457
|
if (scalar(@multipleoctet) >= 1) { |
2337
|
114
|
100
|
|
|
|
193
|
if (scalar(@singleoctet) >= 1) { |
2338
|
|
|
|
|
|
|
|
2339
|
|
|
|
|
|
|
# any character other than multiple-octet and single octet character class |
2340
|
70
|
|
|
|
|
498
|
return '(?!' . join('|', @multipleoctet) . ')(?:[^\x8E\xA1-\xFE' . join('', @singleoctet) . ']|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])'; |
2341
|
|
|
|
|
|
|
} |
2342
|
|
|
|
|
|
|
else { |
2343
|
|
|
|
|
|
|
|
2344
|
|
|
|
|
|
|
# any character other than multiple-octet character class |
2345
|
44
|
|
|
|
|
300
|
return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)"; |
2346
|
|
|
|
|
|
|
} |
2347
|
|
|
|
|
|
|
} |
2348
|
|
|
|
|
|
|
else { |
2349
|
125
|
50
|
|
|
|
190
|
if (scalar(@singleoctet) >= 1) { |
2350
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
# any character other than single octet character class |
2352
|
125
|
|
|
|
|
665
|
return '(?:[^\x8E\xA1-\xFE' . join('', @singleoctet) . ']|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])'; |
2353
|
|
|
|
|
|
|
} |
2354
|
|
|
|
|
|
|
else { |
2355
|
|
|
|
|
|
|
|
2356
|
|
|
|
|
|
|
# any character |
2357
|
0
|
|
|
|
|
0
|
return "(?:$your_char)"; |
2358
|
|
|
|
|
|
|
} |
2359
|
|
|
|
|
|
|
} |
2360
|
|
|
|
|
|
|
} |
2361
|
|
|
|
|
|
|
|
2362
|
|
|
|
|
|
|
# |
2363
|
|
|
|
|
|
|
# open file in read mode |
2364
|
|
|
|
|
|
|
# |
2365
|
|
|
|
|
|
|
sub _open_r { |
2366
|
650
|
|
|
650
|
|
1447
|
my(undef,$file) = @_; |
2367
|
650
|
|
|
|
|
2416
|
$file =~ s#\A (\s) #./$1#oxms; |
2368
|
650
|
|
33
|
|
|
47204
|
return CORE::eval(q{open($_[0],'<',$_[1])}) || |
2369
|
|
|
|
|
|
|
open($_[0],"< $file\0"); |
2370
|
|
|
|
|
|
|
} |
2371
|
|
|
|
|
|
|
|
2372
|
|
|
|
|
|
|
# |
2373
|
|
|
|
|
|
|
# open file in write mode |
2374
|
|
|
|
|
|
|
# |
2375
|
|
|
|
|
|
|
sub _open_w { |
2376
|
0
|
|
|
0
|
|
0
|
my(undef,$file) = @_; |
2377
|
0
|
|
|
|
|
0
|
$file =~ s#\A (\s) #./$1#oxms; |
2378
|
0
|
|
0
|
|
|
0
|
return CORE::eval(q{open($_[0],'>',$_[1])}) || |
2379
|
|
|
|
|
|
|
open($_[0],"> $file\0"); |
2380
|
|
|
|
|
|
|
} |
2381
|
|
|
|
|
|
|
|
2382
|
|
|
|
|
|
|
# |
2383
|
|
|
|
|
|
|
# open file in append mode |
2384
|
|
|
|
|
|
|
# |
2385
|
|
|
|
|
|
|
sub _open_a { |
2386
|
0
|
|
|
0
|
|
0
|
my(undef,$file) = @_; |
2387
|
0
|
|
|
|
|
0
|
$file =~ s#\A (\s) #./$1#oxms; |
2388
|
0
|
|
0
|
|
|
0
|
return CORE::eval(q{open($_[0],'>>',$_[1])}) || |
2389
|
|
|
|
|
|
|
open($_[0],">> $file\0"); |
2390
|
|
|
|
|
|
|
} |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
# |
2393
|
|
|
|
|
|
|
# safe system |
2394
|
|
|
|
|
|
|
# |
2395
|
|
|
|
|
|
|
sub _systemx { |
2396
|
|
|
|
|
|
|
|
2397
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2398
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2399
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2400
|
|
|
|
|
|
|
# |
2401
|
|
|
|
|
|
|
# Be aware that in older releases of Perl, exec (and system) did not flush |
2402
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2403
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output in the case of exec, or |
2404
|
|
|
|
|
|
|
# misordererd output in the case of system. This situation was largely remedied |
2405
|
|
|
|
|
|
|
# in the 5.6 release of Perl. (So, 5.005 release not yet.) |
2406
|
|
|
|
|
|
|
|
2407
|
|
|
|
|
|
|
# P.855 exec |
2408
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2409
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2410
|
|
|
|
|
|
|
# |
2411
|
|
|
|
|
|
|
# In very old release of Perl (before v5.6), exec (and system) did not flush |
2412
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2413
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output with exec or misordered |
2414
|
|
|
|
|
|
|
# output with system. |
2415
|
|
|
|
|
|
|
|
2416
|
325
|
|
|
325
|
|
950
|
$| = 1; |
2417
|
|
|
|
|
|
|
|
2418
|
|
|
|
|
|
|
# P.565 23.1.2. Cleaning Up Your Environment |
2419
|
|
|
|
|
|
|
# in Chapter 23: Security |
2420
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2421
|
|
|
|
|
|
|
|
2422
|
|
|
|
|
|
|
# P.656 Cleaning Up Your Environment |
2423
|
|
|
|
|
|
|
# in Chapter 20: Security |
2424
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2425
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
# local $ENV{'PATH'} = '.'; |
2427
|
325
|
|
|
|
|
2784
|
local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer |
2428
|
|
|
|
|
|
|
|
2429
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2430
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2431
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2432
|
|
|
|
|
|
|
# |
2433
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as an |
2434
|
|
|
|
|
|
|
# indication that it should bypass shell processing. However, there is one |
2435
|
|
|
|
|
|
|
# place where you might still get tripped up. The exec call (and system, too) |
2436
|
|
|
|
|
|
|
# will not distinguish between a single scalar argument and an array containing |
2437
|
|
|
|
|
|
|
# only one element. |
2438
|
|
|
|
|
|
|
# |
2439
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2440
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2441
|
|
|
|
|
|
|
# or die "exec: $!"; # because @args == 1 |
2442
|
|
|
|
|
|
|
# |
2443
|
|
|
|
|
|
|
# To avoid this, you can use the PATHNAME syntax, explicitly duplicating the |
2444
|
|
|
|
|
|
|
# first argument as the pathname, which forces the rest of the arguments to be |
2445
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2446
|
|
|
|
|
|
|
# |
2447
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2448
|
|
|
|
|
|
|
# or die "can't exec @args: $!"; |
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
# P.855 exec |
2451
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2452
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2453
|
|
|
|
|
|
|
# |
2454
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as a |
2455
|
|
|
|
|
|
|
# directive to bypass shell processing. However, there is one place where |
2456
|
|
|
|
|
|
|
# you might still get tripped up. The exec call (and system, too) cannot |
2457
|
|
|
|
|
|
|
# distinguish between a single scalar argument and an array containing |
2458
|
|
|
|
|
|
|
# only one element. |
2459
|
|
|
|
|
|
|
# |
2460
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2461
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2462
|
|
|
|
|
|
|
# || die "exec: $!"; # because @args == 1 |
2463
|
|
|
|
|
|
|
# |
2464
|
|
|
|
|
|
|
# To avoid this, use the PATHNAME syntax, explicitly duplicating the first |
2465
|
|
|
|
|
|
|
# argument as the pathname, which forces the rest of the arguments to be |
2466
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2467
|
|
|
|
|
|
|
# |
2468
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2469
|
|
|
|
|
|
|
# || die "can't exec @args: $!"; |
2470
|
|
|
|
|
|
|
|
2471
|
325
|
|
|
|
|
570
|
return CORE::system { $_[0] } @_; # safe even with one-argument list |
|
325
|
|
|
|
|
28179152
|
|
2472
|
|
|
|
|
|
|
} |
2473
|
|
|
|
|
|
|
|
2474
|
|
|
|
|
|
|
# |
2475
|
|
|
|
|
|
|
# EUC-TW order to character (with parameter) |
2476
|
|
|
|
|
|
|
# |
2477
|
|
|
|
|
|
|
sub Eeuctw::chr(;$) { |
2478
|
|
|
|
|
|
|
|
2479
|
0
|
0
|
|
0
|
0
|
0
|
my $c = @_ ? $_[0] : $_; |
2480
|
|
|
|
|
|
|
|
2481
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2482
|
0
|
|
|
|
|
0
|
return "\x00"; |
2483
|
|
|
|
|
|
|
} |
2484
|
|
|
|
|
|
|
else { |
2485
|
0
|
|
|
|
|
0
|
my @chr = (); |
2486
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2487
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2488
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2489
|
|
|
|
|
|
|
} |
2490
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2491
|
|
|
|
|
|
|
} |
2492
|
|
|
|
|
|
|
} |
2493
|
|
|
|
|
|
|
|
2494
|
|
|
|
|
|
|
# |
2495
|
|
|
|
|
|
|
# EUC-TW order to character (without parameter) |
2496
|
|
|
|
|
|
|
# |
2497
|
|
|
|
|
|
|
sub Eeuctw::chr_() { |
2498
|
|
|
|
|
|
|
|
2499
|
0
|
|
|
0
|
0
|
0
|
my $c = $_; |
2500
|
|
|
|
|
|
|
|
2501
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2502
|
0
|
|
|
|
|
0
|
return "\x00"; |
2503
|
|
|
|
|
|
|
} |
2504
|
|
|
|
|
|
|
else { |
2505
|
0
|
|
|
|
|
0
|
my @chr = (); |
2506
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2507
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2508
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2509
|
|
|
|
|
|
|
} |
2510
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2511
|
|
|
|
|
|
|
} |
2512
|
|
|
|
|
|
|
} |
2513
|
|
|
|
|
|
|
|
2514
|
|
|
|
|
|
|
# |
2515
|
|
|
|
|
|
|
# EUC-TW path globbing (with parameter) |
2516
|
|
|
|
|
|
|
# |
2517
|
|
|
|
|
|
|
sub Eeuctw::glob($) { |
2518
|
|
|
|
|
|
|
|
2519
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
2520
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(@_); |
2521
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
2522
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
2523
|
|
|
|
|
|
|
} |
2524
|
0
|
|
|
|
|
0
|
return @glob; |
2525
|
|
|
|
|
|
|
} |
2526
|
|
|
|
|
|
|
else { |
2527
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(@_); |
2528
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
2529
|
0
|
|
|
|
|
0
|
return $glob; |
2530
|
|
|
|
|
|
|
} |
2531
|
|
|
|
|
|
|
} |
2532
|
|
|
|
|
|
|
|
2533
|
|
|
|
|
|
|
# |
2534
|
|
|
|
|
|
|
# EUC-TW path globbing (without parameter) |
2535
|
|
|
|
|
|
|
# |
2536
|
|
|
|
|
|
|
sub Eeuctw::glob_() { |
2537
|
|
|
|
|
|
|
|
2538
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
2539
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(); |
2540
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
2541
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
2542
|
|
|
|
|
|
|
} |
2543
|
0
|
|
|
|
|
0
|
return @glob; |
2544
|
|
|
|
|
|
|
} |
2545
|
|
|
|
|
|
|
else { |
2546
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(); |
2547
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
2548
|
0
|
|
|
|
|
0
|
return $glob; |
2549
|
|
|
|
|
|
|
} |
2550
|
|
|
|
|
|
|
} |
2551
|
|
|
|
|
|
|
|
2552
|
|
|
|
|
|
|
# |
2553
|
|
|
|
|
|
|
# EUC-TW path globbing via File::DosGlob 1.10 |
2554
|
|
|
|
|
|
|
# |
2555
|
|
|
|
|
|
|
# Often I confuse "_dosglob" and "_doglob". |
2556
|
|
|
|
|
|
|
# So, I renamed "_dosglob" to "_DOS_like_glob". |
2557
|
|
|
|
|
|
|
# |
2558
|
|
|
|
|
|
|
my %iter; |
2559
|
|
|
|
|
|
|
my %entries; |
2560
|
|
|
|
|
|
|
sub _DOS_like_glob { |
2561
|
|
|
|
|
|
|
|
2562
|
|
|
|
|
|
|
# context (keyed by second cxix argument provided by core) |
2563
|
0
|
|
|
0
|
|
0
|
my($expr,$cxix) = @_; |
2564
|
|
|
|
|
|
|
|
2565
|
|
|
|
|
|
|
# glob without args defaults to $_ |
2566
|
0
|
0
|
|
|
|
0
|
$expr = $_ if not defined $expr; |
2567
|
|
|
|
|
|
|
|
2568
|
|
|
|
|
|
|
# represents the current user's home directory |
2569
|
|
|
|
|
|
|
# |
2570
|
|
|
|
|
|
|
# 7.3. Expanding Tildes in Filenames |
2571
|
|
|
|
|
|
|
# in Chapter 7. File Access |
2572
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
2573
|
|
|
|
|
|
|
# |
2574
|
|
|
|
|
|
|
# and File::HomeDir, File::HomeDir::Windows module |
2575
|
|
|
|
|
|
|
|
2576
|
|
|
|
|
|
|
# DOS-like system |
2577
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
2578
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ (?= [^/\\] ) } |
2579
|
0
|
|
|
|
|
0
|
{ my_home_MSWin32() }oxmse; |
2580
|
|
|
|
|
|
|
} |
2581
|
|
|
|
|
|
|
|
2582
|
|
|
|
|
|
|
# UNIX-like system |
2583
|
|
|
|
|
|
|
else { |
2584
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ ( (?:[^\x8E\xA1-\xFE/]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])* ) } |
2585
|
0
|
0
|
0
|
|
|
0
|
{ $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse; |
2586
|
|
|
|
|
|
|
} |
2587
|
|
|
|
|
|
|
|
2588
|
|
|
|
|
|
|
# assume global context if not provided one |
2589
|
0
|
0
|
|
|
|
0
|
$cxix = '_G_' if not defined $cxix; |
2590
|
0
|
0
|
|
|
|
0
|
$iter{$cxix} = 0 if not exists $iter{$cxix}; |
2591
|
|
|
|
|
|
|
|
2592
|
|
|
|
|
|
|
# if we're just beginning, do it all first |
2593
|
0
|
0
|
|
|
|
0
|
if ($iter{$cxix} == 0) { |
2594
|
0
|
|
|
|
|
0
|
$entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ]; |
2595
|
|
|
|
|
|
|
} |
2596
|
|
|
|
|
|
|
|
2597
|
|
|
|
|
|
|
# chuck it all out, quick or slow |
2598
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
2599
|
0
|
|
|
|
|
0
|
delete $iter{$cxix}; |
2600
|
0
|
|
|
|
|
0
|
return @{delete $entries{$cxix}}; |
|
0
|
|
|
|
|
0
|
|
2601
|
|
|
|
|
|
|
} |
2602
|
|
|
|
|
|
|
else { |
2603
|
0
|
0
|
|
|
|
0
|
if ($iter{$cxix} = scalar @{$entries{$cxix}}) { |
|
0
|
|
|
|
|
0
|
|
2604
|
0
|
|
|
|
|
0
|
return shift @{$entries{$cxix}}; |
|
0
|
|
|
|
|
0
|
|
2605
|
|
|
|
|
|
|
} |
2606
|
|
|
|
|
|
|
else { |
2607
|
|
|
|
|
|
|
# return undef for EOL |
2608
|
0
|
|
|
|
|
0
|
delete $iter{$cxix}; |
2609
|
0
|
|
|
|
|
0
|
delete $entries{$cxix}; |
2610
|
0
|
|
|
|
|
0
|
return undef; |
2611
|
|
|
|
|
|
|
} |
2612
|
|
|
|
|
|
|
} |
2613
|
|
|
|
|
|
|
} |
2614
|
|
|
|
|
|
|
|
2615
|
|
|
|
|
|
|
# |
2616
|
|
|
|
|
|
|
# EUC-TW path globbing subroutine |
2617
|
|
|
|
|
|
|
# |
2618
|
|
|
|
|
|
|
sub _do_glob { |
2619
|
|
|
|
|
|
|
|
2620
|
0
|
|
|
0
|
|
0
|
my($cond,@expr) = @_; |
2621
|
0
|
|
|
|
|
0
|
my @glob = (); |
2622
|
0
|
|
|
|
|
0
|
my $fix_drive_relative_paths = 0; |
2623
|
|
|
|
|
|
|
|
2624
|
|
|
|
|
|
|
OUTER: |
2625
|
0
|
|
|
|
|
0
|
for my $expr (@expr) { |
2626
|
0
|
0
|
|
|
|
0
|
next OUTER if not defined $expr; |
2627
|
0
|
0
|
|
|
|
0
|
next OUTER if $expr eq ''; |
2628
|
|
|
|
|
|
|
|
2629
|
0
|
|
|
|
|
0
|
my @matched = (); |
2630
|
0
|
|
|
|
|
0
|
my @globdir = (); |
2631
|
0
|
|
|
|
|
0
|
my $head = '.'; |
2632
|
0
|
|
|
|
|
0
|
my $pathsep = '/'; |
2633
|
0
|
|
|
|
|
0
|
my $tail; |
2634
|
|
|
|
|
|
|
|
2635
|
|
|
|
|
|
|
# if argument is within quotes strip em and do no globbing |
2636
|
0
|
0
|
|
|
|
0
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
2637
|
0
|
|
|
|
|
0
|
$expr = $1; |
2638
|
0
|
0
|
|
|
|
0
|
if ($cond eq 'd') { |
2639
|
0
|
0
|
|
|
|
0
|
if (-d $expr) { |
2640
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
2641
|
|
|
|
|
|
|
} |
2642
|
|
|
|
|
|
|
} |
2643
|
|
|
|
|
|
|
else { |
2644
|
0
|
0
|
|
|
|
0
|
if (-e $expr) { |
2645
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
2646
|
|
|
|
|
|
|
} |
2647
|
|
|
|
|
|
|
} |
2648
|
0
|
|
|
|
|
0
|
next OUTER; |
2649
|
|
|
|
|
|
|
} |
2650
|
|
|
|
|
|
|
|
2651
|
|
|
|
|
|
|
# wildcards with a drive prefix such as h:*.pm must be changed |
2652
|
|
|
|
|
|
|
# to h:./*.pm to expand correctly |
2653
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
2654
|
0
|
0
|
|
|
|
0
|
if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^\x8E\xA1-\xFE/\\]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF]) #$1./$2#oxms) { |
2655
|
0
|
|
|
|
|
0
|
$fix_drive_relative_paths = 1; |
2656
|
|
|
|
|
|
|
} |
2657
|
|
|
|
|
|
|
} |
2658
|
|
|
|
|
|
|
|
2659
|
0
|
0
|
|
|
|
0
|
if (($head, $tail) = _parse_path($expr,$pathsep)) { |
2660
|
0
|
0
|
|
|
|
0
|
if ($tail eq '') { |
2661
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
2662
|
0
|
|
|
|
|
0
|
next OUTER; |
2663
|
|
|
|
|
|
|
} |
2664
|
0
|
0
|
|
|
|
0
|
if ($head =~ / \A (?:$q_char)*? [*?] /oxms) { |
2665
|
0
|
0
|
|
|
|
0
|
if (@globdir = _do_glob('d', $head)) { |
2666
|
0
|
|
|
|
|
0
|
push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir); |
|
0
|
|
|
|
|
0
|
|
2667
|
0
|
|
|
|
|
0
|
next OUTER; |
2668
|
|
|
|
|
|
|
} |
2669
|
|
|
|
|
|
|
} |
2670
|
0
|
0
|
0
|
|
|
0
|
if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) { |
2671
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
2672
|
|
|
|
|
|
|
} |
2673
|
0
|
|
|
|
|
0
|
$expr = $tail; |
2674
|
|
|
|
|
|
|
} |
2675
|
|
|
|
|
|
|
|
2676
|
|
|
|
|
|
|
# If file component has no wildcards, we can avoid opendir |
2677
|
0
|
0
|
|
|
|
0
|
if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) { |
2678
|
0
|
0
|
|
|
|
0
|
if ($head eq '.') { |
2679
|
0
|
|
|
|
|
0
|
$head = ''; |
2680
|
|
|
|
|
|
|
} |
2681
|
0
|
0
|
0
|
|
|
0
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
2682
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
2683
|
|
|
|
|
|
|
} |
2684
|
0
|
|
|
|
|
0
|
$head .= $expr; |
2685
|
0
|
0
|
|
|
|
0
|
if ($cond eq 'd') { |
2686
|
0
|
0
|
|
|
|
0
|
if (-d $head) { |
2687
|
0
|
|
|
|
|
0
|
push @glob, $head; |
2688
|
|
|
|
|
|
|
} |
2689
|
|
|
|
|
|
|
} |
2690
|
|
|
|
|
|
|
else { |
2691
|
0
|
0
|
|
|
|
0
|
if (-e $head) { |
2692
|
0
|
|
|
|
|
0
|
push @glob, $head; |
2693
|
|
|
|
|
|
|
} |
2694
|
|
|
|
|
|
|
} |
2695
|
0
|
|
|
|
|
0
|
next OUTER; |
2696
|
|
|
|
|
|
|
} |
2697
|
0
|
0
|
|
|
|
0
|
opendir(*DIR, $head) or next OUTER; |
2698
|
0
|
|
|
|
|
0
|
my @leaf = readdir DIR; |
2699
|
0
|
|
|
|
|
0
|
closedir DIR; |
2700
|
|
|
|
|
|
|
|
2701
|
0
|
0
|
|
|
|
0
|
if ($head eq '.') { |
2702
|
0
|
|
|
|
|
0
|
$head = ''; |
2703
|
|
|
|
|
|
|
} |
2704
|
0
|
0
|
0
|
|
|
0
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
2705
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
2706
|
|
|
|
|
|
|
} |
2707
|
|
|
|
|
|
|
|
2708
|
0
|
|
|
|
|
0
|
my $pattern = ''; |
2709
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G ($q_char) /oxgc) { |
2710
|
0
|
|
|
|
|
0
|
my $char = $1; |
2711
|
|
|
|
|
|
|
|
2712
|
|
|
|
|
|
|
# 6.9. Matching Shell Globs as Regular Expressions |
2713
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
2714
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
2715
|
|
|
|
|
|
|
# (and so on) |
2716
|
|
|
|
|
|
|
|
2717
|
0
|
0
|
|
|
|
0
|
if ($char eq '*') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2718
|
0
|
|
|
|
|
0
|
$pattern .= "(?:$your_char)*", |
2719
|
|
|
|
|
|
|
} |
2720
|
|
|
|
|
|
|
elsif ($char eq '?') { |
2721
|
0
|
|
|
|
|
0
|
$pattern .= "(?:$your_char)?", # DOS style |
2722
|
|
|
|
|
|
|
# $pattern .= "(?:$your_char)", # UNIX style |
2723
|
|
|
|
|
|
|
} |
2724
|
|
|
|
|
|
|
elsif ((my $fc = Eeuctw::fc($char)) ne $char) { |
2725
|
0
|
|
|
|
|
0
|
$pattern .= $fc; |
2726
|
|
|
|
|
|
|
} |
2727
|
|
|
|
|
|
|
else { |
2728
|
0
|
|
|
|
|
0
|
$pattern .= quotemeta $char; |
2729
|
|
|
|
|
|
|
} |
2730
|
|
|
|
|
|
|
} |
2731
|
0
|
|
|
0
|
|
0
|
my $matchsub = sub { Eeuctw::fc($_[0]) =~ /\A $pattern \z/xms }; |
|
0
|
|
|
|
|
0
|
|
2732
|
|
|
|
|
|
|
|
2733
|
|
|
|
|
|
|
# if ($@) { |
2734
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
2735
|
|
|
|
|
|
|
# next OUTER; |
2736
|
|
|
|
|
|
|
# } |
2737
|
|
|
|
|
|
|
|
2738
|
|
|
|
|
|
|
INNER: |
2739
|
0
|
|
|
|
|
0
|
for my $leaf (@leaf) { |
2740
|
0
|
0
|
0
|
|
|
0
|
if ($leaf eq '.' or $leaf eq '..') { |
2741
|
0
|
|
|
|
|
0
|
next INNER; |
2742
|
|
|
|
|
|
|
} |
2743
|
0
|
0
|
0
|
|
|
0
|
if ($cond eq 'd' and not -d "$head$leaf") { |
2744
|
0
|
|
|
|
|
0
|
next INNER; |
2745
|
|
|
|
|
|
|
} |
2746
|
|
|
|
|
|
|
|
2747
|
0
|
0
|
|
|
|
0
|
if (&$matchsub($leaf)) { |
2748
|
0
|
|
|
|
|
0
|
push @matched, "$head$leaf"; |
2749
|
0
|
|
|
|
|
0
|
next INNER; |
2750
|
|
|
|
|
|
|
} |
2751
|
|
|
|
|
|
|
|
2752
|
|
|
|
|
|
|
# [DOS compatibility special case] |
2753
|
|
|
|
|
|
|
# Failed, add a trailing dot and try again, but only... |
2754
|
|
|
|
|
|
|
|
2755
|
0
|
0
|
0
|
|
|
0
|
if (Eeuctw::index($leaf,'.') == -1 and # if name does not have a dot in it *and* |
|
|
|
0
|
|
|
|
|
2756
|
|
|
|
|
|
|
CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and* |
2757
|
|
|
|
|
|
|
Eeuctw::index($pattern,'\\.') != -1 # pattern has a dot. |
2758
|
|
|
|
|
|
|
) { |
2759
|
0
|
0
|
|
|
|
0
|
if (&$matchsub("$leaf.")) { |
2760
|
0
|
|
|
|
|
0
|
push @matched, "$head$leaf"; |
2761
|
0
|
|
|
|
|
0
|
next INNER; |
2762
|
|
|
|
|
|
|
} |
2763
|
|
|
|
|
|
|
} |
2764
|
|
|
|
|
|
|
} |
2765
|
0
|
0
|
|
|
|
0
|
if (@matched) { |
2766
|
0
|
|
|
|
|
0
|
push @glob, @matched; |
2767
|
|
|
|
|
|
|
} |
2768
|
|
|
|
|
|
|
} |
2769
|
0
|
0
|
|
|
|
0
|
if ($fix_drive_relative_paths) { |
2770
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
2771
|
0
|
|
|
|
|
0
|
$glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms; |
2772
|
|
|
|
|
|
|
} |
2773
|
|
|
|
|
|
|
} |
2774
|
0
|
|
|
|
|
0
|
return @glob; |
2775
|
|
|
|
|
|
|
} |
2776
|
|
|
|
|
|
|
|
2777
|
|
|
|
|
|
|
# |
2778
|
|
|
|
|
|
|
# EUC-TW parse line |
2779
|
|
|
|
|
|
|
# |
2780
|
|
|
|
|
|
|
sub _parse_line { |
2781
|
|
|
|
|
|
|
|
2782
|
0
|
|
|
0
|
|
0
|
my($line) = @_; |
2783
|
|
|
|
|
|
|
|
2784
|
0
|
|
|
|
|
0
|
$line .= ' '; |
2785
|
0
|
|
|
|
|
0
|
my @piece = (); |
2786
|
0
|
|
|
|
|
0
|
while ($line =~ / |
2787
|
|
|
|
|
|
|
" ( (?>(?: [^\x8E\xA1-\xFE"] |[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] )* ) ) " (?>\s+) | |
2788
|
|
|
|
|
|
|
( (?>(?: [^\x8E\xA1-\xFE"\s]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] )* ) ) (?>\s+) |
2789
|
|
|
|
|
|
|
/oxmsg |
2790
|
|
|
|
|
|
|
) { |
2791
|
0
|
0
|
|
|
|
0
|
push @piece, defined($1) ? $1 : $2; |
2792
|
|
|
|
|
|
|
} |
2793
|
0
|
|
|
|
|
0
|
return @piece; |
2794
|
|
|
|
|
|
|
} |
2795
|
|
|
|
|
|
|
|
2796
|
|
|
|
|
|
|
# |
2797
|
|
|
|
|
|
|
# EUC-TW parse path |
2798
|
|
|
|
|
|
|
# |
2799
|
|
|
|
|
|
|
sub _parse_path { |
2800
|
|
|
|
|
|
|
|
2801
|
0
|
|
|
0
|
|
0
|
my($path,$pathsep) = @_; |
2802
|
|
|
|
|
|
|
|
2803
|
0
|
|
|
|
|
0
|
$path .= '/'; |
2804
|
0
|
|
|
|
|
0
|
my @subpath = (); |
2805
|
0
|
|
|
|
|
0
|
while ($path =~ / |
2806
|
|
|
|
|
|
|
((?: [^\x8E\xA1-\xFE\/\\]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] )+?) [\/\\] |
2807
|
|
|
|
|
|
|
/oxmsg |
2808
|
|
|
|
|
|
|
) { |
2809
|
0
|
|
|
|
|
0
|
push @subpath, $1; |
2810
|
|
|
|
|
|
|
} |
2811
|
|
|
|
|
|
|
|
2812
|
0
|
|
|
|
|
0
|
my $tail = pop @subpath; |
2813
|
0
|
|
|
|
|
0
|
my $head = join $pathsep, @subpath; |
2814
|
0
|
|
|
|
|
0
|
return $head, $tail; |
2815
|
|
|
|
|
|
|
} |
2816
|
|
|
|
|
|
|
|
2817
|
|
|
|
|
|
|
# |
2818
|
|
|
|
|
|
|
# via File::HomeDir::Windows 1.00 |
2819
|
|
|
|
|
|
|
# |
2820
|
|
|
|
|
|
|
sub my_home_MSWin32 { |
2821
|
|
|
|
|
|
|
|
2822
|
|
|
|
|
|
|
# A lot of unix people and unix-derived tools rely on |
2823
|
|
|
|
|
|
|
# the ability to overload HOME. We will support it too |
2824
|
|
|
|
|
|
|
# so that they can replace raw HOME calls with File::HomeDir. |
2825
|
0
|
0
|
0
|
0
|
0
|
0
|
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2826
|
0
|
|
|
|
|
0
|
return $ENV{'HOME'}; |
2827
|
|
|
|
|
|
|
} |
2828
|
|
|
|
|
|
|
|
2829
|
|
|
|
|
|
|
# Do we have a user profile? |
2830
|
|
|
|
|
|
|
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { |
2831
|
0
|
|
|
|
|
0
|
return $ENV{'USERPROFILE'}; |
2832
|
|
|
|
|
|
|
} |
2833
|
|
|
|
|
|
|
|
2834
|
|
|
|
|
|
|
# Some Windows use something like $ENV{'HOME'} |
2835
|
|
|
|
|
|
|
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { |
2836
|
0
|
|
|
|
|
0
|
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'}; |
2837
|
|
|
|
|
|
|
} |
2838
|
|
|
|
|
|
|
|
2839
|
0
|
|
|
|
|
0
|
return undef; |
2840
|
|
|
|
|
|
|
} |
2841
|
|
|
|
|
|
|
|
2842
|
|
|
|
|
|
|
# |
2843
|
|
|
|
|
|
|
# via File::HomeDir::Unix 1.00 |
2844
|
|
|
|
|
|
|
# |
2845
|
|
|
|
|
|
|
sub my_home { |
2846
|
0
|
|
|
0
|
0
|
0
|
my $home; |
2847
|
|
|
|
|
|
|
|
2848
|
0
|
0
|
0
|
|
|
0
|
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { |
|
|
0
|
0
|
|
|
|
|
2849
|
0
|
|
|
|
|
0
|
$home = $ENV{'HOME'}; |
2850
|
|
|
|
|
|
|
} |
2851
|
|
|
|
|
|
|
|
2852
|
|
|
|
|
|
|
# This is from the original code, but I'm guessing |
2853
|
|
|
|
|
|
|
# it means "login directory" and exists on some Unixes. |
2854
|
|
|
|
|
|
|
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { |
2855
|
0
|
|
|
|
|
0
|
$home = $ENV{'LOGDIR'}; |
2856
|
|
|
|
|
|
|
} |
2857
|
|
|
|
|
|
|
|
2858
|
|
|
|
|
|
|
### More-desperate methods |
2859
|
|
|
|
|
|
|
|
2860
|
|
|
|
|
|
|
# Light desperation on any (Unixish) platform |
2861
|
|
|
|
|
|
|
else { |
2862
|
0
|
|
|
|
|
0
|
$home = CORE::eval q{ (getpwuid($<))[7] }; |
2863
|
|
|
|
|
|
|
} |
2864
|
|
|
|
|
|
|
|
2865
|
|
|
|
|
|
|
# On Unix in general, a non-existant home means "no home" |
2866
|
|
|
|
|
|
|
# For example, "nobody"-like users might use /nonexistant |
2867
|
0
|
0
|
0
|
|
|
0
|
if (defined $home and ! -d($home)) { |
2868
|
0
|
|
|
|
|
0
|
$home = undef; |
2869
|
|
|
|
|
|
|
} |
2870
|
0
|
|
|
|
|
0
|
return $home; |
2871
|
|
|
|
|
|
|
} |
2872
|
|
|
|
|
|
|
|
2873
|
|
|
|
|
|
|
# |
2874
|
|
|
|
|
|
|
# ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched |
2875
|
|
|
|
|
|
|
# |
2876
|
|
|
|
|
|
|
sub Eeuctw::PREMATCH { |
2877
|
0
|
0
|
|
0
|
0
|
0
|
if (defined($&)) { |
2878
|
0
|
0
|
0
|
|
|
0
|
if (defined($1) and (CORE::substr($&,-CORE::length($1),CORE::length($1)) eq $1)) { |
2879
|
0
|
|
|
|
|
0
|
return CORE::substr($&,0,CORE::length($&)-CORE::length($1)); |
2880
|
|
|
|
|
|
|
} |
2881
|
|
|
|
|
|
|
else { |
2882
|
0
|
|
|
|
|
0
|
croak 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp'; |
2883
|
|
|
|
|
|
|
} |
2884
|
|
|
|
|
|
|
} |
2885
|
|
|
|
|
|
|
else { |
2886
|
0
|
|
|
|
|
0
|
return ''; |
2887
|
|
|
|
|
|
|
} |
2888
|
0
|
|
|
|
|
0
|
return $`; |
2889
|
|
|
|
|
|
|
} |
2890
|
|
|
|
|
|
|
|
2891
|
|
|
|
|
|
|
# |
2892
|
|
|
|
|
|
|
# ${^MATCH}, $MATCH, $& the string that matched |
2893
|
|
|
|
|
|
|
# |
2894
|
|
|
|
|
|
|
sub Eeuctw::MATCH { |
2895
|
0
|
0
|
|
0
|
0
|
0
|
if (defined($&)) { |
2896
|
0
|
0
|
|
|
|
0
|
if (defined($1)) { |
2897
|
0
|
|
|
|
|
0
|
return $1; |
2898
|
|
|
|
|
|
|
} |
2899
|
|
|
|
|
|
|
else { |
2900
|
0
|
|
|
|
|
0
|
croak 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp'; |
2901
|
|
|
|
|
|
|
} |
2902
|
|
|
|
|
|
|
} |
2903
|
|
|
|
|
|
|
else { |
2904
|
0
|
|
|
|
|
0
|
return ''; |
2905
|
|
|
|
|
|
|
} |
2906
|
0
|
|
|
|
|
0
|
return $&; |
2907
|
|
|
|
|
|
|
} |
2908
|
|
|
|
|
|
|
|
2909
|
|
|
|
|
|
|
# |
2910
|
|
|
|
|
|
|
# ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched |
2911
|
|
|
|
|
|
|
# |
2912
|
|
|
|
|
|
|
sub Eeuctw::POSTMATCH { |
2913
|
0
|
|
|
0
|
0
|
0
|
return $'; |
2914
|
|
|
|
|
|
|
} |
2915
|
|
|
|
|
|
|
|
2916
|
|
|
|
|
|
|
# |
2917
|
|
|
|
|
|
|
# EUC-TW character to order (with parameter) |
2918
|
|
|
|
|
|
|
# |
2919
|
|
|
|
|
|
|
sub EUCTW::ord(;$) { |
2920
|
|
|
|
|
|
|
|
2921
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
2922
|
|
|
|
|
|
|
|
2923
|
0
|
0
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
2924
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
2925
|
0
|
|
|
|
|
0
|
my $ord = 0; |
2926
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
2927
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
2928
|
|
|
|
|
|
|
} |
2929
|
0
|
|
|
|
|
0
|
return $ord; |
2930
|
|
|
|
|
|
|
} |
2931
|
|
|
|
|
|
|
else { |
2932
|
0
|
|
|
|
|
0
|
return CORE::ord $_; |
2933
|
|
|
|
|
|
|
} |
2934
|
|
|
|
|
|
|
} |
2935
|
|
|
|
|
|
|
|
2936
|
|
|
|
|
|
|
# |
2937
|
|
|
|
|
|
|
# EUC-TW character to order (without parameter) |
2938
|
|
|
|
|
|
|
# |
2939
|
|
|
|
|
|
|
sub EUCTW::ord_() { |
2940
|
|
|
|
|
|
|
|
2941
|
0
|
0
|
|
0
|
0
|
0
|
if (/\A ($q_char) /oxms) { |
2942
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
2943
|
0
|
|
|
|
|
0
|
my $ord = 0; |
2944
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
2945
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
2946
|
|
|
|
|
|
|
} |
2947
|
0
|
|
|
|
|
0
|
return $ord; |
2948
|
|
|
|
|
|
|
} |
2949
|
|
|
|
|
|
|
else { |
2950
|
0
|
|
|
|
|
0
|
return CORE::ord $_; |
2951
|
|
|
|
|
|
|
} |
2952
|
|
|
|
|
|
|
} |
2953
|
|
|
|
|
|
|
|
2954
|
|
|
|
|
|
|
# |
2955
|
|
|
|
|
|
|
# EUC-TW reverse |
2956
|
|
|
|
|
|
|
# |
2957
|
|
|
|
|
|
|
sub EUCTW::reverse(@) { |
2958
|
|
|
|
|
|
|
|
2959
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
2960
|
0
|
|
|
|
|
0
|
return CORE::reverse @_; |
2961
|
|
|
|
|
|
|
} |
2962
|
|
|
|
|
|
|
else { |
2963
|
|
|
|
|
|
|
|
2964
|
|
|
|
|
|
|
# One of us once cornered Larry in an elevator and asked him what |
2965
|
|
|
|
|
|
|
# problem he was solving with this, but he looked as far off into |
2966
|
|
|
|
|
|
|
# the distance as he could in an elevator and said, "It seemed like |
2967
|
|
|
|
|
|
|
# a good idea at the time." |
2968
|
|
|
|
|
|
|
|
2969
|
0
|
|
|
|
|
0
|
return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg); |
2970
|
|
|
|
|
|
|
} |
2971
|
|
|
|
|
|
|
} |
2972
|
|
|
|
|
|
|
|
2973
|
|
|
|
|
|
|
# |
2974
|
|
|
|
|
|
|
# EUC-TW getc (with parameter, without parameter) |
2975
|
|
|
|
|
|
|
# |
2976
|
|
|
|
|
|
|
sub EUCTW::getc(;*@) { |
2977
|
|
|
|
|
|
|
|
2978
|
0
|
|
|
0
|
0
|
0
|
my($package) = caller; |
2979
|
0
|
0
|
|
|
|
0
|
my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN; |
2980
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for EUCTW::getc' if @_ and not wantarray; |
2981
|
|
|
|
|
|
|
|
2982
|
0
|
|
|
|
|
0
|
my @length = sort { $a <=> $b } keys %range_tr; |
|
0
|
|
|
|
|
0
|
|
2983
|
0
|
|
|
|
|
0
|
my $getc = ''; |
2984
|
0
|
|
|
|
|
0
|
for my $length ($length[0] .. $length[-1]) { |
2985
|
0
|
|
|
|
|
0
|
$getc .= CORE::getc($fh); |
2986
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{CORE::length($getc)}) { |
2987
|
0
|
0
|
|
|
|
0
|
if ($getc =~ /\A ${Eeuctw::dot_s} \z/oxms) { |
2988
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($getc,@_) : $getc; |
2989
|
|
|
|
|
|
|
} |
2990
|
|
|
|
|
|
|
} |
2991
|
|
|
|
|
|
|
} |
2992
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($getc,@_) : $getc; |
2993
|
|
|
|
|
|
|
} |
2994
|
|
|
|
|
|
|
|
2995
|
|
|
|
|
|
|
# |
2996
|
|
|
|
|
|
|
# EUC-TW length by character |
2997
|
|
|
|
|
|
|
# |
2998
|
|
|
|
|
|
|
sub EUCTW::length(;$) { |
2999
|
|
|
|
|
|
|
|
3000
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
3001
|
|
|
|
|
|
|
|
3002
|
0
|
|
|
|
|
0
|
local @_ = /\G ($q_char) /oxmsg; |
3003
|
0
|
|
|
|
|
0
|
return scalar @_; |
3004
|
|
|
|
|
|
|
} |
3005
|
|
|
|
|
|
|
|
3006
|
|
|
|
|
|
|
# |
3007
|
|
|
|
|
|
|
# EUC-TW substr by character |
3008
|
|
|
|
|
|
|
# |
3009
|
|
|
|
|
|
|
BEGIN { |
3010
|
|
|
|
|
|
|
|
3011
|
|
|
|
|
|
|
# P.232 The lvalue Attribute |
3012
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
3013
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
3014
|
|
|
|
|
|
|
|
3015
|
|
|
|
|
|
|
# P.336 The lvalue Attribute |
3016
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
3017
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3018
|
|
|
|
|
|
|
|
3019
|
|
|
|
|
|
|
# P.144 8.4 Lvalue subroutines |
3020
|
|
|
|
|
|
|
# in Chapter 8: perlsub: Perl subroutines |
3021
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
3022
|
|
|
|
|
|
|
|
3023
|
325
|
50
|
0
|
325
|
1
|
146053
|
CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : ''); |
|
0
|
0
|
|
0
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3024
|
|
|
|
|
|
|
# vv----------------------******* |
3025
|
|
|
|
|
|
|
sub EUCTW::substr($$;$$) %s { |
3026
|
|
|
|
|
|
|
|
3027
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
3028
|
|
|
|
|
|
|
|
3029
|
|
|
|
|
|
|
# If the substring is beyond either end of the string, substr() returns the undefined |
3030
|
|
|
|
|
|
|
# value and produces a warning. When used as an lvalue, specifying a substring that |
3031
|
|
|
|
|
|
|
# is entirely outside the string raises an exception. |
3032
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/substr.html |
3033
|
|
|
|
|
|
|
|
3034
|
|
|
|
|
|
|
# A return with no argument returns the scalar value undef in scalar context, |
3035
|
|
|
|
|
|
|
# an empty list () in list context, and (naturally) nothing at all in void |
3036
|
|
|
|
|
|
|
# context. |
3037
|
|
|
|
|
|
|
|
3038
|
|
|
|
|
|
|
my $offset = $_[1]; |
3039
|
|
|
|
|
|
|
if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) { |
3040
|
|
|
|
|
|
|
return; |
3041
|
|
|
|
|
|
|
} |
3042
|
|
|
|
|
|
|
|
3043
|
|
|
|
|
|
|
# substr($string,$offset,$length,$replacement) |
3044
|
|
|
|
|
|
|
if (@_ == 4) { |
3045
|
|
|
|
|
|
|
my(undef,undef,$length,$replacement) = @_; |
3046
|
|
|
|
|
|
|
my $substr = join '', splice(@char, $offset, $length, $replacement); |
3047
|
|
|
|
|
|
|
$_[0] = join '', @char; |
3048
|
|
|
|
|
|
|
|
3049
|
|
|
|
|
|
|
# return $substr; this doesn't work, don't say "return" |
3050
|
|
|
|
|
|
|
$substr; |
3051
|
|
|
|
|
|
|
} |
3052
|
|
|
|
|
|
|
|
3053
|
|
|
|
|
|
|
# substr($string,$offset,$length) |
3054
|
|
|
|
|
|
|
elsif (@_ == 3) { |
3055
|
|
|
|
|
|
|
my(undef,undef,$length) = @_; |
3056
|
|
|
|
|
|
|
my $octet_offset = 0; |
3057
|
|
|
|
|
|
|
my $octet_length = 0; |
3058
|
|
|
|
|
|
|
if ($offset == 0) { |
3059
|
|
|
|
|
|
|
$octet_offset = 0; |
3060
|
|
|
|
|
|
|
} |
3061
|
|
|
|
|
|
|
elsif ($offset > 0) { |
3062
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
3063
|
|
|
|
|
|
|
} |
3064
|
|
|
|
|
|
|
else { |
3065
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
3066
|
|
|
|
|
|
|
} |
3067
|
|
|
|
|
|
|
if ($length == 0) { |
3068
|
|
|
|
|
|
|
$octet_length = 0; |
3069
|
|
|
|
|
|
|
} |
3070
|
|
|
|
|
|
|
elsif ($length > 0) { |
3071
|
|
|
|
|
|
|
$octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]); |
3072
|
|
|
|
|
|
|
} |
3073
|
|
|
|
|
|
|
else { |
3074
|
|
|
|
|
|
|
$octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]); |
3075
|
|
|
|
|
|
|
} |
3076
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset, $octet_length); |
3077
|
|
|
|
|
|
|
} |
3078
|
|
|
|
|
|
|
|
3079
|
|
|
|
|
|
|
# substr($string,$offset) |
3080
|
|
|
|
|
|
|
else { |
3081
|
|
|
|
|
|
|
my $octet_offset = 0; |
3082
|
|
|
|
|
|
|
if ($offset == 0) { |
3083
|
|
|
|
|
|
|
$octet_offset = 0; |
3084
|
|
|
|
|
|
|
} |
3085
|
|
|
|
|
|
|
elsif ($offset > 0) { |
3086
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
3087
|
|
|
|
|
|
|
} |
3088
|
|
|
|
|
|
|
else { |
3089
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
3090
|
|
|
|
|
|
|
} |
3091
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset); |
3092
|
|
|
|
|
|
|
} |
3093
|
|
|
|
|
|
|
} |
3094
|
|
|
|
|
|
|
END |
3095
|
|
|
|
|
|
|
} |
3096
|
|
|
|
|
|
|
|
3097
|
|
|
|
|
|
|
# |
3098
|
|
|
|
|
|
|
# EUC-TW index by character |
3099
|
|
|
|
|
|
|
# |
3100
|
|
|
|
|
|
|
sub EUCTW::index($$;$) { |
3101
|
|
|
|
|
|
|
|
3102
|
0
|
|
|
0
|
1
|
0
|
my $index; |
3103
|
0
|
0
|
|
|
|
0
|
if (@_ == 3) { |
3104
|
0
|
|
|
|
|
0
|
$index = Eeuctw::index($_[0], $_[1], CORE::length(EUCTW::substr($_[0], 0, $_[2]))); |
3105
|
|
|
|
|
|
|
} |
3106
|
|
|
|
|
|
|
else { |
3107
|
0
|
|
|
|
|
0
|
$index = Eeuctw::index($_[0], $_[1]); |
3108
|
|
|
|
|
|
|
} |
3109
|
|
|
|
|
|
|
|
3110
|
0
|
0
|
|
|
|
0
|
if ($index == -1) { |
3111
|
0
|
|
|
|
|
0
|
return -1; |
3112
|
|
|
|
|
|
|
} |
3113
|
|
|
|
|
|
|
else { |
3114
|
0
|
|
|
|
|
0
|
return EUCTW::length(CORE::substr $_[0], 0, $index); |
3115
|
|
|
|
|
|
|
} |
3116
|
|
|
|
|
|
|
} |
3117
|
|
|
|
|
|
|
|
3118
|
|
|
|
|
|
|
# |
3119
|
|
|
|
|
|
|
# EUC-TW rindex by character |
3120
|
|
|
|
|
|
|
# |
3121
|
|
|
|
|
|
|
sub EUCTW::rindex($$;$) { |
3122
|
|
|
|
|
|
|
|
3123
|
0
|
|
|
0
|
1
|
0
|
my $rindex; |
3124
|
0
|
0
|
|
|
|
0
|
if (@_ == 3) { |
3125
|
0
|
|
|
|
|
0
|
$rindex = Eeuctw::rindex($_[0], $_[1], CORE::length(EUCTW::substr($_[0], 0, $_[2]))); |
3126
|
|
|
|
|
|
|
} |
3127
|
|
|
|
|
|
|
else { |
3128
|
0
|
|
|
|
|
0
|
$rindex = Eeuctw::rindex($_[0], $_[1]); |
3129
|
|
|
|
|
|
|
} |
3130
|
|
|
|
|
|
|
|
3131
|
0
|
0
|
|
|
|
0
|
if ($rindex == -1) { |
3132
|
0
|
|
|
|
|
0
|
return -1; |
3133
|
|
|
|
|
|
|
} |
3134
|
|
|
|
|
|
|
else { |
3135
|
0
|
|
|
|
|
0
|
return EUCTW::length(CORE::substr $_[0], 0, $rindex); |
3136
|
|
|
|
|
|
|
} |
3137
|
|
|
|
|
|
|
} |
3138
|
|
|
|
|
|
|
|
3139
|
|
|
|
|
|
|
# when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??' |
3140
|
|
|
|
|
|
|
# when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else) |
3141
|
325
|
|
|
325
|
|
20903
|
BEGIN { CORE::eval q{ use vars qw($slash) } } $slash = 'm//'; |
|
325
|
|
|
325
|
|
2136
|
|
|
325
|
|
|
|
|
485
|
|
|
325
|
|
|
|
|
17967
|
|
3142
|
|
|
|
|
|
|
|
3143
|
|
|
|
|
|
|
# ord() to ord() or EUCTW::ord() |
3144
|
325
|
|
|
325
|
|
15982
|
BEGIN { CORE::eval q{ use vars qw($function_ord) } } $function_ord = 'ord'; |
|
325
|
|
|
325
|
|
1385
|
|
|
325
|
|
|
|
|
513
|
|
|
325
|
|
|
|
|
14118
|
|
3145
|
|
|
|
|
|
|
|
3146
|
|
|
|
|
|
|
# ord to ord or EUCTW::ord_ |
3147
|
325
|
|
|
325
|
|
15298
|
BEGIN { CORE::eval q{ use vars qw($function_ord_) } } $function_ord_ = 'ord'; |
|
325
|
|
|
325
|
|
1308
|
|
|
325
|
|
|
|
|
459
|
|
|
325
|
|
|
|
|
13554
|
|
3148
|
|
|
|
|
|
|
|
3149
|
|
|
|
|
|
|
# reverse to reverse or EUCTW::reverse |
3150
|
325
|
|
|
325
|
|
15183
|
BEGIN { CORE::eval q{ use vars qw($function_reverse) } } $function_reverse = 'reverse'; |
|
325
|
|
|
325
|
|
1990
|
|
|
325
|
|
|
|
|
443
|
|
|
325
|
|
|
|
|
15904
|
|
3151
|
|
|
|
|
|
|
|
3152
|
|
|
|
|
|
|
# getc to getc or EUCTW::getc |
3153
|
325
|
|
|
325
|
|
18127
|
BEGIN { CORE::eval q{ use vars qw($function_getc) } } $function_getc = 'getc'; |
|
325
|
|
|
325
|
|
1906
|
|
|
325
|
|
|
|
|
1098
|
|
|
325
|
|
|
|
|
23261
|
|
3154
|
|
|
|
|
|
|
|
3155
|
|
|
|
|
|
|
# P.1023 Appendix W.9 Multibyte Anchoring |
3156
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
3157
|
|
|
|
|
|
|
|
3158
|
|
|
|
|
|
|
my $anchor = ''; |
3159
|
|
|
|
|
|
|
$anchor = q{${Eeuctw::anchor}}; |
3160
|
|
|
|
|
|
|
|
3161
|
325
|
|
|
325
|
|
21489
|
BEGIN { CORE::eval q{ use vars qw($nest) } } |
|
325
|
|
|
325
|
|
2003
|
|
|
325
|
|
|
|
|
976
|
|
|
325
|
|
|
|
|
11142408
|
|
3162
|
|
|
|
|
|
|
|
3163
|
|
|
|
|
|
|
# regexp of nested parens in qqXX |
3164
|
|
|
|
|
|
|
|
3165
|
|
|
|
|
|
|
# P.340 Matching Nested Constructs with Embedded Code |
3166
|
|
|
|
|
|
|
# in Chapter 7: Perl |
3167
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
3168
|
|
|
|
|
|
|
|
3169
|
|
|
|
|
|
|
my $qq_paren = qr{(?{local $nest=0}) (?>(?: |
3170
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\()] | |
3171
|
|
|
|
|
|
|
\( (?{$nest++}) | |
3172
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3173
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3174
|
|
|
|
|
|
|
\\ [^\x8E\xA1-\xFEc] | |
3175
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
3176
|
|
|
|
|
|
|
\\ [\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3177
|
|
|
|
|
|
|
[\x00-\xFF] |
3178
|
|
|
|
|
|
|
}xms; |
3179
|
|
|
|
|
|
|
|
3180
|
|
|
|
|
|
|
my $qq_brace = qr{(?{local $nest=0}) (?>(?: |
3181
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\{}] | |
3182
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
3183
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3184
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3185
|
|
|
|
|
|
|
\\ [^\x8E\xA1-\xFEc] | |
3186
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
3187
|
|
|
|
|
|
|
\\ [\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3188
|
|
|
|
|
|
|
[\x00-\xFF] |
3189
|
|
|
|
|
|
|
}xms; |
3190
|
|
|
|
|
|
|
|
3191
|
|
|
|
|
|
|
my $qq_bracket = qr{(?{local $nest=0}) (?>(?: |
3192
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\[\]] | |
3193
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
3194
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3195
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3196
|
|
|
|
|
|
|
\\ [^\x8E\xA1-\xFEc] | |
3197
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
3198
|
|
|
|
|
|
|
\\ [\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3199
|
|
|
|
|
|
|
[\x00-\xFF] |
3200
|
|
|
|
|
|
|
}xms; |
3201
|
|
|
|
|
|
|
|
3202
|
|
|
|
|
|
|
my $qq_angle = qr{(?{local $nest=0}) (?>(?: |
3203
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\<>] | |
3204
|
|
|
|
|
|
|
\< (?{$nest++}) | |
3205
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3206
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3207
|
|
|
|
|
|
|
\\ [^\x8E\xA1-\xFEc] | |
3208
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
3209
|
|
|
|
|
|
|
\\ [\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3210
|
|
|
|
|
|
|
[\x00-\xFF] |
3211
|
|
|
|
|
|
|
}xms; |
3212
|
|
|
|
|
|
|
|
3213
|
|
|
|
|
|
|
my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} | |
3214
|
|
|
|
|
|
|
(?: ::)? (?: |
3215
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
3216
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
3217
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
3218
|
|
|
|
|
|
|
)) |
3219
|
|
|
|
|
|
|
}xms; |
3220
|
|
|
|
|
|
|
|
3221
|
|
|
|
|
|
|
my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} | |
3222
|
|
|
|
|
|
|
(?: ::)? (?: |
3223
|
|
|
|
|
|
|
(?>[0-9]+) | |
3224
|
|
|
|
|
|
|
[^\x8E\xA1-\xFEa-zA-Z_0-9\[\]] | |
3225
|
|
|
|
|
|
|
^[A-Z] | |
3226
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
3227
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
3228
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
3229
|
|
|
|
|
|
|
)) |
3230
|
|
|
|
|
|
|
}xms; |
3231
|
|
|
|
|
|
|
|
3232
|
|
|
|
|
|
|
my $qq_substr = qr{(?> Char::substr | EUCTW::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \) |
3233
|
|
|
|
|
|
|
}xms; |
3234
|
|
|
|
|
|
|
|
3235
|
|
|
|
|
|
|
# regexp of nested parens in qXX |
3236
|
|
|
|
|
|
|
my $q_paren = qr{(?{local $nest=0}) (?>(?: |
3237
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE()] | |
3238
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3239
|
|
|
|
|
|
|
\( (?{$nest++}) | |
3240
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3241
|
|
|
|
|
|
|
[\x00-\xFF] |
3242
|
|
|
|
|
|
|
}xms; |
3243
|
|
|
|
|
|
|
|
3244
|
|
|
|
|
|
|
my $q_brace = qr{(?{local $nest=0}) (?>(?: |
3245
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\{\}] | |
3246
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3247
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
3248
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3249
|
|
|
|
|
|
|
[\x00-\xFF] |
3250
|
|
|
|
|
|
|
}xms; |
3251
|
|
|
|
|
|
|
|
3252
|
|
|
|
|
|
|
my $q_bracket = qr{(?{local $nest=0}) (?>(?: |
3253
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\[\]] | |
3254
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3255
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
3256
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3257
|
|
|
|
|
|
|
[\x00-\xFF] |
3258
|
|
|
|
|
|
|
}xms; |
3259
|
|
|
|
|
|
|
|
3260
|
|
|
|
|
|
|
my $q_angle = qr{(?{local $nest=0}) (?>(?: |
3261
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE<>] | |
3262
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
3263
|
|
|
|
|
|
|
\< (?{$nest++}) | |
3264
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
3265
|
|
|
|
|
|
|
[\x00-\xFF] |
3266
|
|
|
|
|
|
|
}xms; |
3267
|
|
|
|
|
|
|
|
3268
|
|
|
|
|
|
|
my $matched = ''; |
3269
|
|
|
|
|
|
|
my $s_matched = ''; |
3270
|
|
|
|
|
|
|
$matched = q{$Eeuctw::matched}; |
3271
|
|
|
|
|
|
|
$s_matched = q{ Eeuctw::s_matched();}; |
3272
|
|
|
|
|
|
|
|
3273
|
|
|
|
|
|
|
my $tr_variable = ''; # variable of tr/// |
3274
|
|
|
|
|
|
|
my $sub_variable = ''; # variable of s/// |
3275
|
|
|
|
|
|
|
my $bind_operator = ''; # =~ or !~ |
3276
|
|
|
|
|
|
|
|
3277
|
|
|
|
|
|
|
my @heredoc = (); # here document |
3278
|
|
|
|
|
|
|
my @heredoc_delimiter = (); |
3279
|
|
|
|
|
|
|
my $here_script = ''; # here script |
3280
|
|
|
|
|
|
|
|
3281
|
|
|
|
|
|
|
# |
3282
|
|
|
|
|
|
|
# escape EUC-TW script |
3283
|
|
|
|
|
|
|
# |
3284
|
|
|
|
|
|
|
sub EUCTW::escape(;$) { |
3285
|
325
|
50
|
|
325
|
0
|
2321
|
local($_) = $_[0] if @_; |
3286
|
|
|
|
|
|
|
|
3287
|
|
|
|
|
|
|
# P.359 The Study Function |
3288
|
|
|
|
|
|
|
# in Chapter 7: Perl |
3289
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
3290
|
|
|
|
|
|
|
|
3291
|
325
|
|
|
|
|
1905
|
study $_; # Yes, I studied study yesterday. |
3292
|
|
|
|
|
|
|
|
3293
|
|
|
|
|
|
|
# while all script |
3294
|
|
|
|
|
|
|
|
3295
|
|
|
|
|
|
|
# 6.14. Matching from Where the Last Pattern Left Off |
3296
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
3297
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
3298
|
|
|
|
|
|
|
# (and so on) |
3299
|
|
|
|
|
|
|
|
3300
|
|
|
|
|
|
|
# one member of Tag-team |
3301
|
|
|
|
|
|
|
# |
3302
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
3303
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
3304
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
3305
|
|
|
|
|
|
|
# P.255 Use leading anchors |
3306
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front expressions |
3307
|
|
|
|
|
|
|
# in Chapter 6: Crafting an Efficient Expression |
3308
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
3309
|
|
|
|
|
|
|
# in Chapter 7: Perl |
3310
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
3311
|
|
|
|
|
|
|
|
3312
|
325
|
|
|
|
|
1101
|
my $e_script = ''; |
3313
|
325
|
|
|
|
|
1903
|
while (not /\G \z/oxgc) { # member |
3314
|
128759
|
|
|
|
|
141372
|
$e_script .= EUCTW::escape_token(); |
3315
|
|
|
|
|
|
|
} |
3316
|
|
|
|
|
|
|
|
3317
|
325
|
|
|
|
|
3616
|
return $e_script; |
3318
|
|
|
|
|
|
|
} |
3319
|
|
|
|
|
|
|
|
3320
|
|
|
|
|
|
|
# |
3321
|
|
|
|
|
|
|
# escape EUC-TW token of script |
3322
|
|
|
|
|
|
|
# |
3323
|
|
|
|
|
|
|
sub EUCTW::escape_token { |
3324
|
|
|
|
|
|
|
|
3325
|
|
|
|
|
|
|
# \n output here document |
3326
|
|
|
|
|
|
|
|
3327
|
128759
|
|
|
128759
|
0
|
96233
|
my $ignore_modules = join('|', qw( |
3328
|
|
|
|
|
|
|
utf8 |
3329
|
|
|
|
|
|
|
bytes |
3330
|
|
|
|
|
|
|
charnames |
3331
|
|
|
|
|
|
|
I18N::Japanese |
3332
|
|
|
|
|
|
|
I18N::Collate |
3333
|
|
|
|
|
|
|
I18N::JExt |
3334
|
|
|
|
|
|
|
File::DosGlob |
3335
|
|
|
|
|
|
|
Wild |
3336
|
|
|
|
|
|
|
Wildcard |
3337
|
|
|
|
|
|
|
Japanese |
3338
|
|
|
|
|
|
|
)); |
3339
|
|
|
|
|
|
|
|
3340
|
|
|
|
|
|
|
# another member of Tag-team |
3341
|
|
|
|
|
|
|
# |
3342
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
3343
|
|
|
|
|
|
|
# in Chapter 7: Perl |
3344
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
3345
|
|
|
|
|
|
|
|
3346
|
128759
|
100
|
100
|
|
|
8356352
|
if (/\G ( \n ) /oxgc) { # another member (and so on) |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3347
|
21991
|
|
|
|
|
16756
|
my $heredoc = ''; |
3348
|
21991
|
100
|
|
|
|
35799
|
if (scalar(@heredoc_delimiter) >= 1) { |
3349
|
167
|
|
|
|
|
163
|
$slash = 'm//'; |
3350
|
|
|
|
|
|
|
|
3351
|
167
|
|
|
|
|
259
|
$heredoc = join '', @heredoc; |
3352
|
167
|
|
|
|
|
233
|
@heredoc = (); |
3353
|
|
|
|
|
|
|
|
3354
|
|
|
|
|
|
|
# skip here document |
3355
|
167
|
|
|
|
|
257
|
for my $heredoc_delimiter (@heredoc_delimiter) { |
3356
|
175
|
|
|
|
|
1052
|
/\G .*? \n $heredoc_delimiter \n/xmsgc; |
3357
|
|
|
|
|
|
|
} |
3358
|
167
|
|
|
|
|
215
|
@heredoc_delimiter = (); |
3359
|
|
|
|
|
|
|
|
3360
|
167
|
|
|
|
|
175
|
$here_script = ''; |
3361
|
|
|
|
|
|
|
} |
3362
|
21991
|
|
|
|
|
54792
|
return "\n" . $heredoc; |
3363
|
|
|
|
|
|
|
} |
3364
|
|
|
|
|
|
|
|
3365
|
|
|
|
|
|
|
# ignore space, comment |
3366
|
30494
|
|
|
|
|
74612
|
elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; } |
3367
|
|
|
|
|
|
|
|
3368
|
|
|
|
|
|
|
# if (, elsif (, unless (, while (, until (, given (, and when ( |
3369
|
|
|
|
|
|
|
|
3370
|
|
|
|
|
|
|
# given, when |
3371
|
|
|
|
|
|
|
|
3372
|
|
|
|
|
|
|
# P.225 The given Statement |
3373
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
3374
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
3375
|
|
|
|
|
|
|
|
3376
|
|
|
|
|
|
|
# P.133 The given Statement |
3377
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
3378
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3379
|
|
|
|
|
|
|
|
3380
|
|
|
|
|
|
|
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) { |
3381
|
2600
|
|
|
|
|
2916
|
$slash = 'm//'; |
3382
|
2600
|
|
|
|
|
6834
|
return $1; |
3383
|
|
|
|
|
|
|
} |
3384
|
|
|
|
|
|
|
|
3385
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ tr///; |
3386
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ s///; |
3387
|
|
|
|
|
|
|
|
3388
|
|
|
|
|
|
|
# state |
3389
|
|
|
|
|
|
|
|
3390
|
|
|
|
|
|
|
# P.68 Persistent, Private Variables |
3391
|
|
|
|
|
|
|
# in Chapter 4: Subroutines |
3392
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
3393
|
|
|
|
|
|
|
|
3394
|
|
|
|
|
|
|
# P.160 Persistent Lexically Scoped Variables: state |
3395
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
3396
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3397
|
|
|
|
|
|
|
|
3398
|
|
|
|
|
|
|
# (and so on) |
3399
|
|
|
|
|
|
|
|
3400
|
|
|
|
|
|
|
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) { |
3401
|
144
|
|
|
|
|
253
|
my $e_string = e_string($1); |
3402
|
|
|
|
|
|
|
|
3403
|
144
|
50
|
|
|
|
4301
|
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
|
|
50
|
|
|
|
|
|
3404
|
0
|
|
|
|
|
0
|
$tr_variable = $e_string . e_string($1); |
3405
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
3406
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
3407
|
0
|
|
|
|
|
0
|
return ''; |
3408
|
|
|
|
|
|
|
} |
3409
|
|
|
|
|
|
|
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
3410
|
0
|
|
|
|
|
0
|
$sub_variable = $e_string . e_string($1); |
3411
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
3412
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
3413
|
0
|
|
|
|
|
0
|
return ''; |
3414
|
|
|
|
|
|
|
} |
3415
|
|
|
|
|
|
|
else { |
3416
|
144
|
|
|
|
|
170
|
$slash = 'div'; |
3417
|
144
|
|
|
|
|
432
|
return $e_string; |
3418
|
|
|
|
|
|
|
} |
3419
|
|
|
|
|
|
|
} |
3420
|
|
|
|
|
|
|
|
3421
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
3422
|
|
|
|
|
|
|
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
3423
|
4
|
|
|
|
|
6
|
$slash = 'div'; |
3424
|
4
|
|
|
|
|
11
|
return q{Eeuctw::PREMATCH()}; |
3425
|
|
|
|
|
|
|
} |
3426
|
|
|
|
|
|
|
|
3427
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
3428
|
|
|
|
|
|
|
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
3429
|
28
|
|
|
|
|
41
|
$slash = 'div'; |
3430
|
28
|
|
|
|
|
74
|
return q{Eeuctw::MATCH()}; |
3431
|
|
|
|
|
|
|
} |
3432
|
|
|
|
|
|
|
|
3433
|
|
|
|
|
|
|
# $', ${'} --> $', ${'} |
3434
|
|
|
|
|
|
|
elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) { |
3435
|
1
|
|
|
|
|
3
|
$slash = 'div'; |
3436
|
1
|
|
|
|
|
5
|
return $1; |
3437
|
|
|
|
|
|
|
} |
3438
|
|
|
|
|
|
|
|
3439
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
3440
|
|
|
|
|
|
|
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
3441
|
3
|
|
|
|
|
6
|
$slash = 'div'; |
3442
|
3
|
|
|
|
|
14
|
return q{Eeuctw::POSTMATCH()}; |
3443
|
|
|
|
|
|
|
} |
3444
|
|
|
|
|
|
|
|
3445
|
|
|
|
|
|
|
# scalar variable $scalar =~ tr///; |
3446
|
|
|
|
|
|
|
# scalar variable $scalar =~ s///; |
3447
|
|
|
|
|
|
|
# substr() =~ tr///; |
3448
|
|
|
|
|
|
|
# substr() =~ s///; |
3449
|
|
|
|
|
|
|
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) { |
3450
|
2372
|
|
|
|
|
3971
|
my $scalar = e_string($1); |
3451
|
|
|
|
|
|
|
|
3452
|
2372
|
100
|
|
|
|
7932
|
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
|
|
100
|
|
|
|
|
|
3453
|
9
|
|
|
|
|
15
|
$tr_variable = $scalar; |
3454
|
9
|
|
|
|
|
9
|
$bind_operator = $1; |
3455
|
9
|
|
|
|
|
10
|
$slash = 'm//'; |
3456
|
9
|
|
|
|
|
21
|
return ''; |
3457
|
|
|
|
|
|
|
} |
3458
|
|
|
|
|
|
|
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
3459
|
119
|
|
|
|
|
195
|
$sub_variable = $scalar; |
3460
|
119
|
|
|
|
|
179
|
$bind_operator = $1; |
3461
|
119
|
|
|
|
|
127
|
$slash = 'm//'; |
3462
|
119
|
|
|
|
|
301
|
return ''; |
3463
|
|
|
|
|
|
|
} |
3464
|
|
|
|
|
|
|
else { |
3465
|
2244
|
|
|
|
|
2191
|
$slash = 'div'; |
3466
|
2244
|
|
|
|
|
5530
|
return $scalar; |
3467
|
|
|
|
|
|
|
} |
3468
|
|
|
|
|
|
|
} |
3469
|
|
|
|
|
|
|
|
3470
|
|
|
|
|
|
|
# end of statement |
3471
|
|
|
|
|
|
|
elsif (/\G ( [,;] ) /oxgc) { |
3472
|
8010
|
|
|
|
|
7916
|
$slash = 'm//'; |
3473
|
|
|
|
|
|
|
|
3474
|
|
|
|
|
|
|
# clear tr/// variable |
3475
|
8010
|
|
|
|
|
6837
|
$tr_variable = ''; |
3476
|
|
|
|
|
|
|
|
3477
|
|
|
|
|
|
|
# clear s/// variable |
3478
|
8010
|
|
|
|
|
5907
|
$sub_variable = ''; |
3479
|
|
|
|
|
|
|
|
3480
|
8010
|
|
|
|
|
5731
|
$bind_operator = ''; |
3481
|
|
|
|
|
|
|
|
3482
|
8010
|
|
|
|
|
22635
|
return $1; |
3483
|
|
|
|
|
|
|
} |
3484
|
|
|
|
|
|
|
|
3485
|
|
|
|
|
|
|
# bareword |
3486
|
|
|
|
|
|
|
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
3487
|
0
|
|
|
|
|
0
|
return $1; |
3488
|
|
|
|
|
|
|
} |
3489
|
|
|
|
|
|
|
|
3490
|
|
|
|
|
|
|
# $0 --> $0 |
3491
|
|
|
|
|
|
|
elsif (/\G ( \$ 0 ) /oxmsgc) { |
3492
|
2
|
|
|
|
|
3
|
$slash = 'div'; |
3493
|
2
|
|
|
|
|
10
|
return $1; |
3494
|
|
|
|
|
|
|
} |
3495
|
|
|
|
|
|
|
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
3496
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3497
|
0
|
|
|
|
|
0
|
return $1; |
3498
|
|
|
|
|
|
|
} |
3499
|
|
|
|
|
|
|
|
3500
|
|
|
|
|
|
|
# $$ --> $$ |
3501
|
|
|
|
|
|
|
elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
3502
|
1
|
|
|
|
|
2
|
$slash = 'div'; |
3503
|
1
|
|
|
|
|
3
|
return $1; |
3504
|
|
|
|
|
|
|
} |
3505
|
|
|
|
|
|
|
|
3506
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
3507
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
3508
|
|
|
|
|
|
|
elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
3509
|
129
|
|
|
|
|
160
|
$slash = 'div'; |
3510
|
129
|
|
|
|
|
256
|
return e_capture($1); |
3511
|
|
|
|
|
|
|
} |
3512
|
|
|
|
|
|
|
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
3513
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3514
|
0
|
|
|
|
|
0
|
return e_capture($1); |
3515
|
|
|
|
|
|
|
} |
3516
|
|
|
|
|
|
|
|
3517
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
3518
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
3519
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3520
|
0
|
|
|
|
|
0
|
return e_capture($1.'->'.$2); |
3521
|
|
|
|
|
|
|
} |
3522
|
|
|
|
|
|
|
|
3523
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
3524
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
3525
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3526
|
0
|
|
|
|
|
0
|
return e_capture($1.'->'.$2); |
3527
|
|
|
|
|
|
|
} |
3528
|
|
|
|
|
|
|
|
3529
|
|
|
|
|
|
|
# $$foo |
3530
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
3531
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3532
|
0
|
|
|
|
|
0
|
return e_capture($1); |
3533
|
|
|
|
|
|
|
} |
3534
|
|
|
|
|
|
|
|
3535
|
|
|
|
|
|
|
# ${ foo } |
3536
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) { |
3537
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3538
|
0
|
|
|
|
|
0
|
return '${' . $1 . '}'; |
3539
|
|
|
|
|
|
|
} |
3540
|
|
|
|
|
|
|
|
3541
|
|
|
|
|
|
|
# ${ ... } |
3542
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
3543
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
3544
|
0
|
|
|
|
|
0
|
return e_capture($1); |
3545
|
|
|
|
|
|
|
} |
3546
|
|
|
|
|
|
|
|
3547
|
|
|
|
|
|
|
# variable or function |
3548
|
|
|
|
|
|
|
# $ @ % & * $ # |
3549
|
|
|
|
|
|
|
elsif (/\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) { |
3550
|
149
|
|
|
|
|
168
|
$slash = 'div'; |
3551
|
149
|
|
|
|
|
478
|
return $1; |
3552
|
|
|
|
|
|
|
} |
3553
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
3554
|
|
|
|
|
|
|
# $ @ # \ ' " / ? ( ) [ ] < > |
3555
|
|
|
|
|
|
|
elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
3556
|
89
|
|
|
|
|
135
|
$slash = 'div'; |
3557
|
89
|
|
|
|
|
282
|
return $1; |
3558
|
|
|
|
|
|
|
} |
3559
|
|
|
|
|
|
|
|
3560
|
|
|
|
|
|
|
# while () |
3561
|
|
|
|
|
|
|
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) { |
3562
|
0
|
|
|
|
|
0
|
return $1; |
3563
|
|
|
|
|
|
|
} |
3564
|
|
|
|
|
|
|
|
3565
|
|
|
|
|
|
|
# while () --- glob |
3566
|
|
|
|
|
|
|
|
3567
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
3568
|
|
|
|
|
|
|
|
3569
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^\x8E\xA1-\xFE>\0\a\e\f\n\r\t]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])+?) > (?>\s*) \) \b /oxgc) { |
3570
|
0
|
|
|
|
|
0
|
return 'while ($_ = Eeuctw::glob("' . $1 . '"))'; |
3571
|
|
|
|
|
|
|
} |
3572
|
|
|
|
|
|
|
|
3573
|
|
|
|
|
|
|
# while (glob) |
3574
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) { |
3575
|
0
|
|
|
|
|
0
|
return 'while ($_ = Eeuctw::glob_)'; |
3576
|
|
|
|
|
|
|
} |
3577
|
|
|
|
|
|
|
|
3578
|
|
|
|
|
|
|
# while (glob(WILDCARD)) |
3579
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) { |
3580
|
0
|
|
|
|
|
0
|
return 'while ($_ = Eeuctw::glob'; |
3581
|
|
|
|
|
|
|
} |
3582
|
|
|
|
|
|
|
|
3583
|
|
|
|
|
|
|
# doit if, doit unless, doit while, doit until, doit for, doit when |
3584
|
418
|
|
|
|
|
670
|
elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; } |
|
418
|
|
|
|
|
1410
|
|
3585
|
|
|
|
|
|
|
|
3586
|
|
|
|
|
|
|
# subroutines of package Eeuctw |
3587
|
19
|
|
|
|
|
33
|
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; } |
|
19
|
|
|
|
|
61
|
|
3588
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
0
|
|
|
|
|
0
|
|
3589
|
13
|
|
|
|
|
11
|
elsif (/\G \b EUCTW::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
13
|
|
|
|
|
24
|
|
3590
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; } |
|
0
|
|
|
|
|
0
|
|
3591
|
114
|
|
|
|
|
124
|
elsif (/\G \b EUCTW::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval EUCTW::escape'; } |
|
114
|
|
|
|
|
287
|
|
3592
|
2
|
|
|
|
|
3
|
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; } |
|
2
|
|
|
|
|
5
|
|
3593
|
2
|
|
|
|
|
4
|
elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::chop'; } |
|
2
|
|
|
|
|
7
|
|
3594
|
2
|
|
|
|
|
4
|
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; } |
|
2
|
|
|
|
|
6
|
|
3595
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; } |
|
0
|
|
|
|
|
0
|
|
3596
|
2
|
|
|
|
|
3
|
elsif (/\G \b EUCTW::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'EUCTW::index'; } |
|
2
|
|
|
|
|
5
|
|
3597
|
2
|
|
|
|
|
2
|
elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::index'; } |
|
2
|
|
|
|
|
5
|
|
3598
|
2
|
|
|
|
|
3
|
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; } |
|
2
|
|
|
|
|
5
|
|
3599
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; } |
|
0
|
|
|
|
|
0
|
|
3600
|
2
|
|
|
|
|
4
|
elsif (/\G \b EUCTW::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'EUCTW::rindex'; } |
|
2
|
|
|
|
|
13
|
|
3601
|
2
|
|
|
|
|
3
|
elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::rindex'; } |
|
2
|
|
|
|
|
5
|
|
3602
|
1
|
|
|
|
|
2
|
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::lc'; } |
|
1
|
|
|
|
|
3
|
|
3603
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::lcfirst'; } |
|
0
|
|
|
|
|
0
|
|
3604
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::uc'; } |
|
0
|
|
|
|
|
0
|
|
3605
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::ucfirst'; } |
|
0
|
|
|
|
|
0
|
|
3606
|
3
|
|
|
|
|
4
|
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::fc'; } |
|
3
|
|
|
|
|
6
|
|
3607
|
|
|
|
|
|
|
|
3608
|
|
|
|
|
|
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
3609
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3610
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3611
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3612
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3613
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3614
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3615
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3616
|
|
|
|
|
|
|
|
3617
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3618
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3619
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3620
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3621
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3622
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3623
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
3624
|
|
|
|
|
|
|
|
3625
|
|
|
|
|
|
|
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
3626
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
3627
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; } |
|
0
|
|
|
|
|
0
|
|
3628
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; } |
|
0
|
|
|
|
|
0
|
|
3629
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
3630
|
|
|
|
|
|
|
|
3631
|
2
|
|
|
|
|
4
|
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; } |
|
2
|
|
|
|
|
5
|
|
3632
|
2
|
|
|
|
|
3
|
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
6
|
|
3633
|
36
|
|
|
|
|
43
|
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::chr'; } |
|
36
|
|
|
|
|
90
|
|
3634
|
2
|
|
|
|
|
5
|
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; } |
|
2
|
|
|
|
|
7
|
|
3635
|
2
|
|
|
|
|
3
|
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; } |
|
2
|
|
|
|
|
10
|
|
3636
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Eeuctw::glob'; } |
|
0
|
|
|
|
|
0
|
|
3637
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::lc_'; } |
|
0
|
|
|
|
|
0
|
|
3638
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::lcfirst_'; } |
|
0
|
|
|
|
|
0
|
|
3639
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::uc_'; } |
|
0
|
|
|
|
|
0
|
|
3640
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::ucfirst_'; } |
|
0
|
|
|
|
|
0
|
|
3641
|
0
|
|
|
|
|
0
|
elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::fc_'; } |
|
0
|
|
|
|
|
0
|
|
3642
|
0
|
|
|
|
|
0
|
elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; } |
|
0
|
|
|
|
|
0
|
|
3643
|
|
|
|
|
|
|
|
3644
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; } |
|
0
|
|
|
|
|
0
|
|
3645
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
0
|
|
|
|
|
0
|
|
3646
|
0
|
|
|
|
|
0
|
elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::chr_'; } |
|
0
|
|
|
|
|
0
|
|
3647
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; } |
|
0
|
|
|
|
|
0
|
|
3648
|
2
|
|
|
|
|
4
|
elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; } |
|
2
|
|
|
|
|
6
|
|
3649
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Eeuctw::glob_'; } |
|
0
|
|
|
|
|
0
|
|
3650
|
4
|
|
|
|
|
5
|
elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; } |
|
4
|
|
|
|
|
13
|
|
3651
|
8
|
|
|
|
|
14
|
elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; } |
|
8
|
|
|
|
|
30
|
|
3652
|
|
|
|
|
|
|
# split |
3653
|
|
|
|
|
|
|
elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
3654
|
186
|
|
|
|
|
265
|
$slash = 'm//'; |
3655
|
|
|
|
|
|
|
|
3656
|
186
|
|
|
|
|
210
|
my $e = ''; |
3657
|
186
|
|
|
|
|
608
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
3658
|
183
|
|
|
|
|
649
|
$e .= $1; |
3659
|
|
|
|
|
|
|
} |
3660
|
|
|
|
|
|
|
|
3661
|
|
|
|
|
|
|
# end of split |
3662
|
186
|
100
|
|
|
|
14865
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Eeuctw::split' . $e; } |
|
3
|
100
|
|
|
|
16
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3663
|
|
|
|
|
|
|
|
3664
|
|
|
|
|
|
|
# split scalar value |
3665
|
1
|
|
|
|
|
3
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Eeuctw::split' . $e . e_string($1); } |
3666
|
|
|
|
|
|
|
|
3667
|
|
|
|
|
|
|
# split literal space |
3668
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Eeuctw::split' . $e . qq {qq$1 $2}; } |
3669
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Eeuctw::split' . $e . qq{$1qq$2 $3}; } |
3670
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Eeuctw::split' . $e . qq{$1qq$2 $3}; } |
3671
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Eeuctw::split' . $e . qq{$1qq$2 $3}; } |
3672
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Eeuctw::split' . $e . qq{$1qq$2 $3}; } |
3673
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Eeuctw::split' . $e . qq{$1qq$2 $3}; } |
3674
|
0
|
|
|
|
|
0
|
elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Eeuctw::split' . $e . qq {q$1 $2}; } |
3675
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Eeuctw::split' . $e . qq {$1q$2 $3}; } |
3676
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Eeuctw::split' . $e . qq {$1q$2 $3}; } |
3677
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Eeuctw::split' . $e . qq {$1q$2 $3}; } |
3678
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Eeuctw::split' . $e . qq {$1q$2 $3}; } |
3679
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Eeuctw::split' . $e . qq {$1q$2 $3}; } |
3680
|
13
|
|
|
|
|
45
|
elsif (/\G ' [ ] ' /oxgc) { return 'Eeuctw::split' . $e . qq {' '}; } |
3681
|
2
|
|
|
|
|
8
|
elsif (/\G " [ ] " /oxgc) { return 'Eeuctw::split' . $e . qq {" "}; } |
3682
|
|
|
|
|
|
|
|
3683
|
|
|
|
|
|
|
# split qq// |
3684
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
3685
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
3686
|
|
|
|
|
|
|
else { |
3687
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3688
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3689
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( ) |
3690
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { } |
3691
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ] |
3692
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < > |
3693
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { } |
3694
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * * |
3695
|
|
|
|
|
|
|
} |
3696
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3697
|
|
|
|
|
|
|
} |
3698
|
|
|
|
|
|
|
} |
3699
|
|
|
|
|
|
|
|
3700
|
|
|
|
|
|
|
# split qr// |
3701
|
|
|
|
|
|
|
elsif (/\G \b (qr) \b /oxgc) { |
3702
|
36
|
50
|
|
|
|
738
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# # |
|
0
|
|
|
|
|
0
|
|
3703
|
|
|
|
|
|
|
else { |
3704
|
36
|
|
|
|
|
112
|
while (not /\G \z/oxgc) { |
3705
|
36
|
50
|
|
|
|
5454
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3706
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( ) |
3707
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { } |
3708
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ] |
3709
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < > |
3710
|
12
|
|
|
|
|
57
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' ' |
3711
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { } |
3712
|
24
|
|
|
|
|
115
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * * |
3713
|
|
|
|
|
|
|
} |
3714
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3715
|
|
|
|
|
|
|
} |
3716
|
|
|
|
|
|
|
} |
3717
|
|
|
|
|
|
|
|
3718
|
|
|
|
|
|
|
# split q// |
3719
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
3720
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
3721
|
|
|
|
|
|
|
else { |
3722
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3723
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3724
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( ) |
3725
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { } |
3726
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ] |
3727
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < > |
3728
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { } |
3729
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * * |
3730
|
|
|
|
|
|
|
} |
3731
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3732
|
|
|
|
|
|
|
} |
3733
|
|
|
|
|
|
|
} |
3734
|
|
|
|
|
|
|
|
3735
|
|
|
|
|
|
|
# split m// |
3736
|
|
|
|
|
|
|
elsif (/\G \b (m) \b /oxgc) { |
3737
|
48
|
50
|
|
|
|
838
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
3738
|
|
|
|
|
|
|
else { |
3739
|
48
|
|
|
|
|
137
|
while (not /\G \z/oxgc) { |
3740
|
48
|
50
|
|
|
|
5677
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3741
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( ) |
3742
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { } |
3743
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ] |
3744
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < > |
3745
|
12
|
|
|
|
|
51
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' ' |
3746
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { } |
3747
|
36
|
|
|
|
|
141
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * * |
3748
|
|
|
|
|
|
|
} |
3749
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
3750
|
|
|
|
|
|
|
} |
3751
|
|
|
|
|
|
|
} |
3752
|
|
|
|
|
|
|
|
3753
|
|
|
|
|
|
|
# split '' |
3754
|
|
|
|
|
|
|
elsif (/\G (\') /oxgc) { |
3755
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
3756
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3757
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3758
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
3759
|
0
|
|
|
|
|
0
|
elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' ' |
3760
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
3761
|
|
|
|
|
|
|
} |
3762
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3763
|
|
|
|
|
|
|
} |
3764
|
|
|
|
|
|
|
|
3765
|
|
|
|
|
|
|
# split "" |
3766
|
|
|
|
|
|
|
elsif (/\G (\") /oxgc) { |
3767
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
3768
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3769
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3770
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
3771
|
0
|
|
|
|
|
0
|
elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " " |
3772
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
3773
|
|
|
|
|
|
|
} |
3774
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3775
|
|
|
|
|
|
|
} |
3776
|
|
|
|
|
|
|
|
3777
|
|
|
|
|
|
|
# split // |
3778
|
|
|
|
|
|
|
elsif (/\G (\/) /oxgc) { |
3779
|
83
|
|
|
|
|
114
|
my $regexp = ''; |
3780
|
83
|
|
|
|
|
212
|
while (not /\G \z/oxgc) { |
3781
|
470
|
50
|
|
|
|
2129
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3782
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
3783
|
83
|
|
|
|
|
296
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / / |
3784
|
387
|
|
|
|
|
707
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
3785
|
|
|
|
|
|
|
} |
3786
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
3787
|
|
|
|
|
|
|
} |
3788
|
|
|
|
|
|
|
} |
3789
|
|
|
|
|
|
|
|
3790
|
|
|
|
|
|
|
# tr/// or y/// |
3791
|
|
|
|
|
|
|
|
3792
|
|
|
|
|
|
|
# about [cdsrbB]* (/B modifier) |
3793
|
|
|
|
|
|
|
# |
3794
|
|
|
|
|
|
|
# P.559 appendix C |
3795
|
|
|
|
|
|
|
# of ISBN 4-89052-384-7 Programming perl |
3796
|
|
|
|
|
|
|
# (Japanese title is: Perl puroguramingu) |
3797
|
|
|
|
|
|
|
|
3798
|
|
|
|
|
|
|
elsif (/\G \b ( tr | y ) \b /oxgc) { |
3799
|
11
|
|
|
|
|
18
|
my $ope = $1; |
3800
|
|
|
|
|
|
|
|
3801
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
3802
|
11
|
50
|
|
|
|
167
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # # |
3803
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
3804
|
0
|
|
|
|
|
0
|
return e_tr(@tr,'',$4,$6); |
3805
|
|
|
|
|
|
|
} |
3806
|
|
|
|
|
|
|
else { |
3807
|
11
|
|
|
|
|
13
|
my $e = ''; |
3808
|
11
|
|
|
|
|
24
|
while (not /\G \z/oxgc) { |
3809
|
11
|
50
|
|
|
|
840
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3810
|
|
|
|
|
|
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
3811
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
3812
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3813
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3814
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( ) |
3815
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { } |
3816
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ] |
3817
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < > |
3818
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * * |
3819
|
|
|
|
|
|
|
} |
3820
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
3821
|
|
|
|
|
|
|
} |
3822
|
|
|
|
|
|
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
3823
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
3824
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3825
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3826
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( ) |
3827
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { } |
3828
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ] |
3829
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < > |
3830
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * * |
3831
|
|
|
|
|
|
|
} |
3832
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
3833
|
|
|
|
|
|
|
} |
3834
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
3835
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
3836
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3837
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3838
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( ) |
3839
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { } |
3840
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ] |
3841
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < > |
3842
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * * |
3843
|
|
|
|
|
|
|
} |
3844
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
3845
|
|
|
|
|
|
|
} |
3846
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
3847
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
3848
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3849
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3850
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( ) |
3851
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { } |
3852
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ] |
3853
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < > |
3854
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * * |
3855
|
|
|
|
|
|
|
} |
3856
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
3857
|
|
|
|
|
|
|
} |
3858
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
3859
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * * |
3860
|
11
|
|
|
|
|
30
|
my @tr = ($tr_variable,$2); |
3861
|
11
|
|
|
|
|
27
|
return e_tr(@tr,'',$4,$6); |
3862
|
|
|
|
|
|
|
} |
3863
|
|
|
|
|
|
|
} |
3864
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration pattern not terminated\n"; |
3865
|
|
|
|
|
|
|
} |
3866
|
|
|
|
|
|
|
} |
3867
|
|
|
|
|
|
|
|
3868
|
|
|
|
|
|
|
# qq// |
3869
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
3870
|
4159
|
|
|
|
|
6373
|
my $ope = $1; |
3871
|
|
|
|
|
|
|
|
3872
|
|
|
|
|
|
|
# if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# # |
3873
|
4159
|
100
|
|
|
|
6157
|
if (/\G (\#) /oxgc) { # qq# # |
3874
|
40
|
|
|
|
|
29
|
my $qq_string = ''; |
3875
|
40
|
|
|
|
|
81
|
while (not /\G \z/oxgc) { |
3876
|
1948
|
100
|
|
|
|
4932
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
80
|
50
|
|
|
|
138
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3877
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; } |
3878
|
40
|
|
|
|
|
64
|
elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); } |
3879
|
1828
|
|
|
|
|
2785
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3880
|
|
|
|
|
|
|
} |
3881
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3882
|
|
|
|
|
|
|
} |
3883
|
|
|
|
|
|
|
|
3884
|
|
|
|
|
|
|
else { |
3885
|
4119
|
|
|
|
|
3726
|
my $e = ''; |
3886
|
4119
|
|
|
|
|
8329
|
while (not /\G \z/oxgc) { |
3887
|
4119
|
50
|
|
|
|
13972
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3888
|
|
|
|
|
|
|
|
3889
|
|
|
|
|
|
|
# elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( ) |
3890
|
|
|
|
|
|
|
elsif (/\G (\() /oxgc) { # qq ( ) |
3891
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
3892
|
0
|
|
|
|
|
0
|
local $nest = 1; |
3893
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3894
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3895
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; } |
3896
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
3897
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
3898
|
0
|
0
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); } |
|
0
|
|
|
|
|
0
|
|
3899
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
3900
|
|
|
|
|
|
|
} |
3901
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3902
|
|
|
|
|
|
|
} |
3903
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3904
|
|
|
|
|
|
|
} |
3905
|
|
|
|
|
|
|
|
3906
|
|
|
|
|
|
|
# elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { } |
3907
|
|
|
|
|
|
|
elsif (/\G (\{) /oxgc) { # qq { } |
3908
|
4061
|
|
|
|
|
3454
|
my $qq_string = ''; |
3909
|
4061
|
|
|
|
|
4549
|
local $nest = 1; |
3910
|
4061
|
|
|
|
|
7102
|
while (not /\G \z/oxgc) { |
3911
|
171271
|
100
|
|
|
|
514503
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
708
|
50
|
|
|
|
1232
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3912
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; } |
3913
|
1334
|
|
|
|
|
1386
|
elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; } |
|
1334
|
|
|
|
|
2044
|
|
3914
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
3915
|
5395
|
100
|
|
|
|
6725
|
if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); } |
|
4061
|
|
|
|
|
7230
|
|
3916
|
1334
|
|
|
|
|
2520
|
else { $qq_string .= $1; } |
3917
|
|
|
|
|
|
|
} |
3918
|
163834
|
|
|
|
|
264824
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3919
|
|
|
|
|
|
|
} |
3920
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3921
|
|
|
|
|
|
|
} |
3922
|
|
|
|
|
|
|
|
3923
|
|
|
|
|
|
|
# elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ] |
3924
|
|
|
|
|
|
|
elsif (/\G (\[) /oxgc) { # qq [ ] |
3925
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
3926
|
0
|
|
|
|
|
0
|
local $nest = 1; |
3927
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
3928
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3929
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; } |
3930
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
3931
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
3932
|
0
|
0
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); } |
|
0
|
|
|
|
|
0
|
|
3933
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
3934
|
|
|
|
|
|
|
} |
3935
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3936
|
|
|
|
|
|
|
} |
3937
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3938
|
|
|
|
|
|
|
} |
3939
|
|
|
|
|
|
|
|
3940
|
|
|
|
|
|
|
# elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < > |
3941
|
|
|
|
|
|
|
elsif (/\G (\<) /oxgc) { # qq < > |
3942
|
38
|
|
|
|
|
48
|
my $qq_string = ''; |
3943
|
38
|
|
|
|
|
53
|
local $nest = 1; |
3944
|
38
|
|
|
|
|
194
|
while (not /\G \z/oxgc) { |
3945
|
1418
|
100
|
|
|
|
5389
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
22
|
50
|
|
|
|
48
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3946
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; } |
3947
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
3948
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
3949
|
38
|
50
|
|
|
|
86
|
if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); } |
|
38
|
|
|
|
|
94
|
|
3950
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
3951
|
|
|
|
|
|
|
} |
3952
|
1358
|
|
|
|
|
2395
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3953
|
|
|
|
|
|
|
} |
3954
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3955
|
|
|
|
|
|
|
} |
3956
|
|
|
|
|
|
|
|
3957
|
|
|
|
|
|
|
# elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * * |
3958
|
|
|
|
|
|
|
elsif (/\G (\S) /oxgc) { # qq * * |
3959
|
20
|
|
|
|
|
19
|
my $delimiter = $1; |
3960
|
20
|
|
|
|
|
18
|
my $qq_string = ''; |
3961
|
20
|
|
|
|
|
30
|
while (not /\G \z/oxgc) { |
3962
|
840
|
50
|
|
|
|
2206
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3963
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; } |
3964
|
20
|
|
|
|
|
32
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); } |
3965
|
820
|
|
|
|
|
1299
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
3966
|
|
|
|
|
|
|
} |
3967
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3968
|
|
|
|
|
|
|
} |
3969
|
|
|
|
|
|
|
} |
3970
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3971
|
|
|
|
|
|
|
} |
3972
|
|
|
|
|
|
|
} |
3973
|
|
|
|
|
|
|
|
3974
|
|
|
|
|
|
|
# qr// |
3975
|
|
|
|
|
|
|
elsif (/\G \b (qr) \b /oxgc) { |
3976
|
60
|
|
|
|
|
96
|
my $ope = $1; |
3977
|
60
|
50
|
|
|
|
580
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # # |
3978
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
3979
|
|
|
|
|
|
|
} |
3980
|
|
|
|
|
|
|
else { |
3981
|
60
|
|
|
|
|
63
|
my $e = ''; |
3982
|
60
|
|
|
|
|
142
|
while (not /\G \z/oxgc) { |
3983
|
60
|
50
|
|
|
|
3965
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3984
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( ) |
3985
|
1
|
|
|
|
|
4
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { } |
3986
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ] |
3987
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < > |
3988
|
14
|
|
|
|
|
42
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' ' |
3989
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { } |
3990
|
45
|
|
|
|
|
104
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * * |
3991
|
|
|
|
|
|
|
} |
3992
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
3993
|
|
|
|
|
|
|
} |
3994
|
|
|
|
|
|
|
} |
3995
|
|
|
|
|
|
|
|
3996
|
|
|
|
|
|
|
# qw// |
3997
|
|
|
|
|
|
|
elsif (/\G \b (qw) \b /oxgc) { |
3998
|
34
|
|
|
|
|
63
|
my $ope = $1; |
3999
|
34
|
50
|
|
|
|
137
|
if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# # |
4000
|
0
|
|
|
|
|
0
|
return e_qw($ope,$1,$3,$2); |
4001
|
|
|
|
|
|
|
} |
4002
|
|
|
|
|
|
|
else { |
4003
|
34
|
|
|
|
|
47
|
my $e = ''; |
4004
|
34
|
|
|
|
|
107
|
while (not /\G \z/oxgc) { |
4005
|
34
|
50
|
|
|
|
174
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4006
|
|
|
|
|
|
|
|
4007
|
34
|
|
|
|
|
94
|
elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
4008
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
4009
|
|
|
|
|
|
|
|
4010
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
4011
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
4012
|
|
|
|
|
|
|
|
4013
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
4014
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
4015
|
|
|
|
|
|
|
|
4016
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
4017
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
4018
|
|
|
|
|
|
|
|
4019
|
0
|
|
|
|
|
0
|
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
4020
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
4021
|
|
|
|
|
|
|
} |
4022
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4023
|
|
|
|
|
|
|
} |
4024
|
|
|
|
|
|
|
} |
4025
|
|
|
|
|
|
|
|
4026
|
|
|
|
|
|
|
# qx// |
4027
|
|
|
|
|
|
|
elsif (/\G \b (qx) \b /oxgc) { |
4028
|
2
|
|
|
|
|
3
|
my $ope = $1; |
4029
|
2
|
50
|
|
|
|
41
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
4030
|
0
|
|
|
|
|
0
|
return e_qq($ope,$1,$3,$2); |
4031
|
|
|
|
|
|
|
} |
4032
|
|
|
|
|
|
|
else { |
4033
|
2
|
|
|
|
|
4
|
my $e = ''; |
4034
|
2
|
|
|
|
|
6
|
while (not /\G \z/oxgc) { |
4035
|
2
|
50
|
|
|
|
126
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4036
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( ) |
4037
|
2
|
|
|
|
|
4
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { } |
4038
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ] |
4039
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < > |
4040
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' ' |
4041
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * * |
4042
|
|
|
|
|
|
|
} |
4043
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4044
|
|
|
|
|
|
|
} |
4045
|
|
|
|
|
|
|
} |
4046
|
|
|
|
|
|
|
|
4047
|
|
|
|
|
|
|
# q// |
4048
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
4049
|
385
|
|
|
|
|
932
|
my $ope = $1; |
4050
|
|
|
|
|
|
|
|
4051
|
|
|
|
|
|
|
# if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# # |
4052
|
|
|
|
|
|
|
|
4053
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
4054
|
|
|
|
|
|
|
# (and so on) |
4055
|
|
|
|
|
|
|
|
4056
|
385
|
50
|
|
|
|
1124
|
if (/\G (\#) /oxgc) { # q# # |
4057
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
4058
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4059
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4060
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\#) /oxgc) { $q_string .= $1; } |
4061
|
0
|
|
|
|
|
0
|
elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); } |
4062
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4063
|
|
|
|
|
|
|
} |
4064
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4065
|
|
|
|
|
|
|
} |
4066
|
|
|
|
|
|
|
|
4067
|
|
|
|
|
|
|
else { |
4068
|
385
|
|
|
|
|
646
|
my $e = ''; |
4069
|
385
|
|
|
|
|
1290
|
while (not /\G \z/oxgc) { |
4070
|
385
|
50
|
|
|
|
2446
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4071
|
|
|
|
|
|
|
|
4072
|
|
|
|
|
|
|
# elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( ) |
4073
|
|
|
|
|
|
|
elsif (/\G (\() /oxgc) { # q ( ) |
4074
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
4075
|
0
|
|
|
|
|
0
|
local $nest = 1; |
4076
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4077
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4078
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $q_string .= $1; } |
4079
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\() /oxgc) { $q_string .= $1; } |
4080
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
4081
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
4082
|
0
|
0
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); } |
|
0
|
|
|
|
|
0
|
|
4083
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
4084
|
|
|
|
|
|
|
} |
4085
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4086
|
|
|
|
|
|
|
} |
4087
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4088
|
|
|
|
|
|
|
} |
4089
|
|
|
|
|
|
|
|
4090
|
|
|
|
|
|
|
# elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { } |
4091
|
|
|
|
|
|
|
elsif (/\G (\{) /oxgc) { # q { } |
4092
|
379
|
|
|
|
|
617
|
my $q_string = ''; |
4093
|
379
|
|
|
|
|
701
|
local $nest = 1; |
4094
|
379
|
|
|
|
|
1219
|
while (not /\G \z/oxgc) { |
4095
|
4974
|
50
|
|
|
|
26547
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4096
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\}) /oxgc) { $q_string .= $1; } |
4097
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\{) /oxgc) { $q_string .= $1; } |
4098
|
114
|
|
|
|
|
151
|
elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; } |
|
114
|
|
|
|
|
211
|
|
4099
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
4100
|
493
|
100
|
|
|
|
997
|
if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); } |
|
379
|
|
|
|
|
1275
|
|
4101
|
114
|
|
|
|
|
239
|
else { $q_string .= $1; } |
4102
|
|
|
|
|
|
|
} |
4103
|
4367
|
|
|
|
|
7772
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4104
|
|
|
|
|
|
|
} |
4105
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4106
|
|
|
|
|
|
|
} |
4107
|
|
|
|
|
|
|
|
4108
|
|
|
|
|
|
|
# elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ] |
4109
|
|
|
|
|
|
|
elsif (/\G (\[) /oxgc) { # q [ ] |
4110
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
4111
|
0
|
|
|
|
|
0
|
local $nest = 1; |
4112
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4113
|
0
|
0
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4114
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $q_string .= $1; } |
4115
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\[) /oxgc) { $q_string .= $1; } |
4116
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
4117
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
4118
|
0
|
0
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); } |
|
0
|
|
|
|
|
0
|
|
4119
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
4120
|
|
|
|
|
|
|
} |
4121
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4122
|
|
|
|
|
|
|
} |
4123
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4124
|
|
|
|
|
|
|
} |
4125
|
|
|
|
|
|
|
|
4126
|
|
|
|
|
|
|
# elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < > |
4127
|
|
|
|
|
|
|
elsif (/\G (\<) /oxgc) { # q < > |
4128
|
5
|
|
|
|
|
7
|
my $q_string = ''; |
4129
|
5
|
|
|
|
|
10
|
local $nest = 1; |
4130
|
5
|
|
|
|
|
14
|
while (not /\G \z/oxgc) { |
4131
|
82
|
50
|
|
|
|
441
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4132
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\>) /oxgc) { $q_string .= $1; } |
4133
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\<) /oxgc) { $q_string .= $1; } |
4134
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
4135
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
4136
|
5
|
50
|
|
|
|
15
|
if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); } |
|
5
|
|
|
|
|
13
|
|
4137
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
4138
|
|
|
|
|
|
|
} |
4139
|
77
|
|
|
|
|
129
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4140
|
|
|
|
|
|
|
} |
4141
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4142
|
|
|
|
|
|
|
} |
4143
|
|
|
|
|
|
|
|
4144
|
|
|
|
|
|
|
# elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * * |
4145
|
|
|
|
|
|
|
elsif (/\G (\S) /oxgc) { # q * * |
4146
|
1
|
|
|
|
|
2
|
my $delimiter = $1; |
4147
|
1
|
|
|
|
|
2
|
my $q_string = ''; |
4148
|
1
|
|
|
|
|
8
|
while (not /\G \z/oxgc) { |
4149
|
14
|
50
|
|
|
|
77
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4150
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; } |
4151
|
1
|
|
|
|
|
3
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); } |
4152
|
13
|
|
|
|
|
22
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4153
|
|
|
|
|
|
|
} |
4154
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4155
|
|
|
|
|
|
|
} |
4156
|
|
|
|
|
|
|
} |
4157
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4158
|
|
|
|
|
|
|
} |
4159
|
|
|
|
|
|
|
} |
4160
|
|
|
|
|
|
|
|
4161
|
|
|
|
|
|
|
# m// |
4162
|
|
|
|
|
|
|
elsif (/\G \b (m) \b /oxgc) { |
4163
|
305
|
|
|
|
|
539
|
my $ope = $1; |
4164
|
305
|
50
|
|
|
|
2882
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# # |
4165
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
4166
|
|
|
|
|
|
|
} |
4167
|
|
|
|
|
|
|
else { |
4168
|
305
|
|
|
|
|
355
|
my $e = ''; |
4169
|
305
|
|
|
|
|
748
|
while (not /\G \z/oxgc) { |
4170
|
305
|
50
|
|
|
|
22134
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4171
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( ) |
4172
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { } |
4173
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ] |
4174
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < > |
4175
|
30
|
|
|
|
|
80
|
elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ? |
4176
|
25
|
|
|
|
|
76
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' ' |
4177
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { } |
4178
|
250
|
|
|
|
|
675
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * * |
4179
|
|
|
|
|
|
|
} |
4180
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
4181
|
|
|
|
|
|
|
} |
4182
|
|
|
|
|
|
|
} |
4183
|
|
|
|
|
|
|
|
4184
|
|
|
|
|
|
|
# s/// |
4185
|
|
|
|
|
|
|
|
4186
|
|
|
|
|
|
|
# about [cegimosxpradlunbB]* (/cg modifier) |
4187
|
|
|
|
|
|
|
# |
4188
|
|
|
|
|
|
|
# P.67 Pattern-Matching Operators |
4189
|
|
|
|
|
|
|
# of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition. |
4190
|
|
|
|
|
|
|
|
4191
|
|
|
|
|
|
|
elsif (/\G \b (s) \b /oxgc) { |
4192
|
156
|
|
|
|
|
310
|
my $ope = $1; |
4193
|
|
|
|
|
|
|
|
4194
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
4195
|
156
|
100
|
|
|
|
4490
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # # |
4196
|
1
|
|
|
|
|
5
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
4197
|
|
|
|
|
|
|
} |
4198
|
|
|
|
|
|
|
else { |
4199
|
155
|
|
|
|
|
203
|
my $e = ''; |
4200
|
155
|
|
|
|
|
425
|
while (not /\G \z/oxgc) { |
4201
|
155
|
50
|
|
|
|
27042
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4202
|
|
|
|
|
|
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
4203
|
0
|
|
|
|
|
0
|
my @s = ($1,$2,$3); |
4204
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4205
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4206
|
|
|
|
|
|
|
# $1 $2 $3 $4 |
4207
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4208
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4209
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4210
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4211
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4212
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4213
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4214
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4215
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4216
|
|
|
|
|
|
|
} |
4217
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
4218
|
|
|
|
|
|
|
} |
4219
|
|
|
|
|
|
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
4220
|
0
|
|
|
|
|
0
|
my @s = ($1,$2,$3); |
4221
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4222
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4223
|
|
|
|
|
|
|
# $1 $2 $3 $4 |
4224
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4225
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4226
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4227
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4228
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4229
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4230
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4231
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4232
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4233
|
|
|
|
|
|
|
} |
4234
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
4235
|
|
|
|
|
|
|
} |
4236
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
4237
|
0
|
|
|
|
|
0
|
my @s = ($1,$2,$3); |
4238
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4239
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4240
|
|
|
|
|
|
|
# $1 $2 $3 $4 |
4241
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4242
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4243
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4244
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4245
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4246
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4247
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4248
|
|
|
|
|
|
|
} |
4249
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
4250
|
|
|
|
|
|
|
} |
4251
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
4252
|
0
|
|
|
|
|
0
|
my @s = ($1,$2,$3); |
4253
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
4254
|
0
|
0
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4255
|
|
|
|
|
|
|
# $1 $2 $3 $4 |
4256
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4257
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4258
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4259
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4260
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4261
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4262
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4263
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4264
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
4265
|
|
|
|
|
|
|
} |
4266
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
4267
|
|
|
|
|
|
|
} |
4268
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
4269
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { |
4270
|
34
|
|
|
|
|
77
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
4271
|
|
|
|
|
|
|
} |
4272
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
4273
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
4274
|
2
|
|
|
|
|
10
|
return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { } |
4275
|
|
|
|
|
|
|
} |
4276
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
4277
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
4278
|
0
|
|
|
|
|
0
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
4279
|
|
|
|
|
|
|
} |
4280
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
4281
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
4282
|
119
|
|
|
|
|
458
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
4283
|
|
|
|
|
|
|
} |
4284
|
|
|
|
|
|
|
} |
4285
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution pattern not terminated\n"; |
4286
|
|
|
|
|
|
|
} |
4287
|
|
|
|
|
|
|
} |
4288
|
|
|
|
|
|
|
|
4289
|
|
|
|
|
|
|
# require ignore module |
4290
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; } |
4291
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x8E\xA1-\xFE#]) /oxmsgc) { return "# require$1\n$2"; } |
4292
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; } |
4293
|
|
|
|
|
|
|
|
4294
|
|
|
|
|
|
|
# use strict; --> use strict; no strict qw(refs); |
4295
|
65
|
|
|
|
|
523
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; } |
4296
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^\x8E\xA1-\xFE#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; } |
4297
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; } |
4298
|
|
|
|
|
|
|
|
4299
|
|
|
|
|
|
|
# use 5.12.0; --> use 5.12.0; no strict qw(refs); |
4300
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
4301
|
3
|
50
|
33
|
|
|
56
|
if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) { |
|
|
|
33
|
|
|
|
|
4302
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
4303
|
|
|
|
|
|
|
} |
4304
|
|
|
|
|
|
|
else { |
4305
|
3
|
|
|
|
|
16
|
return "use $1;"; |
4306
|
|
|
|
|
|
|
} |
4307
|
|
|
|
|
|
|
} |
4308
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
4309
|
0
|
0
|
0
|
|
|
0
|
if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) { |
|
|
|
0
|
|
|
|
|
4310
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
4311
|
|
|
|
|
|
|
} |
4312
|
|
|
|
|
|
|
else { |
4313
|
0
|
|
|
|
|
0
|
return "use $1;"; |
4314
|
|
|
|
|
|
|
} |
4315
|
|
|
|
|
|
|
} |
4316
|
|
|
|
|
|
|
|
4317
|
|
|
|
|
|
|
# ignore use module |
4318
|
2
|
|
|
|
|
12
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; } |
4319
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x8E\xA1-\xFE#]) /oxmsgc) { return "# use$1\n$2"; } |
4320
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; } |
4321
|
|
|
|
|
|
|
|
4322
|
|
|
|
|
|
|
# ignore no module |
4323
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; } |
4324
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x8E\xA1-\xFE#]) /oxmsgc) { return "# no$1\n$2"; } |
4325
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; } |
4326
|
|
|
|
|
|
|
|
4327
|
|
|
|
|
|
|
# use else |
4328
|
0
|
|
|
|
|
0
|
elsif (/\G \b use \b /oxmsgc) { return "use"; } |
4329
|
|
|
|
|
|
|
|
4330
|
|
|
|
|
|
|
# use else |
4331
|
2
|
|
|
|
|
7
|
elsif (/\G \b no \b /oxmsgc) { return "no"; } |
4332
|
|
|
|
|
|
|
|
4333
|
|
|
|
|
|
|
# '' |
4334
|
|
|
|
|
|
|
elsif (/\G (?
|
4335
|
1843
|
|
|
|
|
2480
|
my $q_string = ''; |
4336
|
1843
|
|
|
|
|
4189
|
while (not /\G \z/oxgc) { |
4337
|
11443
|
100
|
|
|
|
38929
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
4
|
100
|
|
|
|
9
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4338
|
48
|
|
|
|
|
75
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
4339
|
1843
|
|
|
|
|
3706
|
elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); } |
4340
|
9548
|
|
|
|
|
17501
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
4341
|
|
|
|
|
|
|
} |
4342
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4343
|
|
|
|
|
|
|
} |
4344
|
|
|
|
|
|
|
|
4345
|
|
|
|
|
|
|
# "" |
4346
|
|
|
|
|
|
|
elsif (/\G (\") /oxgc) { |
4347
|
2628
|
|
|
|
|
3486
|
my $qq_string = ''; |
4348
|
2628
|
|
|
|
|
5740
|
while (not /\G \z/oxgc) { |
4349
|
49751
|
100
|
|
|
|
145175
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
109
|
100
|
|
|
|
216
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4350
|
12
|
|
|
|
|
23
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
4351
|
2628
|
|
|
|
|
5437
|
elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); } |
4352
|
47002
|
|
|
|
|
77955
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
4353
|
|
|
|
|
|
|
} |
4354
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4355
|
|
|
|
|
|
|
} |
4356
|
|
|
|
|
|
|
|
4357
|
|
|
|
|
|
|
# `` |
4358
|
|
|
|
|
|
|
elsif (/\G (\`) /oxgc) { |
4359
|
1
|
|
|
|
|
2
|
my $qx_string = ''; |
4360
|
1
|
|
|
|
|
3
|
while (not /\G \z/oxgc) { |
4361
|
19
|
50
|
|
|
|
81
|
if (/\G (\\\\) /oxgc) { $qx_string .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4362
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; } |
4363
|
1
|
|
|
|
|
3
|
elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); } |
4364
|
18
|
|
|
|
|
26
|
elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; } |
4365
|
|
|
|
|
|
|
} |
4366
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4367
|
|
|
|
|
|
|
} |
4368
|
|
|
|
|
|
|
|
4369
|
|
|
|
|
|
|
# // --- not divide operator (num / num), not defined-or |
4370
|
|
|
|
|
|
|
elsif (($slash eq 'm//') and /\G (\/) /oxgc) { |
4371
|
1069
|
|
|
|
|
1603
|
my $regexp = ''; |
4372
|
1069
|
|
|
|
|
2591
|
while (not /\G \z/oxgc) { |
4373
|
10078
|
100
|
|
|
|
34013
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
|
1
|
50
|
|
|
|
3
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4374
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } |
4375
|
1069
|
|
|
|
|
2688
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); } |
4376
|
9008
|
|
|
|
|
15729
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
4377
|
|
|
|
|
|
|
} |
4378
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
4379
|
|
|
|
|
|
|
} |
4380
|
|
|
|
|
|
|
|
4381
|
|
|
|
|
|
|
# ?? --- not conditional operator (condition ? then : else) |
4382
|
|
|
|
|
|
|
elsif (($slash eq 'm//') and /\G (\?) /oxgc) { |
4383
|
30
|
|
|
|
|
49
|
my $regexp = ''; |
4384
|
30
|
|
|
|
|
88
|
while (not /\G \z/oxgc) { |
4385
|
122
|
50
|
|
|
|
639
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4386
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\?) /oxgc) { $regexp .= $1; } |
4387
|
30
|
|
|
|
|
105
|
elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); } |
4388
|
92
|
|
|
|
|
218
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
4389
|
|
|
|
|
|
|
} |
4390
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
4391
|
|
|
|
|
|
|
} |
4392
|
|
|
|
|
|
|
|
4393
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
4394
|
0
|
|
|
|
|
0
|
elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
4395
|
|
|
|
|
|
|
|
4396
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
4397
|
0
|
|
|
|
|
0
|
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
4398
|
|
|
|
|
|
|
|
4399
|
|
|
|
|
|
|
# <<'HEREDOC' |
4400
|
|
|
|
|
|
|
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
4401
|
80
|
|
|
|
|
109
|
$slash = 'm//'; |
4402
|
80
|
|
|
|
|
118
|
my $here_quote = $1; |
4403
|
80
|
|
|
|
|
106
|
my $delimiter = $2; |
4404
|
|
|
|
|
|
|
|
4405
|
|
|
|
|
|
|
# get here document |
4406
|
80
|
100
|
|
|
|
140
|
if ($here_script eq '') { |
4407
|
77
|
|
|
|
|
342
|
$here_script = CORE::substr $_, pos $_; |
4408
|
77
|
|
|
|
|
348
|
$here_script =~ s/.*?\n//oxm; |
4409
|
|
|
|
|
|
|
} |
4410
|
80
|
50
|
|
|
|
619
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
4411
|
80
|
|
|
|
|
201
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
4412
|
80
|
|
|
|
|
101
|
push @heredoc_delimiter, $delimiter; |
4413
|
|
|
|
|
|
|
} |
4414
|
|
|
|
|
|
|
else { |
4415
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
4416
|
|
|
|
|
|
|
} |
4417
|
80
|
|
|
|
|
270
|
return $here_quote; |
4418
|
|
|
|
|
|
|
} |
4419
|
|
|
|
|
|
|
|
4420
|
|
|
|
|
|
|
# <<\HEREDOC |
4421
|
|
|
|
|
|
|
|
4422
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
4423
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
4424
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4425
|
|
|
|
|
|
|
|
4426
|
|
|
|
|
|
|
# P.73 "Here" Documents |
4427
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
4428
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4429
|
|
|
|
|
|
|
|
4430
|
|
|
|
|
|
|
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
4431
|
2
|
|
|
|
|
4
|
$slash = 'm//'; |
4432
|
2
|
|
|
|
|
2
|
my $here_quote = $1; |
4433
|
2
|
|
|
|
|
4
|
my $delimiter = $2; |
4434
|
|
|
|
|
|
|
|
4435
|
|
|
|
|
|
|
# get here document |
4436
|
2
|
100
|
|
|
|
5
|
if ($here_script eq '') { |
4437
|
1
|
|
|
|
|
5
|
$here_script = CORE::substr $_, pos $_; |
4438
|
1
|
|
|
|
|
5
|
$here_script =~ s/.*?\n//oxm; |
4439
|
|
|
|
|
|
|
} |
4440
|
2
|
50
|
|
|
|
28
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
4441
|
2
|
|
|
|
|
6
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
4442
|
2
|
|
|
|
|
3
|
push @heredoc_delimiter, $delimiter; |
4443
|
|
|
|
|
|
|
} |
4444
|
|
|
|
|
|
|
else { |
4445
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
4446
|
|
|
|
|
|
|
} |
4447
|
2
|
|
|
|
|
7
|
return $here_quote; |
4448
|
|
|
|
|
|
|
} |
4449
|
|
|
|
|
|
|
|
4450
|
|
|
|
|
|
|
# <<"HEREDOC" |
4451
|
|
|
|
|
|
|
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
4452
|
39
|
|
|
|
|
78
|
$slash = 'm//'; |
4453
|
39
|
|
|
|
|
83
|
my $here_quote = $1; |
4454
|
39
|
|
|
|
|
67
|
my $delimiter = $2; |
4455
|
|
|
|
|
|
|
|
4456
|
|
|
|
|
|
|
# get here document |
4457
|
39
|
100
|
|
|
|
96
|
if ($here_script eq '') { |
4458
|
38
|
|
|
|
|
216
|
$here_script = CORE::substr $_, pos $_; |
4459
|
38
|
|
|
|
|
225
|
$here_script =~ s/.*?\n//oxm; |
4460
|
|
|
|
|
|
|
} |
4461
|
39
|
50
|
|
|
|
535
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
4462
|
39
|
|
|
|
|
124
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
4463
|
39
|
|
|
|
|
79
|
push @heredoc_delimiter, $delimiter; |
4464
|
|
|
|
|
|
|
} |
4465
|
|
|
|
|
|
|
else { |
4466
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
4467
|
|
|
|
|
|
|
} |
4468
|
39
|
|
|
|
|
174
|
return $here_quote; |
4469
|
|
|
|
|
|
|
} |
4470
|
|
|
|
|
|
|
|
4471
|
|
|
|
|
|
|
# <
|
4472
|
|
|
|
|
|
|
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
4473
|
54
|
|
|
|
|
84
|
$slash = 'm//'; |
4474
|
54
|
|
|
|
|
105
|
my $here_quote = $1; |
4475
|
54
|
|
|
|
|
85
|
my $delimiter = $2; |
4476
|
|
|
|
|
|
|
|
4477
|
|
|
|
|
|
|
# get here document |
4478
|
54
|
100
|
|
|
|
125
|
if ($here_script eq '') { |
4479
|
51
|
|
|
|
|
291
|
$here_script = CORE::substr $_, pos $_; |
4480
|
51
|
|
|
|
|
335
|
$here_script =~ s/.*?\n//oxm; |
4481
|
|
|
|
|
|
|
} |
4482
|
54
|
50
|
|
|
|
711
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
4483
|
54
|
|
|
|
|
155
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
4484
|
54
|
|
|
|
|
92
|
push @heredoc_delimiter, $delimiter; |
4485
|
|
|
|
|
|
|
} |
4486
|
|
|
|
|
|
|
else { |
4487
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
4488
|
|
|
|
|
|
|
} |
4489
|
54
|
|
|
|
|
190
|
return $here_quote; |
4490
|
|
|
|
|
|
|
} |
4491
|
|
|
|
|
|
|
|
4492
|
|
|
|
|
|
|
# <<`HEREDOC` |
4493
|
|
|
|
|
|
|
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
4494
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
4495
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
4496
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
4497
|
|
|
|
|
|
|
|
4498
|
|
|
|
|
|
|
# get here document |
4499
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
4500
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
4501
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
4502
|
|
|
|
|
|
|
} |
4503
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
4504
|
0
|
|
|
|
|
0
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
4505
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
4506
|
|
|
|
|
|
|
} |
4507
|
|
|
|
|
|
|
else { |
4508
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
4509
|
|
|
|
|
|
|
} |
4510
|
0
|
|
|
|
|
0
|
return $here_quote; |
4511
|
|
|
|
|
|
|
} |
4512
|
|
|
|
|
|
|
|
4513
|
|
|
|
|
|
|
# <<= <=> <= < operator |
4514
|
|
|
|
|
|
|
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { |
4515
|
12
|
|
|
|
|
47
|
return $1; |
4516
|
|
|
|
|
|
|
} |
4517
|
|
|
|
|
|
|
|
4518
|
|
|
|
|
|
|
# |
4519
|
|
|
|
|
|
|
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { |
4520
|
0
|
|
|
|
|
0
|
return $1; |
4521
|
|
|
|
|
|
|
} |
4522
|
|
|
|
|
|
|
|
4523
|
|
|
|
|
|
|
# --- glob |
4524
|
|
|
|
|
|
|
|
4525
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
4526
|
|
|
|
|
|
|
|
4527
|
|
|
|
|
|
|
elsif (/\G < ((?:[^\x8E\xA1-\xFE>\0\a\e\f\n\r\t]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF])+?) > /oxgc) { |
4528
|
0
|
|
|
|
|
0
|
return 'Eeuctw::glob("' . $1 . '")'; |
4529
|
|
|
|
|
|
|
} |
4530
|
|
|
|
|
|
|
|
4531
|
|
|
|
|
|
|
# __DATA__ |
4532
|
0
|
|
|
|
|
0
|
elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; } |
4533
|
|
|
|
|
|
|
|
4534
|
|
|
|
|
|
|
# __END__ |
4535
|
325
|
|
|
|
|
1892
|
elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; } |
4536
|
|
|
|
|
|
|
|
4537
|
|
|
|
|
|
|
# \cD Control-D |
4538
|
|
|
|
|
|
|
|
4539
|
|
|
|
|
|
|
# P.68 2.6.8. Other Literal Tokens |
4540
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
4541
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4542
|
|
|
|
|
|
|
|
4543
|
|
|
|
|
|
|
# P.76 Other Literal Tokens |
4544
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
4545
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4546
|
|
|
|
|
|
|
|
4547
|
0
|
|
|
|
|
0
|
elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; } |
4548
|
|
|
|
|
|
|
|
4549
|
|
|
|
|
|
|
# \cZ Control-Z |
4550
|
0
|
|
|
|
|
0
|
elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; } |
4551
|
|
|
|
|
|
|
|
4552
|
|
|
|
|
|
|
# any operator before div |
4553
|
|
|
|
|
|
|
elsif (/\G ( |
4554
|
|
|
|
|
|
|
-- | \+\+ | |
4555
|
|
|
|
|
|
|
[\)\}\]] |
4556
|
|
|
|
|
|
|
|
4557
|
9193
|
|
|
|
|
10265
|
) /oxgc) { $slash = 'div'; return $1; } |
|
9193
|
|
|
|
|
33729
|
|
4558
|
|
|
|
|
|
|
|
4559
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
4560
|
|
|
|
|
|
|
elsif (/\G ( |
4561
|
|
|
|
|
|
|
\.\.\. |
4562
|
|
|
|
|
|
|
|
4563
|
7
|
|
|
|
|
8
|
) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; } |
|
7
|
|
|
|
|
22
|
|
4564
|
|
|
|
|
|
|
|
4565
|
|
|
|
|
|
|
# any operator before m// |
4566
|
|
|
|
|
|
|
|
4567
|
|
|
|
|
|
|
# //, //= (defined-or) |
4568
|
|
|
|
|
|
|
|
4569
|
|
|
|
|
|
|
# P.164 Logical Operators |
4570
|
|
|
|
|
|
|
# in Chapter 10: More Control Structures |
4571
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
4572
|
|
|
|
|
|
|
|
4573
|
|
|
|
|
|
|
# P.119 C-Style Logical (Short-Circuit) Operators |
4574
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
4575
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4576
|
|
|
|
|
|
|
|
4577
|
|
|
|
|
|
|
# (and so on) |
4578
|
|
|
|
|
|
|
|
4579
|
|
|
|
|
|
|
# ~~ |
4580
|
|
|
|
|
|
|
|
4581
|
|
|
|
|
|
|
# P.221 The Smart Match Operator |
4582
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
4583
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
4584
|
|
|
|
|
|
|
|
4585
|
|
|
|
|
|
|
# P.112 Smartmatch Operator |
4586
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
4587
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4588
|
|
|
|
|
|
|
|
4589
|
|
|
|
|
|
|
# (and so on) |
4590
|
|
|
|
|
|
|
|
4591
|
|
|
|
|
|
|
elsif (/\G ((?> |
4592
|
|
|
|
|
|
|
|
4593
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
4594
|
|
|
|
|
|
|
%= | % | |
4595
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
4596
|
|
|
|
|
|
|
-= | -> | - | |
4597
|
|
|
|
|
|
|
:(?>\s*)= | |
4598
|
|
|
|
|
|
|
: | |
4599
|
|
|
|
|
|
|
<<>> | |
4600
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
4601
|
|
|
|
|
|
|
== | => | =~ | = | |
4602
|
|
|
|
|
|
|
>>= | >> | >= | > | |
4603
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
4604
|
|
|
|
|
|
|
\+= | \+ | |
4605
|
|
|
|
|
|
|
\.\. | \.= | \. | |
4606
|
|
|
|
|
|
|
\/\/= | \/\/ | |
4607
|
|
|
|
|
|
|
\/= | \/ | |
4608
|
|
|
|
|
|
|
\? | |
4609
|
|
|
|
|
|
|
\\ | |
4610
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
4611
|
|
|
|
|
|
|
\b x= | |
4612
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
4613
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
4614
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
4615
|
|
|
|
|
|
|
\b(?: print )\b | |
4616
|
|
|
|
|
|
|
|
4617
|
|
|
|
|
|
|
[,;\(\{\[] |
4618
|
|
|
|
|
|
|
|
4619
|
15933
|
|
|
|
|
16787
|
)) /oxgc) { $slash = 'm//'; return $1; } |
|
15933
|
|
|
|
|
57600
|
|
4620
|
|
|
|
|
|
|
|
4621
|
|
|
|
|
|
|
# other any character |
4622
|
25514
|
|
|
|
|
25569
|
elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; } |
|
25514
|
|
|
|
|
94342
|
|
4623
|
|
|
|
|
|
|
|
4624
|
|
|
|
|
|
|
# system error |
4625
|
|
|
|
|
|
|
else { |
4626
|
0
|
|
|
|
|
0
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
4627
|
|
|
|
|
|
|
} |
4628
|
|
|
|
|
|
|
} |
4629
|
|
|
|
|
|
|
|
4630
|
|
|
|
|
|
|
# escape EUC-TW string |
4631
|
|
|
|
|
|
|
sub e_string { |
4632
|
2558
|
|
|
2558
|
0
|
4101
|
my($string) = @_; |
4633
|
2558
|
|
|
|
|
2422
|
my $e_string = ''; |
4634
|
|
|
|
|
|
|
|
4635
|
2558
|
|
|
|
|
2722
|
local $slash = 'm//'; |
4636
|
|
|
|
|
|
|
|
4637
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
4638
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
4639
|
|
|
|
|
|
|
# (and so on) |
4640
|
|
|
|
|
|
|
|
4641
|
2558
|
|
|
|
|
26541
|
my @char = $string =~ / \G (?>[^\x8E\xA1-\xFE\\]|\\$q_char|$q_char) /oxmsg; |
4642
|
|
|
|
|
|
|
|
4643
|
|
|
|
|
|
|
# without { ... } |
4644
|
2558
|
100
|
66
|
|
|
10317
|
if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) { |
4645
|
2520
|
50
|
|
|
|
4543
|
if ($string !~ /<
|
4646
|
2520
|
|
|
|
|
5189
|
return $string; |
4647
|
|
|
|
|
|
|
} |
4648
|
|
|
|
|
|
|
} |
4649
|
|
|
|
|
|
|
|
4650
|
|
|
|
|
|
|
E_STRING_LOOP: |
4651
|
38
|
|
|
|
|
85
|
while ($string !~ /\G \z/oxgc) { |
4652
|
288
|
50
|
|
|
|
19334
|
if (0) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
4653
|
|
|
|
|
|
|
} |
4654
|
|
|
|
|
|
|
|
4655
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Eeuctw::PREMATCH()]} |
4656
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
4657
|
0
|
|
|
|
|
0
|
$e_string .= q{Eeuctw::PREMATCH()}; |
4658
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4659
|
|
|
|
|
|
|
} |
4660
|
|
|
|
|
|
|
|
4661
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Eeuctw::MATCH()]} |
4662
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
4663
|
0
|
|
|
|
|
0
|
$e_string .= q{Eeuctw::MATCH()}; |
4664
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4665
|
|
|
|
|
|
|
} |
4666
|
|
|
|
|
|
|
|
4667
|
|
|
|
|
|
|
# $', ${'} --> $', ${'} |
4668
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) { |
4669
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4670
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4671
|
|
|
|
|
|
|
} |
4672
|
|
|
|
|
|
|
|
4673
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Eeuctw::POSTMATCH()]} |
4674
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
4675
|
0
|
|
|
|
|
0
|
$e_string .= q{Eeuctw::POSTMATCH()}; |
4676
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4677
|
|
|
|
|
|
|
} |
4678
|
|
|
|
|
|
|
|
4679
|
|
|
|
|
|
|
# bareword |
4680
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
4681
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4682
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4683
|
|
|
|
|
|
|
} |
4684
|
|
|
|
|
|
|
|
4685
|
|
|
|
|
|
|
# $0 --> $0 |
4686
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) { |
4687
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4688
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4689
|
|
|
|
|
|
|
} |
4690
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
4691
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4692
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4693
|
|
|
|
|
|
|
} |
4694
|
|
|
|
|
|
|
|
4695
|
|
|
|
|
|
|
# $$ --> $$ |
4696
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
4697
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4698
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4699
|
|
|
|
|
|
|
} |
4700
|
|
|
|
|
|
|
|
4701
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
4702
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
4703
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
4704
|
0
|
|
|
|
|
0
|
$e_string .= e_capture($1); |
4705
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4706
|
|
|
|
|
|
|
} |
4707
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
4708
|
0
|
|
|
|
|
0
|
$e_string .= e_capture($1); |
4709
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4710
|
|
|
|
|
|
|
} |
4711
|
|
|
|
|
|
|
|
4712
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
4713
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
4714
|
0
|
|
|
|
|
0
|
$e_string .= e_capture($1.'->'.$2); |
4715
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4716
|
|
|
|
|
|
|
} |
4717
|
|
|
|
|
|
|
|
4718
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
4719
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
4720
|
0
|
|
|
|
|
0
|
$e_string .= e_capture($1.'->'.$2); |
4721
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4722
|
|
|
|
|
|
|
} |
4723
|
|
|
|
|
|
|
|
4724
|
|
|
|
|
|
|
# $$foo |
4725
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
4726
|
0
|
|
|
|
|
0
|
$e_string .= e_capture($1); |
4727
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4728
|
|
|
|
|
|
|
} |
4729
|
|
|
|
|
|
|
|
4730
|
|
|
|
|
|
|
# ${ foo } |
4731
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) { |
4732
|
0
|
|
|
|
|
0
|
$e_string .= '${' . $1 . '}'; |
4733
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4734
|
|
|
|
|
|
|
} |
4735
|
|
|
|
|
|
|
|
4736
|
|
|
|
|
|
|
# ${ ... } |
4737
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
4738
|
3
|
|
|
|
|
8
|
$e_string .= e_capture($1); |
4739
|
3
|
|
|
|
|
12
|
$slash = 'div'; |
4740
|
|
|
|
|
|
|
} |
4741
|
|
|
|
|
|
|
|
4742
|
|
|
|
|
|
|
# variable or function |
4743
|
|
|
|
|
|
|
# $ @ % & * $ # |
4744
|
|
|
|
|
|
|
elsif ($string =~ /\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) { |
4745
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4746
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4747
|
|
|
|
|
|
|
} |
4748
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
4749
|
|
|
|
|
|
|
# $ @ # \ ' " / ? ( ) [ ] < > |
4750
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
4751
|
0
|
|
|
|
|
0
|
$e_string .= $1; |
4752
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
4753
|
|
|
|
|
|
|
} |
4754
|
|
|
|
|
|
|
|
4755
|
|
|
|
|
|
|
# subroutines of package Eeuctw |
4756
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4757
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4758
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b EUCTW::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4759
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4760
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b EUCTW::eval \b /oxgc) { $e_string .= 'eval EUCTW::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4761
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4762
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Eeuctw::chop'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4763
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4764
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4765
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b EUCTW::index \b /oxgc) { $e_string .= 'EUCTW::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4766
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Eeuctw::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4767
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4768
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4769
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b EUCTW::rindex \b /oxgc) { $e_string .= 'EUCTW::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4770
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Eeuctw::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4771
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::lc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4772
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::lcfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4773
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::uc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4774
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::ucfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4775
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::fc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4776
|
|
|
|
|
|
|
|
4777
|
|
|
|
|
|
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
4778
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4779
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4780
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4781
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4782
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4783
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4784
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4785
|
|
|
|
|
|
|
|
4786
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4787
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4788
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4789
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4790
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4791
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4792
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4793
|
|
|
|
|
|
|
|
4794
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc) |
4795
|
0
|
|
|
|
|
0
|
{ $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4796
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4797
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4798
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4799
|
|
|
|
|
|
|
|
4800
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4801
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4802
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4803
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
4804
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
4805
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Eeuctw::glob'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4806
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Eeuctw::lc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4807
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Eeuctw::lcfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4808
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Eeuctw::uc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4809
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Eeuctw::ucfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4810
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Eeuctw::fc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4811
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4812
|
|
|
|
|
|
|
|
4813
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4814
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4815
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Eeuctw::chr_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4816
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
4817
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
4818
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Eeuctw::glob_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4819
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4820
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
4821
|
|
|
|
|
|
|
# split |
4822
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
4823
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
4824
|
|
|
|
|
|
|
|
4825
|
0
|
|
|
|
|
0
|
my $e = ''; |
4826
|
0
|
|
|
|
|
0
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
4827
|
0
|
|
|
|
|
0
|
$e .= $1; |
4828
|
|
|
|
|
|
|
} |
4829
|
|
|
|
|
|
|
|
4830
|
|
|
|
|
|
|
# end of split |
4831
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Eeuctw::split' . $e; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4832
|
|
|
|
|
|
|
|
4833
|
|
|
|
|
|
|
# split scalar value |
4834
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Eeuctw::split' . $e . e_string($1); next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4835
|
|
|
|
|
|
|
|
4836
|
|
|
|
|
|
|
# split literal space |
4837
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4838
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4839
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4840
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4841
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4842
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4843
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4844
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4845
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4846
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4847
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4848
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4849
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {' '}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4850
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Eeuctw::split' . $e . qq {" "}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
4851
|
|
|
|
|
|
|
|
4852
|
|
|
|
|
|
|
# split qq// |
4853
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
4854
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4855
|
|
|
|
|
|
|
else { |
4856
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4857
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4858
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
4859
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
4860
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
4861
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
4862
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { } |
|
0
|
|
|
|
|
0
|
|
4863
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * * |
|
0
|
|
|
|
|
0
|
|
4864
|
|
|
|
|
|
|
} |
4865
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4866
|
|
|
|
|
|
|
} |
4867
|
|
|
|
|
|
|
} |
4868
|
|
|
|
|
|
|
|
4869
|
|
|
|
|
|
|
# split qr// |
4870
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qr) \b /oxgc) { |
4871
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # qr# # |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4872
|
|
|
|
|
|
|
else { |
4873
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4874
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4875
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ( ) |
|
0
|
|
|
|
|
0
|
|
4876
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr { } |
|
0
|
|
|
|
|
0
|
|
4877
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr [ ] |
|
0
|
|
|
|
|
0
|
|
4878
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr < > |
|
0
|
|
|
|
|
0
|
|
4879
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' ' |
|
0
|
|
|
|
|
0
|
|
4880
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { } |
|
0
|
|
|
|
|
0
|
|
4881
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr * * |
|
0
|
|
|
|
|
0
|
|
4882
|
|
|
|
|
|
|
} |
4883
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4884
|
|
|
|
|
|
|
} |
4885
|
|
|
|
|
|
|
} |
4886
|
|
|
|
|
|
|
|
4887
|
|
|
|
|
|
|
# split q// |
4888
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
4889
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4890
|
|
|
|
|
|
|
else { |
4891
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4892
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4893
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
4894
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
4895
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
4896
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
4897
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { } |
|
0
|
|
|
|
|
0
|
|
4898
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q * * --> qr * * |
|
0
|
|
|
|
|
0
|
|
4899
|
|
|
|
|
|
|
} |
4900
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4901
|
|
|
|
|
|
|
} |
4902
|
|
|
|
|
|
|
} |
4903
|
|
|
|
|
|
|
|
4904
|
|
|
|
|
|
|
# split m// |
4905
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (m) \b /oxgc) { |
4906
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # m# # --> qr # # |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4907
|
|
|
|
|
|
|
else { |
4908
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4909
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4910
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
4911
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
4912
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
4913
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
4914
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ' ' --> qr ' ' |
|
0
|
|
|
|
|
0
|
|
4915
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { } |
|
0
|
|
|
|
|
0
|
|
4916
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m * * --> qr * * |
|
0
|
|
|
|
|
0
|
|
4917
|
|
|
|
|
|
|
} |
4918
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
4919
|
|
|
|
|
|
|
} |
4920
|
|
|
|
|
|
|
} |
4921
|
|
|
|
|
|
|
|
4922
|
|
|
|
|
|
|
# split '' |
4923
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') /oxgc) { |
4924
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
4925
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4926
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4927
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
4928
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' ' |
|
0
|
|
|
|
|
0
|
|
4929
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
4930
|
|
|
|
|
|
|
} |
4931
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4932
|
|
|
|
|
|
|
} |
4933
|
|
|
|
|
|
|
|
4934
|
|
|
|
|
|
|
# split "" |
4935
|
|
|
|
|
|
|
elsif ($string =~ /\G (\") /oxgc) { |
4936
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
4937
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4938
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4939
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
4940
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " " |
|
0
|
|
|
|
|
0
|
|
4941
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
4942
|
|
|
|
|
|
|
} |
4943
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4944
|
|
|
|
|
|
|
} |
4945
|
|
|
|
|
|
|
|
4946
|
|
|
|
|
|
|
# split // |
4947
|
|
|
|
|
|
|
elsif ($string =~ /\G (\/) /oxgc) { |
4948
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
4949
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4950
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4951
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
4952
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / / |
|
0
|
|
|
|
|
0
|
|
4953
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; } |
4954
|
|
|
|
|
|
|
} |
4955
|
0
|
|
|
|
|
0
|
die __FILE__, ": Search pattern not terminated\n"; |
4956
|
|
|
|
|
|
|
} |
4957
|
|
|
|
|
|
|
} |
4958
|
|
|
|
|
|
|
|
4959
|
|
|
|
|
|
|
# qq// |
4960
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
4961
|
0
|
|
|
|
|
0
|
my $ope = $1; |
4962
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# # |
4963
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
4964
|
|
|
|
|
|
|
} |
4965
|
|
|
|
|
|
|
else { |
4966
|
0
|
|
|
|
|
0
|
my $e = ''; |
4967
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4968
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4969
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( ) |
|
0
|
|
|
|
|
0
|
|
4970
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { } |
|
0
|
|
|
|
|
0
|
|
4971
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ] |
|
0
|
|
|
|
|
0
|
|
4972
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < > |
|
0
|
|
|
|
|
0
|
|
4973
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * * |
|
0
|
|
|
|
|
0
|
|
4974
|
|
|
|
|
|
|
} |
4975
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4976
|
|
|
|
|
|
|
} |
4977
|
|
|
|
|
|
|
} |
4978
|
|
|
|
|
|
|
|
4979
|
|
|
|
|
|
|
# qx// |
4980
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qx) \b /oxgc) { |
4981
|
0
|
|
|
|
|
0
|
my $ope = $1; |
4982
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
4983
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
4984
|
|
|
|
|
|
|
} |
4985
|
|
|
|
|
|
|
else { |
4986
|
0
|
|
|
|
|
0
|
my $e = ''; |
4987
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
4988
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4989
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( ) |
|
0
|
|
|
|
|
0
|
|
4990
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { } |
|
0
|
|
|
|
|
0
|
|
4991
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ] |
|
0
|
|
|
|
|
0
|
|
4992
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < > |
|
0
|
|
|
|
|
0
|
|
4993
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' ' |
|
0
|
|
|
|
|
0
|
|
4994
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * * |
|
0
|
|
|
|
|
0
|
|
4995
|
|
|
|
|
|
|
} |
4996
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
4997
|
|
|
|
|
|
|
} |
4998
|
|
|
|
|
|
|
} |
4999
|
|
|
|
|
|
|
|
5000
|
|
|
|
|
|
|
# q// |
5001
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
5002
|
0
|
|
|
|
|
0
|
my $ope = $1; |
5003
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# # |
5004
|
0
|
|
|
|
|
0
|
$e_string .= e_q($ope,$1,$3,$2); |
5005
|
|
|
|
|
|
|
} |
5006
|
|
|
|
|
|
|
else { |
5007
|
0
|
|
|
|
|
0
|
my $e = ''; |
5008
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
5009
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5010
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( ) |
|
0
|
|
|
|
|
0
|
|
5011
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { } |
|
0
|
|
|
|
|
0
|
|
5012
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ] |
|
0
|
|
|
|
|
0
|
|
5013
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < > |
|
0
|
|
|
|
|
0
|
|
5014
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * * |
|
0
|
|
|
|
|
0
|
|
5015
|
|
|
|
|
|
|
} |
5016
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
5017
|
|
|
|
|
|
|
} |
5018
|
|
|
|
|
|
|
} |
5019
|
|
|
|
|
|
|
|
5020
|
|
|
|
|
|
|
# '' |
5021
|
12
|
|
|
|
|
34
|
elsif ($string =~ /\G (?
|
5022
|
|
|
|
|
|
|
|
5023
|
|
|
|
|
|
|
# "" |
5024
|
6
|
|
|
|
|
19
|
elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
5025
|
|
|
|
|
|
|
|
5026
|
|
|
|
|
|
|
# `` |
5027
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
5028
|
|
|
|
|
|
|
|
5029
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
5030
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; } |
5031
|
|
|
|
|
|
|
|
5032
|
|
|
|
|
|
|
# <<= <=> <= < operator |
5033
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; } |
5034
|
|
|
|
|
|
|
|
5035
|
|
|
|
|
|
|
# |
5036
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; } |
5037
|
|
|
|
|
|
|
|
5038
|
|
|
|
|
|
|
# --- glob |
5039
|
|
|
|
|
|
|
elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) { |
5040
|
0
|
|
|
|
|
0
|
$e_string .= 'Eeuctw::glob("' . $1 . '")'; |
5041
|
|
|
|
|
|
|
} |
5042
|
|
|
|
|
|
|
|
5043
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
5044
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
5045
|
|
|
|
|
|
|
|
5046
|
|
|
|
|
|
|
# <<'HEREDOC' |
5047
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
5048
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
5049
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
5050
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
5051
|
|
|
|
|
|
|
|
5052
|
|
|
|
|
|
|
# get here document |
5053
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
5054
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
5055
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
5056
|
|
|
|
|
|
|
} |
5057
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
5058
|
0
|
|
|
|
|
0
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
5059
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
5060
|
|
|
|
|
|
|
} |
5061
|
|
|
|
|
|
|
else { |
5062
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
5063
|
|
|
|
|
|
|
} |
5064
|
0
|
|
|
|
|
0
|
$e_string .= $here_quote; |
5065
|
|
|
|
|
|
|
} |
5066
|
|
|
|
|
|
|
|
5067
|
|
|
|
|
|
|
# <<\HEREDOC |
5068
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
5069
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
5070
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
5071
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
5072
|
|
|
|
|
|
|
|
5073
|
|
|
|
|
|
|
# get here document |
5074
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
5075
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
5076
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
5077
|
|
|
|
|
|
|
} |
5078
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
5079
|
0
|
|
|
|
|
0
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
5080
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
5081
|
|
|
|
|
|
|
} |
5082
|
|
|
|
|
|
|
else { |
5083
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
5084
|
|
|
|
|
|
|
} |
5085
|
0
|
|
|
|
|
0
|
$e_string .= $here_quote; |
5086
|
|
|
|
|
|
|
} |
5087
|
|
|
|
|
|
|
|
5088
|
|
|
|
|
|
|
# <<"HEREDOC" |
5089
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
5090
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
5091
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
5092
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
5093
|
|
|
|
|
|
|
|
5094
|
|
|
|
|
|
|
# get here document |
5095
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
5096
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
5097
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
5098
|
|
|
|
|
|
|
} |
5099
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
5100
|
0
|
|
|
|
|
0
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
5101
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
5102
|
|
|
|
|
|
|
} |
5103
|
|
|
|
|
|
|
else { |
5104
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
5105
|
|
|
|
|
|
|
} |
5106
|
0
|
|
|
|
|
0
|
$e_string .= $here_quote; |
5107
|
|
|
|
|
|
|
} |
5108
|
|
|
|
|
|
|
|
5109
|
|
|
|
|
|
|
# <
|
5110
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
5111
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
5112
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
5113
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
5114
|
|
|
|
|
|
|
|
5115
|
|
|
|
|
|
|
# get here document |
5116
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
5117
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
5118
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
5119
|
|
|
|
|
|
|
} |
5120
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
5121
|
0
|
|
|
|
|
0
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
5122
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
5123
|
|
|
|
|
|
|
} |
5124
|
|
|
|
|
|
|
else { |
5125
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
5126
|
|
|
|
|
|
|
} |
5127
|
0
|
|
|
|
|
0
|
$e_string .= $here_quote; |
5128
|
|
|
|
|
|
|
} |
5129
|
|
|
|
|
|
|
|
5130
|
|
|
|
|
|
|
# <<`HEREDOC` |
5131
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
5132
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
5133
|
0
|
|
|
|
|
0
|
my $here_quote = $1; |
5134
|
0
|
|
|
|
|
0
|
my $delimiter = $2; |
5135
|
|
|
|
|
|
|
|
5136
|
|
|
|
|
|
|
# get here document |
5137
|
0
|
0
|
|
|
|
0
|
if ($here_script eq '') { |
5138
|
0
|
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
5139
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
5140
|
|
|
|
|
|
|
} |
5141
|
0
|
0
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
5142
|
0
|
|
|
|
|
0
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
5143
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
5144
|
|
|
|
|
|
|
} |
5145
|
|
|
|
|
|
|
else { |
5146
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
5147
|
|
|
|
|
|
|
} |
5148
|
0
|
|
|
|
|
0
|
$e_string .= $here_quote; |
5149
|
|
|
|
|
|
|
} |
5150
|
|
|
|
|
|
|
|
5151
|
|
|
|
|
|
|
# any operator before div |
5152
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
5153
|
|
|
|
|
|
|
-- | \+\+ | |
5154
|
|
|
|
|
|
|
[\)\}\]] |
5155
|
|
|
|
|
|
|
|
5156
|
39
|
|
|
|
|
44
|
) /oxgc) { $slash = 'div'; $e_string .= $1; } |
|
39
|
|
|
|
|
105
|
|
5157
|
|
|
|
|
|
|
|
5158
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
5159
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
5160
|
|
|
|
|
|
|
\.\.\. |
5161
|
|
|
|
|
|
|
|
5162
|
0
|
|
|
|
|
0
|
) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; } |
|
0
|
|
|
|
|
0
|
|
5163
|
|
|
|
|
|
|
|
5164
|
|
|
|
|
|
|
# any operator before m// |
5165
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?> |
5166
|
|
|
|
|
|
|
|
5167
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
5168
|
|
|
|
|
|
|
%= | % | |
5169
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
5170
|
|
|
|
|
|
|
-= | -> | - | |
5171
|
|
|
|
|
|
|
:(?>\s*)= | |
5172
|
|
|
|
|
|
|
: | |
5173
|
|
|
|
|
|
|
<<>> | |
5174
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
5175
|
|
|
|
|
|
|
== | => | =~ | = | |
5176
|
|
|
|
|
|
|
>>= | >> | >= | > | |
5177
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
5178
|
|
|
|
|
|
|
\+= | \+ | |
5179
|
|
|
|
|
|
|
\.\. | \.= | \. | |
5180
|
|
|
|
|
|
|
\/\/= | \/\/ | |
5181
|
|
|
|
|
|
|
\/= | \/ | |
5182
|
|
|
|
|
|
|
\? | |
5183
|
|
|
|
|
|
|
\\ | |
5184
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
5185
|
|
|
|
|
|
|
\b x= | |
5186
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
5187
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
5188
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
5189
|
|
|
|
|
|
|
\b(?: print )\b | |
5190
|
|
|
|
|
|
|
|
5191
|
|
|
|
|
|
|
[,;\(\{\[] |
5192
|
|
|
|
|
|
|
|
5193
|
49
|
|
|
|
|
61
|
)) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
|
49
|
|
|
|
|
133
|
|
5194
|
|
|
|
|
|
|
|
5195
|
|
|
|
|
|
|
# other any character |
5196
|
179
|
|
|
|
|
544
|
elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; } |
5197
|
|
|
|
|
|
|
|
5198
|
|
|
|
|
|
|
# system error |
5199
|
|
|
|
|
|
|
else { |
5200
|
0
|
|
|
|
|
0
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
5201
|
|
|
|
|
|
|
} |
5202
|
|
|
|
|
|
|
} |
5203
|
|
|
|
|
|
|
|
5204
|
38
|
|
|
|
|
110
|
return $e_string; |
5205
|
|
|
|
|
|
|
} |
5206
|
|
|
|
|
|
|
|
5207
|
|
|
|
|
|
|
# |
5208
|
|
|
|
|
|
|
# character class |
5209
|
|
|
|
|
|
|
# |
5210
|
|
|
|
|
|
|
sub character_class { |
5211
|
3060
|
|
|
3060
|
0
|
3213
|
my($char,$modifier) = @_; |
5212
|
|
|
|
|
|
|
|
5213
|
3060
|
100
|
|
|
|
3739
|
if ($char eq '.') { |
5214
|
115
|
100
|
|
|
|
296
|
if ($modifier =~ /s/) { |
5215
|
23
|
|
|
|
|
54
|
return '${Eeuctw::dot_s}'; |
5216
|
|
|
|
|
|
|
} |
5217
|
|
|
|
|
|
|
else { |
5218
|
92
|
|
|
|
|
168
|
return '${Eeuctw::dot}'; |
5219
|
|
|
|
|
|
|
} |
5220
|
|
|
|
|
|
|
} |
5221
|
|
|
|
|
|
|
else { |
5222
|
2945
|
|
|
|
|
4044
|
return Eeuctw::classic_character_class($char); |
5223
|
|
|
|
|
|
|
} |
5224
|
|
|
|
|
|
|
} |
5225
|
|
|
|
|
|
|
|
5226
|
|
|
|
|
|
|
# |
5227
|
|
|
|
|
|
|
# escape capture ($1, $2, $3, ...) |
5228
|
|
|
|
|
|
|
# |
5229
|
|
|
|
|
|
|
sub e_capture { |
5230
|
|
|
|
|
|
|
|
5231
|
547
|
|
|
547
|
0
|
2144
|
return join '', '${Eeuctw::capture(', $_[0], ')}'; |
5232
|
0
|
|
|
|
|
0
|
return join '', '${', $_[0], '}'; |
5233
|
|
|
|
|
|
|
} |
5234
|
|
|
|
|
|
|
|
5235
|
|
|
|
|
|
|
# |
5236
|
|
|
|
|
|
|
# escape transliteration (tr/// or y///) |
5237
|
|
|
|
|
|
|
# |
5238
|
|
|
|
|
|
|
sub e_tr { |
5239
|
11
|
|
|
11
|
0
|
25
|
my($variable,$charclass,$e,$charclass2,$modifier) = @_; |
5240
|
11
|
|
|
|
|
37
|
my $e_tr = ''; |
5241
|
11
|
|
100
|
|
|
28
|
$modifier ||= ''; |
5242
|
|
|
|
|
|
|
|
5243
|
11
|
|
|
|
|
12
|
$slash = 'div'; |
5244
|
|
|
|
|
|
|
|
5245
|
|
|
|
|
|
|
# quote character class 1 |
5246
|
11
|
|
|
|
|
19
|
$charclass = q_tr($charclass); |
5247
|
|
|
|
|
|
|
|
5248
|
|
|
|
|
|
|
# quote character class 2 |
5249
|
11
|
|
|
|
|
14
|
$charclass2 = q_tr($charclass2); |
5250
|
|
|
|
|
|
|
|
5251
|
|
|
|
|
|
|
# /b /B modifier |
5252
|
11
|
50
|
|
|
|
25
|
if ($modifier =~ tr/bB//d) { |
5253
|
0
|
0
|
|
|
|
0
|
if ($variable eq '') { |
5254
|
0
|
|
|
|
|
0
|
$e_tr = qq{tr$charclass$e$charclass2$modifier}; |
5255
|
|
|
|
|
|
|
} |
5256
|
|
|
|
|
|
|
else { |
5257
|
0
|
|
|
|
|
0
|
$e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier}; |
5258
|
|
|
|
|
|
|
} |
5259
|
|
|
|
|
|
|
} |
5260
|
|
|
|
|
|
|
else { |
5261
|
11
|
100
|
|
|
|
19
|
if ($variable eq '') { |
5262
|
2
|
|
|
|
|
6
|
$e_tr = qq{Eeuctw::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}; |
5263
|
|
|
|
|
|
|
} |
5264
|
|
|
|
|
|
|
else { |
5265
|
9
|
|
|
|
|
24
|
$e_tr = qq{Eeuctw::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}; |
5266
|
|
|
|
|
|
|
} |
5267
|
|
|
|
|
|
|
} |
5268
|
|
|
|
|
|
|
|
5269
|
|
|
|
|
|
|
# clear tr/// variable |
5270
|
11
|
|
|
|
|
9
|
$tr_variable = ''; |
5271
|
11
|
|
|
|
|
10
|
$bind_operator = ''; |
5272
|
|
|
|
|
|
|
|
5273
|
11
|
|
|
|
|
57
|
return $e_tr; |
5274
|
|
|
|
|
|
|
} |
5275
|
|
|
|
|
|
|
|
5276
|
|
|
|
|
|
|
# |
5277
|
|
|
|
|
|
|
# quote for escape transliteration (tr/// or y///) |
5278
|
|
|
|
|
|
|
# |
5279
|
|
|
|
|
|
|
sub q_tr { |
5280
|
22
|
|
|
22
|
0
|
20
|
my($charclass) = @_; |
5281
|
|
|
|
|
|
|
|
5282
|
|
|
|
|
|
|
# quote character class |
5283
|
22
|
50
|
|
|
|
33
|
if ($charclass !~ /'/oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5284
|
22
|
|
|
|
|
25
|
return e_q('', "'", "'", $charclass); # --> q' ' |
5285
|
|
|
|
|
|
|
} |
5286
|
|
|
|
|
|
|
elsif ($charclass !~ /\//oxms) { |
5287
|
0
|
|
|
|
|
0
|
return e_q('q', '/', '/', $charclass); # --> q/ / |
5288
|
|
|
|
|
|
|
} |
5289
|
|
|
|
|
|
|
elsif ($charclass !~ /\#/oxms) { |
5290
|
0
|
|
|
|
|
0
|
return e_q('q', '#', '#', $charclass); # --> q# # |
5291
|
|
|
|
|
|
|
} |
5292
|
|
|
|
|
|
|
elsif ($charclass !~ /[\<\>]/oxms) { |
5293
|
0
|
|
|
|
|
0
|
return e_q('q', '<', '>', $charclass); # --> q< > |
5294
|
|
|
|
|
|
|
} |
5295
|
|
|
|
|
|
|
elsif ($charclass !~ /[\(\)]/oxms) { |
5296
|
0
|
|
|
|
|
0
|
return e_q('q', '(', ')', $charclass); # --> q( ) |
5297
|
|
|
|
|
|
|
} |
5298
|
|
|
|
|
|
|
elsif ($charclass !~ /[\{\}]/oxms) { |
5299
|
0
|
|
|
|
|
0
|
return e_q('q', '{', '}', $charclass); # --> q{ } |
5300
|
|
|
|
|
|
|
} |
5301
|
|
|
|
|
|
|
else { |
5302
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
5303
|
0
|
0
|
|
|
|
0
|
if ($charclass !~ /\Q$char\E/xms) { |
5304
|
0
|
|
|
|
|
0
|
return e_q('q', $char, $char, $charclass); |
5305
|
|
|
|
|
|
|
} |
5306
|
|
|
|
|
|
|
} |
5307
|
|
|
|
|
|
|
} |
5308
|
|
|
|
|
|
|
|
5309
|
0
|
|
|
|
|
0
|
return e_q('q', '{', '}', $charclass); |
5310
|
|
|
|
|
|
|
} |
5311
|
|
|
|
|
|
|
|
5312
|
|
|
|
|
|
|
# |
5313
|
|
|
|
|
|
|
# escape q string (q//, '') |
5314
|
|
|
|
|
|
|
# |
5315
|
|
|
|
|
|
|
sub e_q { |
5316
|
2262
|
|
|
2262
|
0
|
3659
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
5317
|
|
|
|
|
|
|
|
5318
|
2262
|
|
|
|
|
2352
|
$slash = 'div'; |
5319
|
|
|
|
|
|
|
|
5320
|
2262
|
|
|
|
|
10169
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
5321
|
|
|
|
|
|
|
} |
5322
|
|
|
|
|
|
|
|
5323
|
|
|
|
|
|
|
# |
5324
|
|
|
|
|
|
|
# escape qq string (qq//, "", qx//, ``) |
5325
|
|
|
|
|
|
|
# |
5326
|
|
|
|
|
|
|
sub e_qq { |
5327
|
6923
|
|
|
6923
|
0
|
10703
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
5328
|
|
|
|
|
|
|
|
5329
|
6923
|
|
|
|
|
6682
|
$slash = 'div'; |
5330
|
|
|
|
|
|
|
|
5331
|
6923
|
|
|
|
|
5740
|
my $left_e = 0; |
5332
|
6923
|
|
|
|
|
5224
|
my $right_e = 0; |
5333
|
|
|
|
|
|
|
|
5334
|
|
|
|
|
|
|
# split regexp |
5335
|
6923
|
|
|
|
|
257320
|
my @char = $string =~ /\G((?> |
5336
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\$]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
5337
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
5338
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
5339
|
|
|
|
|
|
|
\\N\{ (?>[^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} | |
5340
|
|
|
|
|
|
|
\\ $q_char | |
5341
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
5342
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
5343
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
5344
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
5345
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
5346
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
5347
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
5348
|
|
|
|
|
|
|
$q_char |
5349
|
|
|
|
|
|
|
))/oxmsg; |
5350
|
|
|
|
|
|
|
|
5351
|
6923
|
|
|
|
|
23839
|
for (my $i=0; $i <= $#char; $i++) { |
5352
|
|
|
|
|
|
|
|
5353
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
5354
|
215374
|
50
|
66
|
|
|
775859
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5355
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5356
|
|
|
|
|
|
|
} |
5357
|
|
|
|
|
|
|
|
5358
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
5359
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
5360
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5361
|
|
|
|
|
|
|
} |
5362
|
|
|
|
|
|
|
|
5363
|
|
|
|
|
|
|
# octal escape sequence |
5364
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
5365
|
1
|
|
|
|
|
3
|
$char[$i] = Eeuctw::octchr($1); |
5366
|
|
|
|
|
|
|
} |
5367
|
|
|
|
|
|
|
|
5368
|
|
|
|
|
|
|
# hexadecimal escape sequence |
5369
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
5370
|
1
|
|
|
|
|
5
|
$char[$i] = Eeuctw::hexchr($1); |
5371
|
|
|
|
|
|
|
} |
5372
|
|
|
|
|
|
|
|
5373
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
5374
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
5375
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
5376
|
|
|
|
|
|
|
} |
5377
|
|
|
|
|
|
|
|
5378
|
215374
|
100
|
|
|
|
2085514
|
if (0) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5379
|
|
|
|
|
|
|
} |
5380
|
|
|
|
|
|
|
|
5381
|
|
|
|
|
|
|
# \F |
5382
|
|
|
|
|
|
|
# |
5383
|
|
|
|
|
|
|
# P.69 Table 2-6. Translation escapes |
5384
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
5385
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5386
|
|
|
|
|
|
|
# (and so on) |
5387
|
|
|
|
|
|
|
|
5388
|
|
|
|
|
|
|
# \u \l \U \L \F \Q \E |
5389
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
5390
|
602
|
50
|
|
|
|
1291
|
if ($right_e < $left_e) { |
5391
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
5392
|
|
|
|
|
|
|
} |
5393
|
|
|
|
|
|
|
} |
5394
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
5395
|
|
|
|
|
|
|
|
5396
|
|
|
|
|
|
|
# "STRING @{[ LIST EXPR ]} MORE STRING" |
5397
|
|
|
|
|
|
|
|
5398
|
|
|
|
|
|
|
# P.257 Other Tricks You Can Do with Hard References |
5399
|
|
|
|
|
|
|
# in Chapter 8: References |
5400
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5401
|
|
|
|
|
|
|
|
5402
|
|
|
|
|
|
|
# P.353 Other Tricks You Can Do with Hard References |
5403
|
|
|
|
|
|
|
# in Chapter 8: References |
5404
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5405
|
|
|
|
|
|
|
|
5406
|
|
|
|
|
|
|
# (and so on) |
5407
|
|
|
|
|
|
|
|
5408
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ucfirst qq<'; |
5409
|
0
|
|
|
|
|
0
|
$left_e++; |
5410
|
|
|
|
|
|
|
} |
5411
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
5412
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lcfirst qq<'; |
5413
|
0
|
|
|
|
|
0
|
$left_e++; |
5414
|
|
|
|
|
|
|
} |
5415
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
5416
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::uc qq<'; |
5417
|
0
|
|
|
|
|
0
|
$left_e++; |
5418
|
|
|
|
|
|
|
} |
5419
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
5420
|
6
|
|
|
|
|
8
|
$char[$i] = '@{[Eeuctw::lc qq<'; |
5421
|
6
|
|
|
|
|
16
|
$left_e++; |
5422
|
|
|
|
|
|
|
} |
5423
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
5424
|
9
|
|
|
|
|
9
|
$char[$i] = '@{[Eeuctw::fc qq<'; |
5425
|
9
|
|
|
|
|
15
|
$left_e++; |
5426
|
|
|
|
|
|
|
} |
5427
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
5428
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
5429
|
0
|
|
|
|
|
0
|
$left_e++; |
5430
|
|
|
|
|
|
|
} |
5431
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
5432
|
12
|
50
|
|
|
|
19
|
if ($right_e < $left_e) { |
5433
|
12
|
|
|
|
|
10
|
$char[$i] = '>]}'; |
5434
|
12
|
|
|
|
|
19
|
$right_e++; |
5435
|
|
|
|
|
|
|
} |
5436
|
|
|
|
|
|
|
else { |
5437
|
0
|
|
|
|
|
0
|
$char[$i] = ''; |
5438
|
|
|
|
|
|
|
} |
5439
|
|
|
|
|
|
|
} |
5440
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
5441
|
0
|
|
|
|
|
0
|
while (1) { |
5442
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
5443
|
0
|
|
|
|
|
0
|
last; |
5444
|
|
|
|
|
|
|
} |
5445
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\E') { |
5446
|
0
|
|
|
|
|
0
|
last; |
5447
|
|
|
|
|
|
|
} |
5448
|
|
|
|
|
|
|
} |
5449
|
|
|
|
|
|
|
} |
5450
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
5451
|
|
|
|
|
|
|
} |
5452
|
|
|
|
|
|
|
|
5453
|
|
|
|
|
|
|
# $0 --> $0 |
5454
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
5455
|
|
|
|
|
|
|
} |
5456
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
5457
|
|
|
|
|
|
|
} |
5458
|
|
|
|
|
|
|
|
5459
|
|
|
|
|
|
|
# $$ --> $$ |
5460
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
5461
|
|
|
|
|
|
|
} |
5462
|
|
|
|
|
|
|
|
5463
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
5464
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
5465
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
5466
|
415
|
|
|
|
|
680
|
$char[$i] = e_capture($1); |
5467
|
|
|
|
|
|
|
} |
5468
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
5469
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5470
|
|
|
|
|
|
|
} |
5471
|
|
|
|
|
|
|
|
5472
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
5473
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
5474
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
5475
|
|
|
|
|
|
|
} |
5476
|
|
|
|
|
|
|
|
5477
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
5478
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
5479
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
5480
|
|
|
|
|
|
|
} |
5481
|
|
|
|
|
|
|
|
5482
|
|
|
|
|
|
|
# $$foo |
5483
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
5484
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5485
|
|
|
|
|
|
|
} |
5486
|
|
|
|
|
|
|
|
5487
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
5488
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
5489
|
44
|
|
|
|
|
105
|
$char[$i] = '@{[Eeuctw::PREMATCH()]}'; |
5490
|
|
|
|
|
|
|
} |
5491
|
|
|
|
|
|
|
|
5492
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
5493
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
5494
|
45
|
|
|
|
|
115
|
$char[$i] = '@{[Eeuctw::MATCH()]}'; |
5495
|
|
|
|
|
|
|
} |
5496
|
|
|
|
|
|
|
|
5497
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
5498
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
5499
|
33
|
|
|
|
|
85
|
$char[$i] = '@{[Eeuctw::POSTMATCH()]}'; |
5500
|
|
|
|
|
|
|
} |
5501
|
|
|
|
|
|
|
|
5502
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
5503
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
5504
|
|
|
|
|
|
|
} |
5505
|
|
|
|
|
|
|
|
5506
|
|
|
|
|
|
|
# ${ ... } |
5507
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
5508
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5509
|
|
|
|
|
|
|
} |
5510
|
|
|
|
|
|
|
} |
5511
|
|
|
|
|
|
|
|
5512
|
|
|
|
|
|
|
# return string |
5513
|
6923
|
100
|
|
|
|
10750
|
if ($left_e > $right_e) { |
5514
|
3
|
|
|
|
|
24
|
return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter; |
5515
|
|
|
|
|
|
|
} |
5516
|
6920
|
|
|
|
|
56609
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
5517
|
|
|
|
|
|
|
} |
5518
|
|
|
|
|
|
|
|
5519
|
|
|
|
|
|
|
# |
5520
|
|
|
|
|
|
|
# escape qw string (qw//) |
5521
|
|
|
|
|
|
|
# |
5522
|
|
|
|
|
|
|
sub e_qw { |
5523
|
34
|
|
|
34
|
0
|
98
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
5524
|
|
|
|
|
|
|
|
5525
|
34
|
|
|
|
|
40
|
$slash = 'div'; |
5526
|
|
|
|
|
|
|
|
5527
|
|
|
|
|
|
|
# choice again delimiter |
5528
|
34
|
|
|
|
|
273
|
my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg); |
|
621
|
|
|
|
|
684
|
|
5529
|
34
|
50
|
|
|
|
143
|
if (not $octet{$end_delimiter}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5530
|
34
|
|
|
|
|
192
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
5531
|
|
|
|
|
|
|
} |
5532
|
|
|
|
|
|
|
elsif (not $octet{')'}) { |
5533
|
0
|
|
|
|
|
0
|
return join '', $ope, '(', $string, ')'; |
5534
|
|
|
|
|
|
|
} |
5535
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
5536
|
0
|
|
|
|
|
0
|
return join '', $ope, '{', $string, '}'; |
5537
|
|
|
|
|
|
|
} |
5538
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
5539
|
0
|
|
|
|
|
0
|
return join '', $ope, '[', $string, ']'; |
5540
|
|
|
|
|
|
|
} |
5541
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
5542
|
0
|
|
|
|
|
0
|
return join '', $ope, '<', $string, '>'; |
5543
|
|
|
|
|
|
|
} |
5544
|
|
|
|
|
|
|
else { |
5545
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
5546
|
0
|
0
|
|
|
|
0
|
if (not $octet{$char}) { |
5547
|
0
|
|
|
|
|
0
|
return join '', $ope, $char, $string, $char; |
5548
|
|
|
|
|
|
|
} |
5549
|
|
|
|
|
|
|
} |
5550
|
|
|
|
|
|
|
} |
5551
|
|
|
|
|
|
|
|
5552
|
|
|
|
|
|
|
# qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC') |
5553
|
0
|
|
|
|
|
0
|
my @string = CORE::split(/\s+/, $string); |
5554
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
5555
|
0
|
|
|
|
|
0
|
my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
5556
|
0
|
|
|
|
|
0
|
for my $octet (@octet) { |
5557
|
0
|
0
|
|
|
|
0
|
if ($octet =~ /\A (['\\]) \z/oxms) { |
5558
|
0
|
|
|
|
|
0
|
$octet = '\\' . $1; |
5559
|
|
|
|
|
|
|
} |
5560
|
|
|
|
|
|
|
} |
5561
|
0
|
|
|
|
|
0
|
$string = join '', @octet; |
5562
|
|
|
|
|
|
|
} |
5563
|
0
|
|
|
|
|
0
|
return join '', '(', (join ', ', map { "'$_'" } @string), ')'; |
|
0
|
|
|
|
|
0
|
|
5564
|
|
|
|
|
|
|
} |
5565
|
|
|
|
|
|
|
|
5566
|
|
|
|
|
|
|
# |
5567
|
|
|
|
|
|
|
# escape here document (<<"HEREDOC", <
|
5568
|
|
|
|
|
|
|
# |
5569
|
|
|
|
|
|
|
sub e_heredoc { |
5570
|
93
|
|
|
93
|
0
|
594
|
my($string) = @_; |
5571
|
|
|
|
|
|
|
|
5572
|
93
|
|
|
|
|
111
|
$slash = 'm//'; |
5573
|
|
|
|
|
|
|
|
5574
|
93
|
|
|
|
|
288
|
my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC` |
5575
|
|
|
|
|
|
|
|
5576
|
93
|
|
|
|
|
105
|
my $left_e = 0; |
5577
|
93
|
|
|
|
|
345
|
my $right_e = 0; |
5578
|
|
|
|
|
|
|
|
5579
|
|
|
|
|
|
|
# split regexp |
5580
|
93
|
|
|
|
|
9858
|
my @char = $string =~ /\G((?> |
5581
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\$]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
5582
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
5583
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
5584
|
|
|
|
|
|
|
\\N\{ (?>[^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} | |
5585
|
|
|
|
|
|
|
\\ $q_char | |
5586
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
5587
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
5588
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
5589
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
5590
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
5591
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
5592
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
5593
|
|
|
|
|
|
|
$q_char |
5594
|
|
|
|
|
|
|
))/oxmsg; |
5595
|
|
|
|
|
|
|
|
5596
|
93
|
|
|
|
|
514
|
for (my $i=0; $i <= $#char; $i++) { |
5597
|
|
|
|
|
|
|
|
5598
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
5599
|
2970
|
50
|
66
|
|
|
11054
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5600
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5601
|
|
|
|
|
|
|
} |
5602
|
|
|
|
|
|
|
|
5603
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
5604
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
5605
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5606
|
|
|
|
|
|
|
} |
5607
|
|
|
|
|
|
|
|
5608
|
|
|
|
|
|
|
# octal escape sequence |
5609
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
5610
|
1
|
|
|
|
|
3
|
$char[$i] = Eeuctw::octchr($1); |
5611
|
|
|
|
|
|
|
} |
5612
|
|
|
|
|
|
|
|
5613
|
|
|
|
|
|
|
# hexadecimal escape sequence |
5614
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
5615
|
1
|
|
|
|
|
4
|
$char[$i] = Eeuctw::hexchr($1); |
5616
|
|
|
|
|
|
|
} |
5617
|
|
|
|
|
|
|
|
5618
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
5619
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
5620
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
5621
|
|
|
|
|
|
|
} |
5622
|
|
|
|
|
|
|
|
5623
|
2970
|
100
|
|
|
|
32098
|
if (0) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5624
|
|
|
|
|
|
|
} |
5625
|
|
|
|
|
|
|
|
5626
|
|
|
|
|
|
|
# \u \l \U \L \F \Q \E |
5627
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
5628
|
72
|
50
|
|
|
|
131
|
if ($right_e < $left_e) { |
5629
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
5630
|
|
|
|
|
|
|
} |
5631
|
|
|
|
|
|
|
} |
5632
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
5633
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ucfirst qq<'; |
5634
|
0
|
|
|
|
|
0
|
$left_e++; |
5635
|
|
|
|
|
|
|
} |
5636
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
5637
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lcfirst qq<'; |
5638
|
0
|
|
|
|
|
0
|
$left_e++; |
5639
|
|
|
|
|
|
|
} |
5640
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
5641
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::uc qq<'; |
5642
|
0
|
|
|
|
|
0
|
$left_e++; |
5643
|
|
|
|
|
|
|
} |
5644
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
5645
|
6
|
|
|
|
|
9
|
$char[$i] = '@{[Eeuctw::lc qq<'; |
5646
|
6
|
|
|
|
|
10
|
$left_e++; |
5647
|
|
|
|
|
|
|
} |
5648
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
5649
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::fc qq<'; |
5650
|
0
|
|
|
|
|
0
|
$left_e++; |
5651
|
|
|
|
|
|
|
} |
5652
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
5653
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
5654
|
0
|
|
|
|
|
0
|
$left_e++; |
5655
|
|
|
|
|
|
|
} |
5656
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
5657
|
3
|
50
|
|
|
|
7
|
if ($right_e < $left_e) { |
5658
|
3
|
|
|
|
|
3
|
$char[$i] = '>]}'; |
5659
|
3
|
|
|
|
|
5
|
$right_e++; |
5660
|
|
|
|
|
|
|
} |
5661
|
|
|
|
|
|
|
else { |
5662
|
0
|
|
|
|
|
0
|
$char[$i] = ''; |
5663
|
|
|
|
|
|
|
} |
5664
|
|
|
|
|
|
|
} |
5665
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
5666
|
0
|
|
|
|
|
0
|
while (1) { |
5667
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
5668
|
0
|
|
|
|
|
0
|
last; |
5669
|
|
|
|
|
|
|
} |
5670
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\E') { |
5671
|
0
|
|
|
|
|
0
|
last; |
5672
|
|
|
|
|
|
|
} |
5673
|
|
|
|
|
|
|
} |
5674
|
|
|
|
|
|
|
} |
5675
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
5676
|
|
|
|
|
|
|
} |
5677
|
|
|
|
|
|
|
|
5678
|
|
|
|
|
|
|
# $0 --> $0 |
5679
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
5680
|
|
|
|
|
|
|
} |
5681
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
5682
|
|
|
|
|
|
|
} |
5683
|
|
|
|
|
|
|
|
5684
|
|
|
|
|
|
|
# $$ --> $$ |
5685
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
5686
|
|
|
|
|
|
|
} |
5687
|
|
|
|
|
|
|
|
5688
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
5689
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
5690
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
5691
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5692
|
|
|
|
|
|
|
} |
5693
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
5694
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5695
|
|
|
|
|
|
|
} |
5696
|
|
|
|
|
|
|
|
5697
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
5698
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
5699
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
5700
|
|
|
|
|
|
|
} |
5701
|
|
|
|
|
|
|
|
5702
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
5703
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
5704
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
5705
|
|
|
|
|
|
|
} |
5706
|
|
|
|
|
|
|
|
5707
|
|
|
|
|
|
|
# $$foo |
5708
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
5709
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5710
|
|
|
|
|
|
|
} |
5711
|
|
|
|
|
|
|
|
5712
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
5713
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
5714
|
8
|
|
|
|
|
39
|
$char[$i] = '@{[Eeuctw::PREMATCH()]}'; |
5715
|
|
|
|
|
|
|
} |
5716
|
|
|
|
|
|
|
|
5717
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
5718
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
5719
|
8
|
|
|
|
|
46
|
$char[$i] = '@{[Eeuctw::MATCH()]}'; |
5720
|
|
|
|
|
|
|
} |
5721
|
|
|
|
|
|
|
|
5722
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
5723
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
5724
|
6
|
|
|
|
|
29
|
$char[$i] = '@{[Eeuctw::POSTMATCH()]}'; |
5725
|
|
|
|
|
|
|
} |
5726
|
|
|
|
|
|
|
|
5727
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
5728
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
5729
|
|
|
|
|
|
|
} |
5730
|
|
|
|
|
|
|
|
5731
|
|
|
|
|
|
|
# ${ ... } |
5732
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
5733
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
5734
|
|
|
|
|
|
|
} |
5735
|
|
|
|
|
|
|
} |
5736
|
|
|
|
|
|
|
|
5737
|
|
|
|
|
|
|
# return string |
5738
|
93
|
100
|
|
|
|
174
|
if ($left_e > $right_e) { |
5739
|
3
|
|
|
|
|
23
|
return join '', @char, '>]}' x ($left_e - $right_e); |
5740
|
|
|
|
|
|
|
} |
5741
|
90
|
|
|
|
|
724
|
return join '', @char; |
5742
|
|
|
|
|
|
|
} |
5743
|
|
|
|
|
|
|
|
5744
|
|
|
|
|
|
|
# |
5745
|
|
|
|
|
|
|
# escape regexp (m//, qr//) |
5746
|
|
|
|
|
|
|
# |
5747
|
|
|
|
|
|
|
sub e_qr { |
5748
|
1425
|
|
|
1425
|
0
|
3429
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
5749
|
1425
|
|
100
|
|
|
4106
|
$modifier ||= ''; |
5750
|
|
|
|
|
|
|
|
5751
|
1425
|
|
|
|
|
2095
|
$modifier =~ tr/p//d; |
5752
|
1425
|
50
|
|
|
|
3358
|
if ($modifier =~ /([adlu])/oxms) { |
5753
|
0
|
|
|
|
|
0
|
my $line = 0; |
5754
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
5755
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
5756
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
5757
|
0
|
|
|
|
|
0
|
last; |
5758
|
|
|
|
|
|
|
} |
5759
|
|
|
|
|
|
|
} |
5760
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
5761
|
|
|
|
|
|
|
} |
5762
|
|
|
|
|
|
|
|
5763
|
1425
|
|
|
|
|
1760
|
$slash = 'div'; |
5764
|
|
|
|
|
|
|
|
5765
|
|
|
|
|
|
|
# literal null string pattern |
5766
|
1425
|
100
|
|
|
|
4011
|
if ($string eq '') { |
|
|
100
|
|
|
|
|
|
5767
|
8
|
|
|
|
|
5
|
$modifier =~ tr/bB//d; |
5768
|
8
|
|
|
|
|
9
|
$modifier =~ tr/i//d; |
5769
|
8
|
|
|
|
|
33
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
5770
|
|
|
|
|
|
|
} |
5771
|
|
|
|
|
|
|
|
5772
|
|
|
|
|
|
|
# /b /B modifier |
5773
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
5774
|
|
|
|
|
|
|
|
5775
|
|
|
|
|
|
|
# choice again delimiter |
5776
|
60
|
50
|
|
|
|
177
|
if ($delimiter =~ / [\@:] /oxms) { |
5777
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
5778
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
|
0
|
|
|
|
|
0
|
|
5779
|
0
|
0
|
|
|
|
0
|
if (not $octet{')'}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5780
|
0
|
|
|
|
|
0
|
$delimiter = '('; |
5781
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
5782
|
|
|
|
|
|
|
} |
5783
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
5784
|
0
|
|
|
|
|
0
|
$delimiter = '{'; |
5785
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
5786
|
|
|
|
|
|
|
} |
5787
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
5788
|
0
|
|
|
|
|
0
|
$delimiter = '['; |
5789
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
5790
|
|
|
|
|
|
|
} |
5791
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
5792
|
0
|
|
|
|
|
0
|
$delimiter = '<'; |
5793
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
5794
|
|
|
|
|
|
|
} |
5795
|
|
|
|
|
|
|
else { |
5796
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
5797
|
0
|
0
|
|
|
|
0
|
if (not $octet{$char}) { |
5798
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
5799
|
0
|
|
|
|
|
0
|
$end_delimiter = $char; |
5800
|
0
|
|
|
|
|
0
|
last; |
5801
|
|
|
|
|
|
|
} |
5802
|
|
|
|
|
|
|
} |
5803
|
|
|
|
|
|
|
} |
5804
|
|
|
|
|
|
|
} |
5805
|
|
|
|
|
|
|
|
5806
|
60
|
100
|
100
|
|
|
338
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
5807
|
18
|
|
|
|
|
119
|
return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier; |
5808
|
|
|
|
|
|
|
} |
5809
|
|
|
|
|
|
|
else { |
5810
|
42
|
|
|
|
|
253
|
return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
5811
|
|
|
|
|
|
|
} |
5812
|
|
|
|
|
|
|
} |
5813
|
|
|
|
|
|
|
|
5814
|
1357
|
100
|
|
|
|
2711
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
5815
|
1357
|
|
|
|
|
4589
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
5816
|
|
|
|
|
|
|
|
5817
|
|
|
|
|
|
|
# split regexp |
5818
|
1357
|
|
|
|
|
121203
|
my @char = $string =~ /\G((?> |
5819
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\$\@\[\(]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
5820
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
5821
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
5822
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
5823
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
5824
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
5825
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} | |
5826
|
|
|
|
|
|
|
\\ $q_char | |
5827
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
5828
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
5829
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
5830
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
5831
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
5832
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
5833
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
5834
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
5835
|
|
|
|
|
|
|
\[\^ | |
5836
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
5837
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
5838
|
|
|
|
|
|
|
\(\? | |
5839
|
|
|
|
|
|
|
$q_char |
5840
|
|
|
|
|
|
|
))/oxmsg; |
5841
|
|
|
|
|
|
|
|
5842
|
|
|
|
|
|
|
# choice again delimiter |
5843
|
1357
|
50
|
|
|
|
6242
|
if ($delimiter =~ / [\@:] /oxms) { |
5844
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
|
0
|
|
|
|
|
0
|
|
5845
|
0
|
0
|
|
|
|
0
|
if (not $octet{')'}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5846
|
0
|
|
|
|
|
0
|
$delimiter = '('; |
5847
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
5848
|
|
|
|
|
|
|
} |
5849
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
5850
|
0
|
|
|
|
|
0
|
$delimiter = '{'; |
5851
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
5852
|
|
|
|
|
|
|
} |
5853
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
5854
|
0
|
|
|
|
|
0
|
$delimiter = '['; |
5855
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
5856
|
|
|
|
|
|
|
} |
5857
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
5858
|
0
|
|
|
|
|
0
|
$delimiter = '<'; |
5859
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
5860
|
|
|
|
|
|
|
} |
5861
|
|
|
|
|
|
|
else { |
5862
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
5863
|
0
|
0
|
|
|
|
0
|
if (not $octet{$char}) { |
5864
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
5865
|
0
|
|
|
|
|
0
|
$end_delimiter = $char; |
5866
|
0
|
|
|
|
|
0
|
last; |
5867
|
|
|
|
|
|
|
} |
5868
|
|
|
|
|
|
|
} |
5869
|
|
|
|
|
|
|
} |
5870
|
|
|
|
|
|
|
} |
5871
|
|
|
|
|
|
|
|
5872
|
1357
|
|
|
|
|
1542
|
my $left_e = 0; |
5873
|
1357
|
|
|
|
|
1333
|
my $right_e = 0; |
5874
|
1357
|
|
|
|
|
3494
|
for (my $i=0; $i <= $#char; $i++) { |
5875
|
|
|
|
|
|
|
|
5876
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
5877
|
3264
|
50
|
66
|
|
|
19242
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
5878
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5879
|
|
|
|
|
|
|
} |
5880
|
|
|
|
|
|
|
|
5881
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
5882
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
5883
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
5884
|
|
|
|
|
|
|
} |
5885
|
|
|
|
|
|
|
|
5886
|
|
|
|
|
|
|
# octal escape sequence |
5887
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
5888
|
1
|
|
|
|
|
2
|
$char[$i] = Eeuctw::octchr($1); |
5889
|
|
|
|
|
|
|
} |
5890
|
|
|
|
|
|
|
|
5891
|
|
|
|
|
|
|
# hexadecimal escape sequence |
5892
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
5893
|
1
|
|
|
|
|
6
|
$char[$i] = Eeuctw::hexchr($1); |
5894
|
|
|
|
|
|
|
} |
5895
|
|
|
|
|
|
|
|
5896
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
5897
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
5898
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
5899
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
5900
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
5901
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
5902
|
6
|
|
|
|
|
16
|
$char[$i] = $1 . '\\' . $2; |
5903
|
|
|
|
|
|
|
} |
5904
|
|
|
|
|
|
|
|
5905
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
5906
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
5907
|
4
|
|
|
|
|
8
|
$char[$i] = $1; |
5908
|
|
|
|
|
|
|
} |
5909
|
|
|
|
|
|
|
|
5910
|
3264
|
100
|
100
|
|
|
9422
|
if (0) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
5911
|
|
|
|
|
|
|
} |
5912
|
|
|
|
|
|
|
|
5913
|
|
|
|
|
|
|
# join separated multiple-octet |
5914
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
5915
|
6
|
50
|
33
|
|
|
98
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
5916
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
5917
|
|
|
|
|
|
|
} |
5918
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
5919
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
5920
|
|
|
|
|
|
|
} |
5921
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
5922
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 1; |
5923
|
|
|
|
|
|
|
} |
5924
|
|
|
|
|
|
|
} |
5925
|
|
|
|
|
|
|
|
5926
|
|
|
|
|
|
|
# open character class [...] |
5927
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
5928
|
586
|
|
|
|
|
653
|
my $left = $i; |
5929
|
|
|
|
|
|
|
|
5930
|
|
|
|
|
|
|
# [] make die "Unmatched [] in regexp ...\n" |
5931
|
|
|
|
|
|
|
# (and so on) |
5932
|
|
|
|
|
|
|
|
5933
|
586
|
100
|
|
|
|
1661
|
if ($char[$i+1] eq ']') { |
5934
|
3
|
|
|
|
|
3
|
$i++; |
5935
|
|
|
|
|
|
|
} |
5936
|
|
|
|
|
|
|
|
5937
|
586
|
|
|
|
|
570
|
while (1) { |
5938
|
2583
|
50
|
|
|
|
3276
|
if (++$i > $#char) { |
5939
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
5940
|
|
|
|
|
|
|
} |
5941
|
2583
|
100
|
|
|
|
3557
|
if ($char[$i] eq ']') { |
5942
|
586
|
|
|
|
|
579
|
my $right = $i; |
5943
|
|
|
|
|
|
|
|
5944
|
|
|
|
|
|
|
# [...] |
5945
|
586
|
100
|
|
|
|
3286
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
5946
|
90
|
|
|
|
|
166
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
270
|
|
|
|
|
319
|
|
5947
|
|
|
|
|
|
|
} |
5948
|
|
|
|
|
|
|
else { |
5949
|
496
|
|
|
|
|
1901
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
5950
|
|
|
|
|
|
|
} |
5951
|
|
|
|
|
|
|
|
5952
|
586
|
|
|
|
|
793
|
$i = $left; |
5953
|
586
|
|
|
|
|
1579
|
last; |
5954
|
|
|
|
|
|
|
} |
5955
|
|
|
|
|
|
|
} |
5956
|
|
|
|
|
|
|
} |
5957
|
|
|
|
|
|
|
|
5958
|
|
|
|
|
|
|
# open character class [^...] |
5959
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
5960
|
328
|
|
|
|
|
347
|
my $left = $i; |
5961
|
|
|
|
|
|
|
|
5962
|
|
|
|
|
|
|
# [^] make die "Unmatched [] in regexp ...\n" |
5963
|
|
|
|
|
|
|
# (and so on) |
5964
|
|
|
|
|
|
|
|
5965
|
328
|
100
|
|
|
|
883
|
if ($char[$i+1] eq ']') { |
5966
|
5
|
|
|
|
|
6
|
$i++; |
5967
|
|
|
|
|
|
|
} |
5968
|
|
|
|
|
|
|
|
5969
|
328
|
|
|
|
|
259
|
while (1) { |
5970
|
1447
|
50
|
|
|
|
1728
|
if (++$i > $#char) { |
5971
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
5972
|
|
|
|
|
|
|
} |
5973
|
1447
|
100
|
|
|
|
1965
|
if ($char[$i] eq ']') { |
5974
|
328
|
|
|
|
|
300
|
my $right = $i; |
5975
|
|
|
|
|
|
|
|
5976
|
|
|
|
|
|
|
# [^...] |
5977
|
328
|
100
|
|
|
|
1797
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
5978
|
90
|
|
|
|
|
176
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
270
|
|
|
|
|
352
|
|
5979
|
|
|
|
|
|
|
} |
5980
|
|
|
|
|
|
|
else { |
5981
|
238
|
|
|
|
|
828
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
5982
|
|
|
|
|
|
|
} |
5983
|
|
|
|
|
|
|
|
5984
|
328
|
|
|
|
|
427
|
$i = $left; |
5985
|
328
|
|
|
|
|
873
|
last; |
5986
|
|
|
|
|
|
|
} |
5987
|
|
|
|
|
|
|
} |
5988
|
|
|
|
|
|
|
} |
5989
|
|
|
|
|
|
|
|
5990
|
|
|
|
|
|
|
# rewrite character class or escape character |
5991
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
5992
|
215
|
|
|
|
|
692
|
$char[$i] = $char; |
5993
|
|
|
|
|
|
|
} |
5994
|
|
|
|
|
|
|
|
5995
|
|
|
|
|
|
|
# /i modifier |
5996
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
5997
|
54
|
50
|
|
|
|
105
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
5998
|
54
|
|
|
|
|
96
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
5999
|
|
|
|
|
|
|
} |
6000
|
|
|
|
|
|
|
else { |
6001
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
6002
|
|
|
|
|
|
|
} |
6003
|
|
|
|
|
|
|
} |
6004
|
|
|
|
|
|
|
|
6005
|
|
|
|
|
|
|
# \u \l \U \L \F \Q \E |
6006
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
6007
|
1
|
50
|
|
|
|
9
|
if ($right_e < $left_e) { |
6008
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
6009
|
|
|
|
|
|
|
} |
6010
|
|
|
|
|
|
|
} |
6011
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
6012
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ucfirst qq<'; |
6013
|
0
|
|
|
|
|
0
|
$left_e++; |
6014
|
|
|
|
|
|
|
} |
6015
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
6016
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lcfirst qq<'; |
6017
|
0
|
|
|
|
|
0
|
$left_e++; |
6018
|
|
|
|
|
|
|
} |
6019
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
6020
|
1
|
|
|
|
|
2
|
$char[$i] = '@{[Eeuctw::uc qq<'; |
6021
|
1
|
|
|
|
|
5
|
$left_e++; |
6022
|
|
|
|
|
|
|
} |
6023
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
6024
|
1
|
|
|
|
|
2
|
$char[$i] = '@{[Eeuctw::lc qq<'; |
6025
|
1
|
|
|
|
|
5
|
$left_e++; |
6026
|
|
|
|
|
|
|
} |
6027
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
6028
|
9
|
|
|
|
|
9
|
$char[$i] = '@{[Eeuctw::fc qq<'; |
6029
|
9
|
|
|
|
|
34
|
$left_e++; |
6030
|
|
|
|
|
|
|
} |
6031
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
6032
|
20
|
|
|
|
|
26
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
6033
|
20
|
|
|
|
|
75
|
$left_e++; |
6034
|
|
|
|
|
|
|
} |
6035
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
6036
|
31
|
50
|
|
|
|
50
|
if ($right_e < $left_e) { |
6037
|
31
|
|
|
|
|
32
|
$char[$i] = '>]}'; |
6038
|
31
|
|
|
|
|
105
|
$right_e++; |
6039
|
|
|
|
|
|
|
} |
6040
|
|
|
|
|
|
|
else { |
6041
|
0
|
|
|
|
|
0
|
$char[$i] = ''; |
6042
|
|
|
|
|
|
|
} |
6043
|
|
|
|
|
|
|
} |
6044
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
6045
|
0
|
|
|
|
|
0
|
while (1) { |
6046
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6047
|
0
|
|
|
|
|
0
|
last; |
6048
|
|
|
|
|
|
|
} |
6049
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\E') { |
6050
|
0
|
|
|
|
|
0
|
last; |
6051
|
|
|
|
|
|
|
} |
6052
|
|
|
|
|
|
|
} |
6053
|
|
|
|
|
|
|
} |
6054
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
6055
|
|
|
|
|
|
|
} |
6056
|
|
|
|
|
|
|
|
6057
|
|
|
|
|
|
|
# $0 --> $0 |
6058
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
6059
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6060
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6061
|
|
|
|
|
|
|
} |
6062
|
|
|
|
|
|
|
} |
6063
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
6064
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6065
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6066
|
|
|
|
|
|
|
} |
6067
|
|
|
|
|
|
|
} |
6068
|
|
|
|
|
|
|
|
6069
|
|
|
|
|
|
|
# $$ --> $$ |
6070
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
6071
|
|
|
|
|
|
|
} |
6072
|
|
|
|
|
|
|
|
6073
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6074
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6075
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
6076
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6077
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6078
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6079
|
|
|
|
|
|
|
} |
6080
|
|
|
|
|
|
|
} |
6081
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
6082
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6083
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6084
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6085
|
|
|
|
|
|
|
} |
6086
|
|
|
|
|
|
|
} |
6087
|
|
|
|
|
|
|
|
6088
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6089
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
6090
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
6091
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6092
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6093
|
|
|
|
|
|
|
} |
6094
|
|
|
|
|
|
|
} |
6095
|
|
|
|
|
|
|
|
6096
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
6097
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
6098
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
6099
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6100
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6101
|
|
|
|
|
|
|
} |
6102
|
|
|
|
|
|
|
} |
6103
|
|
|
|
|
|
|
|
6104
|
|
|
|
|
|
|
# $$foo |
6105
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
6106
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6107
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6108
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6109
|
|
|
|
|
|
|
} |
6110
|
|
|
|
|
|
|
} |
6111
|
|
|
|
|
|
|
|
6112
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
6113
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
6114
|
8
|
50
|
|
|
|
21
|
if ($ignorecase) { |
6115
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::PREMATCH())]}'; |
6116
|
|
|
|
|
|
|
} |
6117
|
|
|
|
|
|
|
else { |
6118
|
8
|
|
|
|
|
43
|
$char[$i] = '@{[Eeuctw::PREMATCH()]}'; |
6119
|
|
|
|
|
|
|
} |
6120
|
|
|
|
|
|
|
} |
6121
|
|
|
|
|
|
|
|
6122
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
6123
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
6124
|
8
|
50
|
|
|
|
17
|
if ($ignorecase) { |
6125
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::MATCH())]}'; |
6126
|
|
|
|
|
|
|
} |
6127
|
|
|
|
|
|
|
else { |
6128
|
8
|
|
|
|
|
35
|
$char[$i] = '@{[Eeuctw::MATCH()]}'; |
6129
|
|
|
|
|
|
|
} |
6130
|
|
|
|
|
|
|
} |
6131
|
|
|
|
|
|
|
|
6132
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
6133
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
6134
|
6
|
50
|
|
|
|
14
|
if ($ignorecase) { |
6135
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::POSTMATCH())]}'; |
6136
|
|
|
|
|
|
|
} |
6137
|
|
|
|
|
|
|
else { |
6138
|
6
|
|
|
|
|
27
|
$char[$i] = '@{[Eeuctw::POSTMATCH()]}'; |
6139
|
|
|
|
|
|
|
} |
6140
|
|
|
|
|
|
|
} |
6141
|
|
|
|
|
|
|
|
6142
|
|
|
|
|
|
|
# ${ foo } |
6143
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
6144
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6145
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6146
|
|
|
|
|
|
|
} |
6147
|
|
|
|
|
|
|
} |
6148
|
|
|
|
|
|
|
|
6149
|
|
|
|
|
|
|
# ${ ... } |
6150
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
6151
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6152
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6153
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6154
|
|
|
|
|
|
|
} |
6155
|
|
|
|
|
|
|
} |
6156
|
|
|
|
|
|
|
|
6157
|
|
|
|
|
|
|
# $scalar or @array |
6158
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
6159
|
29
|
|
|
|
|
83
|
$char[$i] = e_string($char[$i]); |
6160
|
29
|
100
|
|
|
|
188
|
if ($ignorecase) { |
6161
|
4
|
|
|
|
|
19
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6162
|
|
|
|
|
|
|
} |
6163
|
|
|
|
|
|
|
} |
6164
|
|
|
|
|
|
|
|
6165
|
|
|
|
|
|
|
# quote character before ? + * { |
6166
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
6167
|
188
|
100
|
66
|
|
|
1496
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
|
|
50
|
|
|
|
|
|
6168
|
|
|
|
|
|
|
} |
6169
|
|
|
|
|
|
|
elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
6170
|
0
|
|
|
|
|
0
|
my $char = $char[$i-1]; |
6171
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '{') { |
6172
|
0
|
|
|
|
|
0
|
die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n}; |
6173
|
|
|
|
|
|
|
} |
6174
|
|
|
|
|
|
|
else { |
6175
|
0
|
|
|
|
|
0
|
die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n}; |
6176
|
|
|
|
|
|
|
} |
6177
|
|
|
|
|
|
|
} |
6178
|
|
|
|
|
|
|
else { |
6179
|
187
|
|
|
|
|
988
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
6180
|
|
|
|
|
|
|
} |
6181
|
|
|
|
|
|
|
} |
6182
|
|
|
|
|
|
|
} |
6183
|
|
|
|
|
|
|
|
6184
|
|
|
|
|
|
|
# make regexp string |
6185
|
1357
|
|
|
|
|
1801
|
$modifier =~ tr/i//d; |
6186
|
1357
|
50
|
|
|
|
2807
|
if ($left_e > $right_e) { |
6187
|
0
|
0
|
0
|
|
|
0
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
6188
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier; |
6189
|
|
|
|
|
|
|
} |
6190
|
|
|
|
|
|
|
else { |
6191
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
6192
|
|
|
|
|
|
|
} |
6193
|
|
|
|
|
|
|
} |
6194
|
1357
|
100
|
100
|
|
|
7553
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
6195
|
42
|
|
|
|
|
355
|
return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier; |
6196
|
|
|
|
|
|
|
} |
6197
|
|
|
|
|
|
|
else { |
6198
|
1315
|
|
|
|
|
10557
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
6199
|
|
|
|
|
|
|
} |
6200
|
|
|
|
|
|
|
} |
6201
|
|
|
|
|
|
|
|
6202
|
|
|
|
|
|
|
# |
6203
|
|
|
|
|
|
|
# double quote stuff |
6204
|
|
|
|
|
|
|
# |
6205
|
|
|
|
|
|
|
sub qq_stuff { |
6206
|
540
|
|
|
540
|
0
|
540
|
my($delimiter,$end_delimiter,$stuff) = @_; |
6207
|
|
|
|
|
|
|
|
6208
|
|
|
|
|
|
|
# scalar variable or array variable |
6209
|
540
|
100
|
|
|
|
1011
|
if ($stuff =~ /\A [\$\@] /oxms) { |
6210
|
300
|
|
|
|
|
974
|
return $stuff; |
6211
|
|
|
|
|
|
|
} |
6212
|
|
|
|
|
|
|
|
6213
|
|
|
|
|
|
|
# quote by delimiter |
6214
|
240
|
|
|
|
|
496
|
my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg); |
|
280
|
|
|
|
|
740
|
|
6215
|
240
|
|
|
|
|
527
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
6216
|
240
|
50
|
|
|
|
414
|
next if $char eq $delimiter; |
6217
|
240
|
50
|
|
|
|
337
|
next if $char eq $end_delimiter; |
6218
|
240
|
50
|
|
|
|
431
|
if (not $octet{$char}) { |
6219
|
240
|
|
|
|
|
950
|
return join '', 'qq', $char, $stuff, $char; |
6220
|
|
|
|
|
|
|
} |
6221
|
|
|
|
|
|
|
} |
6222
|
0
|
|
|
|
|
0
|
return join '', 'qq', '<', $stuff, '>'; |
6223
|
|
|
|
|
|
|
} |
6224
|
|
|
|
|
|
|
|
6225
|
|
|
|
|
|
|
# |
6226
|
|
|
|
|
|
|
# escape regexp (m'', qr'', and m''b, qr''b) |
6227
|
|
|
|
|
|
|
# |
6228
|
|
|
|
|
|
|
sub e_qr_q { |
6229
|
39
|
|
|
39
|
0
|
106
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6230
|
39
|
|
100
|
|
|
107
|
$modifier ||= ''; |
6231
|
|
|
|
|
|
|
|
6232
|
39
|
|
|
|
|
56
|
$modifier =~ tr/p//d; |
6233
|
39
|
50
|
|
|
|
93
|
if ($modifier =~ /([adlu])/oxms) { |
6234
|
0
|
|
|
|
|
0
|
my $line = 0; |
6235
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
6236
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
6237
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
6238
|
0
|
|
|
|
|
0
|
last; |
6239
|
|
|
|
|
|
|
} |
6240
|
|
|
|
|
|
|
} |
6241
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
6242
|
|
|
|
|
|
|
} |
6243
|
|
|
|
|
|
|
|
6244
|
39
|
|
|
|
|
47
|
$slash = 'div'; |
6245
|
|
|
|
|
|
|
|
6246
|
|
|
|
|
|
|
# literal null string pattern |
6247
|
39
|
100
|
|
|
|
117
|
if ($string eq '') { |
|
|
100
|
|
|
|
|
|
6248
|
8
|
|
|
|
|
6
|
$modifier =~ tr/bB//d; |
6249
|
8
|
|
|
|
|
6
|
$modifier =~ tr/i//d; |
6250
|
8
|
|
|
|
|
33
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
6251
|
|
|
|
|
|
|
} |
6252
|
|
|
|
|
|
|
|
6253
|
|
|
|
|
|
|
# with /b /B modifier |
6254
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
6255
|
17
|
|
|
|
|
44
|
return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
6256
|
|
|
|
|
|
|
} |
6257
|
|
|
|
|
|
|
|
6258
|
|
|
|
|
|
|
# without /b /B modifier |
6259
|
|
|
|
|
|
|
else { |
6260
|
14
|
|
|
|
|
42
|
return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
6261
|
|
|
|
|
|
|
} |
6262
|
|
|
|
|
|
|
} |
6263
|
|
|
|
|
|
|
|
6264
|
|
|
|
|
|
|
# |
6265
|
|
|
|
|
|
|
# escape regexp (m'', qr'') |
6266
|
|
|
|
|
|
|
# |
6267
|
|
|
|
|
|
|
sub e_qr_qt { |
6268
|
14
|
|
|
14
|
0
|
28
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6269
|
|
|
|
|
|
|
|
6270
|
14
|
100
|
|
|
|
38
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
6271
|
|
|
|
|
|
|
|
6272
|
|
|
|
|
|
|
# split regexp |
6273
|
14
|
|
|
|
|
626
|
my @char = $string =~ /\G((?> |
6274
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\[\$\@\/] | |
6275
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
6276
|
|
|
|
|
|
|
\[\^ | |
6277
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
6278
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
6279
|
|
|
|
|
|
|
[\$\@\/] | |
6280
|
|
|
|
|
|
|
\\ (?:$q_char) | |
6281
|
|
|
|
|
|
|
(?:$q_char) |
6282
|
|
|
|
|
|
|
))/oxmsg; |
6283
|
|
|
|
|
|
|
|
6284
|
|
|
|
|
|
|
# unescape character |
6285
|
14
|
|
|
|
|
77
|
for (my $i=0; $i <= $#char; $i++) { |
6286
|
27
|
50
|
100
|
|
|
139
|
if (0) { |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6287
|
|
|
|
|
|
|
} |
6288
|
|
|
|
|
|
|
|
6289
|
|
|
|
|
|
|
# open character class [...] |
6290
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
6291
|
0
|
|
|
|
|
0
|
my $left = $i; |
6292
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
6293
|
0
|
|
|
|
|
0
|
$i++; |
6294
|
|
|
|
|
|
|
} |
6295
|
0
|
|
|
|
|
0
|
while (1) { |
6296
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6297
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6298
|
|
|
|
|
|
|
} |
6299
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
6300
|
0
|
|
|
|
|
0
|
my $right = $i; |
6301
|
|
|
|
|
|
|
|
6302
|
|
|
|
|
|
|
# [...] |
6303
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
6304
|
|
|
|
|
|
|
|
6305
|
0
|
|
|
|
|
0
|
$i = $left; |
6306
|
0
|
|
|
|
|
0
|
last; |
6307
|
|
|
|
|
|
|
} |
6308
|
|
|
|
|
|
|
} |
6309
|
|
|
|
|
|
|
} |
6310
|
|
|
|
|
|
|
|
6311
|
|
|
|
|
|
|
# open character class [^...] |
6312
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
6313
|
0
|
|
|
|
|
0
|
my $left = $i; |
6314
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
6315
|
0
|
|
|
|
|
0
|
$i++; |
6316
|
|
|
|
|
|
|
} |
6317
|
0
|
|
|
|
|
0
|
while (1) { |
6318
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6319
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6320
|
|
|
|
|
|
|
} |
6321
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
6322
|
0
|
|
|
|
|
0
|
my $right = $i; |
6323
|
|
|
|
|
|
|
|
6324
|
|
|
|
|
|
|
# [^...] |
6325
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
6326
|
|
|
|
|
|
|
|
6327
|
0
|
|
|
|
|
0
|
$i = $left; |
6328
|
0
|
|
|
|
|
0
|
last; |
6329
|
|
|
|
|
|
|
} |
6330
|
|
|
|
|
|
|
} |
6331
|
|
|
|
|
|
|
} |
6332
|
|
|
|
|
|
|
|
6333
|
|
|
|
|
|
|
# escape $ @ / and \ |
6334
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
6335
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
6336
|
|
|
|
|
|
|
} |
6337
|
|
|
|
|
|
|
|
6338
|
|
|
|
|
|
|
# rewrite character class or escape character |
6339
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
6340
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
6341
|
|
|
|
|
|
|
} |
6342
|
|
|
|
|
|
|
|
6343
|
|
|
|
|
|
|
# /i modifier |
6344
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
6345
|
4
|
50
|
|
|
|
11
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
6346
|
4
|
|
|
|
|
9
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
6347
|
|
|
|
|
|
|
} |
6348
|
|
|
|
|
|
|
else { |
6349
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
6350
|
|
|
|
|
|
|
} |
6351
|
|
|
|
|
|
|
} |
6352
|
|
|
|
|
|
|
|
6353
|
|
|
|
|
|
|
# quote character before ? + * { |
6354
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
6355
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
6356
|
|
|
|
|
|
|
} |
6357
|
|
|
|
|
|
|
else { |
6358
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
6359
|
|
|
|
|
|
|
} |
6360
|
|
|
|
|
|
|
} |
6361
|
|
|
|
|
|
|
} |
6362
|
|
|
|
|
|
|
|
6363
|
14
|
|
|
|
|
22
|
$delimiter = '/'; |
6364
|
14
|
|
|
|
|
17
|
$end_delimiter = '/'; |
6365
|
|
|
|
|
|
|
|
6366
|
14
|
|
|
|
|
17
|
$modifier =~ tr/i//d; |
6367
|
14
|
|
|
|
|
134
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
6368
|
|
|
|
|
|
|
} |
6369
|
|
|
|
|
|
|
|
6370
|
|
|
|
|
|
|
# |
6371
|
|
|
|
|
|
|
# escape regexp (m''b, qr''b) |
6372
|
|
|
|
|
|
|
# |
6373
|
|
|
|
|
|
|
sub e_qr_qb { |
6374
|
17
|
|
|
17
|
0
|
26
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6375
|
|
|
|
|
|
|
|
6376
|
|
|
|
|
|
|
# split regexp |
6377
|
17
|
|
|
|
|
79
|
my @char = $string =~ /\G ((?>[^\\]|\\\\|[\x00-\xFF])) /oxmsg; |
6378
|
|
|
|
|
|
|
|
6379
|
|
|
|
|
|
|
# unescape character |
6380
|
17
|
|
|
|
|
54
|
for (my $i=0; $i <= $#char; $i++) { |
6381
|
51
|
50
|
|
|
|
172
|
if (0) { |
|
|
50
|
|
|
|
|
|
6382
|
|
|
|
|
|
|
} |
6383
|
|
|
|
|
|
|
|
6384
|
|
|
|
|
|
|
# remain \\ |
6385
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\\\\') { |
6386
|
|
|
|
|
|
|
} |
6387
|
|
|
|
|
|
|
|
6388
|
|
|
|
|
|
|
# escape $ @ / and \ |
6389
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
6390
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
6391
|
|
|
|
|
|
|
} |
6392
|
|
|
|
|
|
|
} |
6393
|
|
|
|
|
|
|
|
6394
|
17
|
|
|
|
|
23
|
$delimiter = '/'; |
6395
|
17
|
|
|
|
|
17
|
$end_delimiter = '/'; |
6396
|
17
|
|
|
|
|
102
|
return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
6397
|
|
|
|
|
|
|
} |
6398
|
|
|
|
|
|
|
|
6399
|
|
|
|
|
|
|
# |
6400
|
|
|
|
|
|
|
# escape regexp (s/here//) |
6401
|
|
|
|
|
|
|
# |
6402
|
|
|
|
|
|
|
sub e_s1 { |
6403
|
122
|
|
|
122
|
0
|
230
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6404
|
122
|
|
100
|
|
|
374
|
$modifier ||= ''; |
6405
|
|
|
|
|
|
|
|
6406
|
122
|
|
|
|
|
142
|
$modifier =~ tr/p//d; |
6407
|
122
|
50
|
|
|
|
273
|
if ($modifier =~ /([adlu])/oxms) { |
6408
|
0
|
|
|
|
|
0
|
my $line = 0; |
6409
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
6410
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
6411
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
6412
|
0
|
|
|
|
|
0
|
last; |
6413
|
|
|
|
|
|
|
} |
6414
|
|
|
|
|
|
|
} |
6415
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
6416
|
|
|
|
|
|
|
} |
6417
|
|
|
|
|
|
|
|
6418
|
122
|
|
|
|
|
160
|
$slash = 'div'; |
6419
|
|
|
|
|
|
|
|
6420
|
|
|
|
|
|
|
# literal null string pattern |
6421
|
122
|
100
|
|
|
|
352
|
if ($string eq '') { |
|
|
100
|
|
|
|
|
|
6422
|
8
|
|
|
|
|
6
|
$modifier =~ tr/bB//d; |
6423
|
8
|
|
|
|
|
5
|
$modifier =~ tr/i//d; |
6424
|
8
|
|
|
|
|
45
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
6425
|
|
|
|
|
|
|
} |
6426
|
|
|
|
|
|
|
|
6427
|
|
|
|
|
|
|
# /b /B modifier |
6428
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
6429
|
|
|
|
|
|
|
|
6430
|
|
|
|
|
|
|
# choice again delimiter |
6431
|
8
|
50
|
|
|
|
20
|
if ($delimiter =~ / [\@:] /oxms) { |
6432
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
6433
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
|
0
|
|
|
|
|
0
|
|
6434
|
0
|
0
|
|
|
|
0
|
if (not $octet{')'}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6435
|
0
|
|
|
|
|
0
|
$delimiter = '('; |
6436
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
6437
|
|
|
|
|
|
|
} |
6438
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
6439
|
0
|
|
|
|
|
0
|
$delimiter = '{'; |
6440
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
6441
|
|
|
|
|
|
|
} |
6442
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
6443
|
0
|
|
|
|
|
0
|
$delimiter = '['; |
6444
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
6445
|
|
|
|
|
|
|
} |
6446
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
6447
|
0
|
|
|
|
|
0
|
$delimiter = '<'; |
6448
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
6449
|
|
|
|
|
|
|
} |
6450
|
|
|
|
|
|
|
else { |
6451
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
6452
|
0
|
0
|
|
|
|
0
|
if (not $octet{$char}) { |
6453
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
6454
|
0
|
|
|
|
|
0
|
$end_delimiter = $char; |
6455
|
0
|
|
|
|
|
0
|
last; |
6456
|
|
|
|
|
|
|
} |
6457
|
|
|
|
|
|
|
} |
6458
|
|
|
|
|
|
|
} |
6459
|
|
|
|
|
|
|
} |
6460
|
|
|
|
|
|
|
|
6461
|
8
|
|
|
|
|
9
|
my $prematch = ''; |
6462
|
8
|
|
|
|
|
8
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
6463
|
8
|
|
|
|
|
51
|
return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
6464
|
|
|
|
|
|
|
} |
6465
|
|
|
|
|
|
|
|
6466
|
106
|
100
|
|
|
|
224
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
6467
|
106
|
|
|
|
|
378
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
6468
|
|
|
|
|
|
|
|
6469
|
|
|
|
|
|
|
# split regexp |
6470
|
106
|
|
|
|
|
36790
|
my @char = $string =~ /\G((?> |
6471
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\$\@\[\(]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
6472
|
|
|
|
|
|
|
\\ (?>[1-9][0-9]*) | |
6473
|
|
|
|
|
|
|
\\g (?>\s*) (?>[1-9][0-9]*) | |
6474
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
6475
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
6476
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
6477
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
6478
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
6479
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
6480
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
6481
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} | |
6482
|
|
|
|
|
|
|
\\ $q_char | |
6483
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
6484
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
6485
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
6486
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
6487
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
6488
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
6489
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
6490
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
6491
|
|
|
|
|
|
|
\[\^ | |
6492
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
6493
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
6494
|
|
|
|
|
|
|
\(\? | |
6495
|
|
|
|
|
|
|
$q_char |
6496
|
|
|
|
|
|
|
))/oxmsg; |
6497
|
|
|
|
|
|
|
|
6498
|
|
|
|
|
|
|
# choice again delimiter |
6499
|
106
|
50
|
|
|
|
1249
|
if ($delimiter =~ / [\@:] /oxms) { |
6500
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
|
0
|
|
|
|
|
0
|
|
6501
|
0
|
0
|
|
|
|
0
|
if (not $octet{')'}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6502
|
0
|
|
|
|
|
0
|
$delimiter = '('; |
6503
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
6504
|
|
|
|
|
|
|
} |
6505
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
6506
|
0
|
|
|
|
|
0
|
$delimiter = '{'; |
6507
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
6508
|
|
|
|
|
|
|
} |
6509
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
6510
|
0
|
|
|
|
|
0
|
$delimiter = '['; |
6511
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
6512
|
|
|
|
|
|
|
} |
6513
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
6514
|
0
|
|
|
|
|
0
|
$delimiter = '<'; |
6515
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
6516
|
|
|
|
|
|
|
} |
6517
|
|
|
|
|
|
|
else { |
6518
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
6519
|
0
|
0
|
|
|
|
0
|
if (not $octet{$char}) { |
6520
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
6521
|
0
|
|
|
|
|
0
|
$end_delimiter = $char; |
6522
|
0
|
|
|
|
|
0
|
last; |
6523
|
|
|
|
|
|
|
} |
6524
|
|
|
|
|
|
|
} |
6525
|
|
|
|
|
|
|
} |
6526
|
|
|
|
|
|
|
} |
6527
|
|
|
|
|
|
|
|
6528
|
|
|
|
|
|
|
# count '(' |
6529
|
106
|
|
|
|
|
173
|
my $parens = grep { $_ eq '(' } @char; |
|
436
|
|
|
|
|
575
|
|
6530
|
|
|
|
|
|
|
|
6531
|
106
|
|
|
|
|
123
|
my $left_e = 0; |
6532
|
106
|
|
|
|
|
125
|
my $right_e = 0; |
6533
|
106
|
|
|
|
|
304
|
for (my $i=0; $i <= $#char; $i++) { |
6534
|
|
|
|
|
|
|
|
6535
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
6536
|
357
|
50
|
33
|
|
|
2149
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6537
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
6538
|
|
|
|
|
|
|
} |
6539
|
|
|
|
|
|
|
|
6540
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
6541
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
6542
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
6543
|
|
|
|
|
|
|
} |
6544
|
|
|
|
|
|
|
|
6545
|
|
|
|
|
|
|
# octal escape sequence |
6546
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
6547
|
1
|
|
|
|
|
3
|
$char[$i] = Eeuctw::octchr($1); |
6548
|
|
|
|
|
|
|
} |
6549
|
|
|
|
|
|
|
|
6550
|
|
|
|
|
|
|
# hexadecimal escape sequence |
6551
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
6552
|
1
|
|
|
|
|
3
|
$char[$i] = Eeuctw::hexchr($1); |
6553
|
|
|
|
|
|
|
} |
6554
|
|
|
|
|
|
|
|
6555
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
6556
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
6557
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
6558
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
6559
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
6560
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
6561
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
6562
|
|
|
|
|
|
|
} |
6563
|
|
|
|
|
|
|
|
6564
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
6565
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
6566
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
6567
|
|
|
|
|
|
|
} |
6568
|
|
|
|
|
|
|
|
6569
|
357
|
50
|
100
|
|
|
1152
|
if (0) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
6570
|
|
|
|
|
|
|
} |
6571
|
|
|
|
|
|
|
|
6572
|
|
|
|
|
|
|
# join separated multiple-octet |
6573
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
6574
|
0
|
0
|
0
|
|
|
0
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
6575
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
6576
|
|
|
|
|
|
|
} |
6577
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
6578
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
6579
|
|
|
|
|
|
|
} |
6580
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
6581
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 1; |
6582
|
|
|
|
|
|
|
} |
6583
|
|
|
|
|
|
|
} |
6584
|
|
|
|
|
|
|
|
6585
|
|
|
|
|
|
|
# open character class [...] |
6586
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
6587
|
20
|
|
|
|
|
29
|
my $left = $i; |
6588
|
20
|
50
|
|
|
|
54
|
if ($char[$i+1] eq ']') { |
6589
|
0
|
|
|
|
|
0
|
$i++; |
6590
|
|
|
|
|
|
|
} |
6591
|
20
|
|
|
|
|
20
|
while (1) { |
6592
|
79
|
50
|
|
|
|
164
|
if (++$i > $#char) { |
6593
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6594
|
|
|
|
|
|
|
} |
6595
|
79
|
100
|
|
|
|
120
|
if ($char[$i] eq ']') { |
6596
|
20
|
|
|
|
|
23
|
my $right = $i; |
6597
|
|
|
|
|
|
|
|
6598
|
|
|
|
|
|
|
# [...] |
6599
|
20
|
50
|
|
|
|
120
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
6600
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
0
|
|
|
|
|
0
|
|
6601
|
|
|
|
|
|
|
} |
6602
|
|
|
|
|
|
|
else { |
6603
|
20
|
|
|
|
|
175
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
6604
|
|
|
|
|
|
|
} |
6605
|
|
|
|
|
|
|
|
6606
|
20
|
|
|
|
|
28
|
$i = $left; |
6607
|
20
|
|
|
|
|
58
|
last; |
6608
|
|
|
|
|
|
|
} |
6609
|
|
|
|
|
|
|
} |
6610
|
|
|
|
|
|
|
} |
6611
|
|
|
|
|
|
|
|
6612
|
|
|
|
|
|
|
# open character class [^...] |
6613
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
6614
|
0
|
|
|
|
|
0
|
my $left = $i; |
6615
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
6616
|
0
|
|
|
|
|
0
|
$i++; |
6617
|
|
|
|
|
|
|
} |
6618
|
0
|
|
|
|
|
0
|
while (1) { |
6619
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6620
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6621
|
|
|
|
|
|
|
} |
6622
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
6623
|
0
|
|
|
|
|
0
|
my $right = $i; |
6624
|
|
|
|
|
|
|
|
6625
|
|
|
|
|
|
|
# [^...] |
6626
|
0
|
0
|
|
|
|
0
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
6627
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
0
|
|
|
|
|
0
|
|
6628
|
|
|
|
|
|
|
} |
6629
|
|
|
|
|
|
|
else { |
6630
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
6631
|
|
|
|
|
|
|
} |
6632
|
|
|
|
|
|
|
|
6633
|
0
|
|
|
|
|
0
|
$i = $left; |
6634
|
0
|
|
|
|
|
0
|
last; |
6635
|
|
|
|
|
|
|
} |
6636
|
|
|
|
|
|
|
} |
6637
|
|
|
|
|
|
|
} |
6638
|
|
|
|
|
|
|
|
6639
|
|
|
|
|
|
|
# rewrite character class or escape character |
6640
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
6641
|
11
|
|
|
|
|
23
|
$char[$i] = $char; |
6642
|
|
|
|
|
|
|
} |
6643
|
|
|
|
|
|
|
|
6644
|
|
|
|
|
|
|
# /i modifier |
6645
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
6646
|
5
|
50
|
|
|
|
9
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
6647
|
5
|
|
|
|
|
9
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
6648
|
|
|
|
|
|
|
} |
6649
|
|
|
|
|
|
|
else { |
6650
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
6651
|
|
|
|
|
|
|
} |
6652
|
|
|
|
|
|
|
} |
6653
|
|
|
|
|
|
|
|
6654
|
|
|
|
|
|
|
# \u \l \U \L \F \Q \E |
6655
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
6656
|
8
|
50
|
|
|
|
35
|
if ($right_e < $left_e) { |
6657
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
6658
|
|
|
|
|
|
|
} |
6659
|
|
|
|
|
|
|
} |
6660
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
6661
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ucfirst qq<'; |
6662
|
0
|
|
|
|
|
0
|
$left_e++; |
6663
|
|
|
|
|
|
|
} |
6664
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
6665
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lcfirst qq<'; |
6666
|
0
|
|
|
|
|
0
|
$left_e++; |
6667
|
|
|
|
|
|
|
} |
6668
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
6669
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::uc qq<'; |
6670
|
0
|
|
|
|
|
0
|
$left_e++; |
6671
|
|
|
|
|
|
|
} |
6672
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
6673
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lc qq<'; |
6674
|
0
|
|
|
|
|
0
|
$left_e++; |
6675
|
|
|
|
|
|
|
} |
6676
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
6677
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::fc qq<'; |
6678
|
0
|
|
|
|
|
0
|
$left_e++; |
6679
|
|
|
|
|
|
|
} |
6680
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
6681
|
5
|
|
|
|
|
6
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
6682
|
5
|
|
|
|
|
16
|
$left_e++; |
6683
|
|
|
|
|
|
|
} |
6684
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
6685
|
5
|
50
|
|
|
|
7
|
if ($right_e < $left_e) { |
6686
|
5
|
|
|
|
|
5
|
$char[$i] = '>]}'; |
6687
|
5
|
|
|
|
|
15
|
$right_e++; |
6688
|
|
|
|
|
|
|
} |
6689
|
|
|
|
|
|
|
else { |
6690
|
0
|
|
|
|
|
0
|
$char[$i] = ''; |
6691
|
|
|
|
|
|
|
} |
6692
|
|
|
|
|
|
|
} |
6693
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
6694
|
0
|
|
|
|
|
0
|
while (1) { |
6695
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6696
|
0
|
|
|
|
|
0
|
last; |
6697
|
|
|
|
|
|
|
} |
6698
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\E') { |
6699
|
0
|
|
|
|
|
0
|
last; |
6700
|
|
|
|
|
|
|
} |
6701
|
|
|
|
|
|
|
} |
6702
|
|
|
|
|
|
|
} |
6703
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
6704
|
|
|
|
|
|
|
} |
6705
|
|
|
|
|
|
|
|
6706
|
|
|
|
|
|
|
# \0 --> \0 |
6707
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) { |
6708
|
|
|
|
|
|
|
} |
6709
|
|
|
|
|
|
|
|
6710
|
|
|
|
|
|
|
# \g{N}, \g{-N} |
6711
|
|
|
|
|
|
|
|
6712
|
|
|
|
|
|
|
# P.108 Using Simple Patterns |
6713
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
6714
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6715
|
|
|
|
|
|
|
|
6716
|
|
|
|
|
|
|
# P.221 Capturing |
6717
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
6718
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6719
|
|
|
|
|
|
|
|
6720
|
|
|
|
|
|
|
# \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3} |
6721
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
6722
|
|
|
|
|
|
|
} |
6723
|
|
|
|
|
|
|
|
6724
|
|
|
|
|
|
|
# \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable) |
6725
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
6726
|
0
|
0
|
|
|
|
0
|
if ($1 <= $parens) { |
6727
|
0
|
|
|
|
|
0
|
$char[$i] = '\\g{' . ($1 + 1) . '}'; |
6728
|
|
|
|
|
|
|
} |
6729
|
|
|
|
|
|
|
} |
6730
|
|
|
|
|
|
|
|
6731
|
|
|
|
|
|
|
# \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable) |
6732
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
6733
|
0
|
0
|
|
|
|
0
|
if ($1 <= $parens) { |
6734
|
0
|
|
|
|
|
0
|
$char[$i] = '\\g' . ($1 + 1); |
6735
|
|
|
|
|
|
|
} |
6736
|
|
|
|
|
|
|
} |
6737
|
|
|
|
|
|
|
|
6738
|
|
|
|
|
|
|
# \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable) |
6739
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
6740
|
0
|
0
|
|
|
|
0
|
if ($1 <= $parens) { |
6741
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . ($1 + 1); |
6742
|
|
|
|
|
|
|
} |
6743
|
|
|
|
|
|
|
} |
6744
|
|
|
|
|
|
|
|
6745
|
|
|
|
|
|
|
# $0 --> $0 |
6746
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
6747
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6748
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6749
|
|
|
|
|
|
|
} |
6750
|
|
|
|
|
|
|
} |
6751
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
6752
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6753
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6754
|
|
|
|
|
|
|
} |
6755
|
|
|
|
|
|
|
} |
6756
|
|
|
|
|
|
|
|
6757
|
|
|
|
|
|
|
# $$ --> $$ |
6758
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
6759
|
|
|
|
|
|
|
} |
6760
|
|
|
|
|
|
|
|
6761
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6762
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6763
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
6764
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6765
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6766
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6767
|
|
|
|
|
|
|
} |
6768
|
|
|
|
|
|
|
} |
6769
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
6770
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6771
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6772
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6773
|
|
|
|
|
|
|
} |
6774
|
|
|
|
|
|
|
} |
6775
|
|
|
|
|
|
|
|
6776
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6777
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
6778
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
6779
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6780
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6781
|
|
|
|
|
|
|
} |
6782
|
|
|
|
|
|
|
} |
6783
|
|
|
|
|
|
|
|
6784
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
6785
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
6786
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
6787
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6788
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6789
|
|
|
|
|
|
|
} |
6790
|
|
|
|
|
|
|
} |
6791
|
|
|
|
|
|
|
|
6792
|
|
|
|
|
|
|
# $$foo |
6793
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
6794
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6795
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6796
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6797
|
|
|
|
|
|
|
} |
6798
|
|
|
|
|
|
|
} |
6799
|
|
|
|
|
|
|
|
6800
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
6801
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
6802
|
4
|
50
|
|
|
|
11
|
if ($ignorecase) { |
6803
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::PREMATCH())]}'; |
6804
|
|
|
|
|
|
|
} |
6805
|
|
|
|
|
|
|
else { |
6806
|
4
|
|
|
|
|
22
|
$char[$i] = '@{[Eeuctw::PREMATCH()]}'; |
6807
|
|
|
|
|
|
|
} |
6808
|
|
|
|
|
|
|
} |
6809
|
|
|
|
|
|
|
|
6810
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
6811
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
6812
|
4
|
50
|
|
|
|
12
|
if ($ignorecase) { |
6813
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::MATCH())]}'; |
6814
|
|
|
|
|
|
|
} |
6815
|
|
|
|
|
|
|
else { |
6816
|
4
|
|
|
|
|
20
|
$char[$i] = '@{[Eeuctw::MATCH()]}'; |
6817
|
|
|
|
|
|
|
} |
6818
|
|
|
|
|
|
|
} |
6819
|
|
|
|
|
|
|
|
6820
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
6821
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
6822
|
3
|
50
|
|
|
|
9
|
if ($ignorecase) { |
6823
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::POSTMATCH())]}'; |
6824
|
|
|
|
|
|
|
} |
6825
|
|
|
|
|
|
|
else { |
6826
|
3
|
|
|
|
|
13
|
$char[$i] = '@{[Eeuctw::POSTMATCH()]}'; |
6827
|
|
|
|
|
|
|
} |
6828
|
|
|
|
|
|
|
} |
6829
|
|
|
|
|
|
|
|
6830
|
|
|
|
|
|
|
# ${ foo } |
6831
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
6832
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6833
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6834
|
|
|
|
|
|
|
} |
6835
|
|
|
|
|
|
|
} |
6836
|
|
|
|
|
|
|
|
6837
|
|
|
|
|
|
|
# ${ ... } |
6838
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
6839
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
6840
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
6841
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6842
|
|
|
|
|
|
|
} |
6843
|
|
|
|
|
|
|
} |
6844
|
|
|
|
|
|
|
|
6845
|
|
|
|
|
|
|
# $scalar or @array |
6846
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
6847
|
9
|
|
|
|
|
18
|
$char[$i] = e_string($char[$i]); |
6848
|
9
|
50
|
|
|
|
67
|
if ($ignorecase) { |
6849
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
6850
|
|
|
|
|
|
|
} |
6851
|
|
|
|
|
|
|
} |
6852
|
|
|
|
|
|
|
|
6853
|
|
|
|
|
|
|
# quote character before ? + * { |
6854
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
6855
|
23
|
50
|
|
|
|
103
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
6856
|
|
|
|
|
|
|
} |
6857
|
|
|
|
|
|
|
else { |
6858
|
23
|
|
|
|
|
145
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
6859
|
|
|
|
|
|
|
} |
6860
|
|
|
|
|
|
|
} |
6861
|
|
|
|
|
|
|
} |
6862
|
|
|
|
|
|
|
|
6863
|
|
|
|
|
|
|
# make regexp string |
6864
|
106
|
|
|
|
|
218
|
my $prematch = ''; |
6865
|
106
|
50
|
|
|
|
267
|
if ($] >= 5.010) { |
6866
|
106
|
|
|
|
|
250
|
$prematch = "(?<_PREMATCH>$anchor)"; |
6867
|
|
|
|
|
|
|
} |
6868
|
|
|
|
|
|
|
else { |
6869
|
0
|
|
|
|
|
0
|
$prematch = "($anchor)"; |
6870
|
|
|
|
|
|
|
} |
6871
|
106
|
|
|
|
|
143
|
$modifier =~ tr/i//d; |
6872
|
106
|
50
|
|
|
|
297
|
if ($left_e > $right_e) { |
6873
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
6874
|
|
|
|
|
|
|
} |
6875
|
106
|
|
|
|
|
1180
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
6876
|
|
|
|
|
|
|
} |
6877
|
|
|
|
|
|
|
|
6878
|
|
|
|
|
|
|
# |
6879
|
|
|
|
|
|
|
# escape regexp (s'here'' or s'here''b) |
6880
|
|
|
|
|
|
|
# |
6881
|
|
|
|
|
|
|
sub e_s1_q { |
6882
|
34
|
|
|
34
|
0
|
45
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6883
|
34
|
|
100
|
|
|
92
|
$modifier ||= ''; |
6884
|
|
|
|
|
|
|
|
6885
|
34
|
|
|
|
|
27
|
$modifier =~ tr/p//d; |
6886
|
34
|
50
|
|
|
|
115
|
if ($modifier =~ /([adlu])/oxms) { |
6887
|
0
|
|
|
|
|
0
|
my $line = 0; |
6888
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
6889
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
6890
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
6891
|
0
|
|
|
|
|
0
|
last; |
6892
|
|
|
|
|
|
|
} |
6893
|
|
|
|
|
|
|
} |
6894
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
6895
|
|
|
|
|
|
|
} |
6896
|
|
|
|
|
|
|
|
6897
|
34
|
|
|
|
|
37
|
$slash = 'div'; |
6898
|
|
|
|
|
|
|
|
6899
|
|
|
|
|
|
|
# literal null string pattern |
6900
|
34
|
100
|
|
|
|
73
|
if ($string eq '') { |
|
|
100
|
|
|
|
|
|
6901
|
8
|
|
|
|
|
5
|
$modifier =~ tr/bB//d; |
6902
|
8
|
|
|
|
|
6
|
$modifier =~ tr/i//d; |
6903
|
8
|
|
|
|
|
41
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
6904
|
|
|
|
|
|
|
} |
6905
|
|
|
|
|
|
|
|
6906
|
|
|
|
|
|
|
# with /b /B modifier |
6907
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
6908
|
8
|
|
|
|
|
15
|
return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
6909
|
|
|
|
|
|
|
} |
6910
|
|
|
|
|
|
|
|
6911
|
|
|
|
|
|
|
# without /b /B modifier |
6912
|
|
|
|
|
|
|
else { |
6913
|
18
|
|
|
|
|
28
|
return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
6914
|
|
|
|
|
|
|
} |
6915
|
|
|
|
|
|
|
} |
6916
|
|
|
|
|
|
|
|
6917
|
|
|
|
|
|
|
# |
6918
|
|
|
|
|
|
|
# escape regexp (s'here'') |
6919
|
|
|
|
|
|
|
# |
6920
|
|
|
|
|
|
|
sub e_s1_qt { |
6921
|
18
|
|
|
18
|
0
|
26
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
6922
|
|
|
|
|
|
|
|
6923
|
18
|
100
|
|
|
|
44
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
6924
|
|
|
|
|
|
|
|
6925
|
|
|
|
|
|
|
# split regexp |
6926
|
18
|
|
|
|
|
461
|
my @char = $string =~ /\G((?> |
6927
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\[\$\@\/] | |
6928
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
6929
|
|
|
|
|
|
|
\[\^ | |
6930
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
6931
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
6932
|
|
|
|
|
|
|
[\$\@\/] | |
6933
|
|
|
|
|
|
|
\\ (?:$q_char) | |
6934
|
|
|
|
|
|
|
(?:$q_char) |
6935
|
|
|
|
|
|
|
))/oxmsg; |
6936
|
|
|
|
|
|
|
|
6937
|
|
|
|
|
|
|
# unescape character |
6938
|
18
|
|
|
|
|
69
|
for (my $i=0; $i <= $#char; $i++) { |
6939
|
36
|
50
|
100
|
|
|
145
|
if (0) { |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6940
|
|
|
|
|
|
|
} |
6941
|
|
|
|
|
|
|
|
6942
|
|
|
|
|
|
|
# open character class [...] |
6943
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
6944
|
0
|
|
|
|
|
0
|
my $left = $i; |
6945
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
6946
|
0
|
|
|
|
|
0
|
$i++; |
6947
|
|
|
|
|
|
|
} |
6948
|
0
|
|
|
|
|
0
|
while (1) { |
6949
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6950
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6951
|
|
|
|
|
|
|
} |
6952
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
6953
|
0
|
|
|
|
|
0
|
my $right = $i; |
6954
|
|
|
|
|
|
|
|
6955
|
|
|
|
|
|
|
# [...] |
6956
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
6957
|
|
|
|
|
|
|
|
6958
|
0
|
|
|
|
|
0
|
$i = $left; |
6959
|
0
|
|
|
|
|
0
|
last; |
6960
|
|
|
|
|
|
|
} |
6961
|
|
|
|
|
|
|
} |
6962
|
|
|
|
|
|
|
} |
6963
|
|
|
|
|
|
|
|
6964
|
|
|
|
|
|
|
# open character class [^...] |
6965
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
6966
|
0
|
|
|
|
|
0
|
my $left = $i; |
6967
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
6968
|
0
|
|
|
|
|
0
|
$i++; |
6969
|
|
|
|
|
|
|
} |
6970
|
0
|
|
|
|
|
0
|
while (1) { |
6971
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
6972
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
6973
|
|
|
|
|
|
|
} |
6974
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
6975
|
0
|
|
|
|
|
0
|
my $right = $i; |
6976
|
|
|
|
|
|
|
|
6977
|
|
|
|
|
|
|
# [^...] |
6978
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
6979
|
|
|
|
|
|
|
|
6980
|
0
|
|
|
|
|
0
|
$i = $left; |
6981
|
0
|
|
|
|
|
0
|
last; |
6982
|
|
|
|
|
|
|
} |
6983
|
|
|
|
|
|
|
} |
6984
|
|
|
|
|
|
|
} |
6985
|
|
|
|
|
|
|
|
6986
|
|
|
|
|
|
|
# escape $ @ / and \ |
6987
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
6988
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
6989
|
|
|
|
|
|
|
} |
6990
|
|
|
|
|
|
|
|
6991
|
|
|
|
|
|
|
# rewrite character class or escape character |
6992
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
6993
|
6
|
|
|
|
|
14
|
$char[$i] = $char; |
6994
|
|
|
|
|
|
|
} |
6995
|
|
|
|
|
|
|
|
6996
|
|
|
|
|
|
|
# /i modifier |
6997
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
6998
|
2
|
50
|
|
|
|
3
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
6999
|
2
|
|
|
|
|
4
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
7000
|
|
|
|
|
|
|
} |
7001
|
|
|
|
|
|
|
else { |
7002
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
7003
|
|
|
|
|
|
|
} |
7004
|
|
|
|
|
|
|
} |
7005
|
|
|
|
|
|
|
|
7006
|
|
|
|
|
|
|
# quote character before ? + * { |
7007
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
7008
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
7009
|
|
|
|
|
|
|
} |
7010
|
|
|
|
|
|
|
else { |
7011
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
7012
|
|
|
|
|
|
|
} |
7013
|
|
|
|
|
|
|
} |
7014
|
|
|
|
|
|
|
} |
7015
|
|
|
|
|
|
|
|
7016
|
18
|
|
|
|
|
24
|
$modifier =~ tr/i//d; |
7017
|
18
|
|
|
|
|
21
|
$delimiter = '/'; |
7018
|
18
|
|
|
|
|
14
|
$end_delimiter = '/'; |
7019
|
18
|
|
|
|
|
18
|
my $prematch = ''; |
7020
|
18
|
50
|
|
|
|
29
|
if ($] >= 5.010) { |
7021
|
18
|
|
|
|
|
32
|
$prematch = "(?<_PREMATCH>$anchor)"; |
7022
|
|
|
|
|
|
|
} |
7023
|
|
|
|
|
|
|
else { |
7024
|
0
|
|
|
|
|
0
|
$prematch = "($anchor)"; |
7025
|
|
|
|
|
|
|
} |
7026
|
18
|
|
|
|
|
127
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
7027
|
|
|
|
|
|
|
} |
7028
|
|
|
|
|
|
|
|
7029
|
|
|
|
|
|
|
# |
7030
|
|
|
|
|
|
|
# escape regexp (s'here''b) |
7031
|
|
|
|
|
|
|
# |
7032
|
|
|
|
|
|
|
sub e_s1_qb { |
7033
|
8
|
|
|
8
|
0
|
14
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
7034
|
|
|
|
|
|
|
|
7035
|
|
|
|
|
|
|
# split regexp |
7036
|
8
|
|
|
|
|
32
|
my @char = $string =~ /\G (?>[^\\]|\\\\|[\x00-\xFF]) /oxmsg; |
7037
|
|
|
|
|
|
|
|
7038
|
|
|
|
|
|
|
# unescape character |
7039
|
8
|
|
|
|
|
25
|
for (my $i=0; $i <= $#char; $i++) { |
7040
|
24
|
50
|
|
|
|
86
|
if (0) { |
|
|
50
|
|
|
|
|
|
7041
|
|
|
|
|
|
|
} |
7042
|
|
|
|
|
|
|
|
7043
|
|
|
|
|
|
|
# remain \\ |
7044
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\\\\') { |
7045
|
|
|
|
|
|
|
} |
7046
|
|
|
|
|
|
|
|
7047
|
|
|
|
|
|
|
# escape $ @ / and \ |
7048
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
7049
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
7050
|
|
|
|
|
|
|
} |
7051
|
|
|
|
|
|
|
} |
7052
|
|
|
|
|
|
|
|
7053
|
8
|
|
|
|
|
10
|
$delimiter = '/'; |
7054
|
8
|
|
|
|
|
9
|
$end_delimiter = '/'; |
7055
|
8
|
|
|
|
|
7
|
my $prematch = ''; |
7056
|
8
|
|
|
|
|
10
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
7057
|
8
|
|
|
|
|
53
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
7058
|
|
|
|
|
|
|
} |
7059
|
|
|
|
|
|
|
|
7060
|
|
|
|
|
|
|
# |
7061
|
|
|
|
|
|
|
# escape regexp (s''here') |
7062
|
|
|
|
|
|
|
# |
7063
|
|
|
|
|
|
|
sub e_s2_q { |
7064
|
29
|
|
|
29
|
0
|
32
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
7065
|
|
|
|
|
|
|
|
7066
|
29
|
|
|
|
|
29
|
$slash = 'div'; |
7067
|
|
|
|
|
|
|
|
7068
|
29
|
|
|
|
|
232
|
my @char = $string =~ / \G (?>[^\x8E\xA1-\xFE\\]|\\\\|$q_char) /oxmsg; |
7069
|
29
|
|
|
|
|
73
|
for (my $i=0; $i <= $#char; $i++) { |
7070
|
9
|
100
|
|
|
|
26
|
if (0) { |
|
|
100
|
|
|
|
|
|
7071
|
|
|
|
|
|
|
} |
7072
|
|
|
|
|
|
|
|
7073
|
|
|
|
|
|
|
# not escape \\ |
7074
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\\\ \z/oxms) { |
7075
|
|
|
|
|
|
|
} |
7076
|
|
|
|
|
|
|
|
7077
|
|
|
|
|
|
|
# escape $ @ / and \ |
7078
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
7079
|
5
|
|
|
|
|
12
|
$char[$i] = '\\' . $char[$i]; |
7080
|
|
|
|
|
|
|
} |
7081
|
|
|
|
|
|
|
} |
7082
|
|
|
|
|
|
|
|
7083
|
29
|
|
|
|
|
73
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
7084
|
|
|
|
|
|
|
} |
7085
|
|
|
|
|
|
|
|
7086
|
|
|
|
|
|
|
# |
7087
|
|
|
|
|
|
|
# escape regexp (s/here/and here/modifier) |
7088
|
|
|
|
|
|
|
# |
7089
|
|
|
|
|
|
|
sub e_sub { |
7090
|
156
|
|
|
156
|
0
|
625
|
my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_; |
7091
|
156
|
|
100
|
|
|
475
|
$modifier ||= ''; |
7092
|
|
|
|
|
|
|
|
7093
|
156
|
|
|
|
|
236
|
$modifier =~ tr/p//d; |
7094
|
156
|
50
|
|
|
|
410
|
if ($modifier =~ /([adlu])/oxms) { |
7095
|
0
|
|
|
|
|
0
|
my $line = 0; |
7096
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
7097
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
7098
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
7099
|
0
|
|
|
|
|
0
|
last; |
7100
|
|
|
|
|
|
|
} |
7101
|
|
|
|
|
|
|
} |
7102
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
7103
|
|
|
|
|
|
|
} |
7104
|
|
|
|
|
|
|
|
7105
|
156
|
100
|
|
|
|
329
|
if ($variable eq '') { |
7106
|
37
|
|
|
|
|
35
|
$variable = '$_'; |
7107
|
37
|
|
|
|
|
39
|
$bind_operator = ' =~ '; |
7108
|
|
|
|
|
|
|
} |
7109
|
|
|
|
|
|
|
|
7110
|
156
|
|
|
|
|
181
|
$slash = 'div'; |
7111
|
|
|
|
|
|
|
|
7112
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
7113
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
7114
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
7115
|
|
|
|
|
|
|
# P.312 Iterative Matching: Scalar Context, with /g |
7116
|
|
|
|
|
|
|
# in Chapter 7: Perl |
7117
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
7118
|
|
|
|
|
|
|
|
7119
|
|
|
|
|
|
|
# P.181 Where You Left Off: The \G Assertion |
7120
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
7121
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7122
|
|
|
|
|
|
|
|
7123
|
|
|
|
|
|
|
# P.220 Where You Left Off: The \G Assertion |
7124
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
7125
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7126
|
|
|
|
|
|
|
|
7127
|
156
|
|
|
|
|
177
|
my $e_modifier = $modifier =~ tr/e//d; |
7128
|
156
|
|
|
|
|
173
|
my $r_modifier = $modifier =~ tr/r//d; |
7129
|
|
|
|
|
|
|
|
7130
|
156
|
|
|
|
|
169
|
my $my = ''; |
7131
|
156
|
50
|
|
|
|
348
|
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) { |
7132
|
0
|
|
|
|
|
0
|
$my = $variable; |
7133
|
0
|
|
|
|
|
0
|
$variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms; |
7134
|
0
|
|
|
|
|
0
|
$variable =~ s/ = .+ \z//oxms; |
7135
|
|
|
|
|
|
|
} |
7136
|
|
|
|
|
|
|
|
7137
|
156
|
|
|
|
|
308
|
(my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms; |
7138
|
156
|
|
|
|
|
224
|
$variable_basename =~ s/ \s+ \z//oxms; |
7139
|
|
|
|
|
|
|
|
7140
|
|
|
|
|
|
|
# quote replacement string |
7141
|
156
|
|
|
|
|
153
|
my $e_replacement = ''; |
7142
|
156
|
100
|
|
|
|
302
|
if ($e_modifier >= 1) { |
7143
|
17
|
|
|
|
|
27
|
$e_replacement = e_qq('', '', '', $replacement); |
7144
|
17
|
|
|
|
|
22
|
$e_modifier--; |
7145
|
|
|
|
|
|
|
} |
7146
|
|
|
|
|
|
|
else { |
7147
|
139
|
100
|
|
|
|
239
|
if ($delimiter2 eq "'") { |
7148
|
29
|
|
|
|
|
48
|
$e_replacement = e_s2_q('qq', '/', '/', $replacement); |
7149
|
|
|
|
|
|
|
} |
7150
|
|
|
|
|
|
|
else { |
7151
|
110
|
|
|
|
|
209
|
$e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement); |
7152
|
|
|
|
|
|
|
} |
7153
|
|
|
|
|
|
|
} |
7154
|
|
|
|
|
|
|
|
7155
|
156
|
|
|
|
|
210
|
my $sub = ''; |
7156
|
|
|
|
|
|
|
|
7157
|
|
|
|
|
|
|
# with /r |
7158
|
156
|
100
|
|
|
|
293
|
if ($r_modifier) { |
7159
|
8
|
100
|
|
|
|
18
|
if (0) { |
|
|
50
|
|
|
|
|
|
7160
|
|
|
|
|
|
|
} |
7161
|
|
|
|
|
|
|
|
7162
|
|
|
|
|
|
|
# s///gr with multibyte anchoring |
7163
|
0
|
|
|
|
|
0
|
elsif ($modifier =~ /g/oxms) { |
7164
|
4
|
50
|
|
|
|
13
|
$sub = sprintf( |
7165
|
|
|
|
|
|
|
# 1 2 3 4 5 |
7166
|
|
|
|
|
|
|
q, |
7167
|
|
|
|
|
|
|
|
7168
|
|
|
|
|
|
|
$variable, # 1 |
7169
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
7170
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7171
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7172
|
|
|
|
|
|
|
$s_matched, # 3 |
7173
|
|
|
|
|
|
|
$e_replacement, # 4 |
7174
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 5 |
7175
|
|
|
|
|
|
|
); |
7176
|
|
|
|
|
|
|
} |
7177
|
|
|
|
|
|
|
|
7178
|
|
|
|
|
|
|
# s///gr without multibyte anchoring |
7179
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
7180
|
0
|
0
|
|
|
|
0
|
$sub = sprintf( |
7181
|
|
|
|
|
|
|
# 1 2 3 4 5 |
7182
|
|
|
|
|
|
|
q, |
7183
|
|
|
|
|
|
|
|
7184
|
|
|
|
|
|
|
$variable, # 1 |
7185
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
7186
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7187
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7188
|
|
|
|
|
|
|
$s_matched, # 3 |
7189
|
|
|
|
|
|
|
$e_replacement, # 4 |
7190
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 5 |
7191
|
|
|
|
|
|
|
); |
7192
|
|
|
|
|
|
|
} |
7193
|
|
|
|
|
|
|
|
7194
|
|
|
|
|
|
|
# s///r |
7195
|
|
|
|
|
|
|
else { |
7196
|
|
|
|
|
|
|
|
7197
|
4
|
|
|
|
|
3
|
my $prematch = q{$`}; |
7198
|
4
|
50
|
|
|
|
7
|
if ($] >= 5.010) { |
7199
|
4
|
|
|
|
|
3
|
$prematch = q{$+{_PREMATCH}}; |
7200
|
|
|
|
|
|
|
} |
7201
|
|
|
|
|
|
|
else { |
7202
|
0
|
|
|
|
|
0
|
$prematch = q{${1}}; |
7203
|
|
|
|
|
|
|
} |
7204
|
|
|
|
|
|
|
|
7205
|
4
|
50
|
|
|
|
9
|
$sub = sprintf( |
7206
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 |
7207
|
|
|
|
|
|
|
q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $EUCTW::re_r=%s; %s"%s$EUCTW::re_r$'" } : %s>, |
7208
|
|
|
|
|
|
|
|
7209
|
|
|
|
|
|
|
$variable, # 1 |
7210
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
7211
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7212
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7213
|
|
|
|
|
|
|
$s_matched, # 3 |
7214
|
|
|
|
|
|
|
$e_replacement, # 4 |
7215
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 5 |
7216
|
|
|
|
|
|
|
$prematch, # 6 |
7217
|
|
|
|
|
|
|
$variable, # 7 |
7218
|
|
|
|
|
|
|
); |
7219
|
|
|
|
|
|
|
} |
7220
|
|
|
|
|
|
|
|
7221
|
|
|
|
|
|
|
# $var !~ s///r doesn't make sense |
7222
|
8
|
50
|
|
|
|
17
|
if ($bind_operator =~ / !~ /oxms) { |
7223
|
0
|
|
|
|
|
0
|
$sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub; |
7224
|
|
|
|
|
|
|
} |
7225
|
|
|
|
|
|
|
} |
7226
|
|
|
|
|
|
|
|
7227
|
|
|
|
|
|
|
# without /r |
7228
|
|
|
|
|
|
|
else { |
7229
|
148
|
100
|
|
|
|
409
|
if (0) { |
|
|
50
|
|
|
|
|
|
7230
|
|
|
|
|
|
|
} |
7231
|
|
|
|
|
|
|
|
7232
|
|
|
|
|
|
|
# s///g with multibyte anchoring |
7233
|
0
|
|
|
|
|
0
|
elsif ($modifier =~ /g/oxms) { |
7234
|
29
|
100
|
|
|
|
107
|
$sub = sprintf( |
|
|
100
|
|
|
|
|
|
7235
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 |
7236
|
|
|
|
|
|
|
q, |
7237
|
|
|
|
|
|
|
|
7238
|
|
|
|
|
|
|
$variable, # 1 |
7239
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
7240
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7241
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7242
|
|
|
|
|
|
|
$s_matched, # 3 |
7243
|
|
|
|
|
|
|
$e_replacement, # 4 |
7244
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 5 |
7245
|
|
|
|
|
|
|
$variable, # 6 |
7246
|
|
|
|
|
|
|
$variable, # 7 |
7247
|
|
|
|
|
|
|
$variable, # 8 |
7248
|
|
|
|
|
|
|
$variable, # 9 |
7249
|
|
|
|
|
|
|
|
7250
|
|
|
|
|
|
|
# Binary "!~" is just like "=~" except the return value is negated in the logical sense. |
7251
|
|
|
|
|
|
|
# It returns false if the match succeeds, and true if it fails. |
7252
|
|
|
|
|
|
|
# (and so on) |
7253
|
|
|
|
|
|
|
|
7254
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 10 |
7255
|
|
|
|
|
|
|
); |
7256
|
|
|
|
|
|
|
} |
7257
|
|
|
|
|
|
|
|
7258
|
|
|
|
|
|
|
# s///g without multibyte anchoring |
7259
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
7260
|
0
|
0
|
|
|
|
0
|
$sub = sprintf( |
|
|
0
|
|
|
|
|
|
7261
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
7262
|
|
|
|
|
|
|
q, |
7263
|
|
|
|
|
|
|
|
7264
|
|
|
|
|
|
|
$variable, # 1 |
7265
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
7266
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7267
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7268
|
|
|
|
|
|
|
$s_matched, # 3 |
7269
|
|
|
|
|
|
|
$e_replacement, # 4 |
7270
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 5 |
7271
|
|
|
|
|
|
|
$variable, # 6 |
7272
|
|
|
|
|
|
|
$variable, # 7 |
7273
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 8 |
7274
|
|
|
|
|
|
|
); |
7275
|
|
|
|
|
|
|
} |
7276
|
|
|
|
|
|
|
|
7277
|
|
|
|
|
|
|
# s/// |
7278
|
|
|
|
|
|
|
else { |
7279
|
|
|
|
|
|
|
|
7280
|
119
|
|
|
|
|
153
|
my $prematch = q{$`}; |
7281
|
119
|
50
|
|
|
|
247
|
if ($] >= 5.010) { |
7282
|
119
|
|
|
|
|
136
|
$prematch = q{$+{_PREMATCH}}; |
7283
|
|
|
|
|
|
|
} |
7284
|
|
|
|
|
|
|
else { |
7285
|
0
|
|
|
|
|
0
|
$prematch = q{${1}}; |
7286
|
|
|
|
|
|
|
} |
7287
|
|
|
|
|
|
|
|
7288
|
119
|
100
|
|
|
|
595
|
$sub = sprintf( |
|
|
100
|
|
|
|
|
|
7289
|
|
|
|
|
|
|
|
7290
|
|
|
|
|
|
|
($bind_operator =~ / =~ /oxms) ? |
7291
|
|
|
|
|
|
|
|
7292
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
7293
|
|
|
|
|
|
|
q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $EUCTW::re_r=%s; %s%s="%s$EUCTW::re_r$'"; 1 } : undef> : |
7294
|
|
|
|
|
|
|
|
7295
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
7296
|
|
|
|
|
|
|
q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $EUCTW::re_r=%s; %s%s="%s$EUCTW::re_r$'"; undef }>, |
7297
|
|
|
|
|
|
|
|
7298
|
|
|
|
|
|
|
$variable, # 1 |
7299
|
|
|
|
|
|
|
$bind_operator, # 2 |
7300
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 3 |
7301
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
7302
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
7303
|
|
|
|
|
|
|
$s_matched, # 4 |
7304
|
|
|
|
|
|
|
$e_replacement, # 5 |
7305
|
|
|
|
|
|
|
'$EUCTW::re_r=CORE::eval $EUCTW::re_r; ' x $e_modifier, # 6 |
7306
|
|
|
|
|
|
|
$variable, # 7 |
7307
|
|
|
|
|
|
|
$prematch, # 8 |
7308
|
|
|
|
|
|
|
); |
7309
|
|
|
|
|
|
|
} |
7310
|
|
|
|
|
|
|
} |
7311
|
|
|
|
|
|
|
|
7312
|
|
|
|
|
|
|
# (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1] |
7313
|
156
|
50
|
|
|
|
367
|
if ($my ne '') { |
7314
|
0
|
|
|
|
|
0
|
$sub = "($my, $sub)[1]"; |
7315
|
|
|
|
|
|
|
} |
7316
|
|
|
|
|
|
|
|
7317
|
|
|
|
|
|
|
# clear s/// variable |
7318
|
156
|
|
|
|
|
219
|
$sub_variable = ''; |
7319
|
156
|
|
|
|
|
196
|
$bind_operator = ''; |
7320
|
|
|
|
|
|
|
|
7321
|
156
|
|
|
|
|
1825
|
return $sub; |
7322
|
|
|
|
|
|
|
} |
7323
|
|
|
|
|
|
|
|
7324
|
|
|
|
|
|
|
# |
7325
|
|
|
|
|
|
|
# escape regexp of split qr// |
7326
|
|
|
|
|
|
|
# |
7327
|
|
|
|
|
|
|
sub e_split { |
7328
|
143
|
|
|
143
|
0
|
372
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
7329
|
143
|
|
100
|
|
|
461
|
$modifier ||= ''; |
7330
|
|
|
|
|
|
|
|
7331
|
143
|
|
|
|
|
194
|
$modifier =~ tr/p//d; |
7332
|
143
|
50
|
|
|
|
372
|
if ($modifier =~ /([adlu])/oxms) { |
7333
|
0
|
|
|
|
|
0
|
my $line = 0; |
7334
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
7335
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
7336
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
7337
|
0
|
|
|
|
|
0
|
last; |
7338
|
|
|
|
|
|
|
} |
7339
|
|
|
|
|
|
|
} |
7340
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
7341
|
|
|
|
|
|
|
} |
7342
|
|
|
|
|
|
|
|
7343
|
143
|
|
|
|
|
169
|
$slash = 'div'; |
7344
|
|
|
|
|
|
|
|
7345
|
|
|
|
|
|
|
# /b /B modifier |
7346
|
143
|
100
|
|
|
|
282
|
if ($modifier =~ tr/bB//d) { |
7347
|
18
|
|
|
|
|
97
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
7348
|
|
|
|
|
|
|
} |
7349
|
|
|
|
|
|
|
|
7350
|
125
|
100
|
|
|
|
252
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
7351
|
125
|
|
|
|
|
422
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
7352
|
|
|
|
|
|
|
|
7353
|
|
|
|
|
|
|
# split regexp |
7354
|
125
|
|
|
|
|
16269
|
my @char = $string =~ /\G((?> |
7355
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\$\@\[\(]|[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
7356
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
7357
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
7358
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
7359
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
7360
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
7361
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} | |
7362
|
|
|
|
|
|
|
\\ $q_char | |
7363
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
7364
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
7365
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
7366
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
7367
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
7368
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
7369
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
7370
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
7371
|
|
|
|
|
|
|
\[\^ | |
7372
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
7373
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
7374
|
|
|
|
|
|
|
\(\? | |
7375
|
|
|
|
|
|
|
$q_char |
7376
|
|
|
|
|
|
|
))/oxmsg; |
7377
|
|
|
|
|
|
|
|
7378
|
125
|
|
|
|
|
515
|
my $left_e = 0; |
7379
|
125
|
|
|
|
|
129
|
my $right_e = 0; |
7380
|
125
|
|
|
|
|
356
|
for (my $i=0; $i <= $#char; $i++) { |
7381
|
|
|
|
|
|
|
|
7382
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
7383
|
308
|
50
|
33
|
|
|
1850
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7384
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
7385
|
|
|
|
|
|
|
} |
7386
|
|
|
|
|
|
|
|
7387
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
7388
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
7389
|
0
|
|
|
|
|
0
|
@char[$i,$i+1] = @char[$i+1,$i]; |
7390
|
|
|
|
|
|
|
} |
7391
|
|
|
|
|
|
|
|
7392
|
|
|
|
|
|
|
# octal escape sequence |
7393
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
7394
|
1
|
|
|
|
|
2
|
$char[$i] = Eeuctw::octchr($1); |
7395
|
|
|
|
|
|
|
} |
7396
|
|
|
|
|
|
|
|
7397
|
|
|
|
|
|
|
# hexadecimal escape sequence |
7398
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
7399
|
1
|
|
|
|
|
6
|
$char[$i] = Eeuctw::hexchr($1); |
7400
|
|
|
|
|
|
|
} |
7401
|
|
|
|
|
|
|
|
7402
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
7403
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
7404
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
7405
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
7406
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
7407
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x8E\xA1-\xFE0-9\}][^\x8E\xA1-\xFE\}]*) \} ) \z/oxms) { |
7408
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
7409
|
|
|
|
|
|
|
} |
7410
|
|
|
|
|
|
|
|
7411
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
7412
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
7413
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
7414
|
|
|
|
|
|
|
} |
7415
|
|
|
|
|
|
|
|
7416
|
308
|
50
|
100
|
|
|
959
|
if (0) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
7417
|
|
|
|
|
|
|
} |
7418
|
|
|
|
|
|
|
|
7419
|
|
|
|
|
|
|
# join separated multiple-octet |
7420
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
7421
|
0
|
0
|
0
|
|
|
0
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
7422
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
7423
|
|
|
|
|
|
|
} |
7424
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
7425
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
7426
|
|
|
|
|
|
|
} |
7427
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
7428
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 1; |
7429
|
|
|
|
|
|
|
} |
7430
|
|
|
|
|
|
|
} |
7431
|
|
|
|
|
|
|
|
7432
|
|
|
|
|
|
|
# open character class [...] |
7433
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
7434
|
3
|
|
|
|
|
4
|
my $left = $i; |
7435
|
3
|
50
|
|
|
|
8
|
if ($char[$i+1] eq ']') { |
7436
|
0
|
|
|
|
|
0
|
$i++; |
7437
|
|
|
|
|
|
|
} |
7438
|
3
|
|
|
|
|
3
|
while (1) { |
7439
|
7
|
50
|
|
|
|
10
|
if (++$i > $#char) { |
7440
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
7441
|
|
|
|
|
|
|
} |
7442
|
7
|
100
|
|
|
|
14
|
if ($char[$i] eq ']') { |
7443
|
3
|
|
|
|
|
3
|
my $right = $i; |
7444
|
|
|
|
|
|
|
|
7445
|
|
|
|
|
|
|
# [...] |
7446
|
3
|
50
|
|
|
|
16
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
7447
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
0
|
|
|
|
|
0
|
|
7448
|
|
|
|
|
|
|
} |
7449
|
|
|
|
|
|
|
else { |
7450
|
3
|
|
|
|
|
16
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
7451
|
|
|
|
|
|
|
} |
7452
|
|
|
|
|
|
|
|
7453
|
3
|
|
|
|
|
3
|
$i = $left; |
7454
|
3
|
|
|
|
|
7
|
last; |
7455
|
|
|
|
|
|
|
} |
7456
|
|
|
|
|
|
|
} |
7457
|
|
|
|
|
|
|
} |
7458
|
|
|
|
|
|
|
|
7459
|
|
|
|
|
|
|
# open character class [^...] |
7460
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
7461
|
1
|
|
|
|
|
2
|
my $left = $i; |
7462
|
1
|
50
|
|
|
|
4
|
if ($char[$i+1] eq ']') { |
7463
|
0
|
|
|
|
|
0
|
$i++; |
7464
|
|
|
|
|
|
|
} |
7465
|
1
|
|
|
|
|
1
|
while (1) { |
7466
|
2
|
50
|
|
|
|
5
|
if (++$i > $#char) { |
7467
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
7468
|
|
|
|
|
|
|
} |
7469
|
2
|
100
|
|
|
|
4
|
if ($char[$i] eq ']') { |
7470
|
1
|
|
|
|
|
1
|
my $right = $i; |
7471
|
|
|
|
|
|
|
|
7472
|
|
|
|
|
|
|
# [^...] |
7473
|
1
|
50
|
|
|
|
7
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
7474
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Eeuctw::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
|
0
|
|
|
|
|
0
|
|
7475
|
|
|
|
|
|
|
} |
7476
|
|
|
|
|
|
|
else { |
7477
|
1
|
|
|
|
|
4
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
7478
|
|
|
|
|
|
|
} |
7479
|
|
|
|
|
|
|
|
7480
|
1
|
|
|
|
|
2
|
$i = $left; |
7481
|
1
|
|
|
|
|
3
|
last; |
7482
|
|
|
|
|
|
|
} |
7483
|
|
|
|
|
|
|
} |
7484
|
|
|
|
|
|
|
} |
7485
|
|
|
|
|
|
|
|
7486
|
|
|
|
|
|
|
# rewrite character class or escape character |
7487
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
7488
|
5
|
|
|
|
|
18
|
$char[$i] = $char; |
7489
|
|
|
|
|
|
|
} |
7490
|
|
|
|
|
|
|
|
7491
|
|
|
|
|
|
|
# P.794 29.2.161. split |
7492
|
|
|
|
|
|
|
# in Chapter 29: Functions |
7493
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7494
|
|
|
|
|
|
|
|
7495
|
|
|
|
|
|
|
# P.951 split |
7496
|
|
|
|
|
|
|
# in Chapter 27: Functions |
7497
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7498
|
|
|
|
|
|
|
|
7499
|
|
|
|
|
|
|
# said "The //m modifier is assumed when you split on the pattern /^/", |
7500
|
|
|
|
|
|
|
# but perl5.008 is not so. Therefore, this software adds //m. |
7501
|
|
|
|
|
|
|
# (and so on) |
7502
|
|
|
|
|
|
|
|
7503
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
7504
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
7505
|
11
|
|
|
|
|
47
|
$modifier .= 'm'; |
7506
|
|
|
|
|
|
|
} |
7507
|
|
|
|
|
|
|
|
7508
|
|
|
|
|
|
|
# /i modifier |
7509
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
7510
|
6
|
50
|
|
|
|
17
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
7511
|
6
|
|
|
|
|
17
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
7512
|
|
|
|
|
|
|
} |
7513
|
|
|
|
|
|
|
else { |
7514
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
7515
|
|
|
|
|
|
|
} |
7516
|
|
|
|
|
|
|
} |
7517
|
|
|
|
|
|
|
|
7518
|
|
|
|
|
|
|
# \u \l \U \L \F \Q \E |
7519
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
7520
|
2
|
50
|
|
|
|
11
|
if ($right_e < $left_e) { |
7521
|
0
|
|
|
|
|
0
|
$char[$i] = '\\' . $char[$i]; |
7522
|
|
|
|
|
|
|
} |
7523
|
|
|
|
|
|
|
} |
7524
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
7525
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ucfirst qq<'; |
7526
|
0
|
|
|
|
|
0
|
$left_e++; |
7527
|
|
|
|
|
|
|
} |
7528
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
7529
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lcfirst qq<'; |
7530
|
0
|
|
|
|
|
0
|
$left_e++; |
7531
|
|
|
|
|
|
|
} |
7532
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
7533
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::uc qq<'; |
7534
|
0
|
|
|
|
|
0
|
$left_e++; |
7535
|
|
|
|
|
|
|
} |
7536
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
7537
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::lc qq<'; |
7538
|
0
|
|
|
|
|
0
|
$left_e++; |
7539
|
|
|
|
|
|
|
} |
7540
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
7541
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::fc qq<'; |
7542
|
0
|
|
|
|
|
0
|
$left_e++; |
7543
|
|
|
|
|
|
|
} |
7544
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
7545
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
7546
|
0
|
|
|
|
|
0
|
$left_e++; |
7547
|
|
|
|
|
|
|
} |
7548
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
7549
|
0
|
0
|
|
|
|
0
|
if ($right_e < $left_e) { |
7550
|
0
|
|
|
|
|
0
|
$char[$i] = '>]}'; |
7551
|
0
|
|
|
|
|
0
|
$right_e++; |
7552
|
|
|
|
|
|
|
} |
7553
|
|
|
|
|
|
|
else { |
7554
|
0
|
|
|
|
|
0
|
$char[$i] = ''; |
7555
|
|
|
|
|
|
|
} |
7556
|
|
|
|
|
|
|
} |
7557
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
7558
|
0
|
|
|
|
|
0
|
while (1) { |
7559
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
7560
|
0
|
|
|
|
|
0
|
last; |
7561
|
|
|
|
|
|
|
} |
7562
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\E') { |
7563
|
0
|
|
|
|
|
0
|
last; |
7564
|
|
|
|
|
|
|
} |
7565
|
|
|
|
|
|
|
} |
7566
|
|
|
|
|
|
|
} |
7567
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
7568
|
|
|
|
|
|
|
} |
7569
|
|
|
|
|
|
|
|
7570
|
|
|
|
|
|
|
# $0 --> $0 |
7571
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
7572
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7573
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7574
|
|
|
|
|
|
|
} |
7575
|
|
|
|
|
|
|
} |
7576
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
7577
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7578
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7579
|
|
|
|
|
|
|
} |
7580
|
|
|
|
|
|
|
} |
7581
|
|
|
|
|
|
|
|
7582
|
|
|
|
|
|
|
# $$ --> $$ |
7583
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
7584
|
|
|
|
|
|
|
} |
7585
|
|
|
|
|
|
|
|
7586
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
7587
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
7588
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
7589
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
7590
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7591
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7592
|
|
|
|
|
|
|
} |
7593
|
|
|
|
|
|
|
} |
7594
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
7595
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
7596
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7597
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7598
|
|
|
|
|
|
|
} |
7599
|
|
|
|
|
|
|
} |
7600
|
|
|
|
|
|
|
|
7601
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
7602
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
7603
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
7604
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7605
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7606
|
|
|
|
|
|
|
} |
7607
|
|
|
|
|
|
|
} |
7608
|
|
|
|
|
|
|
|
7609
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
7610
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
7611
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
7612
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7613
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7614
|
|
|
|
|
|
|
} |
7615
|
|
|
|
|
|
|
} |
7616
|
|
|
|
|
|
|
|
7617
|
|
|
|
|
|
|
# $$foo |
7618
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
7619
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
7620
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7621
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7622
|
|
|
|
|
|
|
} |
7623
|
|
|
|
|
|
|
} |
7624
|
|
|
|
|
|
|
|
7625
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Eeuctw::PREMATCH() |
7626
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
7627
|
12
|
50
|
|
|
|
23
|
if ($ignorecase) { |
7628
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::PREMATCH())]}'; |
7629
|
|
|
|
|
|
|
} |
7630
|
|
|
|
|
|
|
else { |
7631
|
12
|
|
|
|
|
82
|
$char[$i] = '@{[Eeuctw::PREMATCH()]}'; |
7632
|
|
|
|
|
|
|
} |
7633
|
|
|
|
|
|
|
} |
7634
|
|
|
|
|
|
|
|
7635
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Eeuctw::MATCH() |
7636
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
7637
|
12
|
50
|
|
|
|
22
|
if ($ignorecase) { |
7638
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::MATCH())]}'; |
7639
|
|
|
|
|
|
|
} |
7640
|
|
|
|
|
|
|
else { |
7641
|
12
|
|
|
|
|
84
|
$char[$i] = '@{[Eeuctw::MATCH()]}'; |
7642
|
|
|
|
|
|
|
} |
7643
|
|
|
|
|
|
|
} |
7644
|
|
|
|
|
|
|
|
7645
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Eeuctw::POSTMATCH() |
7646
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
7647
|
9
|
50
|
|
|
|
20
|
if ($ignorecase) { |
7648
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(Eeuctw::POSTMATCH())]}'; |
7649
|
|
|
|
|
|
|
} |
7650
|
|
|
|
|
|
|
else { |
7651
|
9
|
|
|
|
|
67
|
$char[$i] = '@{[Eeuctw::POSTMATCH()]}'; |
7652
|
|
|
|
|
|
|
} |
7653
|
|
|
|
|
|
|
} |
7654
|
|
|
|
|
|
|
|
7655
|
|
|
|
|
|
|
# ${ foo } |
7656
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
7657
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7658
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $1 . ')]}'; |
7659
|
|
|
|
|
|
|
} |
7660
|
|
|
|
|
|
|
} |
7661
|
|
|
|
|
|
|
|
7662
|
|
|
|
|
|
|
# ${ ... } |
7663
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
7664
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
7665
|
0
|
0
|
|
|
|
0
|
if ($ignorecase) { |
7666
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7667
|
|
|
|
|
|
|
} |
7668
|
|
|
|
|
|
|
} |
7669
|
|
|
|
|
|
|
|
7670
|
|
|
|
|
|
|
# $scalar or @array |
7671
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
7672
|
3
|
|
|
|
|
6
|
$char[$i] = e_string($char[$i]); |
7673
|
3
|
50
|
|
|
|
24
|
if ($ignorecase) { |
7674
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Eeuctw::ignorecase(' . $char[$i] . ')]}'; |
7675
|
|
|
|
|
|
|
} |
7676
|
|
|
|
|
|
|
} |
7677
|
|
|
|
|
|
|
|
7678
|
|
|
|
|
|
|
# quote character before ? + * { |
7679
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
7680
|
7
|
100
|
|
|
|
43
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
7681
|
|
|
|
|
|
|
} |
7682
|
|
|
|
|
|
|
else { |
7683
|
4
|
|
|
|
|
27
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
7684
|
|
|
|
|
|
|
} |
7685
|
|
|
|
|
|
|
} |
7686
|
|
|
|
|
|
|
} |
7687
|
|
|
|
|
|
|
|
7688
|
|
|
|
|
|
|
# make regexp string |
7689
|
125
|
|
|
|
|
159
|
$modifier =~ tr/i//d; |
7690
|
125
|
50
|
|
|
|
271
|
if ($left_e > $right_e) { |
7691
|
0
|
|
|
|
|
0
|
return join '', 'Eeuctw::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier; |
7692
|
|
|
|
|
|
|
} |
7693
|
125
|
|
|
|
|
1189
|
return join '', 'Eeuctw::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
7694
|
|
|
|
|
|
|
} |
7695
|
|
|
|
|
|
|
|
7696
|
|
|
|
|
|
|
# |
7697
|
|
|
|
|
|
|
# escape regexp of split qr'' |
7698
|
|
|
|
|
|
|
# |
7699
|
|
|
|
|
|
|
sub e_split_q { |
7700
|
24
|
|
|
24
|
0
|
79
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
7701
|
24
|
|
100
|
|
|
60
|
$modifier ||= ''; |
7702
|
|
|
|
|
|
|
|
7703
|
24
|
|
|
|
|
39
|
$modifier =~ tr/p//d; |
7704
|
24
|
50
|
|
|
|
71
|
if ($modifier =~ /([adlu])/oxms) { |
7705
|
0
|
|
|
|
|
0
|
my $line = 0; |
7706
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
7707
|
0
|
0
|
|
|
|
0
|
if ($filename ne __FILE__) { |
7708
|
0
|
|
|
|
|
0
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
7709
|
0
|
|
|
|
|
0
|
last; |
7710
|
|
|
|
|
|
|
} |
7711
|
|
|
|
|
|
|
} |
7712
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
7713
|
|
|
|
|
|
|
} |
7714
|
|
|
|
|
|
|
|
7715
|
24
|
|
|
|
|
32
|
$slash = 'div'; |
7716
|
|
|
|
|
|
|
|
7717
|
|
|
|
|
|
|
# /b /B modifier |
7718
|
24
|
100
|
|
|
|
52
|
if ($modifier =~ tr/bB//d) { |
7719
|
12
|
|
|
|
|
61
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
7720
|
|
|
|
|
|
|
} |
7721
|
|
|
|
|
|
|
|
7722
|
12
|
100
|
|
|
|
33
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
7723
|
|
|
|
|
|
|
|
7724
|
|
|
|
|
|
|
# split regexp |
7725
|
12
|
|
|
|
|
188
|
my @char = $string =~ /\G((?> |
7726
|
|
|
|
|
|
|
[^\x8E\xA1-\xFE\\\[] | |
7727
|
|
|
|
|
|
|
[\xA1-\xFE][\xA1-\xFE]|\x8E[\xA1-\xB0][\xA1-\xFE][\x00-\xFF] | |
7728
|
|
|
|
|
|
|
\[\^ | |
7729
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
7730
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
7731
|
|
|
|
|
|
|
\\ (?:$q_char) | |
7732
|
|
|
|
|
|
|
(?:$q_char) |
7733
|
|
|
|
|
|
|
))/oxmsg; |
7734
|
|
|
|
|
|
|
|
7735
|
|
|
|
|
|
|
# unescape character |
7736
|
12
|
|
|
|
|
49
|
for (my $i=0; $i <= $#char; $i++) { |
7737
|
12
|
50
|
33
|
|
|
63
|
if (0) { |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7738
|
|
|
|
|
|
|
} |
7739
|
|
|
|
|
|
|
|
7740
|
|
|
|
|
|
|
# open character class [...] |
7741
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
7742
|
0
|
|
|
|
|
0
|
my $left = $i; |
7743
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
7744
|
0
|
|
|
|
|
0
|
$i++; |
7745
|
|
|
|
|
|
|
} |
7746
|
0
|
|
|
|
|
0
|
while (1) { |
7747
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
7748
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
7749
|
|
|
|
|
|
|
} |
7750
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
7751
|
0
|
|
|
|
|
0
|
my $right = $i; |
7752
|
|
|
|
|
|
|
|
7753
|
|
|
|
|
|
|
# [...] |
7754
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_qr(@char[$left+1..$right-1], $modifier); |
7755
|
|
|
|
|
|
|
|
7756
|
0
|
|
|
|
|
0
|
$i = $left; |
7757
|
0
|
|
|
|
|
0
|
last; |
7758
|
|
|
|
|
|
|
} |
7759
|
|
|
|
|
|
|
} |
7760
|
|
|
|
|
|
|
} |
7761
|
|
|
|
|
|
|
|
7762
|
|
|
|
|
|
|
# open character class [^...] |
7763
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
7764
|
0
|
|
|
|
|
0
|
my $left = $i; |
7765
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
7766
|
0
|
|
|
|
|
0
|
$i++; |
7767
|
|
|
|
|
|
|
} |
7768
|
0
|
|
|
|
|
0
|
while (1) { |
7769
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
7770
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
7771
|
|
|
|
|
|
|
} |
7772
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
7773
|
0
|
|
|
|
|
0
|
my $right = $i; |
7774
|
|
|
|
|
|
|
|
7775
|
|
|
|
|
|
|
# [^...] |
7776
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Eeuctw::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
7777
|
|
|
|
|
|
|
|
7778
|
0
|
|
|
|
|
0
|
$i = $left; |
7779
|
0
|
|
|
|
|
0
|
last; |
7780
|
|
|
|
|
|
|
} |
7781
|
|
|
|
|
|
|
} |
7782
|
|
|
|
|
|
|
} |
7783
|
|
|
|
|
|
|
|
7784
|
|
|
|
|
|
|
# rewrite character class or escape character |
7785
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
7786
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
7787
|
|
|
|
|
|
|
} |
7788
|
|
|
|
|
|
|
|
7789
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
7790
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
7791
|
0
|
|
|
|
|
0
|
$modifier .= 'm'; |
7792
|
|
|
|
|
|
|
} |
7793
|
|
|
|
|
|
|
|
7794
|
|
|
|
|
|
|
# /i modifier |
7795
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Eeuctw::uc($char[$i]) ne Eeuctw::fc($char[$i]))) { |
7796
|
4
|
50
|
|
|
|
10
|
if (CORE::length(Eeuctw::fc($char[$i])) == 1) { |
7797
|
4
|
|
|
|
|
13
|
$char[$i] = '[' . Eeuctw::uc($char[$i]) . Eeuctw::fc($char[$i]) . ']'; |
7798
|
|
|
|
|
|
|
} |
7799
|
|
|
|
|
|
|
else { |
7800
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . Eeuctw::uc($char[$i]) . '|' . Eeuctw::fc($char[$i]) . ')'; |
7801
|
|
|
|
|
|
|
} |
7802
|
|
|
|
|
|
|
} |
7803
|
|
|
|
|
|
|
|
7804
|
|
|
|
|
|
|
# quote character before ? + * { |
7805
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
7806
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
7807
|
|
|
|
|
|
|
} |
7808
|
|
|
|
|
|
|
else { |
7809
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
7810
|
|
|
|
|
|
|
} |
7811
|
|
|
|
|
|
|
} |
7812
|
|
|
|
|
|
|
} |
7813
|
|
|
|
|
|
|
|
7814
|
12
|
|
|
|
|
22
|
$modifier =~ tr/i//d; |
7815
|
12
|
|
|
|
|
103
|
return join '', 'Eeuctw::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
7816
|
|
|
|
|
|
|
} |
7817
|
|
|
|
|
|
|
|
7818
|
|
|
|
|
|
|
# |
7819
|
|
|
|
|
|
|
# instead of Carp::carp |
7820
|
|
|
|
|
|
|
# |
7821
|
|
|
|
|
|
|
sub carp { |
7822
|
0
|
|
|
0
|
0
|
|
my($package,$filename,$line) = caller(1); |
7823
|
0
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
7824
|
|
|
|
|
|
|
} |
7825
|
|
|
|
|
|
|
|
7826
|
|
|
|
|
|
|
# |
7827
|
|
|
|
|
|
|
# instead of Carp::croak |
7828
|
|
|
|
|
|
|
# |
7829
|
|
|
|
|
|
|
sub croak { |
7830
|
0
|
|
|
0
|
0
|
|
my($package,$filename,$line) = caller(1); |
7831
|
0
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
7832
|
0
|
|
|
|
|
|
die "\n"; |
7833
|
|
|
|
|
|
|
} |
7834
|
|
|
|
|
|
|
|
7835
|
|
|
|
|
|
|
# |
7836
|
|
|
|
|
|
|
# instead of Carp::cluck |
7837
|
|
|
|
|
|
|
# |
7838
|
|
|
|
|
|
|
sub cluck { |
7839
|
0
|
|
|
0
|
0
|
|
my $i = 0; |
7840
|
0
|
|
|
|
|
|
my @cluck = (); |
7841
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
7842
|
0
|
|
|
|
|
|
push @cluck, "[$i] $filename($line) $package::$subroutine\n"; |
7843
|
0
|
|
|
|
|
|
$i++; |
7844
|
|
|
|
|
|
|
} |
7845
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @cluck; |
7846
|
0
|
|
|
|
|
|
print STDERR "\n"; |
7847
|
0
|
|
|
|
|
|
carp @_; |
7848
|
|
|
|
|
|
|
} |
7849
|
|
|
|
|
|
|
|
7850
|
|
|
|
|
|
|
# |
7851
|
|
|
|
|
|
|
# instead of Carp::confess |
7852
|
|
|
|
|
|
|
# |
7853
|
|
|
|
|
|
|
sub confess { |
7854
|
0
|
|
|
0
|
0
|
|
my $i = 0; |
7855
|
0
|
|
|
|
|
|
my @confess = (); |
7856
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
7857
|
0
|
|
|
|
|
|
push @confess, "[$i] $filename($line) $package::$subroutine\n"; |
7858
|
0
|
|
|
|
|
|
$i++; |
7859
|
|
|
|
|
|
|
} |
7860
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @confess; |
7861
|
0
|
|
|
|
|
|
print STDERR "\n"; |
7862
|
0
|
|
|
|
|
|
croak @_; |
7863
|
|
|
|
|
|
|
} |
7864
|
|
|
|
|
|
|
|
7865
|
|
|
|
|
|
|
1; |
7866
|
|
|
|
|
|
|
|
7867
|
|
|
|
|
|
|
__END__ |