line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egb18030; |
2
|
389
|
|
|
389
|
|
11884
|
use strict; |
|
389
|
|
|
|
|
683
|
|
|
389
|
|
|
|
|
18233
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Egb18030 - Run-time routines for GB18030.pm |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Char-GB18030/ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi |
10
|
|
|
|
|
|
|
###################################################################### |
11
|
|
|
|
|
|
|
|
12
|
389
|
|
|
389
|
|
5731
|
use 5.00503; # Galapagos Consensus 1998 for primetools |
|
389
|
|
|
|
|
4193
|
|
13
|
|
|
|
|
|
|
# use 5.008001; # Lancaster Consensus 2013 for toolchains |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# 12.3. Delaying use Until Runtime |
16
|
|
|
|
|
|
|
# in Chapter 12. Packages, Libraries, and Modules |
17
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
18
|
|
|
|
|
|
|
# (and so on) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Version numbers should be boring |
21
|
|
|
|
|
|
|
# http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/ |
22
|
|
|
|
|
|
|
# For the impatient, the disinterested or those who just want to follow |
23
|
|
|
|
|
|
|
# a recipe, my advice for all modules is this: |
24
|
|
|
|
|
|
|
# our $VERSION = "0.001"; # or "0.001_001" for a dev release |
25
|
|
|
|
|
|
|
# $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1' |
26
|
|
|
|
|
|
|
|
27
|
389
|
|
|
389
|
|
1870
|
use vars qw($VERSION); |
|
389
|
|
|
|
|
3970
|
|
|
389
|
|
|
|
|
65649
|
|
28
|
|
|
|
|
|
|
$VERSION = '1.13'; |
29
|
|
|
|
|
|
|
$VERSION = $VERSION; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BEGIN { |
32
|
389
|
50
|
|
389
|
|
7353
|
if ($^X =~ / jperl /oxmsi) { |
33
|
0
|
|
|
|
|
0
|
die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n"; |
34
|
|
|
|
|
|
|
} |
35
|
389
|
|
|
|
|
2155
|
if (CORE::ord('A') == 193) { |
36
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n"; |
37
|
|
|
|
|
|
|
} |
38
|
389
|
|
|
|
|
56639
|
if (CORE::ord('A') != 0x41) { |
39
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
BEGIN { |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# instead of utf8.pm |
46
|
389
|
|
|
389
|
|
30851
|
CORE::eval q{ |
|
389
|
|
|
389
|
|
3668
|
|
|
389
|
|
|
140
|
|
2405
|
|
|
389
|
|
|
|
|
52309
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
no warnings qw(redefine); |
48
|
|
|
|
|
|
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
49
|
|
|
|
|
|
|
*utf8::downgrade = sub { 1 }; |
50
|
|
|
|
|
|
|
*utf8::encode = sub { }; |
51
|
|
|
|
|
|
|
*utf8::decode = sub { 1 }; |
52
|
|
|
|
|
|
|
*utf8::is_utf8 = sub { }; |
53
|
|
|
|
|
|
|
*utf8::valid = sub { 1 }; |
54
|
|
|
|
|
|
|
}; |
55
|
389
|
50
|
|
|
|
166684
|
if ($@) { |
56
|
0
|
|
|
|
|
0
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
*utf8::downgrade = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
*utf8::encode = sub { }; |
59
|
0
|
|
|
|
|
0
|
*utf8::decode = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
60
|
0
|
|
|
|
|
0
|
*utf8::is_utf8 = sub { }; |
61
|
0
|
|
|
|
|
0
|
*utf8::valid = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# instead of Symbol.pm |
66
|
0
|
|
|
|
|
0
|
BEGIN { |
67
|
|
|
|
|
|
|
sub gensym () { |
68
|
0
|
|
|
0
|
0
|
0
|
return \do { local *_ }; |
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub qualify ($$) { |
72
|
0
|
|
|
1152
|
0
|
0
|
my($name) = @_; |
73
|
|
|
|
|
|
|
|
74
|
1152
|
50
|
|
|
|
2770
|
if (ref $name) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
75
|
1152
|
|
|
|
|
4766
|
return $name; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif (Egb18030::index($name,'::') >= 0) { |
78
|
0
|
|
|
|
|
0
|
return $name; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif (Egb18030::index($name,"'") >= 0) { |
81
|
0
|
|
|
|
|
0
|
return $name; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# special character, "^xyz" |
85
|
|
|
|
|
|
|
elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) { |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# RGS 2001-11-05 : translate leading ^X to control-char |
88
|
0
|
|
|
|
|
0
|
$name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee; |
|
0
|
|
|
|
|
0
|
|
89
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Global names |
93
|
|
|
|
|
|
|
elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) { |
94
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# or other |
98
|
|
|
|
|
|
|
elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) { |
99
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
elsif (defined $_[1]) { |
103
|
0
|
|
|
|
|
0
|
return $_[1] . '::' . $name; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
1152
|
|
|
|
|
10281
|
return (caller)[0] . '::' . $name; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub qualify_to_ref ($;$) { |
111
|
0
|
50
|
|
1152
|
0
|
0
|
if (defined $_[1]) { |
112
|
389
|
|
|
389
|
|
6727
|
no strict qw(refs); |
|
389
|
|
|
|
|
2246
|
|
|
389
|
|
|
|
|
33349
|
|
113
|
1152
|
|
|
|
|
3562
|
return \*{ qualify $_[0], $_[1] }; |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else { |
116
|
389
|
|
|
389
|
|
2497
|
no strict qw(refs); |
|
389
|
|
|
0
|
|
2163
|
|
|
389
|
|
|
|
|
77101
|
|
117
|
0
|
|
|
|
|
0
|
return \*{ qualify $_[0], (caller)[0] }; |
|
1152
|
|
|
|
|
1893
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# P.714 29.2.39. flock |
123
|
|
|
|
|
|
|
# in Chapter 29: Functions |
124
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# P.863 flock |
127
|
|
|
|
|
|
|
# in Chapter 27: Functions |
128
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub LOCK_SH() {1} |
131
|
|
|
|
|
|
|
sub LOCK_EX() {2} |
132
|
|
|
|
|
|
|
sub LOCK_UN() {8} |
133
|
|
|
|
|
|
|
sub LOCK_NB() {4} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# instead of Carp.pm |
136
|
|
|
|
|
|
|
sub carp; |
137
|
|
|
|
|
|
|
sub croak; |
138
|
|
|
|
|
|
|
sub cluck; |
139
|
|
|
|
|
|
|
sub confess; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# 6.18. Matching Multiple-Byte Characters |
142
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
143
|
|
|
|
|
|
|
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook. |
144
|
|
|
|
|
|
|
# (and so on) |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# regexp of character |
147
|
|
|
|
|
|
|
my $your_char = q{[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF]|[\x00-\xFF]}; |
148
|
389
|
|
|
389
|
|
4562
|
use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms; |
|
389
|
|
|
|
|
3367
|
|
|
389
|
|
|
|
|
32963
|
|
149
|
389
|
|
|
389
|
|
3967
|
use vars qw($q_char); $q_char = qr/$your_char/oxms; |
|
389
|
|
|
|
|
681
|
|
|
389
|
|
|
|
|
692323
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# GB18030 character range per length |
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
my %range_tr = (); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# |
157
|
|
|
|
|
|
|
# GB18030 case conversion |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
my %lc = (); |
160
|
|
|
|
|
|
|
@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)} = |
161
|
|
|
|
|
|
|
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); |
162
|
|
|
|
|
|
|
my %uc = (); |
163
|
|
|
|
|
|
|
@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)} = |
164
|
|
|
|
|
|
|
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); |
165
|
|
|
|
|
|
|
my %fc = (); |
166
|
|
|
|
|
|
|
@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)} = |
167
|
|
|
|
|
|
|
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); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
if (0) { |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b Egb18030 \z/oxms) { |
173
|
|
|
|
|
|
|
%range_tr = ( |
174
|
|
|
|
|
|
|
1 => [ [0x00..0x80], |
175
|
|
|
|
|
|
|
[0xFF..0xFF], |
176
|
|
|
|
|
|
|
], |
177
|
|
|
|
|
|
|
2 => [ [0x81..0xFE],[0x40..0x7E], |
178
|
|
|
|
|
|
|
[0x81..0xFE],[0x80..0xFE], |
179
|
|
|
|
|
|
|
], |
180
|
|
|
|
|
|
|
4 => [ [0x81..0xFE],[0x30..0x39],[0x81..0xFE],[0x30..0x39], |
181
|
|
|
|
|
|
|
], |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
else { |
186
|
|
|
|
|
|
|
croak "Don't know my package name '@{[__PACKAGE__]}'"; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# |
190
|
|
|
|
|
|
|
# @ARGV wildcard globbing |
191
|
|
|
|
|
|
|
# |
192
|
|
|
|
|
|
|
sub import { |
193
|
|
|
|
|
|
|
|
194
|
1152
|
50
|
|
5
|
|
5852
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
195
|
5
|
|
|
|
|
89
|
my @argv = (); |
196
|
0
|
|
|
|
|
0
|
for (@ARGV) { |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# has space |
199
|
0
|
0
|
|
|
|
0
|
if (/\A (?:$q_char)*? [ ] /oxms) { |
|
|
0
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
0
|
if (my @glob = Egb18030::glob(qq{"$_"})) { |
201
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
else { |
204
|
0
|
|
|
|
|
0
|
push @argv, $_; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# has wildcard metachar |
209
|
|
|
|
|
|
|
elsif (/\A (?:$q_char)*? [*?] /oxms) { |
210
|
0
|
0
|
|
|
|
0
|
if (my @glob = Egb18030::glob($_)) { |
211
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
else { |
214
|
0
|
|
|
|
|
0
|
push @argv, $_; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# no wildcard globbing |
219
|
|
|
|
|
|
|
else { |
220
|
0
|
|
|
|
|
0
|
push @argv, $_; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
0
|
|
|
|
|
0
|
@ARGV = @argv; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
0
|
*Char::ord = \&GB18030::ord; |
227
|
5
|
|
|
|
|
29
|
*Char::ord_ = \&GB18030::ord_; |
228
|
5
|
|
|
|
|
15
|
*Char::reverse = \&GB18030::reverse; |
229
|
5
|
|
|
|
|
12
|
*Char::getc = \&GB18030::getc; |
230
|
5
|
|
|
|
|
12
|
*Char::length = \&GB18030::length; |
231
|
5
|
|
|
|
|
11
|
*Char::substr = \&GB18030::substr; |
232
|
5
|
|
|
|
|
13
|
*Char::index = \&GB18030::index; |
233
|
5
|
|
|
|
|
10
|
*Char::rindex = \&GB18030::rindex; |
234
|
5
|
|
|
|
|
10
|
*Char::eval = \&GB18030::eval; |
235
|
5
|
|
|
|
|
37
|
*Char::escape = \&GB18030::escape; |
236
|
5
|
|
|
|
|
14
|
*Char::escape_token = \&GB18030::escape_token; |
237
|
5
|
|
|
|
|
101
|
*Char::escape_script = \&GB18030::escape_script; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# P.230 Care with Prototypes |
241
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
242
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
243
|
|
|
|
|
|
|
# |
244
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
245
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
246
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
247
|
|
|
|
|
|
|
# the world a better place. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# P.332 Care with Prototypes |
250
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
251
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
252
|
|
|
|
|
|
|
# |
253
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
254
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
255
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
256
|
|
|
|
|
|
|
# the world a better place. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# |
259
|
|
|
|
|
|
|
# Prototypes of subroutines |
260
|
|
|
|
|
|
|
# |
261
|
|
|
|
0
|
|
|
sub unimport {} |
262
|
|
|
|
|
|
|
sub Egb18030::split(;$$$); |
263
|
|
|
|
|
|
|
sub Egb18030::tr($$$$;$); |
264
|
|
|
|
|
|
|
sub Egb18030::chop(@); |
265
|
|
|
|
|
|
|
sub Egb18030::index($$;$); |
266
|
|
|
|
|
|
|
sub Egb18030::rindex($$;$); |
267
|
|
|
|
|
|
|
sub Egb18030::lcfirst(@); |
268
|
|
|
|
|
|
|
sub Egb18030::lcfirst_(); |
269
|
|
|
|
|
|
|
sub Egb18030::lc(@); |
270
|
|
|
|
|
|
|
sub Egb18030::lc_(); |
271
|
|
|
|
|
|
|
sub Egb18030::ucfirst(@); |
272
|
|
|
|
|
|
|
sub Egb18030::ucfirst_(); |
273
|
|
|
|
|
|
|
sub Egb18030::uc(@); |
274
|
|
|
|
|
|
|
sub Egb18030::uc_(); |
275
|
|
|
|
|
|
|
sub Egb18030::fc(@); |
276
|
|
|
|
|
|
|
sub Egb18030::fc_(); |
277
|
|
|
|
|
|
|
sub Egb18030::ignorecase; |
278
|
|
|
|
|
|
|
sub Egb18030::classic_character_class; |
279
|
|
|
|
|
|
|
sub Egb18030::capture; |
280
|
|
|
|
|
|
|
sub Egb18030::chr(;$); |
281
|
|
|
|
|
|
|
sub Egb18030::chr_(); |
282
|
|
|
|
|
|
|
sub Egb18030::filetest; |
283
|
|
|
|
|
|
|
sub Egb18030::r(;*@); |
284
|
|
|
|
|
|
|
sub Egb18030::w(;*@); |
285
|
|
|
|
|
|
|
sub Egb18030::x(;*@); |
286
|
|
|
|
|
|
|
sub Egb18030::o(;*@); |
287
|
|
|
|
|
|
|
sub Egb18030::R(;*@); |
288
|
|
|
|
|
|
|
sub Egb18030::W(;*@); |
289
|
|
|
|
|
|
|
sub Egb18030::X(;*@); |
290
|
|
|
|
|
|
|
sub Egb18030::O(;*@); |
291
|
|
|
|
|
|
|
sub Egb18030::e(;*@); |
292
|
|
|
|
|
|
|
sub Egb18030::z(;*@); |
293
|
|
|
|
|
|
|
sub Egb18030::s(;*@); |
294
|
|
|
|
|
|
|
sub Egb18030::f(;*@); |
295
|
|
|
|
|
|
|
sub Egb18030::d(;*@); |
296
|
|
|
|
|
|
|
sub Egb18030::l(;*@); |
297
|
|
|
|
|
|
|
sub Egb18030::p(;*@); |
298
|
|
|
|
|
|
|
sub Egb18030::S(;*@); |
299
|
|
|
|
|
|
|
sub Egb18030::b(;*@); |
300
|
|
|
|
|
|
|
sub Egb18030::c(;*@); |
301
|
|
|
|
|
|
|
sub Egb18030::u(;*@); |
302
|
|
|
|
|
|
|
sub Egb18030::g(;*@); |
303
|
|
|
|
|
|
|
sub Egb18030::k(;*@); |
304
|
|
|
|
|
|
|
sub Egb18030::T(;*@); |
305
|
|
|
|
|
|
|
sub Egb18030::B(;*@); |
306
|
|
|
|
|
|
|
sub Egb18030::M(;*@); |
307
|
|
|
|
|
|
|
sub Egb18030::A(;*@); |
308
|
|
|
|
|
|
|
sub Egb18030::C(;*@); |
309
|
|
|
|
|
|
|
sub Egb18030::filetest_; |
310
|
|
|
|
|
|
|
sub Egb18030::r_(); |
311
|
|
|
|
|
|
|
sub Egb18030::w_(); |
312
|
|
|
|
|
|
|
sub Egb18030::x_(); |
313
|
|
|
|
|
|
|
sub Egb18030::o_(); |
314
|
|
|
|
|
|
|
sub Egb18030::R_(); |
315
|
|
|
|
|
|
|
sub Egb18030::W_(); |
316
|
|
|
|
|
|
|
sub Egb18030::X_(); |
317
|
|
|
|
|
|
|
sub Egb18030::O_(); |
318
|
|
|
|
|
|
|
sub Egb18030::e_(); |
319
|
|
|
|
|
|
|
sub Egb18030::z_(); |
320
|
|
|
|
|
|
|
sub Egb18030::s_(); |
321
|
|
|
|
|
|
|
sub Egb18030::f_(); |
322
|
|
|
|
|
|
|
sub Egb18030::d_(); |
323
|
|
|
|
|
|
|
sub Egb18030::l_(); |
324
|
|
|
|
|
|
|
sub Egb18030::p_(); |
325
|
|
|
|
|
|
|
sub Egb18030::S_(); |
326
|
|
|
|
|
|
|
sub Egb18030::b_(); |
327
|
|
|
|
|
|
|
sub Egb18030::c_(); |
328
|
|
|
|
|
|
|
sub Egb18030::u_(); |
329
|
|
|
|
|
|
|
sub Egb18030::g_(); |
330
|
|
|
|
|
|
|
sub Egb18030::k_(); |
331
|
|
|
|
|
|
|
sub Egb18030::T_(); |
332
|
|
|
|
|
|
|
sub Egb18030::B_(); |
333
|
|
|
|
|
|
|
sub Egb18030::M_(); |
334
|
|
|
|
|
|
|
sub Egb18030::A_(); |
335
|
|
|
|
|
|
|
sub Egb18030::C_(); |
336
|
|
|
|
|
|
|
sub Egb18030::glob($); |
337
|
|
|
|
|
|
|
sub Egb18030::glob_(); |
338
|
|
|
|
|
|
|
sub Egb18030::lstat(*); |
339
|
|
|
|
|
|
|
sub Egb18030::lstat_(); |
340
|
|
|
|
|
|
|
sub Egb18030::opendir(*$); |
341
|
|
|
|
|
|
|
sub Egb18030::stat(*); |
342
|
|
|
|
|
|
|
sub Egb18030::stat_(); |
343
|
|
|
|
|
|
|
sub Egb18030::unlink(@); |
344
|
|
|
|
|
|
|
sub Egb18030::chdir(;$); |
345
|
|
|
|
|
|
|
sub Egb18030::do($); |
346
|
|
|
|
|
|
|
sub Egb18030::require(;$); |
347
|
|
|
|
|
|
|
sub Egb18030::telldir(*); |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub GB18030::ord(;$); |
350
|
|
|
|
|
|
|
sub GB18030::ord_(); |
351
|
|
|
|
|
|
|
sub GB18030::reverse(@); |
352
|
|
|
|
|
|
|
sub GB18030::getc(;*@); |
353
|
|
|
|
|
|
|
sub GB18030::length(;$); |
354
|
|
|
|
|
|
|
sub GB18030::substr($$;$$); |
355
|
|
|
|
|
|
|
sub GB18030::index($$;$); |
356
|
|
|
|
|
|
|
sub GB18030::rindex($$;$); |
357
|
|
|
|
|
|
|
sub GB18030::escape(;$); |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
# |
360
|
|
|
|
|
|
|
# Regexp work |
361
|
|
|
|
|
|
|
# |
362
|
389
|
|
|
|
|
46687
|
use vars qw( |
363
|
|
|
|
|
|
|
$re_a |
364
|
|
|
|
|
|
|
$re_t |
365
|
|
|
|
|
|
|
$re_n |
366
|
|
|
|
|
|
|
$re_r |
367
|
389
|
|
|
389
|
|
4007
|
); |
|
389
|
|
|
|
|
4674
|
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
# |
370
|
|
|
|
|
|
|
# Character class |
371
|
|
|
|
|
|
|
# |
372
|
389
|
|
|
|
|
106577
|
use vars qw( |
373
|
|
|
|
|
|
|
$dot |
374
|
|
|
|
|
|
|
$dot_s |
375
|
|
|
|
|
|
|
$eD |
376
|
|
|
|
|
|
|
$eS |
377
|
|
|
|
|
|
|
$eW |
378
|
|
|
|
|
|
|
$eH |
379
|
|
|
|
|
|
|
$eV |
380
|
|
|
|
|
|
|
$eR |
381
|
|
|
|
|
|
|
$eN |
382
|
|
|
|
|
|
|
$not_alnum |
383
|
|
|
|
|
|
|
$not_alpha |
384
|
|
|
|
|
|
|
$not_ascii |
385
|
|
|
|
|
|
|
$not_blank |
386
|
|
|
|
|
|
|
$not_cntrl |
387
|
|
|
|
|
|
|
$not_digit |
388
|
|
|
|
|
|
|
$not_graph |
389
|
|
|
|
|
|
|
$not_lower |
390
|
|
|
|
|
|
|
$not_lower_i |
391
|
|
|
|
|
|
|
$not_print |
392
|
|
|
|
|
|
|
$not_punct |
393
|
|
|
|
|
|
|
$not_space |
394
|
|
|
|
|
|
|
$not_upper |
395
|
|
|
|
|
|
|
$not_upper_i |
396
|
|
|
|
|
|
|
$not_word |
397
|
|
|
|
|
|
|
$not_xdigit |
398
|
|
|
|
|
|
|
$eb |
399
|
|
|
|
|
|
|
$eB |
400
|
389
|
|
|
389
|
|
6227
|
); |
|
389
|
|
|
|
|
2152
|
|
401
|
|
|
|
|
|
|
|
402
|
389
|
|
|
|
|
5007751
|
use vars qw( |
403
|
|
|
|
|
|
|
$anchor |
404
|
|
|
|
|
|
|
$matched |
405
|
389
|
|
|
389
|
|
2372
|
); |
|
389
|
|
|
|
|
737
|
|
406
|
|
|
|
|
|
|
${Egb18030::anchor} = qr{\G(?>[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])*?}oxms; |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# unless LONG_STRING_FOR_RE |
409
|
|
|
|
|
|
|
if (1) { |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
my $q_char_SADAHIRO_Tomoyuki_2002_01_17 = ''; |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# Quantifiers |
415
|
|
|
|
|
|
|
# {n,m} --- Match at least n but not more than m times |
416
|
|
|
|
|
|
|
# |
417
|
|
|
|
|
|
|
# n and m are limited to non-negative integral values less than a |
418
|
|
|
|
|
|
|
# preset limit defined when perl is built. This is usually 32766 on |
419
|
|
|
|
|
|
|
# the most common platforms. |
420
|
|
|
|
|
|
|
# |
421
|
|
|
|
|
|
|
# The following code is an attempt to solve the above limitations |
422
|
|
|
|
|
|
|
# in a multi-byte anchoring. |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
# avoid "Segmentation fault" and "Error: Parse exception" |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
# perl5101delta |
427
|
|
|
|
|
|
|
# http://perldoc.perl.org/perl5101delta.html |
428
|
|
|
|
|
|
|
# In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767} |
429
|
|
|
|
|
|
|
# [RT #60034, #60464]. For example, this match would fail: |
430
|
|
|
|
|
|
|
# ("ab" x 32768) =~ /^(ab)*$/ |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
# SEE ALSO |
433
|
|
|
|
|
|
|
# |
434
|
|
|
|
|
|
|
# Complex regular subexpression recursion limit |
435
|
|
|
|
|
|
|
# http://www.perlmonks.org/?node_id=810857 |
436
|
|
|
|
|
|
|
# |
437
|
|
|
|
|
|
|
# regexp iteration limits |
438
|
|
|
|
|
|
|
# http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html |
439
|
|
|
|
|
|
|
# |
440
|
|
|
|
|
|
|
# latest Perl won't match certain regexes more than 32768 characters long |
441
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long |
442
|
|
|
|
|
|
|
# |
443
|
|
|
|
|
|
|
# Break through the limitations of regular expressions of Perl |
444
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20110212/1297512479 |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
if (($] >= 5.010001) or |
447
|
|
|
|
|
|
|
# ActivePerl 5.6 or later (include 5.10.0) |
448
|
|
|
|
|
|
|
(defined($ActivePerl::VERSION) and ($ActivePerl::VERSION > 800)) or |
449
|
|
|
|
|
|
|
(($^O eq 'MSWin32') and ($] =~ /\A 5\.006/oxms)) |
450
|
|
|
|
|
|
|
) { |
451
|
|
|
|
|
|
|
my $sbcs = ''; # Single Byte Character Set |
452
|
|
|
|
|
|
|
for my $range (@{ $range_tr{1} }) { |
453
|
|
|
|
|
|
|
$sbcs .= sprintf('\\x%02X-\\x%02X', $range->[0], $range->[-1]); |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
if (0) { |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
# GB18030 encoding |
460
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b Egb18030 \z/oxms) { |
461
|
|
|
|
|
|
|
${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[^\x30-\x39\x81-\xFE](?>[\x30-\x39]|[\x81-\xFE][\x81-\xFE]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x30-\x39])*?}oxms; |
462
|
|
|
|
|
|
|
# ********************* octets not in multiple octet char (always char boundary) |
463
|
|
|
|
|
|
|
# *********** 1 octet chars in multiple octet char |
464
|
|
|
|
|
|
|
# ********************** 2 octet chars |
465
|
|
|
|
|
|
|
# ******************************************** 4 octet chars |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
# other encoding |
469
|
|
|
|
|
|
|
else { |
470
|
|
|
|
|
|
|
${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[$sbcs](?:[^$sbcs][^$sbcs])*?}oxms; |
471
|
|
|
|
|
|
|
# ******* octets not in multiple octet char (always char boundary) |
472
|
|
|
|
|
|
|
# **************** 2 octet chars |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
${Egb18030::anchor_SADAHIRO_Tomoyuki_2002_01_17} = |
476
|
|
|
|
|
|
|
qr{\G(?(?=.{0,32766}\z)(?:[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])*?|(?(?=[$sbcs]+\z).*?|(?:${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17})))}oxms; |
477
|
|
|
|
|
|
|
# qr{ |
478
|
|
|
|
|
|
|
# \G # (1), (2) |
479
|
|
|
|
|
|
|
# (? # (3) |
480
|
|
|
|
|
|
|
# (?=.{0,32766}\z) # (4) |
481
|
|
|
|
|
|
|
# (?:[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])*?| # (5) |
482
|
|
|
|
|
|
|
# (?(?=[$sbcs]+\z) # (6) |
483
|
|
|
|
|
|
|
# .*?| #(7) |
484
|
|
|
|
|
|
|
# (?:${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17}) # (8) |
485
|
|
|
|
|
|
|
# ))}oxms; |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
# avoid: Complex regular subexpression recursion limit (32766) exceeded at here. |
488
|
|
|
|
|
|
|
local $^W = 0; |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
if (((('A' x 32768).'B') !~ / ${Egb18030::anchor} B /oxms) and |
491
|
|
|
|
|
|
|
((('A' x 32768).'B') =~ / ${Egb18030::anchor_SADAHIRO_Tomoyuki_2002_01_17} B /oxms) |
492
|
|
|
|
|
|
|
) { |
493
|
|
|
|
|
|
|
${Egb18030::anchor} = ${Egb18030::anchor_SADAHIRO_Tomoyuki_2002_01_17}; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
else { |
496
|
|
|
|
|
|
|
undef ${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
# (1) |
501
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
502
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
503
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
504
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# (2) |
507
|
|
|
|
|
|
|
# P.255 Use leading anchors |
508
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front of expressions |
509
|
|
|
|
|
|
|
# in Chapter6: Crafting an Efficient Expression |
510
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
# (3) |
513
|
|
|
|
|
|
|
# P.138 Conditional: (? if then| else) |
514
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
515
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
# (4) |
518
|
|
|
|
|
|
|
# perlre |
519
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
520
|
|
|
|
|
|
|
# The "*" quantifier is equivalent to {0,} , the "+" quantifier to {1,} , |
521
|
|
|
|
|
|
|
# and the "?" quantifier to {0,1}, ., n, and m are limited to non-negative |
522
|
|
|
|
|
|
|
# integral values less than a preset limit defined when perl is built. |
523
|
|
|
|
|
|
|
# This is usually 32766 on the most common platforms. The actual limit |
524
|
|
|
|
|
|
|
# can be seen in the error message generated by code such as this: |
525
|
|
|
|
|
|
|
# $_ **= $_ , / {$_} / for 2 .. 42; |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
# (5) |
528
|
|
|
|
|
|
|
# P.1023 Multiple-Byte Anchoring |
529
|
|
|
|
|
|
|
# in Appendix W Perl Code Examples |
530
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
# (6) |
533
|
|
|
|
|
|
|
# if string has only SBCS (Single Byte Character Set) |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
# (7) |
536
|
|
|
|
|
|
|
# then .*? (isn't limited to 32766) |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
# (8) |
539
|
|
|
|
|
|
|
# else GB18030::Regexp::Const (SADAHIRO Tomoyuki) |
540
|
|
|
|
|
|
|
# http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#long |
541
|
|
|
|
|
|
|
# http://search.cpan.org/~sadahiro/GB18030-Regexp/ |
542
|
|
|
|
|
|
|
# $PadA = ' (?:\A| [\x00-\x80\xA0-\xDF])(?:[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE]{2})*?'; |
543
|
|
|
|
|
|
|
# $PadG = '\G(?: |[\x00-\xFF]*?[\x00-\x80\xA0-\xDF])(?:[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE]{2})*?'; |
544
|
|
|
|
|
|
|
# $PadGA = '\G(?:\A|(?:[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE]{2})+?|[\x00-\xFF]*?[\x00-\x80\xA0-\xDF] (?:[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE]{2})*?)'; |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
${Egb18030::dot} = qr{(?>[^\x81-\xFE\x0A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
547
|
|
|
|
|
|
|
${Egb18030::dot_s} = qr{(?>[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
548
|
|
|
|
|
|
|
${Egb18030::eD} = qr{(?>[^\x81-\xFE0-9]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
551
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
552
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
553
|
|
|
|
|
|
|
# ${Egb18030::eS} = qr{(?>[^\x81-\xFE\x09\x0A \x0C\x0D\x20]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
554
|
|
|
|
|
|
|
# ${Egb18030::eS} = qr{(?>[^\x81-\xFE\x09\x0A\x0B\x0C\x0D\x20]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
555
|
|
|
|
|
|
|
${Egb18030::eS} = qr{(?>[^\x81-\xFE\s]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
${Egb18030::eW} = qr{(?>[^\x81-\xFE0-9A-Z_a-z]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
558
|
|
|
|
|
|
|
${Egb18030::eH} = qr{(?>[^\x81-\xFE\x09\x20]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
559
|
|
|
|
|
|
|
${Egb18030::eV} = qr{(?>[^\x81-\xFE\x0A\x0B\x0C\x0D]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
560
|
|
|
|
|
|
|
${Egb18030::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])}; |
561
|
|
|
|
|
|
|
${Egb18030::eN} = qr{(?>[^\x81-\xFE\x0A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
562
|
|
|
|
|
|
|
${Egb18030::not_alnum} = qr{(?>[^\x81-\xFE\x30-\x39\x41-\x5A\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
563
|
|
|
|
|
|
|
${Egb18030::not_alpha} = qr{(?>[^\x81-\xFE\x41-\x5A\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
564
|
|
|
|
|
|
|
${Egb18030::not_ascii} = qr{(?>[^\x81-\xFE\x00-\x7F]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
565
|
|
|
|
|
|
|
${Egb18030::not_blank} = qr{(?>[^\x81-\xFE\x09\x20]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
566
|
|
|
|
|
|
|
${Egb18030::not_cntrl} = qr{(?>[^\x81-\xFE\x00-\x1F\x7F]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
567
|
|
|
|
|
|
|
${Egb18030::not_digit} = qr{(?>[^\x81-\xFE\x30-\x39]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
568
|
|
|
|
|
|
|
${Egb18030::not_graph} = qr{(?>[^\x81-\xFE\x21-\x7F]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
569
|
|
|
|
|
|
|
${Egb18030::not_lower} = qr{(?>[^\x81-\xFE\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
570
|
|
|
|
|
|
|
${Egb18030::not_lower_i} = qr{(?>[^\x81-\xFE\x41-\x5A\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
571
|
|
|
|
|
|
|
# ${Egb18030::not_lower_i} = qr{(?>[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; # older Perl compatible |
572
|
|
|
|
|
|
|
${Egb18030::not_print} = qr{(?>[^\x81-\xFE\x20-\x7F]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
573
|
|
|
|
|
|
|
${Egb18030::not_punct} = qr{(?>[^\x81-\xFE\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
574
|
|
|
|
|
|
|
${Egb18030::not_space} = qr{(?>[^\x81-\xFE\s\x0B]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
575
|
|
|
|
|
|
|
${Egb18030::not_upper} = qr{(?>[^\x81-\xFE\x41-\x5A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
576
|
|
|
|
|
|
|
${Egb18030::not_upper_i} = qr{(?>[^\x81-\xFE\x41-\x5A\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
577
|
|
|
|
|
|
|
# ${Egb18030::not_upper_i} = qr{(?>[^\x81-\xFE]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; # older Perl compatible |
578
|
|
|
|
|
|
|
${Egb18030::not_word} = qr{(?>[^\x81-\xFE\x30-\x39\x41-\x5A\x5F\x61-\x7A]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
579
|
|
|
|
|
|
|
${Egb18030::not_xdigit} = qr{(?>[^\x81-\xFE\x30-\x39\x41-\x46\x61-\x66]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])}; |
580
|
|
|
|
|
|
|
${Egb18030::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))}; |
581
|
|
|
|
|
|
|
${Egb18030::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]))}; |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
# avoid: Name "Egb18030::foo" used only once: possible typo at here. |
584
|
|
|
|
|
|
|
${Egb18030::dot} = ${Egb18030::dot}; |
585
|
|
|
|
|
|
|
${Egb18030::dot_s} = ${Egb18030::dot_s}; |
586
|
|
|
|
|
|
|
${Egb18030::eD} = ${Egb18030::eD}; |
587
|
|
|
|
|
|
|
${Egb18030::eS} = ${Egb18030::eS}; |
588
|
|
|
|
|
|
|
${Egb18030::eW} = ${Egb18030::eW}; |
589
|
|
|
|
|
|
|
${Egb18030::eH} = ${Egb18030::eH}; |
590
|
|
|
|
|
|
|
${Egb18030::eV} = ${Egb18030::eV}; |
591
|
|
|
|
|
|
|
${Egb18030::eR} = ${Egb18030::eR}; |
592
|
|
|
|
|
|
|
${Egb18030::eN} = ${Egb18030::eN}; |
593
|
|
|
|
|
|
|
${Egb18030::not_alnum} = ${Egb18030::not_alnum}; |
594
|
|
|
|
|
|
|
${Egb18030::not_alpha} = ${Egb18030::not_alpha}; |
595
|
|
|
|
|
|
|
${Egb18030::not_ascii} = ${Egb18030::not_ascii}; |
596
|
|
|
|
|
|
|
${Egb18030::not_blank} = ${Egb18030::not_blank}; |
597
|
|
|
|
|
|
|
${Egb18030::not_cntrl} = ${Egb18030::not_cntrl}; |
598
|
|
|
|
|
|
|
${Egb18030::not_digit} = ${Egb18030::not_digit}; |
599
|
|
|
|
|
|
|
${Egb18030::not_graph} = ${Egb18030::not_graph}; |
600
|
|
|
|
|
|
|
${Egb18030::not_lower} = ${Egb18030::not_lower}; |
601
|
|
|
|
|
|
|
${Egb18030::not_lower_i} = ${Egb18030::not_lower_i}; |
602
|
|
|
|
|
|
|
${Egb18030::not_print} = ${Egb18030::not_print}; |
603
|
|
|
|
|
|
|
${Egb18030::not_punct} = ${Egb18030::not_punct}; |
604
|
|
|
|
|
|
|
${Egb18030::not_space} = ${Egb18030::not_space}; |
605
|
|
|
|
|
|
|
${Egb18030::not_upper} = ${Egb18030::not_upper}; |
606
|
|
|
|
|
|
|
${Egb18030::not_upper_i} = ${Egb18030::not_upper_i}; |
607
|
|
|
|
|
|
|
${Egb18030::not_word} = ${Egb18030::not_word}; |
608
|
|
|
|
|
|
|
${Egb18030::not_xdigit} = ${Egb18030::not_xdigit}; |
609
|
|
|
|
|
|
|
${Egb18030::eb} = ${Egb18030::eb}; |
610
|
|
|
|
|
|
|
${Egb18030::eB} = ${Egb18030::eB}; |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
# |
613
|
|
|
|
|
|
|
# GB18030 split |
614
|
|
|
|
|
|
|
# |
615
|
|
|
|
|
|
|
sub Egb18030::split(;$$$) { |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
# P.794 29.2.161. split |
618
|
|
|
|
|
|
|
# in Chapter 29: Functions |
619
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# P.951 split |
622
|
|
|
|
|
|
|
# in Chapter 27: Functions |
623
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
624
|
|
|
|
|
|
|
|
625
|
5
|
|
|
0
|
0
|
11812
|
my $pattern = $_[0]; |
626
|
0
|
|
|
|
|
0
|
my $string = $_[1]; |
627
|
0
|
|
|
|
|
0
|
my $limit = $_[2]; |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " " |
630
|
0
|
0
|
|
|
|
0
|
if (not defined $pattern) { |
631
|
0
|
|
|
|
|
0
|
$pattern = ' '; |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
# if $string is omitted, the function splits the $_ string |
635
|
0
|
0
|
|
|
|
0
|
if (not defined $string) { |
636
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
637
|
0
|
|
|
|
|
0
|
$string = $_; |
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
else { |
640
|
0
|
|
|
|
|
0
|
$string = ''; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
|
644
|
0
|
|
|
|
|
0
|
my @split = (); |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# when string is empty |
647
|
0
|
0
|
|
|
|
0
|
if ($string eq '') { |
|
|
0
|
|
|
|
|
|
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
# resulting list value in list context |
650
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
651
|
0
|
|
|
|
|
0
|
return @split; |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# count of substrings in scalar context |
655
|
|
|
|
|
|
|
else { |
656
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
657
|
0
|
|
|
|
|
0
|
@_ = @split; |
658
|
0
|
|
|
|
|
0
|
return scalar @_; |
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
# split's first argument is more consistently interpreted |
663
|
|
|
|
|
|
|
# |
664
|
|
|
|
|
|
|
# After some changes earlier in v5.17, split's behavior has been simplified: |
665
|
|
|
|
|
|
|
# if the PATTERN argument evaluates to a string containing one space, it is |
666
|
|
|
|
|
|
|
# treated the way that a literal string containing one space once was. |
667
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " ", the function splits |
670
|
|
|
|
|
|
|
# on whitespace, /\s+/, after skipping any leading whitespace |
671
|
|
|
|
|
|
|
# (and so on) |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
elsif ($pattern eq ' ') { |
674
|
0
|
0
|
|
|
|
0
|
if (not defined $limit) { |
675
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string); |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
else { |
678
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string, $limit); |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
} |
681
|
|
|
|
|
|
|
|
682
|
0
|
|
|
|
|
0
|
local $q_char = $q_char; |
683
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 32766) { |
684
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\A [\x00-\x7F]+ \z/oxms) { |
|
|
0
|
|
|
|
|
|
685
|
0
|
|
|
|
|
0
|
$q_char = qr{.}s; |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
elsif (defined ${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17}) { |
688
|
0
|
|
|
|
|
0
|
$q_char = ${Egb18030::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
# if $limit is negative, it is treated as if an arbitrarily large $limit has been specified |
693
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $limit) or ($limit <= 0)) { |
|
|
0
|
|
|
|
|
|
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
# a pattern capable of matching either the null string or something longer than the |
696
|
|
|
|
|
|
|
# null string will split the value of $string into separate characters wherever it |
697
|
|
|
|
|
|
|
# matches the null string between characters |
698
|
|
|
|
|
|
|
# (and so on) |
699
|
|
|
|
|
|
|
|
700
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
701
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
702
|
0
|
|
|
|
|
0
|
my $limit = scalar(() = $string =~ /($pattern)/oxmsg); |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
705
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
706
|
|
|
|
|
|
|
# (and so on) |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
# the //m modifier is assumed when you split on the pattern /^/ |
709
|
|
|
|
|
|
|
# (and so on) |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
# V |
712
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) { |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
# if the $pattern contains parentheses, then the substring matched by each pair of parentheses |
715
|
|
|
|
|
|
|
# is included in the resulting list, interspersed with the fields that are ordinarily returned |
716
|
|
|
|
|
|
|
# (and so on) |
717
|
|
|
|
|
|
|
|
718
|
0
|
|
|
|
|
0
|
local $@; |
719
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
720
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
} |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
else { |
726
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
# V |
729
|
0
|
|
|
|
|
0
|
while ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
730
|
0
|
|
|
|
|
0
|
local $@; |
731
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
732
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
733
|
|
|
|
|
|
|
} |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
} |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
elsif ($limit > 0) { |
739
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
740
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
741
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
# V |
744
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)+?)$pattern//m) { |
745
|
0
|
|
|
|
|
0
|
local $@; |
746
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
747
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
748
|
|
|
|
|
|
|
} |
749
|
|
|
|
|
|
|
} |
750
|
|
|
|
|
|
|
} |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
else { |
753
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
754
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
# V |
757
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
758
|
0
|
|
|
|
|
0
|
local $@; |
759
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
760
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
} |
764
|
|
|
|
|
|
|
} |
765
|
|
|
|
|
|
|
} |
766
|
|
|
|
|
|
|
|
767
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 0) { |
768
|
0
|
|
|
|
|
0
|
push @split, $string; |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
# if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result |
772
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $_[2]) or ($_[2] == 0)) { |
773
|
0
|
|
0
|
|
|
0
|
while ((scalar(@split) >= 1) and ($split[-1] eq '')) { |
774
|
0
|
|
|
|
|
0
|
pop @split; |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
# resulting list value in list context |
779
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
780
|
0
|
|
|
|
|
0
|
return @split; |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
# count of substrings in scalar context |
784
|
|
|
|
|
|
|
else { |
785
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
786
|
0
|
|
|
|
|
0
|
@_ = @split; |
787
|
0
|
|
|
|
|
0
|
return scalar @_; |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
} |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
# |
792
|
|
|
|
|
|
|
# get last subexpression offsets |
793
|
|
|
|
|
|
|
# |
794
|
|
|
|
|
|
|
sub _last_subexpression_offsets { |
795
|
0
|
|
|
0
|
|
0
|
my $pattern = $_[0]; |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
# remove comment |
798
|
0
|
|
|
|
|
0
|
$pattern =~ s/\(\?\# .*? \)//oxmsg; |
799
|
|
|
|
|
|
|
|
800
|
0
|
|
|
|
|
0
|
my $modifier = ''; |
801
|
0
|
0
|
|
|
|
0
|
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) { |
802
|
0
|
|
|
|
|
0
|
$modifier = $1; |
803
|
0
|
|
|
|
|
0
|
$modifier =~ s/-[A-Za-z]*//; |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
# with /x modifier |
807
|
0
|
|
|
|
|
0
|
my @char = (); |
808
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /x/oxms) { |
809
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
810
|
|
|
|
|
|
|
[^\x81-\xFE\\\#\[\(]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
811
|
|
|
|
|
|
|
\\ $q_char | |
812
|
|
|
|
|
|
|
\# (?>[^\n]*) $ | |
813
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\xFE\\\]]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
814
|
|
|
|
|
|
|
\(\? | |
815
|
|
|
|
|
|
|
$q_char |
816
|
|
|
|
|
|
|
))/oxmsg; |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
# without /x modifier |
820
|
|
|
|
|
|
|
else { |
821
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
822
|
|
|
|
|
|
|
[^\x81-\xFE\\\[\(]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
823
|
|
|
|
|
|
|
\\ $q_char | |
824
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\xFE\\\]]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
825
|
|
|
|
|
|
|
\(\? | |
826
|
|
|
|
|
|
|
$q_char |
827
|
|
|
|
|
|
|
))/oxmsg; |
828
|
|
|
|
|
|
|
} |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
|
|
0
|
return scalar grep { $_ eq '(' } @char; |
|
0
|
|
|
|
|
0
|
|
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
# |
834
|
|
|
|
|
|
|
# GB18030 transliteration (tr///) |
835
|
|
|
|
|
|
|
# |
836
|
|
|
|
|
|
|
sub Egb18030::tr($$$$;$) { |
837
|
|
|
|
|
|
|
|
838
|
0
|
|
|
0
|
0
|
0
|
my $bind_operator = $_[1]; |
839
|
0
|
|
|
|
|
0
|
my $searchlist = $_[2]; |
840
|
0
|
|
|
|
|
0
|
my $replacementlist = $_[3]; |
841
|
0
|
|
0
|
|
|
0
|
my $modifier = $_[4] || ''; |
842
|
|
|
|
|
|
|
|
843
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
844
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
845
|
0
|
|
|
|
|
0
|
croak "Using !~ with tr///r doesn't make sense"; |
846
|
|
|
|
|
|
|
} |
847
|
|
|
|
|
|
|
} |
848
|
|
|
|
|
|
|
|
849
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
850
|
0
|
|
|
|
|
0
|
my @searchlist = _charlist_tr($searchlist); |
851
|
0
|
|
|
|
|
0
|
my @replacementlist = _charlist_tr($replacementlist); |
852
|
|
|
|
|
|
|
|
853
|
0
|
|
|
|
|
0
|
my %tr = (); |
854
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#searchlist; $i++) { |
855
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$searchlist[$i]}) { |
856
|
0
|
0
|
0
|
|
|
0
|
if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
857
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[$i]; |
858
|
|
|
|
|
|
|
} |
859
|
|
|
|
|
|
|
elsif ($modifier =~ /d/oxms) { |
860
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = ''; |
861
|
|
|
|
|
|
|
} |
862
|
|
|
|
|
|
|
elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) { |
863
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[-1]; |
864
|
|
|
|
|
|
|
} |
865
|
|
|
|
|
|
|
else { |
866
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $searchlist[$i]; |
867
|
|
|
|
|
|
|
} |
868
|
|
|
|
|
|
|
} |
869
|
|
|
|
|
|
|
} |
870
|
|
|
|
|
|
|
|
871
|
0
|
|
|
|
|
0
|
my $tr = 0; |
872
|
0
|
|
|
|
|
0
|
my $replaced = ''; |
873
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /c/oxms) { |
874
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
875
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$char}) { |
876
|
0
|
0
|
|
|
|
0
|
if (defined $replacementlist[0]) { |
877
|
0
|
|
|
|
|
0
|
$replaced .= $replacementlist[0]; |
878
|
|
|
|
|
|
|
} |
879
|
0
|
|
|
|
|
0
|
$tr++; |
880
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
881
|
0
|
|
0
|
|
|
0
|
while (@char and (not exists $tr{$char[0]})) { |
882
|
0
|
|
|
|
|
0
|
shift @char; |
883
|
0
|
|
|
|
|
0
|
$tr++; |
884
|
|
|
|
|
|
|
} |
885
|
|
|
|
|
|
|
} |
886
|
|
|
|
|
|
|
} |
887
|
|
|
|
|
|
|
else { |
888
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
} |
892
|
|
|
|
|
|
|
else { |
893
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
894
|
0
|
0
|
|
|
|
0
|
if (exists $tr{$char}) { |
895
|
0
|
|
|
|
|
0
|
$replaced .= $tr{$char}; |
896
|
0
|
|
|
|
|
0
|
$tr++; |
897
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
898
|
0
|
|
0
|
|
|
0
|
while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) { |
|
|
|
0
|
|
|
|
|
899
|
0
|
|
|
|
|
0
|
shift @char; |
900
|
0
|
|
|
|
|
0
|
$tr++; |
901
|
|
|
|
|
|
|
} |
902
|
|
|
|
|
|
|
} |
903
|
|
|
|
|
|
|
} |
904
|
|
|
|
|
|
|
else { |
905
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
906
|
|
|
|
|
|
|
} |
907
|
|
|
|
|
|
|
} |
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
|
910
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
911
|
0
|
|
|
|
|
0
|
return $replaced; |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
else { |
914
|
0
|
|
|
|
|
0
|
$_[0] = $replaced; |
915
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
916
|
0
|
|
|
|
|
0
|
return not $tr; |
917
|
|
|
|
|
|
|
} |
918
|
|
|
|
|
|
|
else { |
919
|
0
|
|
|
|
|
0
|
return $tr; |
920
|
|
|
|
|
|
|
} |
921
|
|
|
|
|
|
|
} |
922
|
|
|
|
|
|
|
} |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
# |
925
|
|
|
|
|
|
|
# GB18030 chop |
926
|
|
|
|
|
|
|
# |
927
|
|
|
|
|
|
|
sub Egb18030::chop(@) { |
928
|
|
|
|
|
|
|
|
929
|
0
|
|
|
0
|
0
|
0
|
my $chop; |
930
|
0
|
0
|
|
|
|
0
|
if (@_ == 0) { |
931
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
932
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
933
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
934
|
|
|
|
|
|
|
} |
935
|
|
|
|
|
|
|
else { |
936
|
0
|
|
|
|
|
0
|
for (@_) { |
937
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
938
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
939
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
940
|
|
|
|
|
|
|
} |
941
|
|
|
|
|
|
|
} |
942
|
0
|
|
|
|
|
0
|
return $chop; |
943
|
|
|
|
|
|
|
} |
944
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
# |
946
|
|
|
|
|
|
|
# GB18030 index by octet |
947
|
|
|
|
|
|
|
# |
948
|
|
|
|
|
|
|
sub Egb18030::index($$;$) { |
949
|
|
|
|
|
|
|
|
950
|
0
|
|
|
2304
|
1
|
0
|
my($str,$substr,$position) = @_; |
951
|
2304
|
|
50
|
|
|
4847
|
$position ||= 0; |
952
|
2304
|
|
|
|
|
10068
|
my $pos = 0; |
953
|
|
|
|
|
|
|
|
954
|
2304
|
|
|
|
|
3349
|
while ($pos < CORE::length($str)) { |
955
|
2304
|
50
|
|
|
|
4994
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
956
|
59292
|
0
|
|
|
|
111477
|
if ($pos >= $position) { |
957
|
0
|
|
|
|
|
0
|
return $pos; |
958
|
|
|
|
|
|
|
} |
959
|
|
|
|
|
|
|
} |
960
|
0
|
50
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
961
|
59292
|
|
|
|
|
140967
|
$pos += CORE::length($1); |
962
|
|
|
|
|
|
|
} |
963
|
|
|
|
|
|
|
else { |
964
|
59292
|
|
|
|
|
101754
|
$pos += 1; |
965
|
|
|
|
|
|
|
} |
966
|
|
|
|
|
|
|
} |
967
|
0
|
|
|
|
|
0
|
return -1; |
968
|
|
|
|
|
|
|
} |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
# |
971
|
|
|
|
|
|
|
# GB18030 reverse index |
972
|
|
|
|
|
|
|
# |
973
|
|
|
|
|
|
|
sub Egb18030::rindex($$;$) { |
974
|
|
|
|
|
|
|
|
975
|
2304
|
|
|
0
|
0
|
17017
|
my($str,$substr,$position) = @_; |
976
|
0
|
|
0
|
|
|
0
|
$position ||= CORE::length($str) - 1; |
977
|
0
|
|
|
|
|
0
|
my $pos = 0; |
978
|
0
|
|
|
|
|
0
|
my $rindex = -1; |
979
|
|
|
|
|
|
|
|
980
|
0
|
|
0
|
|
|
0
|
while (($pos < CORE::length($str)) and ($pos <= $position)) { |
981
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
982
|
0
|
|
|
|
|
0
|
$rindex = $pos; |
983
|
|
|
|
|
|
|
} |
984
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
985
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
986
|
|
|
|
|
|
|
} |
987
|
|
|
|
|
|
|
else { |
988
|
0
|
|
|
|
|
0
|
$pos += 1; |
989
|
|
|
|
|
|
|
} |
990
|
|
|
|
|
|
|
} |
991
|
0
|
|
|
|
|
0
|
return $rindex; |
992
|
|
|
|
|
|
|
} |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
# |
995
|
|
|
|
|
|
|
# GB18030 lower case first with parameter |
996
|
|
|
|
|
|
|
# |
997
|
|
|
|
|
|
|
sub Egb18030::lcfirst(@) { |
998
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
999
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1000
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1001
|
0
|
|
|
|
|
0
|
return Egb18030::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
1002
|
|
|
|
|
|
|
} |
1003
|
|
|
|
|
|
|
else { |
1004
|
0
|
|
|
|
|
0
|
return Egb18030::lc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
1005
|
|
|
|
|
|
|
} |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
else { |
1008
|
0
|
|
|
|
|
0
|
return Egb18030::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1009
|
|
|
|
|
|
|
} |
1010
|
|
|
|
|
|
|
} |
1011
|
|
|
|
|
|
|
|
1012
|
|
|
|
|
|
|
# |
1013
|
|
|
|
|
|
|
# GB18030 lower case first without parameter |
1014
|
|
|
|
|
|
|
# |
1015
|
|
|
|
|
|
|
sub Egb18030::lcfirst_() { |
1016
|
0
|
|
|
0
|
0
|
0
|
return Egb18030::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1017
|
|
|
|
|
|
|
} |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
# |
1020
|
|
|
|
|
|
|
# GB18030 lower case with parameter |
1021
|
|
|
|
|
|
|
# |
1022
|
|
|
|
|
|
|
sub Egb18030::lc(@) { |
1023
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1024
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1025
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1026
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
else { |
1029
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
0
|
|
|
|
|
0
|
|
1030
|
|
|
|
|
|
|
} |
1031
|
|
|
|
|
|
|
} |
1032
|
|
|
|
|
|
|
else { |
1033
|
0
|
|
|
|
|
0
|
return Egb18030::lc_(); |
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
# |
1038
|
|
|
|
|
|
|
# GB18030 lower case without parameter |
1039
|
|
|
|
|
|
|
# |
1040
|
|
|
|
|
|
|
sub Egb18030::lc_() { |
1041
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1042
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1043
|
|
|
|
|
|
|
} |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
# |
1046
|
|
|
|
|
|
|
# GB18030 upper case first with parameter |
1047
|
|
|
|
|
|
|
# |
1048
|
|
|
|
|
|
|
sub Egb18030::ucfirst(@) { |
1049
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1050
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1051
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1052
|
0
|
|
|
|
|
0
|
return Egb18030::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
else { |
1055
|
0
|
|
|
|
|
0
|
return Egb18030::uc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
1056
|
|
|
|
|
|
|
} |
1057
|
|
|
|
|
|
|
} |
1058
|
|
|
|
|
|
|
else { |
1059
|
0
|
|
|
|
|
0
|
return Egb18030::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
# |
1064
|
|
|
|
|
|
|
# GB18030 upper case first without parameter |
1065
|
|
|
|
|
|
|
# |
1066
|
|
|
|
|
|
|
sub Egb18030::ucfirst_() { |
1067
|
0
|
|
|
0
|
0
|
0
|
return Egb18030::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1068
|
|
|
|
|
|
|
} |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
# |
1071
|
|
|
|
|
|
|
# GB18030 upper case with parameter |
1072
|
|
|
|
|
|
|
# |
1073
|
|
|
|
|
|
|
sub Egb18030::uc(@) { |
1074
|
0
|
50
|
|
2968
|
0
|
0
|
if (@_) { |
1075
|
2968
|
|
|
|
|
4167
|
my $s = shift @_; |
1076
|
2968
|
50
|
33
|
|
|
3576
|
if (@_ and wantarray) { |
1077
|
2968
|
0
|
|
|
|
5114
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
else { |
1080
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
2968
|
|
|
|
|
8544
|
|
1081
|
|
|
|
|
|
|
} |
1082
|
|
|
|
|
|
|
} |
1083
|
|
|
|
|
|
|
else { |
1084
|
2968
|
|
|
|
|
9967
|
return Egb18030::uc_(); |
1085
|
|
|
|
|
|
|
} |
1086
|
|
|
|
|
|
|
} |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
# |
1089
|
|
|
|
|
|
|
# GB18030 upper case without parameter |
1090
|
|
|
|
|
|
|
# |
1091
|
|
|
|
|
|
|
sub Egb18030::uc_() { |
1092
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1093
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1094
|
|
|
|
|
|
|
} |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
# |
1097
|
|
|
|
|
|
|
# GB18030 fold case with parameter |
1098
|
|
|
|
|
|
|
# |
1099
|
|
|
|
|
|
|
sub Egb18030::fc(@) { |
1100
|
0
|
50
|
|
3271
|
0
|
0
|
if (@_) { |
1101
|
3271
|
|
|
|
|
4513
|
my $s = shift @_; |
1102
|
3271
|
50
|
33
|
|
|
3888
|
if (@_ and wantarray) { |
1103
|
3271
|
0
|
|
|
|
5479
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1104
|
|
|
|
|
|
|
} |
1105
|
|
|
|
|
|
|
else { |
1106
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3271
|
|
|
|
|
8311
|
|
1107
|
|
|
|
|
|
|
} |
1108
|
|
|
|
|
|
|
} |
1109
|
|
|
|
|
|
|
else { |
1110
|
3271
|
|
|
|
|
12188
|
return Egb18030::fc_(); |
1111
|
|
|
|
|
|
|
} |
1112
|
|
|
|
|
|
|
} |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
# |
1115
|
|
|
|
|
|
|
# GB18030 fold case without parameter |
1116
|
|
|
|
|
|
|
# |
1117
|
|
|
|
|
|
|
sub Egb18030::fc_() { |
1118
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1119
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1120
|
|
|
|
|
|
|
} |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
# |
1123
|
|
|
|
|
|
|
# GB18030 regexp capture |
1124
|
|
|
|
|
|
|
# |
1125
|
|
|
|
|
|
|
{ |
1126
|
|
|
|
|
|
|
# 10.3. Creating Persistent Private Variables |
1127
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
1128
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
my $last_s_matched = 0; |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
sub Egb18030::capture { |
1133
|
0
|
0
|
0
|
0
|
1
|
0
|
if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) { |
1134
|
0
|
|
|
|
|
0
|
return $_[0] + 1; |
1135
|
|
|
|
|
|
|
} |
1136
|
0
|
|
|
|
|
0
|
return $_[0]; |
1137
|
|
|
|
|
|
|
} |
1138
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
# GB18030 mark last regexp matched |
1140
|
|
|
|
|
|
|
sub Egb18030::matched() { |
1141
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 0; |
1142
|
|
|
|
|
|
|
} |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
# GB18030 mark last s/// matched |
1145
|
|
|
|
|
|
|
sub Egb18030::s_matched() { |
1146
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 1; |
1147
|
|
|
|
|
|
|
} |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
# P.854 31.17. use re |
1150
|
|
|
|
|
|
|
# in Chapter 31. Pragmatic Modules |
1151
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
# P.1026 re |
1154
|
|
|
|
|
|
|
# in Chapter 29. Pragmatic Modules |
1155
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
$Egb18030::matched = qr/(?{Egb18030::matched})/; |
1158
|
|
|
|
|
|
|
} |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
# |
1161
|
|
|
|
|
|
|
# GB18030 regexp ignore case modifier |
1162
|
|
|
|
|
|
|
# |
1163
|
|
|
|
|
|
|
sub Egb18030::ignorecase { |
1164
|
|
|
|
|
|
|
|
1165
|
0
|
|
|
0
|
0
|
0
|
my @string = @_; |
1166
|
0
|
|
|
|
|
0
|
my $metachar = qr/[\@\\|[\]{]/oxms; |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
# ignore case of $scalar or @array |
1169
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
1170
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
# split regexp |
1172
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg; |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
# unescape character |
1175
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1176
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
# open character class [...] |
1179
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '[') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1180
|
0
|
|
|
|
|
0
|
my $left = $i; |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
# [] make die "unmatched [] in regexp ...\n" |
1183
|
|
|
|
|
|
|
|
1184
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1185
|
0
|
|
|
|
|
0
|
$i++; |
1186
|
|
|
|
|
|
|
} |
1187
|
|
|
|
|
|
|
|
1188
|
0
|
|
|
|
|
0
|
while (1) { |
1189
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1190
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1191
|
|
|
|
|
|
|
} |
1192
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1193
|
0
|
|
|
|
|
0
|
my $right = $i; |
1194
|
0
|
|
|
|
|
0
|
my @charlist = charlist_qr(@char[$left+1..$right-1], 'i'); |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
# escape character |
1197
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1198
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
} |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
# do not use quotemeta here |
1202
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1203
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1206
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
# [...] |
1211
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')'; |
1212
|
|
|
|
|
|
|
|
1213
|
0
|
|
|
|
|
0
|
$i = $left; |
1214
|
0
|
|
|
|
|
0
|
last; |
1215
|
|
|
|
|
|
|
} |
1216
|
|
|
|
|
|
|
} |
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
# open character class [^...] |
1220
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
1221
|
0
|
|
|
|
|
0
|
my $left = $i; |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
# [^] make die "unmatched [] in regexp ...\n" |
1224
|
|
|
|
|
|
|
|
1225
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1226
|
0
|
|
|
|
|
0
|
$i++; |
1227
|
|
|
|
|
|
|
} |
1228
|
|
|
|
|
|
|
|
1229
|
0
|
|
|
|
|
0
|
while (1) { |
1230
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1231
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1232
|
|
|
|
|
|
|
} |
1233
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1234
|
0
|
|
|
|
|
0
|
my $right = $i; |
1235
|
0
|
|
|
|
|
0
|
my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i'); |
1236
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
# escape character |
1238
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1239
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
} |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
# do not use quotemeta here |
1243
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1244
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1245
|
|
|
|
|
|
|
} |
1246
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1247
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
} |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
# [^...] |
1252
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)"; |
1253
|
|
|
|
|
|
|
|
1254
|
0
|
|
|
|
|
0
|
$i = $left; |
1255
|
0
|
|
|
|
|
0
|
last; |
1256
|
|
|
|
|
|
|
} |
1257
|
|
|
|
|
|
|
} |
1258
|
|
|
|
|
|
|
} |
1259
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
# rewrite classic character class or escape character |
1261
|
|
|
|
|
|
|
elsif (my $char = classic_character_class($char[$i])) { |
1262
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
1263
|
|
|
|
|
|
|
} |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
# with /i modifier |
1266
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
1267
|
0
|
|
|
|
|
0
|
my $uc = Egb18030::uc($char[$i]); |
1268
|
0
|
|
|
|
|
0
|
my $fc = Egb18030::fc($char[$i]); |
1269
|
0
|
0
|
|
|
|
0
|
if ($uc ne $fc) { |
1270
|
0
|
0
|
|
|
|
0
|
if (CORE::length($fc) == 1) { |
1271
|
0
|
|
|
|
|
0
|
$char[$i] = '[' . $uc . $fc . ']'; |
1272
|
|
|
|
|
|
|
} |
1273
|
|
|
|
|
|
|
else { |
1274
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . $uc . '|' . $fc . ')'; |
1275
|
|
|
|
|
|
|
} |
1276
|
|
|
|
|
|
|
} |
1277
|
|
|
|
|
|
|
} |
1278
|
|
|
|
|
|
|
} |
1279
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
# characterize |
1281
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1282
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1283
|
|
|
|
|
|
|
|
1284
|
0
|
0
|
0
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
} |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
1288
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1289
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1290
|
|
|
|
|
|
|
} |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
# quote character before ? + * { |
1293
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
1294
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) { |
1295
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
1296
|
|
|
|
|
|
|
} |
1297
|
|
|
|
|
|
|
} |
1298
|
|
|
|
|
|
|
} |
1299
|
|
|
|
|
|
|
|
1300
|
0
|
|
|
|
|
0
|
$string = join '', @char; |
1301
|
|
|
|
|
|
|
} |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
# make regexp string |
1304
|
0
|
|
|
|
|
0
|
return @string; |
1305
|
|
|
|
|
|
|
} |
1306
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
# |
1308
|
|
|
|
|
|
|
# classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B ) |
1309
|
|
|
|
|
|
|
# |
1310
|
|
|
|
|
|
|
sub Egb18030::classic_character_class { |
1311
|
0
|
|
|
5379
|
0
|
0
|
my($char) = @_; |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
return { |
1314
|
|
|
|
|
|
|
'\D' => '${Egb18030::eD}', |
1315
|
|
|
|
|
|
|
'\S' => '${Egb18030::eS}', |
1316
|
|
|
|
|
|
|
'\W' => '${Egb18030::eW}', |
1317
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
# Before Perl 5.6, \s only matched the five whitespace characters |
1320
|
|
|
|
|
|
|
# tab, newline, form-feed, carriage return, and the space character |
1321
|
|
|
|
|
|
|
# itself, which, taken together, is the character class [\t\n\f\r ]. |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1324
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1325
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1326
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1327
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1328
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1329
|
|
|
|
|
|
|
'\s' => '\s', |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1332
|
|
|
|
|
|
|
'\C' => '[\x00-\xFF]', |
1333
|
|
|
|
|
|
|
'\X' => 'X', |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
# \h \v \H \V |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
# P.114 Character Class Shortcuts |
1338
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
1339
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
# P.357 13.2.3 Whitespace |
1342
|
|
|
|
|
|
|
# in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes |
1343
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1344
|
|
|
|
|
|
|
# |
1345
|
|
|
|
|
|
|
# 0x00009 CHARACTER TABULATION h s |
1346
|
|
|
|
|
|
|
# 0x0000a LINE FEED (LF) vs |
1347
|
|
|
|
|
|
|
# 0x0000b LINE TABULATION v |
1348
|
|
|
|
|
|
|
# 0x0000c FORM FEED (FF) vs |
1349
|
|
|
|
|
|
|
# 0x0000d CARRIAGE RETURN (CR) vs |
1350
|
|
|
|
|
|
|
# 0x00020 SPACE h s |
1351
|
|
|
|
|
|
|
|
1352
|
|
|
|
|
|
|
# P.196 Table 5-9. Alphanumeric regex metasymbols |
1353
|
|
|
|
|
|
|
# in Chapter 5. Pattern Matching |
1354
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
# (and so on) |
1357
|
|
|
|
|
|
|
|
1358
|
|
|
|
|
|
|
'\H' => '${Egb18030::eH}', |
1359
|
|
|
|
|
|
|
'\V' => '${Egb18030::eV}', |
1360
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1361
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1362
|
|
|
|
|
|
|
'\R' => '${Egb18030::eR}', |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
# \N |
1365
|
|
|
|
|
|
|
# |
1366
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
1367
|
|
|
|
|
|
|
# Character Classes and other Special Escapes |
1368
|
|
|
|
|
|
|
# Any character but \n (experimental). Not affected by /s modifier |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
'\N' => '${Egb18030::eN}', |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
# \b \B |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
# P.180 Boundaries: The \b and \B Assertions |
1375
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1376
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
# P.219 Boundaries: The \b and \B Assertions |
1379
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1380
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
# \b really means (?:(?<=\w)(?!\w)|(?
|
1383
|
|
|
|
|
|
|
# or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z)) |
1384
|
|
|
|
|
|
|
'\b' => '${Egb18030::eb}', |
1385
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
# \B really means (?:(?<=\w)(?=\w)|(?
|
1387
|
|
|
|
|
|
|
# or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W)) |
1388
|
|
|
|
|
|
|
'\B' => '${Egb18030::eB}', |
1389
|
|
|
|
|
|
|
|
1390
|
5379
|
|
100
|
|
|
7575
|
}->{$char} || ''; |
1391
|
|
|
|
|
|
|
} |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
# |
1394
|
|
|
|
|
|
|
# prepare GB18030 characters per length |
1395
|
|
|
|
|
|
|
# |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
# 1 octet characters |
1398
|
|
|
|
|
|
|
my @chars1 = (); |
1399
|
|
|
|
|
|
|
sub chars1 { |
1400
|
5379
|
0
|
|
0
|
0
|
195739
|
if (@chars1) { |
1401
|
0
|
|
|
|
|
0
|
return @chars1; |
1402
|
|
|
|
|
|
|
} |
1403
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{1}) { |
1404
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{1} }; |
|
0
|
|
|
|
|
0
|
|
1405
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,1)) { |
1406
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1407
|
0
|
|
|
|
|
0
|
push @chars1, pack 'C', $oct0; |
1408
|
|
|
|
|
|
|
} |
1409
|
|
|
|
|
|
|
} |
1410
|
|
|
|
|
|
|
} |
1411
|
0
|
|
|
|
|
0
|
return @chars1; |
1412
|
|
|
|
|
|
|
} |
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
# 2 octets characters |
1415
|
|
|
|
|
|
|
my @chars2 = (); |
1416
|
|
|
|
|
|
|
sub chars2 { |
1417
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars2) { |
1418
|
0
|
|
|
|
|
0
|
return @chars2; |
1419
|
|
|
|
|
|
|
} |
1420
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{2}) { |
1421
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{2} }; |
|
0
|
|
|
|
|
0
|
|
1422
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,2)) { |
1423
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1424
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1425
|
0
|
|
|
|
|
0
|
push @chars2, pack 'CC', $oct0,$oct1; |
1426
|
|
|
|
|
|
|
} |
1427
|
|
|
|
|
|
|
} |
1428
|
|
|
|
|
|
|
} |
1429
|
|
|
|
|
|
|
} |
1430
|
0
|
|
|
|
|
0
|
return @chars2; |
1431
|
|
|
|
|
|
|
} |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
# 3 octets characters |
1434
|
|
|
|
|
|
|
my @chars3 = (); |
1435
|
|
|
|
|
|
|
sub chars3 { |
1436
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars3) { |
1437
|
0
|
|
|
|
|
0
|
return @chars3; |
1438
|
|
|
|
|
|
|
} |
1439
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{3}) { |
1440
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{3} }; |
|
0
|
|
|
|
|
0
|
|
1441
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,3)) { |
1442
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1443
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1444
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1445
|
0
|
|
|
|
|
0
|
push @chars3, pack 'CCC', $oct0,$oct1,$oct2; |
1446
|
|
|
|
|
|
|
} |
1447
|
|
|
|
|
|
|
} |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
} |
1450
|
|
|
|
|
|
|
} |
1451
|
0
|
|
|
|
|
0
|
return @chars3; |
1452
|
|
|
|
|
|
|
} |
1453
|
|
|
|
|
|
|
|
1454
|
|
|
|
|
|
|
# 4 octets characters |
1455
|
|
|
|
|
|
|
my @chars4 = (); |
1456
|
|
|
|
|
|
|
sub chars4 { |
1457
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars4) { |
1458
|
0
|
|
|
|
|
0
|
return @chars4; |
1459
|
|
|
|
|
|
|
} |
1460
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{4}) { |
1461
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{4} }; |
|
0
|
|
|
|
|
0
|
|
1462
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,4)) { |
1463
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1464
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1465
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1466
|
0
|
|
|
|
|
0
|
for my $oct3 (@{$range[3]}) { |
|
0
|
|
|
|
|
0
|
|
1467
|
0
|
|
|
|
|
0
|
push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3; |
1468
|
|
|
|
|
|
|
} |
1469
|
|
|
|
|
|
|
} |
1470
|
|
|
|
|
|
|
} |
1471
|
|
|
|
|
|
|
} |
1472
|
|
|
|
|
|
|
} |
1473
|
|
|
|
|
|
|
} |
1474
|
0
|
|
|
|
|
0
|
return @chars4; |
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
# |
1478
|
|
|
|
|
|
|
# GB18030 open character list for tr |
1479
|
|
|
|
|
|
|
# |
1480
|
|
|
|
|
|
|
sub _charlist_tr { |
1481
|
|
|
|
|
|
|
|
1482
|
0
|
|
|
0
|
|
0
|
local $_ = shift @_; |
1483
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
# unescape character |
1485
|
0
|
|
|
|
|
0
|
my @char = (); |
1486
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxmsgc) { |
1487
|
0
|
0
|
|
|
|
0
|
if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1488
|
0
|
|
|
|
|
0
|
push @char, '\-'; |
1489
|
|
|
|
|
|
|
} |
1490
|
|
|
|
|
|
|
elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) { |
1491
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(oct $1); |
1492
|
|
|
|
|
|
|
} |
1493
|
|
|
|
|
|
|
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) { |
1494
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(hex $1); |
1495
|
|
|
|
|
|
|
} |
1496
|
|
|
|
|
|
|
elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) { |
1497
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(CORE::ord($1) & 0x1F); |
1498
|
|
|
|
|
|
|
} |
1499
|
|
|
|
|
|
|
elsif (/\G (\\ [0nrtfbae]) /oxmsgc) { |
1500
|
|
|
|
|
|
|
push @char, { |
1501
|
|
|
|
|
|
|
'\0' => "\0", |
1502
|
|
|
|
|
|
|
'\n' => "\n", |
1503
|
|
|
|
|
|
|
'\r' => "\r", |
1504
|
|
|
|
|
|
|
'\t' => "\t", |
1505
|
|
|
|
|
|
|
'\f' => "\f", |
1506
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1507
|
|
|
|
|
|
|
'\a' => "\a", |
1508
|
|
|
|
|
|
|
'\e' => "\e", |
1509
|
0
|
|
|
|
|
0
|
}->{$1}; |
1510
|
|
|
|
|
|
|
} |
1511
|
|
|
|
|
|
|
elsif (/\G \\ ($q_char) /oxmsgc) { |
1512
|
0
|
|
|
|
|
0
|
push @char, $1; |
1513
|
|
|
|
|
|
|
} |
1514
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxmsgc) { |
1515
|
0
|
|
|
|
|
0
|
push @char, $1; |
1516
|
|
|
|
|
|
|
} |
1517
|
|
|
|
|
|
|
} |
1518
|
|
|
|
|
|
|
|
1519
|
|
|
|
|
|
|
# join separated multiple-octet |
1520
|
0
|
|
|
|
|
0
|
@char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg; |
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
# unescape '-' |
1523
|
0
|
|
|
|
|
0
|
my @i = (); |
1524
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#char) { |
1525
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\-') { |
|
|
0
|
|
|
|
|
|
1526
|
0
|
|
|
|
|
0
|
$char[$i] = '-'; |
1527
|
|
|
|
|
|
|
} |
1528
|
|
|
|
|
|
|
elsif ($char[$i] eq '-') { |
1529
|
0
|
0
|
0
|
|
|
0
|
if ((0 < $i) and ($i < $#char)) { |
1530
|
0
|
|
|
|
|
0
|
push @i, $i; |
1531
|
|
|
|
|
|
|
} |
1532
|
|
|
|
|
|
|
} |
1533
|
|
|
|
|
|
|
} |
1534
|
|
|
|
|
|
|
|
1535
|
|
|
|
|
|
|
# open character list (reverse for splice) |
1536
|
0
|
|
|
|
|
0
|
for my $i (CORE::reverse @i) { |
1537
|
0
|
|
|
|
|
0
|
my @range = (); |
1538
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
# range error |
1540
|
0
|
0
|
0
|
|
|
0
|
if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) { |
1541
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1542
|
|
|
|
|
|
|
} |
1543
|
|
|
|
|
|
|
|
1544
|
|
|
|
|
|
|
# range of multiple-octet code |
1545
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i-1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1546
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1547
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1(); |
|
0
|
|
|
|
|
0
|
|
1548
|
|
|
|
|
|
|
} |
1549
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 2) { |
1550
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1551
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars2(); |
|
0
|
|
|
|
|
0
|
|
1552
|
|
|
|
|
|
|
} |
1553
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1554
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1555
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1556
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1557
|
|
|
|
|
|
|
} |
1558
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1559
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1560
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1561
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1562
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1563
|
|
|
|
|
|
|
} |
1564
|
|
|
|
|
|
|
else { |
1565
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1566
|
|
|
|
|
|
|
} |
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 2) { |
1569
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 2) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1570
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2(); |
|
0
|
|
|
|
|
0
|
|
1571
|
|
|
|
|
|
|
} |
1572
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1573
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1574
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1575
|
|
|
|
|
|
|
} |
1576
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1577
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1578
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1579
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1580
|
|
|
|
|
|
|
} |
1581
|
|
|
|
|
|
|
else { |
1582
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1583
|
|
|
|
|
|
|
} |
1584
|
|
|
|
|
|
|
} |
1585
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 3) { |
1586
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 3) { |
|
|
0
|
|
|
|
|
|
1587
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars3(); |
|
0
|
|
|
|
|
0
|
|
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1590
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars3(); |
|
0
|
|
|
|
|
0
|
|
1591
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1592
|
|
|
|
|
|
|
} |
1593
|
|
|
|
|
|
|
else { |
1594
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1595
|
|
|
|
|
|
|
} |
1596
|
|
|
|
|
|
|
} |
1597
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 4) { |
1598
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 4) { |
1599
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4(); |
|
0
|
|
|
|
|
0
|
|
1600
|
|
|
|
|
|
|
} |
1601
|
|
|
|
|
|
|
else { |
1602
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1603
|
|
|
|
|
|
|
} |
1604
|
|
|
|
|
|
|
} |
1605
|
|
|
|
|
|
|
else { |
1606
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1607
|
|
|
|
|
|
|
} |
1608
|
|
|
|
|
|
|
|
1609
|
0
|
|
|
|
|
0
|
splice @char, $i-1, 3, @range; |
1610
|
|
|
|
|
|
|
} |
1611
|
|
|
|
|
|
|
|
1612
|
0
|
|
|
|
|
0
|
return @char; |
1613
|
|
|
|
|
|
|
} |
1614
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
# |
1616
|
|
|
|
|
|
|
# GB18030 open character class |
1617
|
|
|
|
|
|
|
# |
1618
|
|
|
|
|
|
|
sub _cc { |
1619
|
0
|
50
|
|
604
|
|
0
|
if (scalar(@_) == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1620
|
604
|
|
|
|
|
1217
|
die __FILE__, ": subroutine cc got no parameter.\n"; |
1621
|
|
|
|
|
|
|
} |
1622
|
|
|
|
|
|
|
elsif (scalar(@_) == 1) { |
1623
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1624
|
|
|
|
|
|
|
} |
1625
|
|
|
|
|
|
|
elsif (scalar(@_) == 2) { |
1626
|
302
|
50
|
|
|
|
906
|
if ($_[0] > $_[1]) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1627
|
302
|
|
|
|
|
734
|
die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n"; |
1628
|
|
|
|
|
|
|
} |
1629
|
|
|
|
|
|
|
elsif ($_[0] == $_[1]) { |
1630
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1631
|
|
|
|
|
|
|
} |
1632
|
|
|
|
|
|
|
elsif (($_[0]+1) == $_[1]) { |
1633
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]); |
1634
|
|
|
|
|
|
|
} |
1635
|
|
|
|
|
|
|
else { |
1636
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]); |
1637
|
|
|
|
|
|
|
} |
1638
|
|
|
|
|
|
|
} |
1639
|
|
|
|
|
|
|
else { |
1640
|
302
|
|
|
|
|
1399
|
die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n"; |
|
0
|
|
|
|
|
0
|
|
1641
|
|
|
|
|
|
|
} |
1642
|
|
|
|
|
|
|
} |
1643
|
|
|
|
|
|
|
|
1644
|
|
|
|
|
|
|
# |
1645
|
|
|
|
|
|
|
# GB18030 octet range |
1646
|
|
|
|
|
|
|
# |
1647
|
|
|
|
|
|
|
sub _octets { |
1648
|
0
|
|
|
676
|
|
0
|
my $length = shift @_; |
1649
|
|
|
|
|
|
|
|
1650
|
676
|
100
|
|
|
|
1008
|
if ($length == 1) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1651
|
676
|
|
|
|
|
1393
|
my($a1) = unpack 'C', $_[0]; |
1652
|
414
|
|
|
|
|
1033
|
my($z1) = unpack 'C', $_[1]; |
1653
|
|
|
|
|
|
|
|
1654
|
414
|
50
|
|
|
|
1172
|
if ($a1 > $z1) { |
1655
|
414
|
|
|
|
|
819
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1); |
1656
|
|
|
|
|
|
|
} |
1657
|
|
|
|
|
|
|
|
1658
|
0
|
100
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1659
|
414
|
|
|
|
|
1057
|
return sprintf('\x%02X',$a1); |
1660
|
|
|
|
|
|
|
} |
1661
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1662
|
20
|
|
|
|
|
86
|
return sprintf('\x%02X\x%02X',$a1,$z1); |
1663
|
|
|
|
|
|
|
} |
1664
|
|
|
|
|
|
|
else { |
1665
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X-\x%02X',$a1,$z1); |
1666
|
|
|
|
|
|
|
} |
1667
|
|
|
|
|
|
|
} |
1668
|
|
|
|
|
|
|
elsif ($length == 2) { |
1669
|
394
|
|
|
|
|
2442
|
my($a1,$a2) = unpack 'CC', $_[0]; |
1670
|
262
|
|
|
|
|
676
|
my($z1,$z2) = unpack 'CC', $_[1]; |
1671
|
262
|
|
|
|
|
441
|
my($A1,$A2) = unpack 'CC', $_[2]; |
1672
|
262
|
|
|
|
|
406
|
my($Z1,$Z2) = unpack 'CC', $_[3]; |
1673
|
|
|
|
|
|
|
|
1674
|
262
|
100
|
|
|
|
403
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
return ( |
1676
|
|
|
|
|
|
|
# 11111111 222222222222 |
1677
|
|
|
|
|
|
|
# A A Z |
1678
|
262
|
|
|
|
|
446
|
_cc($a1) . _cc($a2,$z2), # a2-z2 |
1679
|
|
|
|
|
|
|
); |
1680
|
|
|
|
|
|
|
} |
1681
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1682
|
|
|
|
|
|
|
return ( |
1683
|
|
|
|
|
|
|
# 11111111111 222222222222 |
1684
|
|
|
|
|
|
|
# A Z A Z |
1685
|
222
|
|
|
|
|
331
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1686
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1687
|
|
|
|
|
|
|
); |
1688
|
|
|
|
|
|
|
} |
1689
|
|
|
|
|
|
|
else { |
1690
|
|
|
|
|
|
|
return ( |
1691
|
|
|
|
|
|
|
# 1111111111111111 222222222222 |
1692
|
|
|
|
|
|
|
# A Z A Z |
1693
|
40
|
|
|
|
|
70
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1694
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2), # - |
1695
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1696
|
|
|
|
|
|
|
); |
1697
|
|
|
|
|
|
|
} |
1698
|
|
|
|
|
|
|
} |
1699
|
|
|
|
|
|
|
elsif ($length == 3) { |
1700
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3) = unpack 'CCC', $_[0]; |
1701
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3) = unpack 'CCC', $_[1]; |
1702
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3) = unpack 'CCC', $_[2]; |
1703
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3) = unpack 'CCC', $_[3]; |
1704
|
|
|
|
|
|
|
|
1705
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1706
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1707
|
|
|
|
|
|
|
return ( |
1708
|
|
|
|
|
|
|
# 11111111 22222222 333333333333 |
1709
|
|
|
|
|
|
|
# A A A Z |
1710
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$z3), # a3-z3 |
1711
|
|
|
|
|
|
|
); |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1714
|
|
|
|
|
|
|
return ( |
1715
|
|
|
|
|
|
|
# 11111111 22222222222 333333333333 |
1716
|
|
|
|
|
|
|
# A A Z A Z |
1717
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1718
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1719
|
|
|
|
|
|
|
); |
1720
|
|
|
|
|
|
|
} |
1721
|
|
|
|
|
|
|
else { |
1722
|
|
|
|
|
|
|
return ( |
1723
|
|
|
|
|
|
|
# 11111111 2222222222222222 333333333333 |
1724
|
|
|
|
|
|
|
# A A Z A Z |
1725
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1726
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3), # - |
1727
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1728
|
|
|
|
|
|
|
); |
1729
|
|
|
|
|
|
|
} |
1730
|
|
|
|
|
|
|
} |
1731
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1732
|
|
|
|
|
|
|
return ( |
1733
|
|
|
|
|
|
|
# 11111111111 22222222222222 333333333333 |
1734
|
|
|
|
|
|
|
# A Z A Z A Z |
1735
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1736
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1737
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1738
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1739
|
|
|
|
|
|
|
); |
1740
|
|
|
|
|
|
|
} |
1741
|
|
|
|
|
|
|
else { |
1742
|
|
|
|
|
|
|
return ( |
1743
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 333333333333 |
1744
|
|
|
|
|
|
|
# A Z A Z A Z |
1745
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1746
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1747
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3), # - |
1748
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1749
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1750
|
|
|
|
|
|
|
); |
1751
|
|
|
|
|
|
|
} |
1752
|
|
|
|
|
|
|
} |
1753
|
|
|
|
|
|
|
elsif ($length == 4) { |
1754
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3,$a4) = unpack 'CCCC', $_[0]; |
1755
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3,$z4) = unpack 'CCCC', $_[1]; |
1756
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3,$A4) = unpack 'CCCC', $_[0]; |
1757
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3,$Z4) = unpack 'CCCC', $_[1]; |
1758
|
|
|
|
|
|
|
|
1759
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1760
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1761
|
0
|
0
|
|
|
|
0
|
if ($a3 == $z3) { |
|
|
0
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
return ( |
1763
|
|
|
|
|
|
|
# 11111111 22222222 33333333 444444444444 |
1764
|
|
|
|
|
|
|
# A A A A Z |
1765
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$z4), # a4-z4 |
1766
|
|
|
|
|
|
|
); |
1767
|
|
|
|
|
|
|
} |
1768
|
|
|
|
|
|
|
elsif (($a3+1) == $z3) { |
1769
|
|
|
|
|
|
|
return ( |
1770
|
|
|
|
|
|
|
# 11111111 22222222 33333333333 444444444444 |
1771
|
|
|
|
|
|
|
# A A A Z A Z |
1772
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1773
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1774
|
|
|
|
|
|
|
); |
1775
|
|
|
|
|
|
|
} |
1776
|
|
|
|
|
|
|
else { |
1777
|
|
|
|
|
|
|
return ( |
1778
|
|
|
|
|
|
|
# 11111111 22222222 3333333333333333 444444444444 |
1779
|
|
|
|
|
|
|
# A A A Z A Z |
1780
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1781
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$z3-1) . _cc($A4,$Z4), # - |
1782
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1783
|
|
|
|
|
|
|
); |
1784
|
|
|
|
|
|
|
} |
1785
|
|
|
|
|
|
|
} |
1786
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1787
|
|
|
|
|
|
|
return ( |
1788
|
|
|
|
|
|
|
# 11111111 22222222222 33333333333333 444444444444 |
1789
|
|
|
|
|
|
|
# A A Z A Z A Z |
1790
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1791
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1792
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1793
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1794
|
|
|
|
|
|
|
); |
1795
|
|
|
|
|
|
|
} |
1796
|
|
|
|
|
|
|
else { |
1797
|
|
|
|
|
|
|
return ( |
1798
|
|
|
|
|
|
|
# 11111111 2222222222222222 33333333333333 444444444444 |
1799
|
|
|
|
|
|
|
# A A Z A Z A Z |
1800
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1801
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1802
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1803
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1804
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1805
|
|
|
|
|
|
|
); |
1806
|
|
|
|
|
|
|
} |
1807
|
|
|
|
|
|
|
} |
1808
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1809
|
|
|
|
|
|
|
return ( |
1810
|
|
|
|
|
|
|
# 11111111111 22222222222222 33333333333333 444444444444 |
1811
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1812
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1813
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1814
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1815
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1816
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1817
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1818
|
|
|
|
|
|
|
); |
1819
|
|
|
|
|
|
|
} |
1820
|
|
|
|
|
|
|
else { |
1821
|
|
|
|
|
|
|
return ( |
1822
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 33333333333333 444444444444 |
1823
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1824
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1825
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1826
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1827
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1828
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1829
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1830
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1831
|
|
|
|
|
|
|
); |
1832
|
|
|
|
|
|
|
} |
1833
|
|
|
|
|
|
|
} |
1834
|
|
|
|
|
|
|
else { |
1835
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _octets got invalid length ($length).\n"; |
1836
|
|
|
|
|
|
|
} |
1837
|
|
|
|
|
|
|
} |
1838
|
|
|
|
|
|
|
|
1839
|
|
|
|
|
|
|
# |
1840
|
|
|
|
|
|
|
# GB18030 range regexp |
1841
|
|
|
|
|
|
|
# |
1842
|
|
|
|
|
|
|
sub _range_regexp { |
1843
|
0
|
|
|
525
|
|
0
|
my($length,$first,$last) = @_; |
1844
|
|
|
|
|
|
|
|
1845
|
525
|
|
|
|
|
1085
|
my @range_regexp = (); |
1846
|
525
|
50
|
|
|
|
795
|
if (not exists $range_tr{$length}) { |
1847
|
525
|
|
|
|
|
1241
|
return @range_regexp; |
1848
|
|
|
|
|
|
|
} |
1849
|
|
|
|
|
|
|
|
1850
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{$length} }; |
|
525
|
|
|
|
|
739
|
|
1851
|
525
|
|
|
|
|
1146
|
while (my @range = splice(@ranges,0,$length)) { |
1852
|
525
|
|
|
|
|
1617
|
my $min = ''; |
1853
|
1050
|
|
|
|
|
1470
|
my $max = ''; |
1854
|
1050
|
|
|
|
|
1170
|
for (my $i=0; $i < $length; $i++) { |
1855
|
1050
|
|
|
|
|
1996
|
$min .= pack 'C', $range[$i][0]; |
1856
|
1312
|
|
|
|
|
3098
|
$max .= pack 'C', $range[$i][-1]; |
1857
|
|
|
|
|
|
|
} |
1858
|
|
|
|
|
|
|
|
1859
|
|
|
|
|
|
|
# min___max |
1860
|
|
|
|
|
|
|
# FIRST_____________LAST |
1861
|
|
|
|
|
|
|
# (nothing) |
1862
|
|
|
|
|
|
|
|
1863
|
1312
|
50
|
66
|
|
|
2719
|
if ($max lt $first) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
1864
|
|
|
|
|
|
|
} |
1865
|
|
|
|
|
|
|
|
1866
|
|
|
|
|
|
|
# ********** |
1867
|
|
|
|
|
|
|
# min_________max |
1868
|
|
|
|
|
|
|
# FIRST_____________LAST |
1869
|
|
|
|
|
|
|
# ********** |
1870
|
|
|
|
|
|
|
|
1871
|
|
|
|
|
|
|
elsif (($min le $first) and ($first le $max) and ($max le $last)) { |
1872
|
1050
|
|
|
|
|
9328
|
push @range_regexp, _octets($length,$first,$max,$min,$max); |
1873
|
|
|
|
|
|
|
} |
1874
|
|
|
|
|
|
|
|
1875
|
|
|
|
|
|
|
# ********************** |
1876
|
|
|
|
|
|
|
# min________________max |
1877
|
|
|
|
|
|
|
# FIRST_____________LAST |
1878
|
|
|
|
|
|
|
# ********************** |
1879
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
elsif (($min eq $first) and ($max eq $last)) { |
1881
|
20
|
|
|
|
|
50
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1882
|
|
|
|
|
|
|
} |
1883
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
# ********* |
1885
|
|
|
|
|
|
|
# min___max |
1886
|
|
|
|
|
|
|
# FIRST_____________LAST |
1887
|
|
|
|
|
|
|
# ********* |
1888
|
|
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
elsif (($first le $min) and ($max le $last)) { |
1890
|
0
|
|
|
|
|
0
|
push @range_regexp, _octets($length,$min,$max,$min,$max); |
1891
|
|
|
|
|
|
|
} |
1892
|
|
|
|
|
|
|
|
1893
|
|
|
|
|
|
|
# ********************** |
1894
|
|
|
|
|
|
|
# min__________________________max |
1895
|
|
|
|
|
|
|
# FIRST_____________LAST |
1896
|
|
|
|
|
|
|
# ********************** |
1897
|
|
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
elsif (($min le $first) and ($last le $max)) { |
1899
|
20
|
|
|
|
|
47
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1900
|
|
|
|
|
|
|
} |
1901
|
|
|
|
|
|
|
|
1902
|
|
|
|
|
|
|
# ********* |
1903
|
|
|
|
|
|
|
# min________max |
1904
|
|
|
|
|
|
|
# FIRST_____________LAST |
1905
|
|
|
|
|
|
|
# ********* |
1906
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
elsif (($first le $min) and ($min le $last) and ($last le $max)) { |
1908
|
596
|
|
|
|
|
1313
|
push @range_regexp, _octets($length,$min,$last,$min,$max); |
1909
|
|
|
|
|
|
|
} |
1910
|
|
|
|
|
|
|
|
1911
|
|
|
|
|
|
|
# min___max |
1912
|
|
|
|
|
|
|
# FIRST_____________LAST |
1913
|
|
|
|
|
|
|
# (nothing) |
1914
|
|
|
|
|
|
|
|
1915
|
|
|
|
|
|
|
elsif ($last lt $min) { |
1916
|
|
|
|
|
|
|
} |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
else { |
1919
|
40
|
|
|
|
|
61
|
die __FILE__, ": subroutine _range_regexp panic.\n"; |
1920
|
|
|
|
|
|
|
} |
1921
|
|
|
|
|
|
|
} |
1922
|
|
|
|
|
|
|
|
1923
|
0
|
|
|
|
|
0
|
return @range_regexp; |
1924
|
|
|
|
|
|
|
} |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
# |
1927
|
|
|
|
|
|
|
# GB18030 open character list for qr and not qr |
1928
|
|
|
|
|
|
|
# |
1929
|
|
|
|
|
|
|
sub _charlist { |
1930
|
|
|
|
|
|
|
|
1931
|
525
|
|
|
766
|
|
1328
|
my $modifier = pop @_; |
1932
|
766
|
|
|
|
|
1232
|
my @char = @_; |
1933
|
|
|
|
|
|
|
|
1934
|
766
|
100
|
|
|
|
1684
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
1935
|
|
|
|
|
|
|
|
1936
|
|
|
|
|
|
|
# unescape character |
1937
|
766
|
|
|
|
|
1970
|
for (my $i=0; $i <= $#char; $i++) { |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
# escape - to ... |
1940
|
766
|
100
|
100
|
|
|
2513
|
if ($char[$i] eq '-') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1941
|
2672
|
100
|
100
|
|
|
18996
|
if ((0 < $i) and ($i < $#char)) { |
1942
|
530
|
|
|
|
|
1790
|
$char[$i] = '...'; |
1943
|
|
|
|
|
|
|
} |
1944
|
|
|
|
|
|
|
} |
1945
|
|
|
|
|
|
|
|
1946
|
|
|
|
|
|
|
# octal escape sequence |
1947
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
1948
|
505
|
|
|
|
|
1109
|
$char[$i] = octchr($1); |
1949
|
|
|
|
|
|
|
} |
1950
|
|
|
|
|
|
|
|
1951
|
|
|
|
|
|
|
# hexadecimal escape sequence |
1952
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
1953
|
0
|
|
|
|
|
0
|
$char[$i] = hexchr($1); |
1954
|
|
|
|
|
|
|
} |
1955
|
|
|
|
|
|
|
|
1956
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
1957
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
1958
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
1959
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
1960
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
1961
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
1962
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1963
|
|
|
|
|
|
|
} |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
1966
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
1967
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
1968
|
|
|
|
|
|
|
} |
1969
|
|
|
|
|
|
|
|
1970
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) { |
1971
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr oct $1; |
1972
|
|
|
|
|
|
|
} |
1973
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) { |
1974
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr hex $1; |
1975
|
|
|
|
|
|
|
} |
1976
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) { |
1977
|
206
|
|
|
|
|
763
|
$char[$i] = CORE::chr(CORE::ord($1) & 0x1F); |
1978
|
|
|
|
|
|
|
} |
1979
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) { |
1980
|
|
|
|
|
|
|
$char[$i] = { |
1981
|
|
|
|
|
|
|
'\0' => "\0", |
1982
|
|
|
|
|
|
|
'\n' => "\n", |
1983
|
|
|
|
|
|
|
'\r' => "\r", |
1984
|
|
|
|
|
|
|
'\t' => "\t", |
1985
|
|
|
|
|
|
|
'\f' => "\f", |
1986
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1987
|
|
|
|
|
|
|
'\a' => "\a", |
1988
|
|
|
|
|
|
|
'\e' => "\e", |
1989
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1992
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1993
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1994
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1995
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1996
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1997
|
|
|
|
|
|
|
'\s' => '\s', |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
2000
|
|
|
|
|
|
|
'\D' => '${Egb18030::eD}', |
2001
|
|
|
|
|
|
|
'\S' => '${Egb18030::eS}', |
2002
|
|
|
|
|
|
|
'\W' => '${Egb18030::eW}', |
2003
|
|
|
|
|
|
|
|
2004
|
|
|
|
|
|
|
'\H' => '${Egb18030::eH}', |
2005
|
|
|
|
|
|
|
'\V' => '${Egb18030::eV}', |
2006
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
2007
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
2008
|
|
|
|
|
|
|
'\R' => '${Egb18030::eR}', |
2009
|
|
|
|
|
|
|
|
2010
|
0
|
|
|
|
|
0
|
}->{$1}; |
2011
|
|
|
|
|
|
|
} |
2012
|
|
|
|
|
|
|
|
2013
|
|
|
|
|
|
|
# POSIX-style character classes |
2014
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) { |
2015
|
|
|
|
|
|
|
$char[$i] = { |
2016
|
|
|
|
|
|
|
|
2017
|
|
|
|
|
|
|
'[:lower:]' => '[\x41-\x5A\x61-\x7A]', |
2018
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A\x61-\x7A]', |
2019
|
|
|
|
|
|
|
'[:^lower:]' => '${Egb18030::not_lower_i}', |
2020
|
|
|
|
|
|
|
'[:^upper:]' => '${Egb18030::not_upper_i}', |
2021
|
|
|
|
|
|
|
|
2022
|
33
|
|
|
|
|
539
|
}->{$1}; |
2023
|
|
|
|
|
|
|
} |
2024
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) { |
2025
|
|
|
|
|
|
|
$char[$i] = { |
2026
|
|
|
|
|
|
|
|
2027
|
|
|
|
|
|
|
'[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]', |
2028
|
|
|
|
|
|
|
'[:alpha:]' => '[\x41-\x5A\x61-\x7A]', |
2029
|
|
|
|
|
|
|
'[:ascii:]' => '[\x00-\x7F]', |
2030
|
|
|
|
|
|
|
'[:blank:]' => '[\x09\x20]', |
2031
|
|
|
|
|
|
|
'[:cntrl:]' => '[\x00-\x1F\x7F]', |
2032
|
|
|
|
|
|
|
'[:digit:]' => '[\x30-\x39]', |
2033
|
|
|
|
|
|
|
'[:graph:]' => '[\x21-\x7F]', |
2034
|
|
|
|
|
|
|
'[:lower:]' => '[\x61-\x7A]', |
2035
|
|
|
|
|
|
|
'[:print:]' => '[\x20-\x7F]', |
2036
|
|
|
|
|
|
|
'[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]', |
2037
|
|
|
|
|
|
|
|
2038
|
|
|
|
|
|
|
# P.174 POSIX-Style Character Classes |
2039
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2040
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
# P.311 11.2.4 Character Classes and other Special Escapes |
2043
|
|
|
|
|
|
|
# in Chapter 11: perlre: Perl regular expressions |
2044
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
2045
|
|
|
|
|
|
|
|
2046
|
|
|
|
|
|
|
# P.210 POSIX-Style Character Classes |
2047
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2048
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2049
|
|
|
|
|
|
|
|
2050
|
|
|
|
|
|
|
'[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK") |
2051
|
|
|
|
|
|
|
|
2052
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A]', |
2053
|
|
|
|
|
|
|
'[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]', |
2054
|
|
|
|
|
|
|
'[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]', |
2055
|
|
|
|
|
|
|
'[:^alnum:]' => '${Egb18030::not_alnum}', |
2056
|
|
|
|
|
|
|
'[:^alpha:]' => '${Egb18030::not_alpha}', |
2057
|
|
|
|
|
|
|
'[:^ascii:]' => '${Egb18030::not_ascii}', |
2058
|
|
|
|
|
|
|
'[:^blank:]' => '${Egb18030::not_blank}', |
2059
|
|
|
|
|
|
|
'[:^cntrl:]' => '${Egb18030::not_cntrl}', |
2060
|
|
|
|
|
|
|
'[:^digit:]' => '${Egb18030::not_digit}', |
2061
|
|
|
|
|
|
|
'[:^graph:]' => '${Egb18030::not_graph}', |
2062
|
|
|
|
|
|
|
'[:^lower:]' => '${Egb18030::not_lower}', |
2063
|
|
|
|
|
|
|
'[:^print:]' => '${Egb18030::not_print}', |
2064
|
|
|
|
|
|
|
'[:^punct:]' => '${Egb18030::not_punct}', |
2065
|
|
|
|
|
|
|
'[:^space:]' => '${Egb18030::not_space}', |
2066
|
|
|
|
|
|
|
'[:^upper:]' => '${Egb18030::not_upper}', |
2067
|
|
|
|
|
|
|
'[:^word:]' => '${Egb18030::not_word}', |
2068
|
|
|
|
|
|
|
'[:^xdigit:]' => '${Egb18030::not_xdigit}', |
2069
|
|
|
|
|
|
|
|
2070
|
8
|
|
|
|
|
78
|
}->{$1}; |
2071
|
|
|
|
|
|
|
} |
2072
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) { |
2073
|
70
|
|
|
|
|
1548
|
$char[$i] = $1; |
2074
|
|
|
|
|
|
|
} |
2075
|
|
|
|
|
|
|
} |
2076
|
|
|
|
|
|
|
|
2077
|
|
|
|
|
|
|
# open character list |
2078
|
7
|
|
|
|
|
142
|
my @singleoctet = (); |
2079
|
766
|
|
|
|
|
1279
|
my @multipleoctet = (); |
2080
|
766
|
|
|
|
|
1062
|
for (my $i=0; $i <= $#char; ) { |
2081
|
|
|
|
|
|
|
|
2082
|
|
|
|
|
|
|
# escaped - |
2083
|
766
|
100
|
100
|
|
|
5692
|
if (defined($char[$i+1]) and ($char[$i+1] eq '...')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2084
|
2167
|
|
|
|
|
8883
|
$i += 1; |
2085
|
505
|
|
|
|
|
657
|
next; |
2086
|
|
|
|
|
|
|
} |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
# make range regexp |
2089
|
|
|
|
|
|
|
elsif ($char[$i] eq '...') { |
2090
|
|
|
|
|
|
|
|
2091
|
|
|
|
|
|
|
# range error |
2092
|
505
|
50
|
|
|
|
1002
|
if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) { |
|
|
100
|
|
|
|
|
|
2093
|
505
|
|
|
|
|
1927
|
croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2094
|
|
|
|
|
|
|
} |
2095
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) { |
2096
|
0
|
50
|
|
|
|
0
|
if ($char[$i-1] gt $char[$i+1]) { |
2097
|
485
|
|
|
|
|
1142
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2098
|
|
|
|
|
|
|
} |
2099
|
|
|
|
|
|
|
} |
2100
|
|
|
|
|
|
|
|
2101
|
|
|
|
|
|
|
# make range regexp per length |
2102
|
0
|
|
|
|
|
0
|
for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) { |
2103
|
505
|
|
|
|
|
1307
|
my @regexp = (); |
2104
|
|
|
|
|
|
|
|
2105
|
|
|
|
|
|
|
# is first and last |
2106
|
525
|
100
|
100
|
|
|
724
|
if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2107
|
525
|
|
|
|
|
1794
|
push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]); |
2108
|
|
|
|
|
|
|
} |
2109
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
# is first |
2111
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i-1])) { |
2112
|
485
|
|
|
|
|
1411
|
push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length); |
2113
|
|
|
|
|
|
|
} |
2114
|
|
|
|
|
|
|
|
2115
|
|
|
|
|
|
|
# is inside in first and last |
2116
|
|
|
|
|
|
|
elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) { |
2117
|
20
|
|
|
|
|
72
|
push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length); |
2118
|
|
|
|
|
|
|
} |
2119
|
|
|
|
|
|
|
|
2120
|
|
|
|
|
|
|
# is last |
2121
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i+1])) { |
2122
|
0
|
|
|
|
|
0
|
push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]); |
2123
|
|
|
|
|
|
|
} |
2124
|
|
|
|
|
|
|
|
2125
|
|
|
|
|
|
|
else { |
2126
|
20
|
|
|
|
|
90
|
die __FILE__, ": subroutine make_regexp panic.\n"; |
2127
|
|
|
|
|
|
|
} |
2128
|
|
|
|
|
|
|
|
2129
|
0
|
100
|
|
|
|
0
|
if ($length == 1) { |
2130
|
525
|
|
|
|
|
966
|
push @singleoctet, @regexp; |
2131
|
|
|
|
|
|
|
} |
2132
|
|
|
|
|
|
|
else { |
2133
|
394
|
|
|
|
|
875
|
push @multipleoctet, @regexp; |
2134
|
|
|
|
|
|
|
} |
2135
|
|
|
|
|
|
|
} |
2136
|
|
|
|
|
|
|
|
2137
|
131
|
|
|
|
|
283
|
$i += 2; |
2138
|
|
|
|
|
|
|
} |
2139
|
|
|
|
|
|
|
|
2140
|
|
|
|
|
|
|
# with /i modifier |
2141
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
2142
|
505
|
100
|
|
|
|
1037
|
if ($modifier =~ /i/oxms) { |
2143
|
764
|
|
|
|
|
1708
|
my $uc = Egb18030::uc($char[$i]); |
2144
|
192
|
|
|
|
|
348
|
my $fc = Egb18030::fc($char[$i]); |
2145
|
192
|
50
|
|
|
|
367
|
if ($uc ne $fc) { |
2146
|
192
|
50
|
|
|
|
322
|
if (CORE::length($fc) == 1) { |
2147
|
192
|
|
|
|
|
255
|
push @singleoctet, $uc, $fc; |
2148
|
|
|
|
|
|
|
} |
2149
|
|
|
|
|
|
|
else { |
2150
|
192
|
|
|
|
|
340
|
push @singleoctet, $uc; |
2151
|
0
|
|
|
|
|
0
|
push @multipleoctet, $fc; |
2152
|
|
|
|
|
|
|
} |
2153
|
|
|
|
|
|
|
} |
2154
|
|
|
|
|
|
|
else { |
2155
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2156
|
|
|
|
|
|
|
} |
2157
|
|
|
|
|
|
|
} |
2158
|
|
|
|
|
|
|
else { |
2159
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2160
|
|
|
|
|
|
|
} |
2161
|
572
|
|
|
|
|
894
|
$i += 1; |
2162
|
|
|
|
|
|
|
} |
2163
|
|
|
|
|
|
|
|
2164
|
|
|
|
|
|
|
# single character of single octet code |
2165
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) { |
2166
|
764
|
|
|
|
|
1267
|
push @singleoctet, "\t", "\x20"; |
2167
|
0
|
|
|
|
|
0
|
$i += 1; |
2168
|
|
|
|
|
|
|
} |
2169
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) { |
2170
|
0
|
|
|
|
|
0
|
push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D"; |
2171
|
0
|
|
|
|
|
0
|
$i += 1; |
2172
|
|
|
|
|
|
|
} |
2173
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) { |
2174
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2175
|
2
|
|
|
|
|
6
|
$i += 1; |
2176
|
|
|
|
|
|
|
} |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
# single character of multiple-octet code |
2179
|
|
|
|
|
|
|
else { |
2180
|
2
|
|
|
|
|
6
|
push @multipleoctet, $char[$i]; |
2181
|
391
|
|
|
|
|
679
|
$i += 1; |
2182
|
|
|
|
|
|
|
} |
2183
|
|
|
|
|
|
|
} |
2184
|
|
|
|
|
|
|
|
2185
|
|
|
|
|
|
|
# quote metachar |
2186
|
391
|
|
|
|
|
745
|
for (@singleoctet) { |
2187
|
766
|
50
|
|
|
|
1436
|
if ($_ eq '...') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2188
|
1372
|
|
|
|
|
6353
|
$_ = '-'; |
2189
|
|
|
|
|
|
|
} |
2190
|
|
|
|
|
|
|
elsif (/\A \n \z/oxms) { |
2191
|
0
|
|
|
|
|
0
|
$_ = '\n'; |
2192
|
|
|
|
|
|
|
} |
2193
|
|
|
|
|
|
|
elsif (/\A \r \z/oxms) { |
2194
|
8
|
|
|
|
|
28
|
$_ = '\r'; |
2195
|
|
|
|
|
|
|
} |
2196
|
|
|
|
|
|
|
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) { |
2197
|
8
|
|
|
|
|
17
|
$_ = sprintf('\x%02X', CORE::ord $1); |
2198
|
|
|
|
|
|
|
} |
2199
|
|
|
|
|
|
|
elsif (/\A [\x00-\xFF] \z/oxms) { |
2200
|
1
|
|
|
|
|
6
|
$_ = quotemeta $_; |
2201
|
|
|
|
|
|
|
} |
2202
|
|
|
|
|
|
|
} |
2203
|
939
|
|
|
|
|
1406
|
for (@multipleoctet) { |
2204
|
766
|
100
|
|
|
|
1432
|
if (/\A ([\x80-\xFF].*) ([\x00-\xFF]) \z/oxms) { |
2205
|
693
|
|
|
|
|
1823
|
$_ = $1 . quotemeta $2; |
2206
|
|
|
|
|
|
|
} |
2207
|
|
|
|
|
|
|
} |
2208
|
|
|
|
|
|
|
|
2209
|
|
|
|
|
|
|
# return character list |
2210
|
307
|
|
|
|
|
697
|
return \@singleoctet, \@multipleoctet; |
2211
|
|
|
|
|
|
|
} |
2212
|
|
|
|
|
|
|
|
2213
|
|
|
|
|
|
|
# |
2214
|
|
|
|
|
|
|
# GB18030 octal escape sequence |
2215
|
|
|
|
|
|
|
# |
2216
|
|
|
|
|
|
|
sub octchr { |
2217
|
766
|
|
|
5
|
0
|
2723
|
my($octdigit) = @_; |
2218
|
|
|
|
|
|
|
|
2219
|
5
|
|
|
|
|
14
|
my @binary = (); |
2220
|
5
|
|
|
|
|
8
|
for my $octal (split(//,$octdigit)) { |
2221
|
|
|
|
|
|
|
push @binary, { |
2222
|
|
|
|
|
|
|
'0' => '000', |
2223
|
|
|
|
|
|
|
'1' => '001', |
2224
|
|
|
|
|
|
|
'2' => '010', |
2225
|
|
|
|
|
|
|
'3' => '011', |
2226
|
|
|
|
|
|
|
'4' => '100', |
2227
|
|
|
|
|
|
|
'5' => '101', |
2228
|
|
|
|
|
|
|
'6' => '110', |
2229
|
|
|
|
|
|
|
'7' => '111', |
2230
|
5
|
|
|
|
|
25
|
}->{$octal}; |
2231
|
|
|
|
|
|
|
} |
2232
|
50
|
|
|
|
|
189
|
my $binary = join '', @binary; |
2233
|
|
|
|
|
|
|
|
2234
|
|
|
|
|
|
|
my $octchr = { |
2235
|
|
|
|
|
|
|
# 1234567 |
2236
|
|
|
|
|
|
|
1 => pack('B*', "0000000$binary"), |
2237
|
|
|
|
|
|
|
2 => pack('B*', "000000$binary"), |
2238
|
|
|
|
|
|
|
3 => pack('B*', "00000$binary"), |
2239
|
|
|
|
|
|
|
4 => pack('B*', "0000$binary"), |
2240
|
|
|
|
|
|
|
5 => pack('B*', "000$binary"), |
2241
|
|
|
|
|
|
|
6 => pack('B*', "00$binary"), |
2242
|
|
|
|
|
|
|
7 => pack('B*', "0$binary"), |
2243
|
|
|
|
|
|
|
0 => pack('B*', "$binary"), |
2244
|
|
|
|
|
|
|
|
2245
|
5
|
|
|
|
|
16
|
}->{CORE::length($binary) % 8}; |
2246
|
|
|
|
|
|
|
|
2247
|
5
|
|
|
|
|
61
|
return $octchr; |
2248
|
|
|
|
|
|
|
} |
2249
|
|
|
|
|
|
|
|
2250
|
|
|
|
|
|
|
# |
2251
|
|
|
|
|
|
|
# GB18030 hexadecimal escape sequence |
2252
|
|
|
|
|
|
|
# |
2253
|
|
|
|
|
|
|
sub hexchr { |
2254
|
5
|
|
|
5
|
0
|
20
|
my($hexdigit) = @_; |
2255
|
|
|
|
|
|
|
|
2256
|
|
|
|
|
|
|
my $hexchr = { |
2257
|
|
|
|
|
|
|
1 => pack('H*', "0$hexdigit"), |
2258
|
|
|
|
|
|
|
0 => pack('H*', "$hexdigit"), |
2259
|
|
|
|
|
|
|
|
2260
|
5
|
|
|
|
|
16
|
}->{CORE::length($_[0]) % 2}; |
2261
|
|
|
|
|
|
|
|
2262
|
5
|
|
|
|
|
52
|
return $hexchr; |
2263
|
|
|
|
|
|
|
} |
2264
|
|
|
|
|
|
|
|
2265
|
|
|
|
|
|
|
# |
2266
|
|
|
|
|
|
|
# GB18030 open character list for qr |
2267
|
|
|
|
|
|
|
# |
2268
|
|
|
|
|
|
|
sub charlist_qr { |
2269
|
|
|
|
|
|
|
|
2270
|
5
|
|
|
527
|
0
|
18
|
my $modifier = pop @_; |
2271
|
527
|
|
|
|
|
1005
|
my @char = @_; |
2272
|
|
|
|
|
|
|
|
2273
|
527
|
|
|
|
|
1285
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2274
|
527
|
|
|
|
|
1713
|
my @singleoctet = @$singleoctet; |
2275
|
527
|
|
|
|
|
1342
|
my @multipleoctet = @$multipleoctet; |
2276
|
|
|
|
|
|
|
|
2277
|
|
|
|
|
|
|
# return character list |
2278
|
527
|
100
|
|
|
|
998
|
if (scalar(@singleoctet) >= 1) { |
2279
|
|
|
|
|
|
|
|
2280
|
|
|
|
|
|
|
# with /i modifier |
2281
|
527
|
100
|
|
|
|
1423
|
if ($modifier =~ m/i/oxms) { |
2282
|
392
|
|
|
|
|
914
|
my %singleoctet_ignorecase = (); |
2283
|
107
|
|
|
|
|
156
|
for (@singleoctet) { |
2284
|
107
|
|
100
|
|
|
151
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2285
|
272
|
|
|
|
|
882
|
for my $ord (hex($1) .. hex($2)) { |
2286
|
80
|
|
|
|
|
266
|
my $char = CORE::chr($ord); |
2287
|
1046
|
|
|
|
|
1372
|
my $uc = Egb18030::uc($char); |
2288
|
1046
|
|
|
|
|
1283
|
my $fc = Egb18030::fc($char); |
2289
|
1046
|
100
|
|
|
|
1522
|
if ($uc eq $fc) { |
2290
|
1046
|
|
|
|
|
1552
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2291
|
|
|
|
|
|
|
} |
2292
|
|
|
|
|
|
|
else { |
2293
|
457
|
50
|
|
|
|
1008
|
if (CORE::length($fc) == 1) { |
2294
|
589
|
|
|
|
|
838
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2295
|
589
|
|
|
|
|
1139
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2296
|
|
|
|
|
|
|
} |
2297
|
|
|
|
|
|
|
else { |
2298
|
589
|
|
|
|
|
1365
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2299
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2300
|
|
|
|
|
|
|
} |
2301
|
|
|
|
|
|
|
} |
2302
|
|
|
|
|
|
|
} |
2303
|
|
|
|
|
|
|
} |
2304
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2305
|
272
|
|
|
|
|
468
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2306
|
|
|
|
|
|
|
} |
2307
|
|
|
|
|
|
|
} |
2308
|
192
|
|
|
|
|
468
|
my $i = 0; |
2309
|
107
|
|
|
|
|
138
|
my @singleoctet_ignorecase = (); |
2310
|
107
|
|
|
|
|
154
|
for my $ord (0 .. 255) { |
2311
|
107
|
100
|
|
|
|
181
|
if (exists $singleoctet_ignorecase{$ord}) { |
2312
|
27392
|
|
|
|
|
31662
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1577
|
|
|
|
|
1450
|
|
2313
|
|
|
|
|
|
|
} |
2314
|
|
|
|
|
|
|
else { |
2315
|
1577
|
|
|
|
|
2432
|
$i++; |
2316
|
|
|
|
|
|
|
} |
2317
|
|
|
|
|
|
|
} |
2318
|
25815
|
|
|
|
|
26329
|
@singleoctet = (); |
2319
|
107
|
|
|
|
|
163
|
for my $range (@singleoctet_ignorecase) { |
2320
|
107
|
100
|
|
|
|
228
|
if (ref $range) { |
2321
|
11412
|
100
|
|
|
|
17378
|
if (scalar(@{$range}) == 1) { |
|
214
|
50
|
|
|
|
216
|
|
2322
|
214
|
|
|
|
|
434
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
6
|
|
2323
|
|
|
|
|
|
|
} |
2324
|
5
|
|
|
|
|
55
|
elsif (scalar(@{$range}) == 2) { |
2325
|
209
|
|
|
|
|
292
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2326
|
|
|
|
|
|
|
} |
2327
|
|
|
|
|
|
|
else { |
2328
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
209
|
|
|
|
|
267
|
|
|
209
|
|
|
|
|
239
|
|
2329
|
|
|
|
|
|
|
} |
2330
|
|
|
|
|
|
|
} |
2331
|
|
|
|
|
|
|
} |
2332
|
|
|
|
|
|
|
} |
2333
|
|
|
|
|
|
|
|
2334
|
209
|
|
|
|
|
903
|
my $not_anchor = ''; |
2335
|
392
|
|
|
|
|
726
|
$not_anchor = '(?![\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE])'; |
2336
|
|
|
|
|
|
|
|
2337
|
392
|
|
|
|
|
680
|
push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' ); |
2338
|
|
|
|
|
|
|
} |
2339
|
392
|
100
|
|
|
|
1580
|
if (scalar(@multipleoctet) >= 2) { |
2340
|
527
|
|
|
|
|
1165
|
return '(?:' . join('|', @multipleoctet) . ')'; |
2341
|
|
|
|
|
|
|
} |
2342
|
|
|
|
|
|
|
else { |
2343
|
131
|
|
|
|
|
812
|
return $multipleoctet[0]; |
2344
|
|
|
|
|
|
|
} |
2345
|
|
|
|
|
|
|
} |
2346
|
|
|
|
|
|
|
|
2347
|
|
|
|
|
|
|
# |
2348
|
|
|
|
|
|
|
# GB18030 open character list for not qr |
2349
|
|
|
|
|
|
|
# |
2350
|
|
|
|
|
|
|
sub charlist_not_qr { |
2351
|
|
|
|
|
|
|
|
2352
|
396
|
|
|
239
|
0
|
1785
|
my $modifier = pop @_; |
2353
|
239
|
|
|
|
|
424
|
my @char = @_; |
2354
|
|
|
|
|
|
|
|
2355
|
239
|
|
|
|
|
557
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2356
|
239
|
|
|
|
|
726
|
my @singleoctet = @$singleoctet; |
2357
|
239
|
|
|
|
|
521
|
my @multipleoctet = @$multipleoctet; |
2358
|
|
|
|
|
|
|
|
2359
|
|
|
|
|
|
|
# with /i modifier |
2360
|
239
|
100
|
|
|
|
489
|
if ($modifier =~ m/i/oxms) { |
2361
|
239
|
|
|
|
|
524
|
my %singleoctet_ignorecase = (); |
2362
|
128
|
|
|
|
|
200
|
for (@singleoctet) { |
2363
|
128
|
|
100
|
|
|
193
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2364
|
272
|
|
|
|
|
865
|
for my $ord (hex($1) .. hex($2)) { |
2365
|
80
|
|
|
|
|
258
|
my $char = CORE::chr($ord); |
2366
|
1046
|
|
|
|
|
1383
|
my $uc = Egb18030::uc($char); |
2367
|
1046
|
|
|
|
|
1301
|
my $fc = Egb18030::fc($char); |
2368
|
1046
|
100
|
|
|
|
1657
|
if ($uc eq $fc) { |
2369
|
1046
|
|
|
|
|
1592
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2370
|
|
|
|
|
|
|
} |
2371
|
|
|
|
|
|
|
else { |
2372
|
457
|
50
|
|
|
|
1017
|
if (CORE::length($fc) == 1) { |
2373
|
589
|
|
|
|
|
741
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2374
|
589
|
|
|
|
|
1222
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2375
|
|
|
|
|
|
|
} |
2376
|
|
|
|
|
|
|
else { |
2377
|
589
|
|
|
|
|
1401
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2378
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2379
|
|
|
|
|
|
|
} |
2380
|
|
|
|
|
|
|
} |
2381
|
|
|
|
|
|
|
} |
2382
|
|
|
|
|
|
|
} |
2383
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2384
|
272
|
|
|
|
|
432
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2385
|
|
|
|
|
|
|
} |
2386
|
|
|
|
|
|
|
} |
2387
|
192
|
|
|
|
|
444
|
my $i = 0; |
2388
|
128
|
|
|
|
|
174
|
my @singleoctet_ignorecase = (); |
2389
|
128
|
|
|
|
|
165
|
for my $ord (0 .. 255) { |
2390
|
128
|
100
|
|
|
|
201
|
if (exists $singleoctet_ignorecase{$ord}) { |
2391
|
32768
|
|
|
|
|
37721
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1577
|
|
|
|
|
1451
|
|
2392
|
|
|
|
|
|
|
} |
2393
|
|
|
|
|
|
|
else { |
2394
|
1577
|
|
|
|
|
2412
|
$i++; |
2395
|
|
|
|
|
|
|
} |
2396
|
|
|
|
|
|
|
} |
2397
|
31191
|
|
|
|
|
31077
|
@singleoctet = (); |
2398
|
128
|
|
|
|
|
182
|
for my $range (@singleoctet_ignorecase) { |
2399
|
128
|
100
|
|
|
|
277
|
if (ref $range) { |
2400
|
11412
|
100
|
|
|
|
17296
|
if (scalar(@{$range}) == 1) { |
|
214
|
50
|
|
|
|
210
|
|
2401
|
214
|
|
|
|
|
332
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
8
|
|
2402
|
|
|
|
|
|
|
} |
2403
|
5
|
|
|
|
|
64
|
elsif (scalar(@{$range}) == 2) { |
2404
|
209
|
|
|
|
|
345
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2405
|
|
|
|
|
|
|
} |
2406
|
|
|
|
|
|
|
else { |
2407
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
209
|
|
|
|
|
223
|
|
|
209
|
|
|
|
|
247
|
|
2408
|
|
|
|
|
|
|
} |
2409
|
|
|
|
|
|
|
} |
2410
|
|
|
|
|
|
|
} |
2411
|
|
|
|
|
|
|
} |
2412
|
|
|
|
|
|
|
|
2413
|
|
|
|
|
|
|
# return character list |
2414
|
209
|
100
|
|
|
|
882
|
if (scalar(@multipleoctet) >= 1) { |
2415
|
239
|
100
|
|
|
|
563
|
if (scalar(@singleoctet) >= 1) { |
2416
|
|
|
|
|
|
|
|
2417
|
|
|
|
|
|
|
# any character other than multiple-octet and single octet character class |
2418
|
114
|
|
|
|
|
184
|
return '(?!' . join('|', @multipleoctet) . ')(?:[^\x81-\xFE' . join('', @singleoctet) . ']|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])'; |
2419
|
|
|
|
|
|
|
} |
2420
|
|
|
|
|
|
|
else { |
2421
|
|
|
|
|
|
|
|
2422
|
|
|
|
|
|
|
# any character other than multiple-octet character class |
2423
|
70
|
|
|
|
|
476
|
return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)"; |
2424
|
|
|
|
|
|
|
} |
2425
|
|
|
|
|
|
|
} |
2426
|
|
|
|
|
|
|
else { |
2427
|
44
|
50
|
|
|
|
286
|
if (scalar(@singleoctet) >= 1) { |
2428
|
|
|
|
|
|
|
|
2429
|
|
|
|
|
|
|
# any character other than single octet character class |
2430
|
125
|
|
|
|
|
224
|
return '(?:[^\x81-\xFE' . join('', @singleoctet) . ']|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])'; |
2431
|
|
|
|
|
|
|
} |
2432
|
|
|
|
|
|
|
else { |
2433
|
|
|
|
|
|
|
|
2434
|
|
|
|
|
|
|
# any character |
2435
|
125
|
|
|
|
|
752
|
return "(?:$your_char)"; |
2436
|
|
|
|
|
|
|
} |
2437
|
|
|
|
|
|
|
} |
2438
|
|
|
|
|
|
|
} |
2439
|
|
|
|
|
|
|
|
2440
|
|
|
|
|
|
|
# |
2441
|
|
|
|
|
|
|
# open file in read mode |
2442
|
|
|
|
|
|
|
# |
2443
|
|
|
|
|
|
|
sub _open_r { |
2444
|
0
|
|
|
768
|
|
0
|
my(undef,$file) = @_; |
2445
|
389
|
|
|
389
|
|
5767
|
use Fcntl qw(O_RDONLY); |
|
389
|
|
|
|
|
4683
|
|
|
389
|
|
|
|
|
64491
|
|
2446
|
768
|
|
|
|
|
2370
|
return CORE::sysopen($_[0], $file, &O_RDONLY); |
2447
|
|
|
|
|
|
|
} |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
# |
2450
|
|
|
|
|
|
|
# open file in append mode |
2451
|
|
|
|
|
|
|
# |
2452
|
|
|
|
|
|
|
sub _open_a { |
2453
|
768
|
|
|
384
|
|
31951
|
my(undef,$file) = @_; |
2454
|
389
|
|
|
389
|
|
5310
|
use Fcntl qw(O_WRONLY O_APPEND O_CREAT); |
|
389
|
|
|
|
|
2254
|
|
|
389
|
|
|
|
|
5623469
|
|
2455
|
384
|
|
|
|
|
15523
|
return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT); |
2456
|
|
|
|
|
|
|
} |
2457
|
|
|
|
|
|
|
|
2458
|
|
|
|
|
|
|
# |
2459
|
|
|
|
|
|
|
# safe system |
2460
|
|
|
|
|
|
|
# |
2461
|
|
|
|
|
|
|
sub _systemx { |
2462
|
|
|
|
|
|
|
|
2463
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2464
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2465
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2466
|
|
|
|
|
|
|
# |
2467
|
|
|
|
|
|
|
# Be aware that in older releases of Perl, exec (and system) did not flush |
2468
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2469
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output in the case of exec, or |
2470
|
|
|
|
|
|
|
# misordererd output in the case of system. This situation was largely remedied |
2471
|
|
|
|
|
|
|
# in the 5.6 release of Perl. (So, 5.005 release not yet.) |
2472
|
|
|
|
|
|
|
|
2473
|
|
|
|
|
|
|
# P.855 exec |
2474
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2475
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2476
|
|
|
|
|
|
|
# |
2477
|
|
|
|
|
|
|
# In very old release of Perl (before v5.6), exec (and system) did not flush |
2478
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2479
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output with exec or misordered |
2480
|
|
|
|
|
|
|
# output with system. |
2481
|
|
|
|
|
|
|
|
2482
|
384
|
|
|
384
|
|
77386
|
$| = 1; |
2483
|
|
|
|
|
|
|
|
2484
|
|
|
|
|
|
|
# P.565 23.1.2. Cleaning Up Your Environment |
2485
|
|
|
|
|
|
|
# in Chapter 23: Security |
2486
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2487
|
|
|
|
|
|
|
|
2488
|
|
|
|
|
|
|
# P.656 Cleaning Up Your Environment |
2489
|
|
|
|
|
|
|
# in Chapter 20: Security |
2490
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2491
|
|
|
|
|
|
|
|
2492
|
|
|
|
|
|
|
# local $ENV{'PATH'} = '.'; |
2493
|
384
|
|
|
|
|
1713
|
local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer |
2494
|
|
|
|
|
|
|
|
2495
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2496
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2497
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2498
|
|
|
|
|
|
|
# |
2499
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as an |
2500
|
|
|
|
|
|
|
# indication that it should bypass shell processing. However, there is one |
2501
|
|
|
|
|
|
|
# place where you might still get tripped up. The exec call (and system, too) |
2502
|
|
|
|
|
|
|
# will not distinguish between a single scalar argument and an array containing |
2503
|
|
|
|
|
|
|
# only one element. |
2504
|
|
|
|
|
|
|
# |
2505
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2506
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2507
|
|
|
|
|
|
|
# or die "exec: $!"; # because @args == 1 |
2508
|
|
|
|
|
|
|
# |
2509
|
|
|
|
|
|
|
# To avoid this, you can use the PATHNAME syntax, explicitly duplicating the |
2510
|
|
|
|
|
|
|
# first argument as the pathname, which forces the rest of the arguments to be |
2511
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2512
|
|
|
|
|
|
|
# |
2513
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2514
|
|
|
|
|
|
|
# or die "can't exec @args: $!"; |
2515
|
|
|
|
|
|
|
|
2516
|
|
|
|
|
|
|
# P.855 exec |
2517
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2518
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2519
|
|
|
|
|
|
|
# |
2520
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as a |
2521
|
|
|
|
|
|
|
# directive to bypass shell processing. However, there is one place where |
2522
|
|
|
|
|
|
|
# you might still get tripped up. The exec call (and system, too) cannot |
2523
|
|
|
|
|
|
|
# distinguish between a single scalar argument and an array containing |
2524
|
|
|
|
|
|
|
# only one element. |
2525
|
|
|
|
|
|
|
# |
2526
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2527
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2528
|
|
|
|
|
|
|
# || die "exec: $!"; # because @args == 1 |
2529
|
|
|
|
|
|
|
# |
2530
|
|
|
|
|
|
|
# To avoid this, use the PATHNAME syntax, explicitly duplicating the first |
2531
|
|
|
|
|
|
|
# argument as the pathname, which forces the rest of the arguments to be |
2532
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2533
|
|
|
|
|
|
|
# |
2534
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2535
|
|
|
|
|
|
|
# || die "can't exec @args: $!"; |
2536
|
|
|
|
|
|
|
|
2537
|
384
|
|
|
|
|
3684
|
return CORE::system { $_[0] } @_; # safe even with one-argument list |
|
384
|
|
|
|
|
979
|
|
2538
|
|
|
|
|
|
|
} |
2539
|
|
|
|
|
|
|
|
2540
|
|
|
|
|
|
|
# |
2541
|
|
|
|
|
|
|
# GB18030 order to character (with parameter) |
2542
|
|
|
|
|
|
|
# |
2543
|
|
|
|
|
|
|
sub Egb18030::chr(;$) { |
2544
|
|
|
|
|
|
|
|
2545
|
384
|
0
|
|
0
|
0
|
53730897
|
my $c = @_ ? $_[0] : $_; |
2546
|
|
|
|
|
|
|
|
2547
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2548
|
0
|
|
|
|
|
0
|
return "\x00"; |
2549
|
|
|
|
|
|
|
} |
2550
|
|
|
|
|
|
|
else { |
2551
|
0
|
|
|
|
|
0
|
my @chr = (); |
2552
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2553
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2554
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2555
|
|
|
|
|
|
|
} |
2556
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2557
|
|
|
|
|
|
|
} |
2558
|
|
|
|
|
|
|
} |
2559
|
|
|
|
|
|
|
|
2560
|
|
|
|
|
|
|
# |
2561
|
|
|
|
|
|
|
# GB18030 order to character (without parameter) |
2562
|
|
|
|
|
|
|
# |
2563
|
|
|
|
|
|
|
sub Egb18030::chr_() { |
2564
|
|
|
|
|
|
|
|
2565
|
0
|
|
|
0
|
0
|
0
|
my $c = $_; |
2566
|
|
|
|
|
|
|
|
2567
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2568
|
0
|
|
|
|
|
0
|
return "\x00"; |
2569
|
|
|
|
|
|
|
} |
2570
|
|
|
|
|
|
|
else { |
2571
|
0
|
|
|
|
|
0
|
my @chr = (); |
2572
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2573
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2574
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2575
|
|
|
|
|
|
|
} |
2576
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2577
|
|
|
|
|
|
|
} |
2578
|
|
|
|
|
|
|
} |
2579
|
|
|
|
|
|
|
|
2580
|
|
|
|
|
|
|
# |
2581
|
|
|
|
|
|
|
# GB18030 stacked file test expr |
2582
|
|
|
|
|
|
|
# |
2583
|
|
|
|
|
|
|
sub Egb18030::filetest { |
2584
|
|
|
|
|
|
|
|
2585
|
0
|
|
|
0
|
0
|
0
|
my $file = pop @_; |
2586
|
0
|
|
|
|
|
0
|
my $filetest = substr(pop @_, 1); |
2587
|
|
|
|
|
|
|
|
2588
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Egb18030::$filetest(\$file)}) { |
2589
|
0
|
|
|
|
|
0
|
return ''; |
2590
|
|
|
|
|
|
|
} |
2591
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
2592
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
2593
|
0
|
|
|
|
|
0
|
return ''; |
2594
|
|
|
|
|
|
|
} |
2595
|
|
|
|
|
|
|
} |
2596
|
0
|
|
|
|
|
0
|
return 1; |
2597
|
|
|
|
|
|
|
} |
2598
|
|
|
|
|
|
|
|
2599
|
|
|
|
|
|
|
# |
2600
|
|
|
|
|
|
|
# GB18030 file test -r expr |
2601
|
|
|
|
|
|
|
# |
2602
|
|
|
|
|
|
|
sub Egb18030::r(;*@) { |
2603
|
|
|
|
|
|
|
|
2604
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2605
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -r (Egb18030::r)' if @_ and not wantarray; |
2606
|
|
|
|
|
|
|
|
2607
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2608
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2609
|
|
|
|
|
|
|
} |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
# P.908 32.39. Symbol |
2612
|
|
|
|
|
|
|
# in Chapter 32: Standard Modules |
2613
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2614
|
|
|
|
|
|
|
|
2615
|
|
|
|
|
|
|
# P.326 Prototypes |
2616
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
2617
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2618
|
|
|
|
|
|
|
|
2619
|
|
|
|
|
|
|
# (and so on) |
2620
|
|
|
|
|
|
|
|
2621
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2622
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r $fh,@_) : -r $fh; |
2623
|
|
|
|
|
|
|
} |
2624
|
|
|
|
|
|
|
elsif (-e $_) { |
2625
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2626
|
|
|
|
|
|
|
} |
2627
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2628
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2629
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2630
|
|
|
|
|
|
|
} |
2631
|
|
|
|
|
|
|
else { |
2632
|
|
|
|
|
|
|
|
2633
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Egb18030::*() |
2634
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
2635
|
|
|
|
|
|
|
# (and so on) |
2636
|
|
|
|
|
|
|
|
2637
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2638
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2639
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
2640
|
0
|
|
|
|
|
0
|
close $fh; |
2641
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($r,@_) : $r; |
2642
|
|
|
|
|
|
|
} |
2643
|
|
|
|
|
|
|
} |
2644
|
|
|
|
|
|
|
} |
2645
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2646
|
|
|
|
|
|
|
} |
2647
|
|
|
|
|
|
|
|
2648
|
|
|
|
|
|
|
# |
2649
|
|
|
|
|
|
|
# GB18030 file test -w expr |
2650
|
|
|
|
|
|
|
# |
2651
|
|
|
|
|
|
|
sub Egb18030::w(;*@) { |
2652
|
|
|
|
|
|
|
|
2653
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2654
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -w (Egb18030::w)' if @_ and not wantarray; |
2655
|
|
|
|
|
|
|
|
2656
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2657
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2658
|
|
|
|
|
|
|
} |
2659
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2660
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w $fh,@_) : -w $fh; |
2661
|
|
|
|
|
|
|
} |
2662
|
|
|
|
|
|
|
elsif (-e $_) { |
2663
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2664
|
|
|
|
|
|
|
} |
2665
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2666
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2667
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2668
|
|
|
|
|
|
|
} |
2669
|
|
|
|
|
|
|
else { |
2670
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2671
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2672
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
2673
|
0
|
|
|
|
|
0
|
close $fh; |
2674
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($w,@_) : $w; |
2675
|
|
|
|
|
|
|
} |
2676
|
|
|
|
|
|
|
} |
2677
|
|
|
|
|
|
|
} |
2678
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2679
|
|
|
|
|
|
|
} |
2680
|
|
|
|
|
|
|
|
2681
|
|
|
|
|
|
|
# |
2682
|
|
|
|
|
|
|
# GB18030 file test -x expr |
2683
|
|
|
|
|
|
|
# |
2684
|
|
|
|
|
|
|
sub Egb18030::x(;*@) { |
2685
|
|
|
|
|
|
|
|
2686
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2687
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -x (Egb18030::x)' if @_ and not wantarray; |
2688
|
|
|
|
|
|
|
|
2689
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2690
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2691
|
|
|
|
|
|
|
} |
2692
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2693
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x $fh,@_) : -x $fh; |
2694
|
|
|
|
|
|
|
} |
2695
|
|
|
|
|
|
|
elsif (-e $_) { |
2696
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2697
|
|
|
|
|
|
|
} |
2698
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2699
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2700
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2701
|
|
|
|
|
|
|
} |
2702
|
|
|
|
|
|
|
else { |
2703
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2704
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2705
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
2706
|
0
|
|
|
|
|
0
|
close $fh; |
2707
|
|
|
|
|
|
|
} |
2708
|
|
|
|
|
|
|
|
2709
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2710
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2711
|
|
|
|
|
|
|
} |
2712
|
|
|
|
|
|
|
} |
2713
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2714
|
|
|
|
|
|
|
} |
2715
|
|
|
|
|
|
|
|
2716
|
|
|
|
|
|
|
# |
2717
|
|
|
|
|
|
|
# GB18030 file test -o expr |
2718
|
|
|
|
|
|
|
# |
2719
|
|
|
|
|
|
|
sub Egb18030::o(;*@) { |
2720
|
|
|
|
|
|
|
|
2721
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2722
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -o (Egb18030::o)' if @_ and not wantarray; |
2723
|
|
|
|
|
|
|
|
2724
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2725
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2726
|
|
|
|
|
|
|
} |
2727
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2728
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o $fh,@_) : -o $fh; |
2729
|
|
|
|
|
|
|
} |
2730
|
|
|
|
|
|
|
elsif (-e $_) { |
2731
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2732
|
|
|
|
|
|
|
} |
2733
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2734
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2735
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2736
|
|
|
|
|
|
|
} |
2737
|
|
|
|
|
|
|
else { |
2738
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2739
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2740
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
2741
|
0
|
|
|
|
|
0
|
close $fh; |
2742
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($o,@_) : $o; |
2743
|
|
|
|
|
|
|
} |
2744
|
|
|
|
|
|
|
} |
2745
|
|
|
|
|
|
|
} |
2746
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2747
|
|
|
|
|
|
|
} |
2748
|
|
|
|
|
|
|
|
2749
|
|
|
|
|
|
|
# |
2750
|
|
|
|
|
|
|
# GB18030 file test -R expr |
2751
|
|
|
|
|
|
|
# |
2752
|
|
|
|
|
|
|
sub Egb18030::R(;*@) { |
2753
|
|
|
|
|
|
|
|
2754
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2755
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -R (Egb18030::R)' if @_ and not wantarray; |
2756
|
|
|
|
|
|
|
|
2757
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2758
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2759
|
|
|
|
|
|
|
} |
2760
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2761
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R $fh,@_) : -R $fh; |
2762
|
|
|
|
|
|
|
} |
2763
|
|
|
|
|
|
|
elsif (-e $_) { |
2764
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2765
|
|
|
|
|
|
|
} |
2766
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2767
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2768
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2769
|
|
|
|
|
|
|
} |
2770
|
|
|
|
|
|
|
else { |
2771
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2772
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2773
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
2774
|
0
|
|
|
|
|
0
|
close $fh; |
2775
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($R,@_) : $R; |
2776
|
|
|
|
|
|
|
} |
2777
|
|
|
|
|
|
|
} |
2778
|
|
|
|
|
|
|
} |
2779
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2780
|
|
|
|
|
|
|
} |
2781
|
|
|
|
|
|
|
|
2782
|
|
|
|
|
|
|
# |
2783
|
|
|
|
|
|
|
# GB18030 file test -W expr |
2784
|
|
|
|
|
|
|
# |
2785
|
|
|
|
|
|
|
sub Egb18030::W(;*@) { |
2786
|
|
|
|
|
|
|
|
2787
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2788
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -W (Egb18030::W)' if @_ and not wantarray; |
2789
|
|
|
|
|
|
|
|
2790
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2791
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2792
|
|
|
|
|
|
|
} |
2793
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2794
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W $fh,@_) : -W $fh; |
2795
|
|
|
|
|
|
|
} |
2796
|
|
|
|
|
|
|
elsif (-e $_) { |
2797
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2798
|
|
|
|
|
|
|
} |
2799
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2800
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2801
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2802
|
|
|
|
|
|
|
} |
2803
|
|
|
|
|
|
|
else { |
2804
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2805
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2806
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
2807
|
0
|
|
|
|
|
0
|
close $fh; |
2808
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($W,@_) : $W; |
2809
|
|
|
|
|
|
|
} |
2810
|
|
|
|
|
|
|
} |
2811
|
|
|
|
|
|
|
} |
2812
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2813
|
|
|
|
|
|
|
} |
2814
|
|
|
|
|
|
|
|
2815
|
|
|
|
|
|
|
# |
2816
|
|
|
|
|
|
|
# GB18030 file test -X expr |
2817
|
|
|
|
|
|
|
# |
2818
|
|
|
|
|
|
|
sub Egb18030::X(;*@) { |
2819
|
|
|
|
|
|
|
|
2820
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
2821
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -X (Egb18030::X)' if @_ and not wantarray; |
2822
|
|
|
|
|
|
|
|
2823
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2824
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2825
|
|
|
|
|
|
|
} |
2826
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2827
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X $fh,@_) : -X $fh; |
2828
|
|
|
|
|
|
|
} |
2829
|
|
|
|
|
|
|
elsif (-e $_) { |
2830
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2831
|
|
|
|
|
|
|
} |
2832
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2833
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2834
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2835
|
|
|
|
|
|
|
} |
2836
|
|
|
|
|
|
|
else { |
2837
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2838
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2839
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
2840
|
0
|
|
|
|
|
0
|
close $fh; |
2841
|
|
|
|
|
|
|
} |
2842
|
|
|
|
|
|
|
|
2843
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2844
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2845
|
|
|
|
|
|
|
} |
2846
|
|
|
|
|
|
|
} |
2847
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2848
|
|
|
|
|
|
|
} |
2849
|
|
|
|
|
|
|
|
2850
|
|
|
|
|
|
|
# |
2851
|
|
|
|
|
|
|
# GB18030 file test -O expr |
2852
|
|
|
|
|
|
|
# |
2853
|
|
|
|
|
|
|
sub Egb18030::O(;*@) { |
2854
|
|
|
|
|
|
|
|
2855
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2856
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -O (Egb18030::O)' if @_ and not wantarray; |
2857
|
|
|
|
|
|
|
|
2858
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2859
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2860
|
|
|
|
|
|
|
} |
2861
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2862
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O $fh,@_) : -O $fh; |
2863
|
|
|
|
|
|
|
} |
2864
|
|
|
|
|
|
|
elsif (-e $_) { |
2865
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2866
|
|
|
|
|
|
|
} |
2867
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2868
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2869
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2870
|
|
|
|
|
|
|
} |
2871
|
|
|
|
|
|
|
else { |
2872
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2873
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2874
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
2875
|
0
|
|
|
|
|
0
|
close $fh; |
2876
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($O,@_) : $O; |
2877
|
|
|
|
|
|
|
} |
2878
|
|
|
|
|
|
|
} |
2879
|
|
|
|
|
|
|
} |
2880
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2881
|
|
|
|
|
|
|
} |
2882
|
|
|
|
|
|
|
|
2883
|
|
|
|
|
|
|
# |
2884
|
|
|
|
|
|
|
# GB18030 file test -e expr |
2885
|
|
|
|
|
|
|
# |
2886
|
|
|
|
|
|
|
sub Egb18030::e(;*@) { |
2887
|
|
|
|
|
|
|
|
2888
|
0
|
50
|
|
768
|
0
|
0
|
local $_ = shift if @_; |
2889
|
768
|
50
|
33
|
|
|
2864
|
croak 'Too many arguments for -e (Egb18030::e)' if @_ and not wantarray; |
2890
|
|
|
|
|
|
|
|
2891
|
768
|
|
|
|
|
3107
|
local $^W = 0; |
2892
|
|
|
|
|
|
|
|
2893
|
768
|
|
|
|
|
2478
|
my $fh = qualify_to_ref $_; |
2894
|
768
|
50
|
|
|
|
2234
|
if ($_ eq '_') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2895
|
768
|
0
|
|
|
|
3342
|
return wantarray ? (-e _,@_) : -e _; |
2896
|
|
|
|
|
|
|
} |
2897
|
|
|
|
|
|
|
|
2898
|
|
|
|
|
|
|
# return false if directory handle |
2899
|
|
|
|
|
|
|
elsif (defined Egb18030::telldir($fh)) { |
2900
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2901
|
|
|
|
|
|
|
} |
2902
|
|
|
|
|
|
|
|
2903
|
|
|
|
|
|
|
# return true if file handle |
2904
|
|
|
|
|
|
|
elsif (defined fileno $fh) { |
2905
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2906
|
|
|
|
|
|
|
} |
2907
|
|
|
|
|
|
|
|
2908
|
|
|
|
|
|
|
elsif (-e $_) { |
2909
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2910
|
|
|
|
|
|
|
} |
2911
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2912
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2913
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2914
|
|
|
|
|
|
|
} |
2915
|
|
|
|
|
|
|
else { |
2916
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2917
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2918
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
2919
|
0
|
|
|
|
|
0
|
close $fh; |
2920
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($e,@_) : $e; |
2921
|
|
|
|
|
|
|
} |
2922
|
|
|
|
|
|
|
} |
2923
|
|
|
|
|
|
|
} |
2924
|
0
|
50
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2925
|
|
|
|
|
|
|
} |
2926
|
|
|
|
|
|
|
|
2927
|
|
|
|
|
|
|
# |
2928
|
|
|
|
|
|
|
# GB18030 file test -z expr |
2929
|
|
|
|
|
|
|
# |
2930
|
|
|
|
|
|
|
sub Egb18030::z(;*@) { |
2931
|
|
|
|
|
|
|
|
2932
|
768
|
0
|
|
0
|
0
|
4726
|
local $_ = shift if @_; |
2933
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -z (Egb18030::z)' if @_ and not wantarray; |
2934
|
|
|
|
|
|
|
|
2935
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2936
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2937
|
|
|
|
|
|
|
} |
2938
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2939
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z $fh,@_) : -z $fh; |
2940
|
|
|
|
|
|
|
} |
2941
|
|
|
|
|
|
|
elsif (-e $_) { |
2942
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2943
|
|
|
|
|
|
|
} |
2944
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2945
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2946
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2947
|
|
|
|
|
|
|
} |
2948
|
|
|
|
|
|
|
else { |
2949
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2950
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2951
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
2952
|
0
|
|
|
|
|
0
|
close $fh; |
2953
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($z,@_) : $z; |
2954
|
|
|
|
|
|
|
} |
2955
|
|
|
|
|
|
|
} |
2956
|
|
|
|
|
|
|
} |
2957
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2958
|
|
|
|
|
|
|
} |
2959
|
|
|
|
|
|
|
|
2960
|
|
|
|
|
|
|
# |
2961
|
|
|
|
|
|
|
# GB18030 file test -s expr |
2962
|
|
|
|
|
|
|
# |
2963
|
|
|
|
|
|
|
sub Egb18030::s(;*@) { |
2964
|
|
|
|
|
|
|
|
2965
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2966
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -s (Egb18030::s)' if @_ and not wantarray; |
2967
|
|
|
|
|
|
|
|
2968
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2969
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2970
|
|
|
|
|
|
|
} |
2971
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2972
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s $fh,@_) : -s $fh; |
2973
|
|
|
|
|
|
|
} |
2974
|
|
|
|
|
|
|
elsif (-e $_) { |
2975
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2976
|
|
|
|
|
|
|
} |
2977
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2978
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2979
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2980
|
|
|
|
|
|
|
} |
2981
|
|
|
|
|
|
|
else { |
2982
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2983
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2984
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
2985
|
0
|
|
|
|
|
0
|
close $fh; |
2986
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($s,@_) : $s; |
2987
|
|
|
|
|
|
|
} |
2988
|
|
|
|
|
|
|
} |
2989
|
|
|
|
|
|
|
} |
2990
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2991
|
|
|
|
|
|
|
} |
2992
|
|
|
|
|
|
|
|
2993
|
|
|
|
|
|
|
# |
2994
|
|
|
|
|
|
|
# GB18030 file test -f expr |
2995
|
|
|
|
|
|
|
# |
2996
|
|
|
|
|
|
|
sub Egb18030::f(;*@) { |
2997
|
|
|
|
|
|
|
|
2998
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2999
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -f (Egb18030::f)' if @_ and not wantarray; |
3000
|
|
|
|
|
|
|
|
3001
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3002
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
3003
|
|
|
|
|
|
|
} |
3004
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3005
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f $fh,@_) : -f $fh; |
3006
|
|
|
|
|
|
|
} |
3007
|
|
|
|
|
|
|
elsif (-e $_) { |
3008
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
3009
|
|
|
|
|
|
|
} |
3010
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3011
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3012
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3013
|
|
|
|
|
|
|
} |
3014
|
|
|
|
|
|
|
else { |
3015
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3016
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3017
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3018
|
0
|
|
|
|
|
0
|
close $fh; |
3019
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($f,@_) : $f; |
3020
|
|
|
|
|
|
|
} |
3021
|
|
|
|
|
|
|
} |
3022
|
|
|
|
|
|
|
} |
3023
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3024
|
|
|
|
|
|
|
} |
3025
|
|
|
|
|
|
|
|
3026
|
|
|
|
|
|
|
# |
3027
|
|
|
|
|
|
|
# GB18030 file test -d expr |
3028
|
|
|
|
|
|
|
# |
3029
|
|
|
|
|
|
|
sub Egb18030::d(;*@) { |
3030
|
|
|
|
|
|
|
|
3031
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3032
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -d (Egb18030::d)' if @_ and not wantarray; |
3033
|
|
|
|
|
|
|
|
3034
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3035
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3036
|
|
|
|
|
|
|
} |
3037
|
|
|
|
|
|
|
|
3038
|
|
|
|
|
|
|
# return false if file handle or directory handle |
3039
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3040
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3041
|
|
|
|
|
|
|
} |
3042
|
|
|
|
|
|
|
elsif (-e $_) { |
3043
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3044
|
|
|
|
|
|
|
} |
3045
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3046
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d "$_/.",@_) : -d "$_/."; |
3047
|
|
|
|
|
|
|
} |
3048
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3049
|
|
|
|
|
|
|
} |
3050
|
|
|
|
|
|
|
|
3051
|
|
|
|
|
|
|
# |
3052
|
|
|
|
|
|
|
# GB18030 file test -l expr |
3053
|
|
|
|
|
|
|
# |
3054
|
|
|
|
|
|
|
sub Egb18030::l(;*@) { |
3055
|
|
|
|
|
|
|
|
3056
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3057
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -l (Egb18030::l)' if @_ and not wantarray; |
3058
|
|
|
|
|
|
|
|
3059
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3060
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3061
|
|
|
|
|
|
|
} |
3062
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3063
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l $fh,@_) : -l $fh; |
3064
|
|
|
|
|
|
|
} |
3065
|
|
|
|
|
|
|
elsif (-e $_) { |
3066
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3067
|
|
|
|
|
|
|
} |
3068
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3069
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3070
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3071
|
|
|
|
|
|
|
} |
3072
|
|
|
|
|
|
|
else { |
3073
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3074
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3075
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3076
|
0
|
|
|
|
|
0
|
close $fh; |
3077
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($l,@_) : $l; |
3078
|
|
|
|
|
|
|
} |
3079
|
|
|
|
|
|
|
} |
3080
|
|
|
|
|
|
|
} |
3081
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3082
|
|
|
|
|
|
|
} |
3083
|
|
|
|
|
|
|
|
3084
|
|
|
|
|
|
|
# |
3085
|
|
|
|
|
|
|
# GB18030 file test -p expr |
3086
|
|
|
|
|
|
|
# |
3087
|
|
|
|
|
|
|
sub Egb18030::p(;*@) { |
3088
|
|
|
|
|
|
|
|
3089
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3090
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -p (Egb18030::p)' if @_ and not wantarray; |
3091
|
|
|
|
|
|
|
|
3092
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3093
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3094
|
|
|
|
|
|
|
} |
3095
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3096
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p $fh,@_) : -p $fh; |
3097
|
|
|
|
|
|
|
} |
3098
|
|
|
|
|
|
|
elsif (-e $_) { |
3099
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3100
|
|
|
|
|
|
|
} |
3101
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3102
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3103
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3104
|
|
|
|
|
|
|
} |
3105
|
|
|
|
|
|
|
else { |
3106
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3107
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3108
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3109
|
0
|
|
|
|
|
0
|
close $fh; |
3110
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($p,@_) : $p; |
3111
|
|
|
|
|
|
|
} |
3112
|
|
|
|
|
|
|
} |
3113
|
|
|
|
|
|
|
} |
3114
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3115
|
|
|
|
|
|
|
} |
3116
|
|
|
|
|
|
|
|
3117
|
|
|
|
|
|
|
# |
3118
|
|
|
|
|
|
|
# GB18030 file test -S expr |
3119
|
|
|
|
|
|
|
# |
3120
|
|
|
|
|
|
|
sub Egb18030::S(;*@) { |
3121
|
|
|
|
|
|
|
|
3122
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3123
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -S (Egb18030::S)' if @_ and not wantarray; |
3124
|
|
|
|
|
|
|
|
3125
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3126
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3127
|
|
|
|
|
|
|
} |
3128
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3129
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S $fh,@_) : -S $fh; |
3130
|
|
|
|
|
|
|
} |
3131
|
|
|
|
|
|
|
elsif (-e $_) { |
3132
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3133
|
|
|
|
|
|
|
} |
3134
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3135
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3136
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3137
|
|
|
|
|
|
|
} |
3138
|
|
|
|
|
|
|
else { |
3139
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3140
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3141
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3142
|
0
|
|
|
|
|
0
|
close $fh; |
3143
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($S,@_) : $S; |
3144
|
|
|
|
|
|
|
} |
3145
|
|
|
|
|
|
|
} |
3146
|
|
|
|
|
|
|
} |
3147
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3148
|
|
|
|
|
|
|
} |
3149
|
|
|
|
|
|
|
|
3150
|
|
|
|
|
|
|
# |
3151
|
|
|
|
|
|
|
# GB18030 file test -b expr |
3152
|
|
|
|
|
|
|
# |
3153
|
|
|
|
|
|
|
sub Egb18030::b(;*@) { |
3154
|
|
|
|
|
|
|
|
3155
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3156
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -b (Egb18030::b)' if @_ and not wantarray; |
3157
|
|
|
|
|
|
|
|
3158
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3159
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3160
|
|
|
|
|
|
|
} |
3161
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3162
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b $fh,@_) : -b $fh; |
3163
|
|
|
|
|
|
|
} |
3164
|
|
|
|
|
|
|
elsif (-e $_) { |
3165
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3166
|
|
|
|
|
|
|
} |
3167
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3168
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3169
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3170
|
|
|
|
|
|
|
} |
3171
|
|
|
|
|
|
|
else { |
3172
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3173
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3174
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
3175
|
0
|
|
|
|
|
0
|
close $fh; |
3176
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($b,@_) : $b; |
3177
|
|
|
|
|
|
|
} |
3178
|
|
|
|
|
|
|
} |
3179
|
|
|
|
|
|
|
} |
3180
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3181
|
|
|
|
|
|
|
} |
3182
|
|
|
|
|
|
|
|
3183
|
|
|
|
|
|
|
# |
3184
|
|
|
|
|
|
|
# GB18030 file test -c expr |
3185
|
|
|
|
|
|
|
# |
3186
|
|
|
|
|
|
|
sub Egb18030::c(;*@) { |
3187
|
|
|
|
|
|
|
|
3188
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3189
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -c (Egb18030::c)' if @_ and not wantarray; |
3190
|
|
|
|
|
|
|
|
3191
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3192
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3193
|
|
|
|
|
|
|
} |
3194
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3195
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c $fh,@_) : -c $fh; |
3196
|
|
|
|
|
|
|
} |
3197
|
|
|
|
|
|
|
elsif (-e $_) { |
3198
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3199
|
|
|
|
|
|
|
} |
3200
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3201
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3202
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3203
|
|
|
|
|
|
|
} |
3204
|
|
|
|
|
|
|
else { |
3205
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3206
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3207
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
3208
|
0
|
|
|
|
|
0
|
close $fh; |
3209
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($c,@_) : $c; |
3210
|
|
|
|
|
|
|
} |
3211
|
|
|
|
|
|
|
} |
3212
|
|
|
|
|
|
|
} |
3213
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3214
|
|
|
|
|
|
|
} |
3215
|
|
|
|
|
|
|
|
3216
|
|
|
|
|
|
|
# |
3217
|
|
|
|
|
|
|
# GB18030 file test -u expr |
3218
|
|
|
|
|
|
|
# |
3219
|
|
|
|
|
|
|
sub Egb18030::u(;*@) { |
3220
|
|
|
|
|
|
|
|
3221
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3222
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -u (Egb18030::u)' if @_ and not wantarray; |
3223
|
|
|
|
|
|
|
|
3224
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3225
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3226
|
|
|
|
|
|
|
} |
3227
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3228
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u $fh,@_) : -u $fh; |
3229
|
|
|
|
|
|
|
} |
3230
|
|
|
|
|
|
|
elsif (-e $_) { |
3231
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3232
|
|
|
|
|
|
|
} |
3233
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3234
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3235
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3236
|
|
|
|
|
|
|
} |
3237
|
|
|
|
|
|
|
else { |
3238
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3239
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3240
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
3241
|
0
|
|
|
|
|
0
|
close $fh; |
3242
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($u,@_) : $u; |
3243
|
|
|
|
|
|
|
} |
3244
|
|
|
|
|
|
|
} |
3245
|
|
|
|
|
|
|
} |
3246
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3247
|
|
|
|
|
|
|
} |
3248
|
|
|
|
|
|
|
|
3249
|
|
|
|
|
|
|
# |
3250
|
|
|
|
|
|
|
# GB18030 file test -g expr |
3251
|
|
|
|
|
|
|
# |
3252
|
|
|
|
|
|
|
sub Egb18030::g(;*@) { |
3253
|
|
|
|
|
|
|
|
3254
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3255
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -g (Egb18030::g)' if @_ and not wantarray; |
3256
|
|
|
|
|
|
|
|
3257
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3258
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3259
|
|
|
|
|
|
|
} |
3260
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3261
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g $fh,@_) : -g $fh; |
3262
|
|
|
|
|
|
|
} |
3263
|
|
|
|
|
|
|
elsif (-e $_) { |
3264
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3265
|
|
|
|
|
|
|
} |
3266
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3267
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3268
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3269
|
|
|
|
|
|
|
} |
3270
|
|
|
|
|
|
|
else { |
3271
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3272
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3273
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
3274
|
0
|
|
|
|
|
0
|
close $fh; |
3275
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($g,@_) : $g; |
3276
|
|
|
|
|
|
|
} |
3277
|
|
|
|
|
|
|
} |
3278
|
|
|
|
|
|
|
} |
3279
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3280
|
|
|
|
|
|
|
} |
3281
|
|
|
|
|
|
|
|
3282
|
|
|
|
|
|
|
# |
3283
|
|
|
|
|
|
|
# GB18030 file test -k expr |
3284
|
|
|
|
|
|
|
# |
3285
|
|
|
|
|
|
|
sub Egb18030::k(;*@) { |
3286
|
|
|
|
|
|
|
|
3287
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3288
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -k (Egb18030::k)' if @_ and not wantarray; |
3289
|
|
|
|
|
|
|
|
3290
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3291
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3292
|
|
|
|
|
|
|
} |
3293
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3294
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3295
|
|
|
|
|
|
|
} |
3296
|
|
|
|
|
|
|
elsif ($] =~ /^5\.008/oxms) { |
3297
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3298
|
|
|
|
|
|
|
} |
3299
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
3300
|
|
|
|
|
|
|
} |
3301
|
|
|
|
|
|
|
|
3302
|
|
|
|
|
|
|
# |
3303
|
|
|
|
|
|
|
# GB18030 file test -T expr |
3304
|
|
|
|
|
|
|
# |
3305
|
|
|
|
|
|
|
sub Egb18030::T(;*@) { |
3306
|
|
|
|
|
|
|
|
3307
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3308
|
|
|
|
|
|
|
|
3309
|
|
|
|
|
|
|
# Use of croak without parentheses makes die on Strawberry Perl 5.008 and 5.010, like: |
3310
|
|
|
|
|
|
|
# croak 'Too many arguments for -T (Egb18030::T)'; |
3311
|
|
|
|
|
|
|
# Must be used by parentheses like: |
3312
|
|
|
|
|
|
|
# croak('Too many arguments for -T (Egb18030::T)'); |
3313
|
|
|
|
|
|
|
|
3314
|
0
|
0
|
0
|
|
|
0
|
if (@_ and not wantarray) { |
3315
|
0
|
|
|
|
|
0
|
croak('Too many arguments for -T (Egb18030::T)'); |
3316
|
|
|
|
|
|
|
} |
3317
|
|
|
|
|
|
|
|
3318
|
0
|
|
|
|
|
0
|
my $T = 1; |
3319
|
|
|
|
|
|
|
|
3320
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3321
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3322
|
|
|
|
|
|
|
|
3323
|
0
|
0
|
|
|
|
0
|
if (defined Egb18030::telldir($fh)) { |
3324
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3325
|
|
|
|
|
|
|
} |
3326
|
|
|
|
|
|
|
|
3327
|
|
|
|
|
|
|
# P.813 29.2.176. tell |
3328
|
|
|
|
|
|
|
# in Chapter 29: Functions |
3329
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
3330
|
|
|
|
|
|
|
|
3331
|
|
|
|
|
|
|
# P.970 tell |
3332
|
|
|
|
|
|
|
# in Chapter 27: Functions |
3333
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3334
|
|
|
|
|
|
|
|
3335
|
|
|
|
|
|
|
# (and so on) |
3336
|
|
|
|
|
|
|
|
3337
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3338
|
|
|
|
|
|
|
|
3339
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3340
|
|
|
|
|
|
|
|
3341
|
|
|
|
|
|
|
# P.163 Binary file check in Little Perl Parlor 16 |
3342
|
|
|
|
|
|
|
# of Book No. T1008901080816 ZASSHI 08901-8 UNIX MAGAZINE 1993 Aug VOL8#8 |
3343
|
|
|
|
|
|
|
# (and so on) |
3344
|
|
|
|
|
|
|
|
3345
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3346
|
0
|
|
|
|
|
0
|
$T = ''; |
3347
|
|
|
|
|
|
|
} |
3348
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3349
|
0
|
|
|
|
|
0
|
$T = ''; |
3350
|
|
|
|
|
|
|
} |
3351
|
|
|
|
|
|
|
} |
3352
|
|
|
|
|
|
|
|
3353
|
|
|
|
|
|
|
# 0 byte or eof |
3354
|
|
|
|
|
|
|
else { |
3355
|
0
|
|
|
|
|
0
|
$T = 1; |
3356
|
|
|
|
|
|
|
} |
3357
|
|
|
|
|
|
|
|
3358
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3359
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3360
|
|
|
|
|
|
|
} |
3361
|
|
|
|
|
|
|
else { |
3362
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3363
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3364
|
|
|
|
|
|
|
} |
3365
|
|
|
|
|
|
|
|
3366
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3367
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3368
|
|
|
|
|
|
|
} |
3369
|
|
|
|
|
|
|
else { |
3370
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3371
|
|
|
|
|
|
|
} |
3372
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3373
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3374
|
0
|
|
|
|
|
0
|
$T = ''; |
3375
|
|
|
|
|
|
|
} |
3376
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3377
|
0
|
|
|
|
|
0
|
$T = ''; |
3378
|
|
|
|
|
|
|
} |
3379
|
|
|
|
|
|
|
} |
3380
|
|
|
|
|
|
|
|
3381
|
|
|
|
|
|
|
# 0 byte or eof |
3382
|
|
|
|
|
|
|
else { |
3383
|
0
|
|
|
|
|
0
|
$T = 1; |
3384
|
|
|
|
|
|
|
} |
3385
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3386
|
0
|
|
|
|
|
0
|
close $fh; |
3387
|
|
|
|
|
|
|
} |
3388
|
|
|
|
|
|
|
|
3389
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($T,@_) : $T; |
3390
|
|
|
|
|
|
|
} |
3391
|
|
|
|
|
|
|
|
3392
|
|
|
|
|
|
|
# |
3393
|
|
|
|
|
|
|
# GB18030 file test -B expr |
3394
|
|
|
|
|
|
|
# |
3395
|
|
|
|
|
|
|
sub Egb18030::B(;*@) { |
3396
|
|
|
|
|
|
|
|
3397
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3398
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -B (Egb18030::B)' if @_ and not wantarray; |
3399
|
0
|
|
|
|
|
0
|
my $B = ''; |
3400
|
|
|
|
|
|
|
|
3401
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3402
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3403
|
|
|
|
|
|
|
|
3404
|
0
|
0
|
|
|
|
0
|
if (defined Egb18030::telldir($fh)) { |
3405
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3406
|
|
|
|
|
|
|
} |
3407
|
|
|
|
|
|
|
|
3408
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3409
|
|
|
|
|
|
|
|
3410
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3411
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3412
|
0
|
|
|
|
|
0
|
$B = 1; |
3413
|
|
|
|
|
|
|
} |
3414
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3415
|
0
|
|
|
|
|
0
|
$B = 1; |
3416
|
|
|
|
|
|
|
} |
3417
|
|
|
|
|
|
|
} |
3418
|
|
|
|
|
|
|
|
3419
|
|
|
|
|
|
|
# 0 byte or eof |
3420
|
|
|
|
|
|
|
else { |
3421
|
0
|
|
|
|
|
0
|
$B = 1; |
3422
|
|
|
|
|
|
|
} |
3423
|
|
|
|
|
|
|
|
3424
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3425
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3426
|
|
|
|
|
|
|
} |
3427
|
|
|
|
|
|
|
else { |
3428
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3429
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3430
|
|
|
|
|
|
|
} |
3431
|
|
|
|
|
|
|
|
3432
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3433
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3434
|
|
|
|
|
|
|
} |
3435
|
|
|
|
|
|
|
else { |
3436
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3437
|
|
|
|
|
|
|
} |
3438
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3439
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3440
|
0
|
|
|
|
|
0
|
$B = 1; |
3441
|
|
|
|
|
|
|
} |
3442
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3443
|
0
|
|
|
|
|
0
|
$B = 1; |
3444
|
|
|
|
|
|
|
} |
3445
|
|
|
|
|
|
|
} |
3446
|
|
|
|
|
|
|
|
3447
|
|
|
|
|
|
|
# 0 byte or eof |
3448
|
|
|
|
|
|
|
else { |
3449
|
0
|
|
|
|
|
0
|
$B = 1; |
3450
|
|
|
|
|
|
|
} |
3451
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3452
|
0
|
|
|
|
|
0
|
close $fh; |
3453
|
|
|
|
|
|
|
} |
3454
|
|
|
|
|
|
|
|
3455
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($B,@_) : $B; |
3456
|
|
|
|
|
|
|
} |
3457
|
|
|
|
|
|
|
|
3458
|
|
|
|
|
|
|
# |
3459
|
|
|
|
|
|
|
# GB18030 file test -M expr |
3460
|
|
|
|
|
|
|
# |
3461
|
|
|
|
|
|
|
sub Egb18030::M(;*@) { |
3462
|
|
|
|
|
|
|
|
3463
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3464
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -M (Egb18030::M)' if @_ and not wantarray; |
3465
|
|
|
|
|
|
|
|
3466
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3467
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3468
|
|
|
|
|
|
|
} |
3469
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3470
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M $fh,@_) : -M $fh; |
3471
|
|
|
|
|
|
|
} |
3472
|
|
|
|
|
|
|
elsif (-e $_) { |
3473
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3474
|
|
|
|
|
|
|
} |
3475
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3476
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3477
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3478
|
|
|
|
|
|
|
} |
3479
|
|
|
|
|
|
|
else { |
3480
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3481
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3482
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3483
|
0
|
|
|
|
|
0
|
close $fh; |
3484
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
3485
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($M,@_) : $M; |
3486
|
|
|
|
|
|
|
} |
3487
|
|
|
|
|
|
|
} |
3488
|
|
|
|
|
|
|
} |
3489
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3490
|
|
|
|
|
|
|
} |
3491
|
|
|
|
|
|
|
|
3492
|
|
|
|
|
|
|
# |
3493
|
|
|
|
|
|
|
# GB18030 file test -A expr |
3494
|
|
|
|
|
|
|
# |
3495
|
|
|
|
|
|
|
sub Egb18030::A(;*@) { |
3496
|
|
|
|
|
|
|
|
3497
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3498
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -A (Egb18030::A)' if @_ and not wantarray; |
3499
|
|
|
|
|
|
|
|
3500
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3501
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3502
|
|
|
|
|
|
|
} |
3503
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3504
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A $fh,@_) : -A $fh; |
3505
|
|
|
|
|
|
|
} |
3506
|
|
|
|
|
|
|
elsif (-e $_) { |
3507
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3508
|
|
|
|
|
|
|
} |
3509
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3510
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3511
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3512
|
|
|
|
|
|
|
} |
3513
|
|
|
|
|
|
|
else { |
3514
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3515
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3516
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3517
|
0
|
|
|
|
|
0
|
close $fh; |
3518
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
3519
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($A,@_) : $A; |
3520
|
|
|
|
|
|
|
} |
3521
|
|
|
|
|
|
|
} |
3522
|
|
|
|
|
|
|
} |
3523
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3524
|
|
|
|
|
|
|
} |
3525
|
|
|
|
|
|
|
|
3526
|
|
|
|
|
|
|
# |
3527
|
|
|
|
|
|
|
# GB18030 file test -C expr |
3528
|
|
|
|
|
|
|
# |
3529
|
|
|
|
|
|
|
sub Egb18030::C(;*@) { |
3530
|
|
|
|
|
|
|
|
3531
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3532
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -C (Egb18030::C)' if @_ and not wantarray; |
3533
|
|
|
|
|
|
|
|
3534
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3535
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3536
|
|
|
|
|
|
|
} |
3537
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3538
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C $fh,@_) : -C $fh; |
3539
|
|
|
|
|
|
|
} |
3540
|
|
|
|
|
|
|
elsif (-e $_) { |
3541
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3542
|
|
|
|
|
|
|
} |
3543
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3544
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3545
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3546
|
|
|
|
|
|
|
} |
3547
|
|
|
|
|
|
|
else { |
3548
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3549
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3550
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3551
|
0
|
|
|
|
|
0
|
close $fh; |
3552
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
3553
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($C,@_) : $C; |
3554
|
|
|
|
|
|
|
} |
3555
|
|
|
|
|
|
|
} |
3556
|
|
|
|
|
|
|
} |
3557
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3558
|
|
|
|
|
|
|
} |
3559
|
|
|
|
|
|
|
|
3560
|
|
|
|
|
|
|
# |
3561
|
|
|
|
|
|
|
# GB18030 stacked file test $_ |
3562
|
|
|
|
|
|
|
# |
3563
|
|
|
|
|
|
|
sub Egb18030::filetest_ { |
3564
|
|
|
|
|
|
|
|
3565
|
0
|
|
|
0
|
0
|
0
|
my $filetest = substr(pop @_, 1); |
3566
|
|
|
|
|
|
|
|
3567
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Egb18030::${filetest}_}) { |
3568
|
0
|
|
|
|
|
0
|
return ''; |
3569
|
|
|
|
|
|
|
} |
3570
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
3571
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
3572
|
0
|
|
|
|
|
0
|
return ''; |
3573
|
|
|
|
|
|
|
} |
3574
|
|
|
|
|
|
|
} |
3575
|
0
|
|
|
|
|
0
|
return 1; |
3576
|
|
|
|
|
|
|
} |
3577
|
|
|
|
|
|
|
|
3578
|
|
|
|
|
|
|
# |
3579
|
|
|
|
|
|
|
# GB18030 file test -r $_ |
3580
|
|
|
|
|
|
|
# |
3581
|
|
|
|
|
|
|
sub Egb18030::r_() { |
3582
|
|
|
|
|
|
|
|
3583
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3584
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3585
|
|
|
|
|
|
|
} |
3586
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3587
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3588
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3589
|
|
|
|
|
|
|
} |
3590
|
|
|
|
|
|
|
else { |
3591
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3592
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3593
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
3594
|
0
|
|
|
|
|
0
|
close $fh; |
3595
|
0
|
0
|
|
|
|
0
|
return $r ? 1 : ''; |
3596
|
|
|
|
|
|
|
} |
3597
|
|
|
|
|
|
|
} |
3598
|
|
|
|
|
|
|
} |
3599
|
|
|
|
|
|
|
|
3600
|
|
|
|
|
|
|
# 10.10. Returning Failure |
3601
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
3602
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
3603
|
|
|
|
|
|
|
# (and so on) |
3604
|
|
|
|
|
|
|
|
3605
|
|
|
|
|
|
|
# 2010-01-26 The difference of "return;" and "return undef;" |
3606
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20100126/1264474754 |
3607
|
|
|
|
|
|
|
# |
3608
|
|
|
|
|
|
|
# "Perl Best Practices" recommends to use "return;"*1 to return nothing, but |
3609
|
|
|
|
|
|
|
# it might be wrong in some cases. If you use this idiom for those functions |
3610
|
|
|
|
|
|
|
# which are expected to return a scalar value, e.g. searching functions, the |
3611
|
|
|
|
|
|
|
# user of those functions will be surprised at what they return in list |
3612
|
|
|
|
|
|
|
# context, an empty list - note that many functions and all the methods |
3613
|
|
|
|
|
|
|
# evaluate their arguments in list context. You'd better to use "return undef;" |
3614
|
|
|
|
|
|
|
# for such scalar functions. |
3615
|
|
|
|
|
|
|
# |
3616
|
|
|
|
|
|
|
# sub search_something { |
3617
|
|
|
|
|
|
|
# my($arg) = @_; |
3618
|
|
|
|
|
|
|
# # search_something... |
3619
|
|
|
|
|
|
|
# if(defined $found){ |
3620
|
|
|
|
|
|
|
# return $found; |
3621
|
|
|
|
|
|
|
# } |
3622
|
|
|
|
|
|
|
# return; # XXX: you'd better to "return undef;" |
3623
|
|
|
|
|
|
|
# } |
3624
|
|
|
|
|
|
|
# |
3625
|
|
|
|
|
|
|
# # ... |
3626
|
|
|
|
|
|
|
# |
3627
|
|
|
|
|
|
|
# # you'll get what you want, but ... |
3628
|
|
|
|
|
|
|
# my $something = search_something($source); |
3629
|
|
|
|
|
|
|
# |
3630
|
|
|
|
|
|
|
# # you won't get what you want here. |
3631
|
|
|
|
|
|
|
# # @_ for doit() is (-foo => $opt), not (undef, -foo => $opt). |
3632
|
|
|
|
|
|
|
# $obj->doit(search_something($source), -option=> $optval); |
3633
|
|
|
|
|
|
|
# |
3634
|
|
|
|
|
|
|
# # you have to use the "scalar" operator in such a case. |
3635
|
|
|
|
|
|
|
# $obj->doit(scalar search_something($source), ...); |
3636
|
|
|
|
|
|
|
# |
3637
|
|
|
|
|
|
|
# *1: it returns an empty list in list context, or returns undef in scalar |
3638
|
|
|
|
|
|
|
# context |
3639
|
|
|
|
|
|
|
# |
3640
|
|
|
|
|
|
|
# (and so on) |
3641
|
|
|
|
|
|
|
|
3642
|
0
|
|
|
|
|
0
|
return undef; |
3643
|
|
|
|
|
|
|
} |
3644
|
|
|
|
|
|
|
|
3645
|
|
|
|
|
|
|
# |
3646
|
|
|
|
|
|
|
# GB18030 file test -w $_ |
3647
|
|
|
|
|
|
|
# |
3648
|
|
|
|
|
|
|
sub Egb18030::w_() { |
3649
|
|
|
|
|
|
|
|
3650
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3651
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3652
|
|
|
|
|
|
|
} |
3653
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3654
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3655
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3656
|
|
|
|
|
|
|
} |
3657
|
|
|
|
|
|
|
else { |
3658
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3659
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3660
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
3661
|
0
|
|
|
|
|
0
|
close $fh; |
3662
|
0
|
0
|
|
|
|
0
|
return $w ? 1 : ''; |
3663
|
|
|
|
|
|
|
} |
3664
|
|
|
|
|
|
|
} |
3665
|
|
|
|
|
|
|
} |
3666
|
0
|
|
|
|
|
0
|
return undef; |
3667
|
|
|
|
|
|
|
} |
3668
|
|
|
|
|
|
|
|
3669
|
|
|
|
|
|
|
# |
3670
|
|
|
|
|
|
|
# GB18030 file test -x $_ |
3671
|
|
|
|
|
|
|
# |
3672
|
|
|
|
|
|
|
sub Egb18030::x_() { |
3673
|
|
|
|
|
|
|
|
3674
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3675
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3676
|
|
|
|
|
|
|
} |
3677
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3678
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3679
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3680
|
|
|
|
|
|
|
} |
3681
|
|
|
|
|
|
|
else { |
3682
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3683
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3684
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
3685
|
0
|
|
|
|
|
0
|
close $fh; |
3686
|
|
|
|
|
|
|
} |
3687
|
|
|
|
|
|
|
|
3688
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3689
|
0
|
|
|
|
|
0
|
return ''; |
3690
|
|
|
|
|
|
|
} |
3691
|
|
|
|
|
|
|
} |
3692
|
0
|
|
|
|
|
0
|
return undef; |
3693
|
|
|
|
|
|
|
} |
3694
|
|
|
|
|
|
|
|
3695
|
|
|
|
|
|
|
# |
3696
|
|
|
|
|
|
|
# GB18030 file test -o $_ |
3697
|
|
|
|
|
|
|
# |
3698
|
|
|
|
|
|
|
sub Egb18030::o_() { |
3699
|
|
|
|
|
|
|
|
3700
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3701
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3702
|
|
|
|
|
|
|
} |
3703
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3704
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3705
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3706
|
|
|
|
|
|
|
} |
3707
|
|
|
|
|
|
|
else { |
3708
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3709
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3710
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
3711
|
0
|
|
|
|
|
0
|
close $fh; |
3712
|
0
|
0
|
|
|
|
0
|
return $o ? 1 : ''; |
3713
|
|
|
|
|
|
|
} |
3714
|
|
|
|
|
|
|
} |
3715
|
|
|
|
|
|
|
} |
3716
|
0
|
|
|
|
|
0
|
return undef; |
3717
|
|
|
|
|
|
|
} |
3718
|
|
|
|
|
|
|
|
3719
|
|
|
|
|
|
|
# |
3720
|
|
|
|
|
|
|
# GB18030 file test -R $_ |
3721
|
|
|
|
|
|
|
# |
3722
|
|
|
|
|
|
|
sub Egb18030::R_() { |
3723
|
|
|
|
|
|
|
|
3724
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3725
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3726
|
|
|
|
|
|
|
} |
3727
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3728
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3729
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3730
|
|
|
|
|
|
|
} |
3731
|
|
|
|
|
|
|
else { |
3732
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3733
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3734
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
3735
|
0
|
|
|
|
|
0
|
close $fh; |
3736
|
0
|
0
|
|
|
|
0
|
return $R ? 1 : ''; |
3737
|
|
|
|
|
|
|
} |
3738
|
|
|
|
|
|
|
} |
3739
|
|
|
|
|
|
|
} |
3740
|
0
|
|
|
|
|
0
|
return undef; |
3741
|
|
|
|
|
|
|
} |
3742
|
|
|
|
|
|
|
|
3743
|
|
|
|
|
|
|
# |
3744
|
|
|
|
|
|
|
# GB18030 file test -W $_ |
3745
|
|
|
|
|
|
|
# |
3746
|
|
|
|
|
|
|
sub Egb18030::W_() { |
3747
|
|
|
|
|
|
|
|
3748
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3749
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3750
|
|
|
|
|
|
|
} |
3751
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3752
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3753
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3754
|
|
|
|
|
|
|
} |
3755
|
|
|
|
|
|
|
else { |
3756
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3757
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3758
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
3759
|
0
|
|
|
|
|
0
|
close $fh; |
3760
|
0
|
0
|
|
|
|
0
|
return $W ? 1 : ''; |
3761
|
|
|
|
|
|
|
} |
3762
|
|
|
|
|
|
|
} |
3763
|
|
|
|
|
|
|
} |
3764
|
0
|
|
|
|
|
0
|
return undef; |
3765
|
|
|
|
|
|
|
} |
3766
|
|
|
|
|
|
|
|
3767
|
|
|
|
|
|
|
# |
3768
|
|
|
|
|
|
|
# GB18030 file test -X $_ |
3769
|
|
|
|
|
|
|
# |
3770
|
|
|
|
|
|
|
sub Egb18030::X_() { |
3771
|
|
|
|
|
|
|
|
3772
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3773
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3774
|
|
|
|
|
|
|
} |
3775
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3776
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3777
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3778
|
|
|
|
|
|
|
} |
3779
|
|
|
|
|
|
|
else { |
3780
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3781
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3782
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
3783
|
0
|
|
|
|
|
0
|
close $fh; |
3784
|
|
|
|
|
|
|
} |
3785
|
|
|
|
|
|
|
|
3786
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3787
|
0
|
|
|
|
|
0
|
return ''; |
3788
|
|
|
|
|
|
|
} |
3789
|
|
|
|
|
|
|
} |
3790
|
0
|
|
|
|
|
0
|
return undef; |
3791
|
|
|
|
|
|
|
} |
3792
|
|
|
|
|
|
|
|
3793
|
|
|
|
|
|
|
# |
3794
|
|
|
|
|
|
|
# GB18030 file test -O $_ |
3795
|
|
|
|
|
|
|
# |
3796
|
|
|
|
|
|
|
sub Egb18030::O_() { |
3797
|
|
|
|
|
|
|
|
3798
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3799
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3800
|
|
|
|
|
|
|
} |
3801
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3802
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3803
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3804
|
|
|
|
|
|
|
} |
3805
|
|
|
|
|
|
|
else { |
3806
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3807
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3808
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
3809
|
0
|
|
|
|
|
0
|
close $fh; |
3810
|
0
|
0
|
|
|
|
0
|
return $O ? 1 : ''; |
3811
|
|
|
|
|
|
|
} |
3812
|
|
|
|
|
|
|
} |
3813
|
|
|
|
|
|
|
} |
3814
|
0
|
|
|
|
|
0
|
return undef; |
3815
|
|
|
|
|
|
|
} |
3816
|
|
|
|
|
|
|
|
3817
|
|
|
|
|
|
|
# |
3818
|
|
|
|
|
|
|
# GB18030 file test -e $_ |
3819
|
|
|
|
|
|
|
# |
3820
|
|
|
|
|
|
|
sub Egb18030::e_() { |
3821
|
|
|
|
|
|
|
|
3822
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3823
|
0
|
|
|
|
|
0
|
return 1; |
3824
|
|
|
|
|
|
|
} |
3825
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3826
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3827
|
0
|
|
|
|
|
0
|
return 1; |
3828
|
|
|
|
|
|
|
} |
3829
|
|
|
|
|
|
|
else { |
3830
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3831
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3832
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
3833
|
0
|
|
|
|
|
0
|
close $fh; |
3834
|
0
|
0
|
|
|
|
0
|
return $e ? 1 : ''; |
3835
|
|
|
|
|
|
|
} |
3836
|
|
|
|
|
|
|
} |
3837
|
|
|
|
|
|
|
} |
3838
|
0
|
|
|
|
|
0
|
return undef; |
3839
|
|
|
|
|
|
|
} |
3840
|
|
|
|
|
|
|
|
3841
|
|
|
|
|
|
|
# |
3842
|
|
|
|
|
|
|
# GB18030 file test -z $_ |
3843
|
|
|
|
|
|
|
# |
3844
|
|
|
|
|
|
|
sub Egb18030::z_() { |
3845
|
|
|
|
|
|
|
|
3846
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3847
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3848
|
|
|
|
|
|
|
} |
3849
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3850
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3851
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3852
|
|
|
|
|
|
|
} |
3853
|
|
|
|
|
|
|
else { |
3854
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3855
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3856
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
3857
|
0
|
|
|
|
|
0
|
close $fh; |
3858
|
0
|
0
|
|
|
|
0
|
return $z ? 1 : ''; |
3859
|
|
|
|
|
|
|
} |
3860
|
|
|
|
|
|
|
} |
3861
|
|
|
|
|
|
|
} |
3862
|
0
|
|
|
|
|
0
|
return undef; |
3863
|
|
|
|
|
|
|
} |
3864
|
|
|
|
|
|
|
|
3865
|
|
|
|
|
|
|
# |
3866
|
|
|
|
|
|
|
# GB18030 file test -s $_ |
3867
|
|
|
|
|
|
|
# |
3868
|
|
|
|
|
|
|
sub Egb18030::s_() { |
3869
|
|
|
|
|
|
|
|
3870
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3871
|
0
|
|
|
|
|
0
|
return -s _; |
3872
|
|
|
|
|
|
|
} |
3873
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3874
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3875
|
0
|
|
|
|
|
0
|
return -s _; |
3876
|
|
|
|
|
|
|
} |
3877
|
|
|
|
|
|
|
else { |
3878
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3879
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3880
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
3881
|
0
|
|
|
|
|
0
|
close $fh; |
3882
|
0
|
|
|
|
|
0
|
return $s; |
3883
|
|
|
|
|
|
|
} |
3884
|
|
|
|
|
|
|
} |
3885
|
|
|
|
|
|
|
} |
3886
|
0
|
|
|
|
|
0
|
return undef; |
3887
|
|
|
|
|
|
|
} |
3888
|
|
|
|
|
|
|
|
3889
|
|
|
|
|
|
|
# |
3890
|
|
|
|
|
|
|
# GB18030 file test -f $_ |
3891
|
|
|
|
|
|
|
# |
3892
|
|
|
|
|
|
|
sub Egb18030::f_() { |
3893
|
|
|
|
|
|
|
|
3894
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3895
|
0
|
0
|
|
|
|
0
|
return -f _ ? 1 : ''; |
3896
|
|
|
|
|
|
|
} |
3897
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3898
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3899
|
0
|
|
|
|
|
0
|
return ''; |
3900
|
|
|
|
|
|
|
} |
3901
|
|
|
|
|
|
|
else { |
3902
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3903
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3904
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3905
|
0
|
|
|
|
|
0
|
close $fh; |
3906
|
0
|
0
|
|
|
|
0
|
return $f ? 1 : ''; |
3907
|
|
|
|
|
|
|
} |
3908
|
|
|
|
|
|
|
} |
3909
|
|
|
|
|
|
|
} |
3910
|
0
|
|
|
|
|
0
|
return undef; |
3911
|
|
|
|
|
|
|
} |
3912
|
|
|
|
|
|
|
|
3913
|
|
|
|
|
|
|
# |
3914
|
|
|
|
|
|
|
# GB18030 file test -d $_ |
3915
|
|
|
|
|
|
|
# |
3916
|
|
|
|
|
|
|
sub Egb18030::d_() { |
3917
|
|
|
|
|
|
|
|
3918
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3919
|
0
|
0
|
|
|
|
0
|
return -d _ ? 1 : ''; |
3920
|
|
|
|
|
|
|
} |
3921
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3922
|
0
|
0
|
|
|
|
0
|
return -d "$_/." ? 1 : ''; |
3923
|
|
|
|
|
|
|
} |
3924
|
0
|
|
|
|
|
0
|
return undef; |
3925
|
|
|
|
|
|
|
} |
3926
|
|
|
|
|
|
|
|
3927
|
|
|
|
|
|
|
# |
3928
|
|
|
|
|
|
|
# GB18030 file test -l $_ |
3929
|
|
|
|
|
|
|
# |
3930
|
|
|
|
|
|
|
sub Egb18030::l_() { |
3931
|
|
|
|
|
|
|
|
3932
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3933
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3934
|
|
|
|
|
|
|
} |
3935
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3936
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3937
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3938
|
|
|
|
|
|
|
} |
3939
|
|
|
|
|
|
|
else { |
3940
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3941
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3942
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3943
|
0
|
|
|
|
|
0
|
close $fh; |
3944
|
0
|
0
|
|
|
|
0
|
return $l ? 1 : ''; |
3945
|
|
|
|
|
|
|
} |
3946
|
|
|
|
|
|
|
} |
3947
|
|
|
|
|
|
|
} |
3948
|
0
|
|
|
|
|
0
|
return undef; |
3949
|
|
|
|
|
|
|
} |
3950
|
|
|
|
|
|
|
|
3951
|
|
|
|
|
|
|
# |
3952
|
|
|
|
|
|
|
# GB18030 file test -p $_ |
3953
|
|
|
|
|
|
|
# |
3954
|
|
|
|
|
|
|
sub Egb18030::p_() { |
3955
|
|
|
|
|
|
|
|
3956
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3957
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3958
|
|
|
|
|
|
|
} |
3959
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3960
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3961
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3962
|
|
|
|
|
|
|
} |
3963
|
|
|
|
|
|
|
else { |
3964
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3965
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3966
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3967
|
0
|
|
|
|
|
0
|
close $fh; |
3968
|
0
|
0
|
|
|
|
0
|
return $p ? 1 : ''; |
3969
|
|
|
|
|
|
|
} |
3970
|
|
|
|
|
|
|
} |
3971
|
|
|
|
|
|
|
} |
3972
|
0
|
|
|
|
|
0
|
return undef; |
3973
|
|
|
|
|
|
|
} |
3974
|
|
|
|
|
|
|
|
3975
|
|
|
|
|
|
|
# |
3976
|
|
|
|
|
|
|
# GB18030 file test -S $_ |
3977
|
|
|
|
|
|
|
# |
3978
|
|
|
|
|
|
|
sub Egb18030::S_() { |
3979
|
|
|
|
|
|
|
|
3980
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3981
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3982
|
|
|
|
|
|
|
} |
3983
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3984
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3985
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3986
|
|
|
|
|
|
|
} |
3987
|
|
|
|
|
|
|
else { |
3988
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3989
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3990
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3991
|
0
|
|
|
|
|
0
|
close $fh; |
3992
|
0
|
0
|
|
|
|
0
|
return $S ? 1 : ''; |
3993
|
|
|
|
|
|
|
} |
3994
|
|
|
|
|
|
|
} |
3995
|
|
|
|
|
|
|
} |
3996
|
0
|
|
|
|
|
0
|
return undef; |
3997
|
|
|
|
|
|
|
} |
3998
|
|
|
|
|
|
|
|
3999
|
|
|
|
|
|
|
# |
4000
|
|
|
|
|
|
|
# GB18030 file test -b $_ |
4001
|
|
|
|
|
|
|
# |
4002
|
|
|
|
|
|
|
sub Egb18030::b_() { |
4003
|
|
|
|
|
|
|
|
4004
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4005
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
4006
|
|
|
|
|
|
|
} |
4007
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4008
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4009
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
4010
|
|
|
|
|
|
|
} |
4011
|
|
|
|
|
|
|
else { |
4012
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4013
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4014
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
4015
|
0
|
|
|
|
|
0
|
close $fh; |
4016
|
0
|
0
|
|
|
|
0
|
return $b ? 1 : ''; |
4017
|
|
|
|
|
|
|
} |
4018
|
|
|
|
|
|
|
} |
4019
|
|
|
|
|
|
|
} |
4020
|
0
|
|
|
|
|
0
|
return undef; |
4021
|
|
|
|
|
|
|
} |
4022
|
|
|
|
|
|
|
|
4023
|
|
|
|
|
|
|
# |
4024
|
|
|
|
|
|
|
# GB18030 file test -c $_ |
4025
|
|
|
|
|
|
|
# |
4026
|
|
|
|
|
|
|
sub Egb18030::c_() { |
4027
|
|
|
|
|
|
|
|
4028
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4029
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4030
|
|
|
|
|
|
|
} |
4031
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4032
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4033
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4034
|
|
|
|
|
|
|
} |
4035
|
|
|
|
|
|
|
else { |
4036
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4037
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4038
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
4039
|
0
|
|
|
|
|
0
|
close $fh; |
4040
|
0
|
0
|
|
|
|
0
|
return $c ? 1 : ''; |
4041
|
|
|
|
|
|
|
} |
4042
|
|
|
|
|
|
|
} |
4043
|
|
|
|
|
|
|
} |
4044
|
0
|
|
|
|
|
0
|
return undef; |
4045
|
|
|
|
|
|
|
} |
4046
|
|
|
|
|
|
|
|
4047
|
|
|
|
|
|
|
# |
4048
|
|
|
|
|
|
|
# GB18030 file test -u $_ |
4049
|
|
|
|
|
|
|
# |
4050
|
|
|
|
|
|
|
sub Egb18030::u_() { |
4051
|
|
|
|
|
|
|
|
4052
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4053
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4054
|
|
|
|
|
|
|
} |
4055
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4056
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4057
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4058
|
|
|
|
|
|
|
} |
4059
|
|
|
|
|
|
|
else { |
4060
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4061
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4062
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
4063
|
0
|
|
|
|
|
0
|
close $fh; |
4064
|
0
|
0
|
|
|
|
0
|
return $u ? 1 : ''; |
4065
|
|
|
|
|
|
|
} |
4066
|
|
|
|
|
|
|
} |
4067
|
|
|
|
|
|
|
} |
4068
|
0
|
|
|
|
|
0
|
return undef; |
4069
|
|
|
|
|
|
|
} |
4070
|
|
|
|
|
|
|
|
4071
|
|
|
|
|
|
|
# |
4072
|
|
|
|
|
|
|
# GB18030 file test -g $_ |
4073
|
|
|
|
|
|
|
# |
4074
|
|
|
|
|
|
|
sub Egb18030::g_() { |
4075
|
|
|
|
|
|
|
|
4076
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4077
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4078
|
|
|
|
|
|
|
} |
4079
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4080
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4081
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4082
|
|
|
|
|
|
|
} |
4083
|
|
|
|
|
|
|
else { |
4084
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4085
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4086
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
4087
|
0
|
|
|
|
|
0
|
close $fh; |
4088
|
0
|
0
|
|
|
|
0
|
return $g ? 1 : ''; |
4089
|
|
|
|
|
|
|
} |
4090
|
|
|
|
|
|
|
} |
4091
|
|
|
|
|
|
|
} |
4092
|
0
|
|
|
|
|
0
|
return undef; |
4093
|
|
|
|
|
|
|
} |
4094
|
|
|
|
|
|
|
|
4095
|
|
|
|
|
|
|
# |
4096
|
|
|
|
|
|
|
# GB18030 file test -k $_ |
4097
|
|
|
|
|
|
|
# |
4098
|
|
|
|
|
|
|
sub Egb18030::k_() { |
4099
|
|
|
|
|
|
|
|
4100
|
0
|
0
|
|
0
|
0
|
0
|
if ($] =~ /^5\.008/oxms) { |
4101
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
4102
|
|
|
|
|
|
|
} |
4103
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
4104
|
|
|
|
|
|
|
} |
4105
|
|
|
|
|
|
|
|
4106
|
|
|
|
|
|
|
# |
4107
|
|
|
|
|
|
|
# GB18030 file test -T $_ |
4108
|
|
|
|
|
|
|
# |
4109
|
|
|
|
|
|
|
sub Egb18030::T_() { |
4110
|
|
|
|
|
|
|
|
4111
|
0
|
|
|
0
|
0
|
0
|
my $T = 1; |
4112
|
|
|
|
|
|
|
|
4113
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4114
|
0
|
|
|
|
|
0
|
return undef; |
4115
|
|
|
|
|
|
|
} |
4116
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4117
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4118
|
|
|
|
|
|
|
} |
4119
|
|
|
|
|
|
|
else { |
4120
|
0
|
|
|
|
|
0
|
return undef; |
4121
|
|
|
|
|
|
|
} |
4122
|
|
|
|
|
|
|
|
4123
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4124
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4125
|
0
|
|
|
|
|
0
|
$T = ''; |
4126
|
|
|
|
|
|
|
} |
4127
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4128
|
0
|
|
|
|
|
0
|
$T = ''; |
4129
|
|
|
|
|
|
|
} |
4130
|
|
|
|
|
|
|
} |
4131
|
|
|
|
|
|
|
|
4132
|
|
|
|
|
|
|
# 0 byte or eof |
4133
|
|
|
|
|
|
|
else { |
4134
|
0
|
|
|
|
|
0
|
$T = 1; |
4135
|
|
|
|
|
|
|
} |
4136
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
4137
|
0
|
|
|
|
|
0
|
close $fh; |
4138
|
|
|
|
|
|
|
|
4139
|
0
|
|
|
|
|
0
|
return $T; |
4140
|
|
|
|
|
|
|
} |
4141
|
|
|
|
|
|
|
|
4142
|
|
|
|
|
|
|
# |
4143
|
|
|
|
|
|
|
# GB18030 file test -B $_ |
4144
|
|
|
|
|
|
|
# |
4145
|
|
|
|
|
|
|
sub Egb18030::B_() { |
4146
|
|
|
|
|
|
|
|
4147
|
0
|
|
|
0
|
0
|
0
|
my $B = ''; |
4148
|
|
|
|
|
|
|
|
4149
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4150
|
0
|
|
|
|
|
0
|
return undef; |
4151
|
|
|
|
|
|
|
} |
4152
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4153
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4154
|
|
|
|
|
|
|
} |
4155
|
|
|
|
|
|
|
else { |
4156
|
0
|
|
|
|
|
0
|
return undef; |
4157
|
|
|
|
|
|
|
} |
4158
|
|
|
|
|
|
|
|
4159
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4160
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4161
|
0
|
|
|
|
|
0
|
$B = 1; |
4162
|
|
|
|
|
|
|
} |
4163
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4164
|
0
|
|
|
|
|
0
|
$B = 1; |
4165
|
|
|
|
|
|
|
} |
4166
|
|
|
|
|
|
|
} |
4167
|
|
|
|
|
|
|
|
4168
|
|
|
|
|
|
|
# 0 byte or eof |
4169
|
|
|
|
|
|
|
else { |
4170
|
0
|
|
|
|
|
0
|
$B = 1; |
4171
|
|
|
|
|
|
|
} |
4172
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
4173
|
0
|
|
|
|
|
0
|
close $fh; |
4174
|
|
|
|
|
|
|
|
4175
|
0
|
|
|
|
|
0
|
return $B; |
4176
|
|
|
|
|
|
|
} |
4177
|
|
|
|
|
|
|
|
4178
|
|
|
|
|
|
|
# |
4179
|
|
|
|
|
|
|
# GB18030 file test -M $_ |
4180
|
|
|
|
|
|
|
# |
4181
|
|
|
|
|
|
|
sub Egb18030::M_() { |
4182
|
|
|
|
|
|
|
|
4183
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4184
|
0
|
|
|
|
|
0
|
return -M _; |
4185
|
|
|
|
|
|
|
} |
4186
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4187
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4188
|
0
|
|
|
|
|
0
|
return -M _; |
4189
|
|
|
|
|
|
|
} |
4190
|
|
|
|
|
|
|
else { |
4191
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4192
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4193
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4194
|
0
|
|
|
|
|
0
|
close $fh; |
4195
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
4196
|
0
|
|
|
|
|
0
|
return $M; |
4197
|
|
|
|
|
|
|
} |
4198
|
|
|
|
|
|
|
} |
4199
|
|
|
|
|
|
|
} |
4200
|
0
|
|
|
|
|
0
|
return undef; |
4201
|
|
|
|
|
|
|
} |
4202
|
|
|
|
|
|
|
|
4203
|
|
|
|
|
|
|
# |
4204
|
|
|
|
|
|
|
# GB18030 file test -A $_ |
4205
|
|
|
|
|
|
|
# |
4206
|
|
|
|
|
|
|
sub Egb18030::A_() { |
4207
|
|
|
|
|
|
|
|
4208
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4209
|
0
|
|
|
|
|
0
|
return -A _; |
4210
|
|
|
|
|
|
|
} |
4211
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4212
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4213
|
0
|
|
|
|
|
0
|
return -A _; |
4214
|
|
|
|
|
|
|
} |
4215
|
|
|
|
|
|
|
else { |
4216
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4217
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4218
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4219
|
0
|
|
|
|
|
0
|
close $fh; |
4220
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
4221
|
0
|
|
|
|
|
0
|
return $A; |
4222
|
|
|
|
|
|
|
} |
4223
|
|
|
|
|
|
|
} |
4224
|
|
|
|
|
|
|
} |
4225
|
0
|
|
|
|
|
0
|
return undef; |
4226
|
|
|
|
|
|
|
} |
4227
|
|
|
|
|
|
|
|
4228
|
|
|
|
|
|
|
# |
4229
|
|
|
|
|
|
|
# GB18030 file test -C $_ |
4230
|
|
|
|
|
|
|
# |
4231
|
|
|
|
|
|
|
sub Egb18030::C_() { |
4232
|
|
|
|
|
|
|
|
4233
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4234
|
0
|
|
|
|
|
0
|
return -C _; |
4235
|
|
|
|
|
|
|
} |
4236
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4237
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4238
|
0
|
|
|
|
|
0
|
return -C _; |
4239
|
|
|
|
|
|
|
} |
4240
|
|
|
|
|
|
|
else { |
4241
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4242
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4243
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4244
|
0
|
|
|
|
|
0
|
close $fh; |
4245
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
4246
|
0
|
|
|
|
|
0
|
return $C; |
4247
|
|
|
|
|
|
|
} |
4248
|
|
|
|
|
|
|
} |
4249
|
|
|
|
|
|
|
} |
4250
|
0
|
|
|
|
|
0
|
return undef; |
4251
|
|
|
|
|
|
|
} |
4252
|
|
|
|
|
|
|
|
4253
|
|
|
|
|
|
|
# |
4254
|
|
|
|
|
|
|
# GB18030 path globbing (with parameter) |
4255
|
|
|
|
|
|
|
# |
4256
|
|
|
|
|
|
|
sub Egb18030::glob($) { |
4257
|
|
|
|
|
|
|
|
4258
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4259
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(@_); |
4260
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4261
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4262
|
|
|
|
|
|
|
} |
4263
|
0
|
|
|
|
|
0
|
return @glob; |
4264
|
|
|
|
|
|
|
} |
4265
|
|
|
|
|
|
|
else { |
4266
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(@_); |
4267
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4268
|
0
|
|
|
|
|
0
|
return $glob; |
4269
|
|
|
|
|
|
|
} |
4270
|
|
|
|
|
|
|
} |
4271
|
|
|
|
|
|
|
|
4272
|
|
|
|
|
|
|
# |
4273
|
|
|
|
|
|
|
# GB18030 path globbing (without parameter) |
4274
|
|
|
|
|
|
|
# |
4275
|
|
|
|
|
|
|
sub Egb18030::glob_() { |
4276
|
|
|
|
|
|
|
|
4277
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4278
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(); |
4279
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4280
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4281
|
|
|
|
|
|
|
} |
4282
|
0
|
|
|
|
|
0
|
return @glob; |
4283
|
|
|
|
|
|
|
} |
4284
|
|
|
|
|
|
|
else { |
4285
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(); |
4286
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4287
|
0
|
|
|
|
|
0
|
return $glob; |
4288
|
|
|
|
|
|
|
} |
4289
|
|
|
|
|
|
|
} |
4290
|
|
|
|
|
|
|
|
4291
|
|
|
|
|
|
|
# |
4292
|
|
|
|
|
|
|
# GB18030 path globbing via File::DosGlob 1.10 |
4293
|
|
|
|
|
|
|
# |
4294
|
|
|
|
|
|
|
# Often I confuse "_dosglob" and "_doglob". |
4295
|
|
|
|
|
|
|
# So, I renamed "_dosglob" to "_DOS_like_glob". |
4296
|
|
|
|
|
|
|
# |
4297
|
|
|
|
|
|
|
my %iter; |
4298
|
|
|
|
|
|
|
my %entries; |
4299
|
|
|
|
|
|
|
sub _DOS_like_glob { |
4300
|
|
|
|
|
|
|
|
4301
|
|
|
|
|
|
|
# context (keyed by second cxix argument provided by core) |
4302
|
0
|
|
|
0
|
|
0
|
my($expr,$cxix) = @_; |
4303
|
|
|
|
|
|
|
|
4304
|
|
|
|
|
|
|
# glob without args defaults to $_ |
4305
|
0
|
0
|
|
|
|
0
|
$expr = $_ if not defined $expr; |
4306
|
|
|
|
|
|
|
|
4307
|
|
|
|
|
|
|
# represents the current user's home directory |
4308
|
|
|
|
|
|
|
# |
4309
|
|
|
|
|
|
|
# 7.3. Expanding Tildes in Filenames |
4310
|
|
|
|
|
|
|
# in Chapter 7. File Access |
4311
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4312
|
|
|
|
|
|
|
# |
4313
|
|
|
|
|
|
|
# and File::HomeDir, File::HomeDir::Windows module |
4314
|
|
|
|
|
|
|
|
4315
|
|
|
|
|
|
|
# DOS-like system |
4316
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4317
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ (?= [^/\\] ) } |
|
0
|
|
|
|
|
0
|
|
4318
|
|
|
|
|
|
|
{ my_home_MSWin32() }oxmse; |
4319
|
|
|
|
|
|
|
} |
4320
|
|
|
|
|
|
|
|
4321
|
|
|
|
|
|
|
# UNIX-like system |
4322
|
0
|
0
|
0
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
4323
|
|
|
|
|
|
|
$expr =~ s{ \A ~ ( (?:[^\x81-\xFE/]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])* ) } |
4324
|
|
|
|
|
|
|
{ $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse; |
4325
|
|
|
|
|
|
|
} |
4326
|
0
|
0
|
|
|
|
0
|
|
4327
|
0
|
0
|
|
|
|
0
|
# assume global context if not provided one |
4328
|
|
|
|
|
|
|
$cxix = '_G_' if not defined $cxix; |
4329
|
|
|
|
|
|
|
$iter{$cxix} = 0 if not exists $iter{$cxix}; |
4330
|
0
|
0
|
|
|
|
0
|
|
4331
|
0
|
|
|
|
|
0
|
# if we're just beginning, do it all first |
4332
|
|
|
|
|
|
|
if ($iter{$cxix} == 0) { |
4333
|
|
|
|
|
|
|
$entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ]; |
4334
|
|
|
|
|
|
|
} |
4335
|
0
|
0
|
|
|
|
0
|
|
4336
|
0
|
|
|
|
|
0
|
# chuck it all out, quick or slow |
4337
|
0
|
|
|
|
|
0
|
if (wantarray) { |
|
0
|
|
|
|
|
0
|
|
4338
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4339
|
|
|
|
|
|
|
return @{delete $entries{$cxix}}; |
4340
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4341
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
4342
|
|
|
|
|
|
|
if ($iter{$cxix} = scalar @{$entries{$cxix}}) { |
4343
|
|
|
|
|
|
|
return shift @{$entries{$cxix}}; |
4344
|
|
|
|
|
|
|
} |
4345
|
0
|
|
|
|
|
0
|
else { |
4346
|
0
|
|
|
|
|
0
|
# return undef for EOL |
4347
|
0
|
|
|
|
|
0
|
delete $iter{$cxix}; |
4348
|
|
|
|
|
|
|
delete $entries{$cxix}; |
4349
|
|
|
|
|
|
|
return undef; |
4350
|
|
|
|
|
|
|
} |
4351
|
|
|
|
|
|
|
} |
4352
|
|
|
|
|
|
|
} |
4353
|
|
|
|
|
|
|
|
4354
|
|
|
|
|
|
|
# |
4355
|
|
|
|
|
|
|
# GB18030 path globbing subroutine |
4356
|
|
|
|
|
|
|
# |
4357
|
0
|
|
|
0
|
|
0
|
sub _do_glob { |
4358
|
0
|
|
|
|
|
0
|
|
4359
|
0
|
|
|
|
|
0
|
my($cond,@expr) = @_; |
4360
|
|
|
|
|
|
|
my @glob = (); |
4361
|
|
|
|
|
|
|
my $fix_drive_relative_paths = 0; |
4362
|
0
|
|
|
|
|
0
|
|
4363
|
0
|
0
|
|
|
|
0
|
OUTER: |
4364
|
0
|
0
|
|
|
|
0
|
for my $expr (@expr) { |
4365
|
|
|
|
|
|
|
next OUTER if not defined $expr; |
4366
|
0
|
|
|
|
|
0
|
next OUTER if $expr eq ''; |
4367
|
0
|
|
|
|
|
0
|
|
4368
|
0
|
|
|
|
|
0
|
my @matched = (); |
4369
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4370
|
0
|
|
|
|
|
0
|
my $head = '.'; |
4371
|
|
|
|
|
|
|
my $pathsep = '/'; |
4372
|
|
|
|
|
|
|
my $tail; |
4373
|
0
|
0
|
|
|
|
0
|
|
4374
|
0
|
|
|
|
|
0
|
# if argument is within quotes strip em and do no globbing |
4375
|
0
|
0
|
|
|
|
0
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4376
|
0
|
0
|
|
|
|
0
|
$expr = $1; |
4377
|
0
|
|
|
|
|
0
|
if ($cond eq 'd') { |
4378
|
|
|
|
|
|
|
if (Egb18030::d $expr) { |
4379
|
|
|
|
|
|
|
push @glob, $expr; |
4380
|
|
|
|
|
|
|
} |
4381
|
0
|
0
|
|
|
|
0
|
} |
4382
|
0
|
|
|
|
|
0
|
else { |
4383
|
|
|
|
|
|
|
if (Egb18030::e $expr) { |
4384
|
|
|
|
|
|
|
push @glob, $expr; |
4385
|
0
|
|
|
|
|
0
|
} |
4386
|
|
|
|
|
|
|
} |
4387
|
|
|
|
|
|
|
next OUTER; |
4388
|
|
|
|
|
|
|
} |
4389
|
|
|
|
|
|
|
|
4390
|
0
|
0
|
|
|
|
0
|
# wildcards with a drive prefix such as h:*.pm must be changed |
4391
|
0
|
0
|
|
|
|
0
|
# to h:./*.pm to expand correctly |
4392
|
0
|
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4393
|
|
|
|
|
|
|
if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^\x81-\xFE/\\]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF]) #$1./$2#oxms) { |
4394
|
|
|
|
|
|
|
$fix_drive_relative_paths = 1; |
4395
|
|
|
|
|
|
|
} |
4396
|
0
|
0
|
|
|
|
0
|
} |
4397
|
0
|
0
|
|
|
|
0
|
|
4398
|
0
|
|
|
|
|
0
|
if (($head, $tail) = _parse_path($expr,$pathsep)) { |
4399
|
0
|
|
|
|
|
0
|
if ($tail eq '') { |
4400
|
|
|
|
|
|
|
push @glob, $expr; |
4401
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4402
|
0
|
0
|
|
|
|
0
|
} |
4403
|
0
|
|
|
|
|
0
|
if ($head =~ / \A (?:$q_char)*? [*?] /oxms) { |
|
0
|
|
|
|
|
0
|
|
4404
|
0
|
|
|
|
|
0
|
if (@globdir = _do_glob('d', $head)) { |
4405
|
|
|
|
|
|
|
push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir); |
4406
|
|
|
|
|
|
|
next OUTER; |
4407
|
0
|
0
|
0
|
|
|
0
|
} |
4408
|
0
|
|
|
|
|
0
|
} |
4409
|
|
|
|
|
|
|
if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) { |
4410
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4411
|
|
|
|
|
|
|
} |
4412
|
|
|
|
|
|
|
$expr = $tail; |
4413
|
|
|
|
|
|
|
} |
4414
|
0
|
0
|
|
|
|
0
|
|
4415
|
0
|
0
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4416
|
0
|
|
|
|
|
0
|
if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) { |
4417
|
|
|
|
|
|
|
if ($head eq '.') { |
4418
|
0
|
0
|
0
|
|
|
0
|
$head = ''; |
4419
|
0
|
|
|
|
|
0
|
} |
4420
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4421
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4422
|
0
|
0
|
|
|
|
0
|
} |
4423
|
0
|
0
|
|
|
|
0
|
$head .= $expr; |
4424
|
0
|
|
|
|
|
0
|
if ($cond eq 'd') { |
4425
|
|
|
|
|
|
|
if (Egb18030::d $head) { |
4426
|
|
|
|
|
|
|
push @glob, $head; |
4427
|
|
|
|
|
|
|
} |
4428
|
0
|
0
|
|
|
|
0
|
} |
4429
|
0
|
|
|
|
|
0
|
else { |
4430
|
|
|
|
|
|
|
if (Egb18030::e $head) { |
4431
|
|
|
|
|
|
|
push @glob, $head; |
4432
|
0
|
|
|
|
|
0
|
} |
4433
|
|
|
|
|
|
|
} |
4434
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4435
|
0
|
|
|
|
|
0
|
} |
4436
|
0
|
|
|
|
|
0
|
Egb18030::opendir(*DIR, $head) or next OUTER; |
4437
|
|
|
|
|
|
|
my @leaf = readdir DIR; |
4438
|
0
|
0
|
|
|
|
0
|
closedir DIR; |
4439
|
0
|
|
|
|
|
0
|
|
4440
|
|
|
|
|
|
|
if ($head eq '.') { |
4441
|
0
|
0
|
0
|
|
|
0
|
$head = ''; |
4442
|
0
|
|
|
|
|
0
|
} |
4443
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4444
|
|
|
|
|
|
|
$head .= $pathsep; |
4445
|
0
|
|
|
|
|
0
|
} |
4446
|
0
|
|
|
|
|
0
|
|
4447
|
0
|
|
|
|
|
0
|
my $pattern = ''; |
4448
|
|
|
|
|
|
|
while ($expr =~ / \G ($q_char) /oxgc) { |
4449
|
|
|
|
|
|
|
my $char = $1; |
4450
|
|
|
|
|
|
|
|
4451
|
|
|
|
|
|
|
# 6.9. Matching Shell Globs as Regular Expressions |
4452
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
4453
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4454
|
0
|
0
|
|
|
|
0
|
# (and so on) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4455
|
0
|
|
|
|
|
0
|
|
4456
|
|
|
|
|
|
|
if ($char eq '*') { |
4457
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)*", |
4458
|
0
|
|
|
|
|
0
|
} |
4459
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4460
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)?", # DOS style |
4461
|
|
|
|
|
|
|
# $pattern .= "(?:$your_char)", # UNIX style |
4462
|
0
|
|
|
|
|
0
|
} |
4463
|
|
|
|
|
|
|
elsif ((my $fc = Egb18030::fc($char)) ne $char) { |
4464
|
|
|
|
|
|
|
$pattern .= $fc; |
4465
|
0
|
|
|
|
|
0
|
} |
4466
|
|
|
|
|
|
|
else { |
4467
|
|
|
|
|
|
|
$pattern .= quotemeta $char; |
4468
|
0
|
|
|
0
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4469
|
|
|
|
|
|
|
} |
4470
|
|
|
|
|
|
|
my $matchsub = sub { Egb18030::fc($_[0]) =~ /\A $pattern \z/xms }; |
4471
|
|
|
|
|
|
|
|
4472
|
|
|
|
|
|
|
# if ($@) { |
4473
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4474
|
|
|
|
|
|
|
# next OUTER; |
4475
|
|
|
|
|
|
|
# } |
4476
|
0
|
|
|
|
|
0
|
|
4477
|
0
|
0
|
0
|
|
|
0
|
INNER: |
4478
|
0
|
|
|
|
|
0
|
for my $leaf (@leaf) { |
4479
|
|
|
|
|
|
|
if ($leaf eq '.' or $leaf eq '..') { |
4480
|
0
|
0
|
0
|
|
|
0
|
next INNER; |
4481
|
0
|
|
|
|
|
0
|
} |
4482
|
|
|
|
|
|
|
if ($cond eq 'd' and not Egb18030::d "$head$leaf") { |
4483
|
|
|
|
|
|
|
next INNER; |
4484
|
0
|
0
|
|
|
|
0
|
} |
4485
|
0
|
|
|
|
|
0
|
|
4486
|
0
|
|
|
|
|
0
|
if (&$matchsub($leaf)) { |
4487
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4488
|
|
|
|
|
|
|
next INNER; |
4489
|
|
|
|
|
|
|
} |
4490
|
|
|
|
|
|
|
|
4491
|
|
|
|
|
|
|
# [DOS compatibility special case] |
4492
|
0
|
0
|
0
|
|
|
0
|
# Failed, add a trailing dot and try again, but only... |
|
|
|
0
|
|
|
|
|
4493
|
|
|
|
|
|
|
|
4494
|
|
|
|
|
|
|
if (Egb18030::index($leaf,'.') == -1 and # if name does not have a dot in it *and* |
4495
|
|
|
|
|
|
|
CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and* |
4496
|
0
|
0
|
|
|
|
0
|
Egb18030::index($pattern,'\\.') != -1 # pattern has a dot. |
4497
|
0
|
|
|
|
|
0
|
) { |
4498
|
0
|
|
|
|
|
0
|
if (&$matchsub("$leaf.")) { |
4499
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4500
|
|
|
|
|
|
|
next INNER; |
4501
|
|
|
|
|
|
|
} |
4502
|
0
|
0
|
|
|
|
0
|
} |
4503
|
0
|
|
|
|
|
0
|
} |
4504
|
|
|
|
|
|
|
if (@matched) { |
4505
|
|
|
|
|
|
|
push @glob, @matched; |
4506
|
0
|
0
|
|
|
|
0
|
} |
4507
|
0
|
|
|
|
|
0
|
} |
4508
|
0
|
|
|
|
|
0
|
if ($fix_drive_relative_paths) { |
4509
|
|
|
|
|
|
|
for my $glob (@glob) { |
4510
|
|
|
|
|
|
|
$glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms; |
4511
|
0
|
|
|
|
|
0
|
} |
4512
|
|
|
|
|
|
|
} |
4513
|
|
|
|
|
|
|
return @glob; |
4514
|
|
|
|
|
|
|
} |
4515
|
|
|
|
|
|
|
|
4516
|
|
|
|
|
|
|
# |
4517
|
|
|
|
|
|
|
# GB18030 parse line |
4518
|
|
|
|
|
|
|
# |
4519
|
0
|
|
|
0
|
|
0
|
sub _parse_line { |
4520
|
|
|
|
|
|
|
|
4521
|
0
|
|
|
|
|
0
|
my($line) = @_; |
4522
|
0
|
|
|
|
|
0
|
|
4523
|
0
|
|
|
|
|
0
|
$line .= ' '; |
4524
|
|
|
|
|
|
|
my @piece = (); |
4525
|
|
|
|
|
|
|
while ($line =~ / |
4526
|
|
|
|
|
|
|
" ( (?>(?: [^\x81-\xFE"] |[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] )* ) ) " (?>\s+) | |
4527
|
|
|
|
|
|
|
( (?>(?: [^\x81-\xFE"\s]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] )* ) ) (?>\s+) |
4528
|
0
|
0
|
|
|
|
0
|
/oxmsg |
4529
|
|
|
|
|
|
|
) { |
4530
|
0
|
|
|
|
|
0
|
push @piece, defined($1) ? $1 : $2; |
4531
|
|
|
|
|
|
|
} |
4532
|
|
|
|
|
|
|
return @piece; |
4533
|
|
|
|
|
|
|
} |
4534
|
|
|
|
|
|
|
|
4535
|
|
|
|
|
|
|
# |
4536
|
|
|
|
|
|
|
# GB18030 parse path |
4537
|
|
|
|
|
|
|
# |
4538
|
0
|
|
|
0
|
|
0
|
sub _parse_path { |
4539
|
|
|
|
|
|
|
|
4540
|
0
|
|
|
|
|
0
|
my($path,$pathsep) = @_; |
4541
|
0
|
|
|
|
|
0
|
|
4542
|
0
|
|
|
|
|
0
|
$path .= '/'; |
4543
|
|
|
|
|
|
|
my @subpath = (); |
4544
|
|
|
|
|
|
|
while ($path =~ / |
4545
|
|
|
|
|
|
|
((?: [^\x81-\xFE\/\\]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] )+?) [\/\\] |
4546
|
0
|
|
|
|
|
0
|
/oxmsg |
4547
|
|
|
|
|
|
|
) { |
4548
|
|
|
|
|
|
|
push @subpath, $1; |
4549
|
0
|
|
|
|
|
0
|
} |
4550
|
0
|
|
|
|
|
0
|
|
4551
|
0
|
|
|
|
|
0
|
my $tail = pop @subpath; |
4552
|
|
|
|
|
|
|
my $head = join $pathsep, @subpath; |
4553
|
|
|
|
|
|
|
return $head, $tail; |
4554
|
|
|
|
|
|
|
} |
4555
|
|
|
|
|
|
|
|
4556
|
|
|
|
|
|
|
# |
4557
|
|
|
|
|
|
|
# via File::HomeDir::Windows 1.00 |
4558
|
|
|
|
|
|
|
# |
4559
|
|
|
|
|
|
|
sub my_home_MSWin32 { |
4560
|
|
|
|
|
|
|
|
4561
|
|
|
|
|
|
|
# A lot of unix people and unix-derived tools rely on |
4562
|
0
|
0
|
0
|
0
|
0
|
0
|
# the ability to overload HOME. We will support it too |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
4563
|
0
|
|
|
|
|
0
|
# so that they can replace raw HOME calls with File::HomeDir. |
4564
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { |
4565
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4566
|
|
|
|
|
|
|
} |
4567
|
|
|
|
|
|
|
|
4568
|
0
|
|
|
|
|
0
|
# Do we have a user profile? |
4569
|
|
|
|
|
|
|
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { |
4570
|
|
|
|
|
|
|
return $ENV{'USERPROFILE'}; |
4571
|
|
|
|
|
|
|
} |
4572
|
|
|
|
|
|
|
|
4573
|
0
|
|
|
|
|
0
|
# Some Windows use something like $ENV{'HOME'} |
4574
|
|
|
|
|
|
|
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { |
4575
|
|
|
|
|
|
|
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'}; |
4576
|
0
|
|
|
|
|
0
|
} |
4577
|
|
|
|
|
|
|
|
4578
|
|
|
|
|
|
|
return undef; |
4579
|
|
|
|
|
|
|
} |
4580
|
|
|
|
|
|
|
|
4581
|
|
|
|
|
|
|
# |
4582
|
|
|
|
|
|
|
# via File::HomeDir::Unix 1.00 |
4583
|
0
|
|
|
0
|
0
|
0
|
# |
4584
|
|
|
|
|
|
|
sub my_home { |
4585
|
0
|
0
|
0
|
|
|
0
|
my $home; |
|
|
0
|
0
|
|
|
|
|
4586
|
0
|
|
|
|
|
0
|
|
4587
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { |
4588
|
|
|
|
|
|
|
$home = $ENV{'HOME'}; |
4589
|
|
|
|
|
|
|
} |
4590
|
|
|
|
|
|
|
|
4591
|
|
|
|
|
|
|
# This is from the original code, but I'm guessing |
4592
|
0
|
|
|
|
|
0
|
# it means "login directory" and exists on some Unixes. |
4593
|
|
|
|
|
|
|
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { |
4594
|
|
|
|
|
|
|
$home = $ENV{'LOGDIR'}; |
4595
|
|
|
|
|
|
|
} |
4596
|
|
|
|
|
|
|
|
4597
|
|
|
|
|
|
|
### More-desperate methods |
4598
|
|
|
|
|
|
|
|
4599
|
0
|
|
|
|
|
0
|
# Light desperation on any (Unixish) platform |
4600
|
|
|
|
|
|
|
else { |
4601
|
|
|
|
|
|
|
$home = CORE::eval q{ (getpwuid($<))[7] }; |
4602
|
|
|
|
|
|
|
} |
4603
|
|
|
|
|
|
|
|
4604
|
0
|
0
|
0
|
|
|
0
|
# On Unix in general, a non-existant home means "no home" |
4605
|
0
|
|
|
|
|
0
|
# For example, "nobody"-like users might use /nonexistant |
4606
|
|
|
|
|
|
|
if (defined $home and ! Egb18030::d($home)) { |
4607
|
0
|
|
|
|
|
0
|
$home = undef; |
4608
|
|
|
|
|
|
|
} |
4609
|
|
|
|
|
|
|
return $home; |
4610
|
|
|
|
|
|
|
} |
4611
|
|
|
|
|
|
|
|
4612
|
|
|
|
|
|
|
# |
4613
|
|
|
|
|
|
|
# GB18030 file lstat (with parameter) |
4614
|
|
|
|
|
|
|
# |
4615
|
0
|
0
|
|
0
|
0
|
0
|
sub Egb18030::lstat(*) { |
4616
|
|
|
|
|
|
|
|
4617
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
|
|
0
|
|
|
|
|
|
4618
|
0
|
|
|
|
|
0
|
|
4619
|
|
|
|
|
|
|
if (-e $_) { |
4620
|
|
|
|
|
|
|
return CORE::lstat _; |
4621
|
|
|
|
|
|
|
} |
4622
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4623
|
|
|
|
|
|
|
|
4624
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Egb18030::lstat() |
4625
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
4626
|
0
|
|
|
|
|
0
|
# (and so on) |
4627
|
0
|
0
|
|
|
|
0
|
|
4628
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4629
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4630
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4631
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4632
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4633
|
|
|
|
|
|
|
return @stat; |
4634
|
0
|
|
|
|
|
0
|
} |
4635
|
0
|
|
|
|
|
0
|
else { |
4636
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4637
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4638
|
|
|
|
|
|
|
return $stat; |
4639
|
|
|
|
|
|
|
} |
4640
|
0
|
0
|
|
|
|
0
|
} |
4641
|
|
|
|
|
|
|
} |
4642
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4643
|
|
|
|
|
|
|
} |
4644
|
|
|
|
|
|
|
|
4645
|
|
|
|
|
|
|
# |
4646
|
|
|
|
|
|
|
# GB18030 file lstat (without parameter) |
4647
|
|
|
|
|
|
|
# |
4648
|
0
|
0
|
|
0
|
0
|
0
|
sub Egb18030::lstat_() { |
|
|
0
|
|
|
|
|
|
4649
|
0
|
|
|
|
|
0
|
|
4650
|
|
|
|
|
|
|
if (-e $_) { |
4651
|
|
|
|
|
|
|
return CORE::lstat _; |
4652
|
0
|
|
|
|
|
0
|
} |
4653
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4654
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4655
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4656
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4657
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4658
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4659
|
|
|
|
|
|
|
return @stat; |
4660
|
0
|
|
|
|
|
0
|
} |
4661
|
0
|
|
|
|
|
0
|
else { |
4662
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4663
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4664
|
|
|
|
|
|
|
return $stat; |
4665
|
|
|
|
|
|
|
} |
4666
|
0
|
0
|
|
|
|
0
|
} |
4667
|
|
|
|
|
|
|
} |
4668
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4669
|
|
|
|
|
|
|
} |
4670
|
|
|
|
|
|
|
|
4671
|
|
|
|
|
|
|
# |
4672
|
|
|
|
|
|
|
# GB18030 path opendir |
4673
|
|
|
|
|
|
|
# |
4674
|
0
|
|
|
0
|
0
|
0
|
sub Egb18030::opendir(*$) { |
4675
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4676
|
0
|
|
|
|
|
0
|
my $dh = qualify_to_ref $_[0]; |
4677
|
|
|
|
|
|
|
if (CORE::opendir $dh, $_[1]) { |
4678
|
|
|
|
|
|
|
return 1; |
4679
|
0
|
0
|
|
|
|
0
|
} |
4680
|
0
|
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_[1])) { |
4681
|
|
|
|
|
|
|
if (CORE::opendir $dh, "$_[1]/.") { |
4682
|
|
|
|
|
|
|
return 1; |
4683
|
0
|
|
|
|
|
0
|
} |
4684
|
|
|
|
|
|
|
} |
4685
|
|
|
|
|
|
|
return undef; |
4686
|
|
|
|
|
|
|
} |
4687
|
|
|
|
|
|
|
|
4688
|
|
|
|
|
|
|
# |
4689
|
|
|
|
|
|
|
# GB18030 file stat (with parameter) |
4690
|
|
|
|
|
|
|
# |
4691
|
0
|
50
|
|
384
|
0
|
0
|
sub Egb18030::stat(*) { |
4692
|
|
|
|
|
|
|
|
4693
|
384
|
|
|
|
|
2515
|
local $_ = shift if @_; |
4694
|
384
|
50
|
|
|
|
2399
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4695
|
384
|
|
|
|
|
13105
|
my $fh = qualify_to_ref $_; |
4696
|
|
|
|
|
|
|
if (defined fileno $fh) { |
4697
|
|
|
|
|
|
|
return CORE::stat $fh; |
4698
|
0
|
|
|
|
|
0
|
} |
4699
|
|
|
|
|
|
|
elsif (-e $_) { |
4700
|
|
|
|
|
|
|
return CORE::stat _; |
4701
|
|
|
|
|
|
|
} |
4702
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4703
|
|
|
|
|
|
|
|
4704
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Egb18030::stat() |
4705
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
4706
|
384
|
|
|
|
|
2965
|
# (and so on) |
4707
|
0
|
0
|
|
|
|
0
|
|
4708
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4709
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4710
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4711
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4712
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4713
|
|
|
|
|
|
|
return @stat; |
4714
|
0
|
|
|
|
|
0
|
} |
4715
|
0
|
|
|
|
|
0
|
else { |
4716
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4717
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4718
|
|
|
|
|
|
|
return $stat; |
4719
|
|
|
|
|
|
|
} |
4720
|
0
|
0
|
|
|
|
0
|
} |
4721
|
|
|
|
|
|
|
} |
4722
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4723
|
|
|
|
|
|
|
} |
4724
|
|
|
|
|
|
|
|
4725
|
|
|
|
|
|
|
# |
4726
|
|
|
|
|
|
|
# GB18030 file stat (without parameter) |
4727
|
|
|
|
|
|
|
# |
4728
|
0
|
|
|
0
|
0
|
0
|
sub Egb18030::stat_() { |
4729
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4730
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
4731
|
|
|
|
|
|
|
if (defined fileno $fh) { |
4732
|
|
|
|
|
|
|
return CORE::stat $fh; |
4733
|
0
|
|
|
|
|
0
|
} |
4734
|
|
|
|
|
|
|
elsif (-e $_) { |
4735
|
|
|
|
|
|
|
return CORE::stat _; |
4736
|
0
|
|
|
|
|
0
|
} |
4737
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4738
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4739
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4740
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4741
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4742
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4743
|
|
|
|
|
|
|
return @stat; |
4744
|
0
|
|
|
|
|
0
|
} |
4745
|
0
|
|
|
|
|
0
|
else { |
4746
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4747
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4748
|
|
|
|
|
|
|
return $stat; |
4749
|
|
|
|
|
|
|
} |
4750
|
0
|
0
|
|
|
|
0
|
} |
4751
|
|
|
|
|
|
|
} |
4752
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4753
|
|
|
|
|
|
|
} |
4754
|
|
|
|
|
|
|
|
4755
|
|
|
|
|
|
|
# |
4756
|
|
|
|
|
|
|
# GB18030 path unlink |
4757
|
|
|
|
|
|
|
# |
4758
|
0
|
0
|
|
0
|
0
|
0
|
sub Egb18030::unlink(@) { |
4759
|
|
|
|
|
|
|
|
4760
|
0
|
|
|
|
|
0
|
local @_ = ($_) unless @_; |
4761
|
0
|
|
|
|
|
0
|
|
4762
|
0
|
0
|
|
|
|
0
|
my $unlink = 0; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4763
|
0
|
|
|
|
|
0
|
for (@_) { |
4764
|
|
|
|
|
|
|
if (CORE::unlink) { |
4765
|
|
|
|
|
|
|
$unlink++; |
4766
|
|
|
|
|
|
|
} |
4767
|
|
|
|
|
|
|
elsif (Egb18030::d($_)) { |
4768
|
0
|
|
|
|
|
0
|
} |
4769
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
|
0
|
|
|
|
|
0
|
|
4770
|
0
|
0
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
4771
|
0
|
|
|
|
|
0
|
my $file = join '', map {{'/' => '\\'}->{$_} || $_} @char; |
4772
|
|
|
|
|
|
|
if ($file =~ / \A (?:$q_char)*? [ ] /oxms) { |
4773
|
0
|
|
|
|
|
0
|
$file = qq{"$file"}; |
4774
|
0
|
0
|
|
|
|
0
|
} |
4775
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4776
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
4777
|
|
|
|
|
|
|
close $fh; |
4778
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4779
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000, Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
4780
|
|
|
|
|
|
|
if ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
4781
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
4782
|
|
|
|
|
|
|
} |
4783
|
|
|
|
|
|
|
|
4784
|
0
|
|
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
4785
|
|
|
|
|
|
|
elsif (qx{ver} =~ /\b(?:Windows 2000)\b/oms) { |
4786
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
4787
|
|
|
|
|
|
|
} |
4788
|
|
|
|
|
|
|
|
4789
|
|
|
|
|
|
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
4790
|
0
|
|
|
|
|
0
|
# command.com can not "2>NUL" |
4791
|
0
|
|
|
|
|
0
|
else { |
4792
|
|
|
|
|
|
|
CORE::system 'ATTRIB', '-R', $file; # clears Read-only file attribute |
4793
|
|
|
|
|
|
|
CORE::system 'DEL', $file; |
4794
|
0
|
0
|
|
|
|
0
|
} |
4795
|
0
|
|
|
|
|
0
|
|
4796
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
4797
|
|
|
|
|
|
|
close $fh; |
4798
|
0
|
|
|
|
|
0
|
} |
4799
|
|
|
|
|
|
|
else { |
4800
|
|
|
|
|
|
|
$unlink++; |
4801
|
|
|
|
|
|
|
} |
4802
|
|
|
|
|
|
|
} |
4803
|
0
|
|
|
|
|
0
|
} |
4804
|
|
|
|
|
|
|
} |
4805
|
|
|
|
|
|
|
return $unlink; |
4806
|
|
|
|
|
|
|
} |
4807
|
|
|
|
|
|
|
|
4808
|
|
|
|
|
|
|
# |
4809
|
|
|
|
|
|
|
# GB18030 chdir |
4810
|
|
|
|
|
|
|
# |
4811
|
0
|
0
|
|
0
|
0
|
0
|
sub Egb18030::chdir(;$) { |
4812
|
0
|
|
|
|
|
0
|
|
4813
|
|
|
|
|
|
|
if (@_ == 0) { |
4814
|
|
|
|
|
|
|
return CORE::chdir; |
4815
|
0
|
|
|
|
|
0
|
} |
4816
|
|
|
|
|
|
|
|
4817
|
0
|
0
|
|
|
|
0
|
my($dir) = @_; |
4818
|
0
|
0
|
|
|
|
0
|
|
4819
|
0
|
|
|
|
|
0
|
if (_MSWin32_5Cended_path($dir)) { |
4820
|
|
|
|
|
|
|
if (not Egb18030::d $dir) { |
4821
|
|
|
|
|
|
|
return 0; |
4822
|
0
|
0
|
0
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
4823
|
0
|
|
|
|
|
0
|
|
4824
|
|
|
|
|
|
|
if ($] =~ /^5\.005/oxms) { |
4825
|
|
|
|
|
|
|
return CORE::chdir $dir; |
4826
|
0
|
|
|
|
|
0
|
} |
4827
|
0
|
|
|
|
|
0
|
elsif (($] =~ /^(?:5\.006|5\.008000)/oxms) and ($^O eq 'MSWin32')) { |
4828
|
|
|
|
|
|
|
local $@; |
4829
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
4830
|
|
|
|
|
|
|
CORE::require 'jacode.pl'; |
4831
|
|
|
|
|
|
|
|
4832
|
|
|
|
|
|
|
# P.676 ${^WIDE_SYSTEM_CALLS} |
4833
|
|
|
|
|
|
|
# in Chapter 28: Special Names |
4834
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4835
|
|
|
|
|
|
|
|
4836
|
|
|
|
|
|
|
# P.790 ${^WIDE_SYSTEM_CALLS} |
4837
|
|
|
|
|
|
|
# in Chapter 25: Special Names |
4838
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4839
|
|
|
|
|
|
|
|
4840
|
|
|
|
|
|
|
local ${^WIDE_SYSTEM_CALLS} = 1; |
4841
|
0
|
0
|
|
|
|
0
|
return CORE::chdir jcode::utf8($dir,'sjis'); |
4842
|
0
|
|
|
|
|
0
|
}; |
4843
|
|
|
|
|
|
|
if (not $@) { |
4844
|
|
|
|
|
|
|
return $chdir; |
4845
|
|
|
|
|
|
|
} |
4846
|
|
|
|
|
|
|
} |
4847
|
|
|
|
|
|
|
|
4848
|
|
|
|
|
|
|
# old idea (Win32 module required) |
4849
|
|
|
|
|
|
|
elsif (0) { |
4850
|
|
|
|
|
|
|
local $@; |
4851
|
|
|
|
|
|
|
my $shortdir = ''; |
4852
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
4853
|
|
|
|
|
|
|
use Win32; |
4854
|
|
|
|
|
|
|
$shortdir = Win32::GetShortPathName($dir); |
4855
|
|
|
|
|
|
|
if ($shortdir ne $dir) { |
4856
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
4857
|
|
|
|
|
|
|
} |
4858
|
|
|
|
|
|
|
else { |
4859
|
|
|
|
|
|
|
return 0; |
4860
|
|
|
|
|
|
|
} |
4861
|
|
|
|
|
|
|
}; |
4862
|
|
|
|
|
|
|
if ($@) { |
4863
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
4864
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
4865
|
|
|
|
|
|
|
pop @char; |
4866
|
|
|
|
|
|
|
} |
4867
|
|
|
|
|
|
|
$dir = join '', @char; |
4868
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path), Win32.pm module may help you"; |
4869
|
|
|
|
|
|
|
} |
4870
|
|
|
|
|
|
|
elsif ($shortdir eq $dir) { |
4871
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
4872
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
4873
|
|
|
|
|
|
|
pop @char; |
4874
|
|
|
|
|
|
|
} |
4875
|
|
|
|
|
|
|
$dir = join '', @char; |
4876
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path)"; |
4877
|
|
|
|
|
|
|
} |
4878
|
|
|
|
|
|
|
return $chdir; |
4879
|
|
|
|
|
|
|
} |
4880
|
0
|
|
|
|
|
0
|
|
4881
|
|
|
|
|
|
|
# rejected idea ... |
4882
|
|
|
|
|
|
|
elsif (0) { |
4883
|
|
|
|
|
|
|
|
4884
|
|
|
|
|
|
|
# MSDN SetCurrentDirectory function |
4885
|
|
|
|
|
|
|
# http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365530(v=vs.85).aspx |
4886
|
|
|
|
|
|
|
# |
4887
|
|
|
|
|
|
|
# Data Execution Prevention (DEP) |
4888
|
|
|
|
|
|
|
# http://vlaurie.com/computers2/Articles/dep.htm |
4889
|
|
|
|
|
|
|
# |
4890
|
|
|
|
|
|
|
# Learning x86 assembler with Perl -- Shibuya.pm#11 |
4891
|
|
|
|
|
|
|
# http://developer.cybozu.co.jp/takesako/2009/06/perl-x86-shibuy.html |
4892
|
|
|
|
|
|
|
# |
4893
|
|
|
|
|
|
|
# Introduction to Win32::API programming in Perl |
4894
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559 |
4895
|
|
|
|
|
|
|
# |
4896
|
|
|
|
|
|
|
# DynaLoader - Dynamically load C libraries into Perl code |
4897
|
|
|
|
|
|
|
# http://perldoc.perl.org/DynaLoader.html |
4898
|
|
|
|
|
|
|
# |
4899
|
|
|
|
|
|
|
# Basic knowledge of DynaLoader |
4900
|
|
|
|
|
|
|
# http://blog.64p.org/entry/20090313/1236934042 |
4901
|
|
|
|
|
|
|
|
4902
|
|
|
|
|
|
|
if (($] =~ /^5\.006/oxms) and |
4903
|
|
|
|
|
|
|
($^O eq 'MSWin32') and |
4904
|
|
|
|
|
|
|
($ENV{'PROCESSOR_ARCHITECTURE'} eq 'x86') and |
4905
|
|
|
|
|
|
|
CORE::eval(q{CORE::require 'Dyna'.'Loader'}) |
4906
|
|
|
|
|
|
|
) { |
4907
|
|
|
|
|
|
|
my $x86 = join('', |
4908
|
|
|
|
|
|
|
|
4909
|
|
|
|
|
|
|
# PUSH Iv |
4910
|
|
|
|
|
|
|
"\x68", pack('P', "$dir\\\0"), |
4911
|
|
|
|
|
|
|
|
4912
|
|
|
|
|
|
|
# MOV eAX, Iv |
4913
|
|
|
|
|
|
|
"\xb8", pack('L', |
4914
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_find_symbol'}{'CODE'}->( |
4915
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_load_file'}{'CODE'}->("$ENV{'SystemRoot'}\\system32\\kernel32.dll"), |
4916
|
|
|
|
|
|
|
'SetCurrentDirectoryA' |
4917
|
|
|
|
|
|
|
) |
4918
|
|
|
|
|
|
|
), |
4919
|
|
|
|
|
|
|
|
4920
|
|
|
|
|
|
|
# CALL eAX |
4921
|
|
|
|
|
|
|
"\xff\xd0", |
4922
|
|
|
|
|
|
|
|
4923
|
|
|
|
|
|
|
# RETN |
4924
|
|
|
|
|
|
|
"\xc3", |
4925
|
|
|
|
|
|
|
); |
4926
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_install_xsub'}{'CODE'}->('_SetCurrentDirectoryA', unpack('L', pack 'P', $x86)); |
4927
|
|
|
|
|
|
|
_SetCurrentDirectoryA(); |
4928
|
|
|
|
|
|
|
chomp(my $chdir = qx{chdir}); |
4929
|
|
|
|
|
|
|
if (Egb18030::fc($chdir) eq Egb18030::fc($dir)) { |
4930
|
|
|
|
|
|
|
return 1; |
4931
|
|
|
|
|
|
|
} |
4932
|
|
|
|
|
|
|
else { |
4933
|
|
|
|
|
|
|
return 0; |
4934
|
|
|
|
|
|
|
} |
4935
|
|
|
|
|
|
|
} |
4936
|
|
|
|
|
|
|
} |
4937
|
|
|
|
|
|
|
|
4938
|
|
|
|
|
|
|
# COMMAND.COM's unhelpful tips: |
4939
|
|
|
|
|
|
|
# Displays a list of files and subdirectories in a directory. |
4940
|
|
|
|
|
|
|
# http://www.lagmonster.org/docs/DOS7/z-dir.html |
4941
|
|
|
|
|
|
|
# |
4942
|
|
|
|
|
|
|
# Syntax: |
4943
|
|
|
|
|
|
|
# |
4944
|
|
|
|
|
|
|
# DIR [drive:] [path] [filename] [/Switches] |
4945
|
|
|
|
|
|
|
# |
4946
|
|
|
|
|
|
|
# /Z Long file names are not displayed in the file listing |
4947
|
|
|
|
|
|
|
# |
4948
|
|
|
|
|
|
|
# Limitations |
4949
|
|
|
|
|
|
|
# The undocumented /Z switch (no long names) would appear to |
4950
|
|
|
|
|
|
|
# have been not fully developed and has a couple of problems: |
4951
|
|
|
|
|
|
|
# |
4952
|
|
|
|
|
|
|
# 1. It will only work if: |
4953
|
|
|
|
|
|
|
# There is no path specified (ie. for the current directory in |
4954
|
|
|
|
|
|
|
# the current drive) |
4955
|
|
|
|
|
|
|
# The path is specified as the root directory of any drive |
4956
|
|
|
|
|
|
|
# (eg. C:\, D:\, etc.) |
4957
|
|
|
|
|
|
|
# The path is specified as the current directory of any drive |
4958
|
|
|
|
|
|
|
# by using the drive letter only (eg. C:, D:, etc.) |
4959
|
|
|
|
|
|
|
# The path is specified as the parent directory using the .. |
4960
|
|
|
|
|
|
|
# notation (eg. DIR .. /Z) |
4961
|
|
|
|
|
|
|
# Any other syntax results in a "File Not Found" error message. |
4962
|
|
|
|
|
|
|
# |
4963
|
|
|
|
|
|
|
# 2. The /Z switch is compatable with the /S switch to show |
4964
|
|
|
|
|
|
|
# subdirectories (as long as the above rules are followed) and |
4965
|
|
|
|
|
|
|
# all the files are shown with short names only. The |
4966
|
|
|
|
|
|
|
# subdirectories are also shown with short names only. However, |
4967
|
|
|
|
|
|
|
# the header for each subdirectory after the first level gives |
4968
|
|
|
|
|
|
|
# the subdirectory's long name. |
4969
|
|
|
|
|
|
|
# |
4970
|
|
|
|
|
|
|
# 3. The /Z switch is also compatable with the /B switch to give |
4971
|
|
|
|
|
|
|
# a simple list of files with short names only. When used with |
4972
|
|
|
|
|
|
|
# the /S switch as well, all files are listed with their full |
4973
|
|
|
|
|
|
|
# paths. The file names themselves are all in short form, and |
4974
|
|
|
|
|
|
|
# the path of those files in the current directory are in short |
4975
|
|
|
|
|
|
|
# form, but the paths of any files in subdirectories are in |
4976
|
0
|
|
|
|
|
0
|
# long filename form. |
4977
|
0
|
|
|
|
|
0
|
|
4978
|
0
|
|
|
|
|
0
|
my $shortdir = ''; |
4979
|
0
|
|
|
|
|
0
|
my $i = 0; |
4980
|
0
|
|
|
|
|
0
|
my @subdir = (); |
4981
|
0
|
0
|
0
|
|
|
0
|
while ($dir =~ / \G ($q_char) /oxgc) { |
4982
|
0
|
|
|
|
|
0
|
my $char = $1; |
4983
|
0
|
|
|
|
|
0
|
if (($char eq '\\') or ($char eq '/')) { |
4984
|
0
|
|
|
|
|
0
|
$i++; |
4985
|
|
|
|
|
|
|
$subdir[$i] = $char; |
4986
|
|
|
|
|
|
|
$i++; |
4987
|
0
|
|
|
|
|
0
|
} |
4988
|
|
|
|
|
|
|
else { |
4989
|
|
|
|
|
|
|
$subdir[$i] .= $char; |
4990
|
0
|
0
|
0
|
|
|
0
|
} |
4991
|
0
|
|
|
|
|
0
|
} |
4992
|
|
|
|
|
|
|
if (($subdir[-1] eq '\\') or ($subdir[-1] eq '/')) { |
4993
|
|
|
|
|
|
|
pop @subdir; |
4994
|
|
|
|
|
|
|
} |
4995
|
|
|
|
|
|
|
|
4996
|
|
|
|
|
|
|
# P.504 PERL5SHELL (Microsoft ports only) |
4997
|
|
|
|
|
|
|
# in Chapter 19: The Command-Line Interface |
4998
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4999
|
|
|
|
|
|
|
|
5000
|
|
|
|
|
|
|
# P.597 PERL5SHELL (Microsoft ports only) |
5001
|
|
|
|
|
|
|
# in Chapter 17: The Command-Line Interface |
5002
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5003
|
|
|
|
|
|
|
|
5004
|
0
|
0
|
0
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
|
|
0
|
|
|
|
|
|
5005
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000 |
5006
|
0
|
|
|
|
|
0
|
if (qx{ver} =~ /\b(?:Windows NT|Windows 2000)\b/oms) { |
|
0
|
|
|
|
|
0
|
|
5007
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5008
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5009
|
|
|
|
|
|
|
if (Egb18030::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Egb18030::fc($subdir[-1])) { |
5010
|
0
|
|
|
|
|
0
|
|
5011
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5012
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 39, 8+1+3; |
5013
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5014
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5015
|
|
|
|
|
|
|
last; |
5016
|
|
|
|
|
|
|
} |
5017
|
|
|
|
|
|
|
} |
5018
|
|
|
|
|
|
|
} |
5019
|
|
|
|
|
|
|
|
5020
|
|
|
|
|
|
|
# an idea (not so portable, only Windows 2000 or later) |
5021
|
|
|
|
|
|
|
elsif (0) { |
5022
|
|
|
|
|
|
|
chomp($shortdir = qx{for %I in ("$dir") do \@echo %~sI 2>NUL}); |
5023
|
|
|
|
|
|
|
} |
5024
|
|
|
|
|
|
|
|
5025
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
5026
|
0
|
|
|
|
|
0
|
elsif ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
|
0
|
|
|
|
|
0
|
|
5027
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5028
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5029
|
|
|
|
|
|
|
if (Egb18030::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Egb18030::fc($subdir[-1])) { |
5030
|
0
|
|
|
|
|
0
|
|
5031
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5032
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 36, 8+1+3; |
5033
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5034
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5035
|
|
|
|
|
|
|
last; |
5036
|
|
|
|
|
|
|
} |
5037
|
|
|
|
|
|
|
} |
5038
|
|
|
|
|
|
|
} |
5039
|
|
|
|
|
|
|
|
5040
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
5041
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
5042
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad "$dir*"}); |
5043
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5044
|
|
|
|
|
|
|
if (Egb18030::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Egb18030::fc($subdir[-1])) { |
5045
|
0
|
|
|
|
|
0
|
|
5046
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----v |
5047
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 0, 8+1+3; |
5048
|
0
|
|
|
|
|
0
|
CORE::substr($shortleafdir,8,1) = '.'; |
5049
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ \. [ ]+ \z//oxms; |
5050
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5051
|
|
|
|
|
|
|
last; |
5052
|
|
|
|
|
|
|
} |
5053
|
|
|
|
|
|
|
} |
5054
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5055
|
0
|
|
|
|
|
0
|
|
5056
|
|
|
|
|
|
|
if ($shortdir eq '') { |
5057
|
|
|
|
|
|
|
return 0; |
5058
|
0
|
|
|
|
|
0
|
} |
5059
|
|
|
|
|
|
|
elsif (Egb18030::fc($shortdir) eq Egb18030::fc($dir)) { |
5060
|
0
|
|
|
|
|
0
|
return 0; |
5061
|
|
|
|
|
|
|
} |
5062
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
5063
|
0
|
|
|
|
|
0
|
} |
5064
|
|
|
|
|
|
|
else { |
5065
|
|
|
|
|
|
|
return CORE::chdir $dir; |
5066
|
|
|
|
|
|
|
} |
5067
|
|
|
|
|
|
|
} |
5068
|
|
|
|
|
|
|
|
5069
|
|
|
|
|
|
|
# |
5070
|
|
|
|
|
|
|
# GB18030 chr(0x5C) ended path on MSWin32 |
5071
|
|
|
|
|
|
|
# |
5072
|
0
|
50
|
33
|
768
|
|
0
|
sub _MSWin32_5Cended_path { |
5073
|
768
|
50
|
|
|
|
5125
|
|
5074
|
768
|
|
|
|
|
4287
|
if ((@_ >= 1) and ($_[0] ne '')) { |
5075
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
5076
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5077
|
|
|
|
|
|
|
if ($char[-1] =~ / \x5C \z/oxms) { |
5078
|
|
|
|
|
|
|
return 1; |
5079
|
|
|
|
|
|
|
} |
5080
|
0
|
|
|
|
|
0
|
} |
5081
|
|
|
|
|
|
|
} |
5082
|
|
|
|
|
|
|
return undef; |
5083
|
|
|
|
|
|
|
} |
5084
|
|
|
|
|
|
|
|
5085
|
|
|
|
|
|
|
# |
5086
|
|
|
|
|
|
|
# do GB18030 file |
5087
|
|
|
|
|
|
|
# |
5088
|
768
|
|
|
0
|
0
|
1969
|
sub Egb18030::do($) { |
5089
|
|
|
|
|
|
|
|
5090
|
0
|
|
|
|
|
0
|
my($filename) = @_; |
5091
|
|
|
|
|
|
|
|
5092
|
|
|
|
|
|
|
my $realfilename; |
5093
|
|
|
|
|
|
|
my $result; |
5094
|
0
|
|
|
|
|
0
|
ITER_DO: |
|
0
|
|
|
|
|
0
|
|
5095
|
0
|
0
|
|
|
|
0
|
{ |
5096
|
0
|
|
|
|
|
0
|
for my $prefix (@INC) { |
5097
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5098
|
|
|
|
|
|
|
$realfilename = "$prefix$filename"; |
5099
|
0
|
|
|
|
|
0
|
} |
5100
|
|
|
|
|
|
|
else { |
5101
|
|
|
|
|
|
|
$realfilename = "$prefix/$filename"; |
5102
|
0
|
0
|
|
|
|
0
|
} |
5103
|
|
|
|
|
|
|
|
5104
|
0
|
|
|
|
|
0
|
if (Egb18030::f($realfilename)) { |
5105
|
|
|
|
|
|
|
|
5106
|
0
|
0
|
|
|
|
0
|
my $script = ''; |
5107
|
0
|
|
|
|
|
0
|
|
5108
|
0
|
|
|
|
|
0
|
if (Egb18030::e("$realfilename.e")) { |
5109
|
0
|
|
|
|
|
0
|
my $e_mtime = (Egb18030::stat("$realfilename.e"))[9]; |
5110
|
0
|
0
|
0
|
|
|
0
|
my $mtime = (Egb18030::stat($realfilename))[9]; |
5111
|
0
|
|
|
|
|
0
|
my $module_mtime = (Egb18030::stat(__FILE__))[9]; |
5112
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5113
|
|
|
|
|
|
|
Egb18030::unlink "$realfilename.e"; |
5114
|
|
|
|
|
|
|
} |
5115
|
0
|
0
|
|
|
|
0
|
} |
5116
|
0
|
|
|
|
|
0
|
|
5117
|
0
|
0
|
|
|
|
0
|
if (Egb18030::e("$realfilename.e")) { |
5118
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5119
|
0
|
|
|
|
|
0
|
if (_open_r($fh, "$realfilename.e")) { |
5120
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5121
|
|
|
|
|
|
|
CORE::eval q{ |
5122
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5123
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5124
|
|
|
|
|
|
|
}; |
5125
|
|
|
|
|
|
|
} |
5126
|
|
|
|
|
|
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5127
|
|
|
|
|
|
|
|
5128
|
|
|
|
|
|
|
# P.419 File Locking |
5129
|
|
|
|
|
|
|
# in Chapter 16: Interprocess Communication |
5130
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5131
|
|
|
|
|
|
|
|
5132
|
|
|
|
|
|
|
# P.524 File Locking |
5133
|
|
|
|
|
|
|
# in Chapter 15: Interprocess Communication |
5134
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5135
|
|
|
|
|
|
|
|
5136
|
0
|
|
|
|
|
0
|
# (and so on) |
5137
|
0
|
0
|
|
|
|
0
|
|
5138
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5139
|
|
|
|
|
|
|
if ($@) { |
5140
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5141
|
|
|
|
|
|
|
} |
5142
|
0
|
|
|
|
|
0
|
} |
5143
|
|
|
|
|
|
|
else { |
5144
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5145
|
0
|
|
|
|
|
0
|
} |
5146
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5147
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5148
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5149
|
|
|
|
|
|
|
CORE::eval q{ |
5150
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5151
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5152
|
0
|
|
|
|
|
0
|
}; |
5153
|
|
|
|
|
|
|
} |
5154
|
|
|
|
|
|
|
close $fh; |
5155
|
|
|
|
|
|
|
} |
5156
|
0
|
|
|
|
|
0
|
} |
5157
|
0
|
0
|
|
|
|
0
|
else { |
5158
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5159
|
0
|
|
|
|
|
0
|
if (_open_r($fh, $realfilename)) { |
5160
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5161
|
|
|
|
|
|
|
CORE::eval q{ |
5162
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5163
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5164
|
|
|
|
|
|
|
}; |
5165
|
0
|
|
|
|
|
0
|
} |
5166
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5167
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5168
|
|
|
|
|
|
|
if ($@) { |
5169
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5170
|
|
|
|
|
|
|
} |
5171
|
0
|
|
|
|
|
0
|
} |
5172
|
|
|
|
|
|
|
else { |
5173
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5174
|
0
|
|
|
|
|
0
|
} |
5175
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5176
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5177
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5178
|
|
|
|
|
|
|
CORE::eval q{ |
5179
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5180
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock($realfilename); |
5181
|
0
|
|
|
|
|
0
|
}; |
5182
|
|
|
|
|
|
|
} |
5183
|
|
|
|
|
|
|
close $fh; |
5184
|
0
|
0
|
|
|
|
0
|
} |
5185
|
0
|
|
|
|
|
0
|
|
5186
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
5187
|
0
|
|
|
|
|
0
|
CORE::require GB18030; |
5188
|
0
|
0
|
|
|
|
0
|
$script = GB18030::escape_script($script); |
5189
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5190
|
0
|
|
|
|
|
0
|
open($fh, ">$realfilename.e") or die __FILE__, ": Can't write open file: $realfilename.e\n"; |
5191
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5192
|
|
|
|
|
|
|
CORE::eval q{ |
5193
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5194
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5195
|
|
|
|
|
|
|
}; |
5196
|
0
|
|
|
|
|
0
|
} |
5197
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5198
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5199
|
|
|
|
|
|
|
if ($@) { |
5200
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5201
|
|
|
|
|
|
|
} |
5202
|
0
|
|
|
|
|
0
|
} |
5203
|
|
|
|
|
|
|
else { |
5204
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5205
|
0
|
0
|
|
|
|
0
|
} |
5206
|
0
|
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
|
0
|
|
|
|
|
0
|
|
5207
|
0
|
0
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5208
|
0
|
|
|
|
|
0
|
print {$fh} $script; |
5209
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5210
|
|
|
|
|
|
|
CORE::eval q{ |
5211
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5212
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5213
|
0
|
|
|
|
|
0
|
}; |
5214
|
|
|
|
|
|
|
} |
5215
|
|
|
|
|
|
|
close $fh; |
5216
|
|
|
|
|
|
|
} |
5217
|
|
|
|
|
|
|
} |
5218
|
389
|
|
|
389
|
|
13471
|
|
|
389
|
|
|
|
|
2994
|
|
|
389
|
|
|
|
|
357439
|
|
|
0
|
|
|
|
|
0
|
|
5219
|
0
|
|
|
|
|
0
|
{ |
5220
|
|
|
|
|
|
|
no strict; |
5221
|
0
|
|
|
|
|
0
|
$result = scalar CORE::eval $script; |
5222
|
|
|
|
|
|
|
} |
5223
|
|
|
|
|
|
|
last ITER_DO; |
5224
|
|
|
|
|
|
|
} |
5225
|
|
|
|
|
|
|
} |
5226
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5227
|
0
|
|
|
|
|
0
|
|
5228
|
0
|
|
|
|
|
0
|
if ($@) { |
5229
|
|
|
|
|
|
|
$INC{$filename} = undef; |
5230
|
|
|
|
|
|
|
return undef; |
5231
|
0
|
|
|
|
|
0
|
} |
5232
|
|
|
|
|
|
|
elsif (not $result) { |
5233
|
|
|
|
|
|
|
return undef; |
5234
|
0
|
|
|
|
|
0
|
} |
5235
|
0
|
|
|
|
|
0
|
else { |
5236
|
|
|
|
|
|
|
$INC{$filename} = $realfilename; |
5237
|
|
|
|
|
|
|
return $result; |
5238
|
|
|
|
|
|
|
} |
5239
|
|
|
|
|
|
|
} |
5240
|
|
|
|
|
|
|
|
5241
|
|
|
|
|
|
|
# |
5242
|
|
|
|
|
|
|
# require GB18030 file |
5243
|
|
|
|
|
|
|
# |
5244
|
|
|
|
|
|
|
|
5245
|
|
|
|
|
|
|
# require |
5246
|
|
|
|
|
|
|
# in Chapter 3: Functions |
5247
|
|
|
|
|
|
|
# of ISBN 1-56592-149-6 Programming Perl, Second Edition. |
5248
|
|
|
|
|
|
|
# |
5249
|
|
|
|
|
|
|
# sub require { |
5250
|
|
|
|
|
|
|
# my($filename) = @_; |
5251
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5252
|
|
|
|
|
|
|
# my($realfilename, $result); |
5253
|
|
|
|
|
|
|
# ITER: { |
5254
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5255
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5256
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5257
|
|
|
|
|
|
|
# $result = CORE::eval `cat $realfilename`; |
5258
|
|
|
|
|
|
|
# last ITER; |
5259
|
|
|
|
|
|
|
# } |
5260
|
|
|
|
|
|
|
# } |
5261
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5262
|
|
|
|
|
|
|
# } |
5263
|
|
|
|
|
|
|
# die $@ if $@; |
5264
|
|
|
|
|
|
|
# die "$filename did not return true value" unless $result; |
5265
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5266
|
|
|
|
|
|
|
# return $result; |
5267
|
|
|
|
|
|
|
# } |
5268
|
|
|
|
|
|
|
|
5269
|
|
|
|
|
|
|
# require |
5270
|
|
|
|
|
|
|
# in Chapter 9: perlfunc: Perl builtin functions |
5271
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5272
|
|
|
|
|
|
|
# |
5273
|
|
|
|
|
|
|
# sub require { |
5274
|
|
|
|
|
|
|
# my($filename) = @_; |
5275
|
|
|
|
|
|
|
# if (exists $INC{$filename}) { |
5276
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5277
|
|
|
|
|
|
|
# die "Compilation failed in require"; |
5278
|
|
|
|
|
|
|
# } |
5279
|
|
|
|
|
|
|
# my($realfilename, $result); |
5280
|
|
|
|
|
|
|
# ITER: { |
5281
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5282
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5283
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5284
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5285
|
|
|
|
|
|
|
# $result = do $realfilename; |
5286
|
|
|
|
|
|
|
# last ITER; |
5287
|
|
|
|
|
|
|
# } |
5288
|
|
|
|
|
|
|
# } |
5289
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5290
|
|
|
|
|
|
|
# } |
5291
|
|
|
|
|
|
|
# if ($@) { |
5292
|
|
|
|
|
|
|
# $INC{$filename} = undef; |
5293
|
|
|
|
|
|
|
# die $@; |
5294
|
|
|
|
|
|
|
# } |
5295
|
|
|
|
|
|
|
# elsif (!$result) { |
5296
|
|
|
|
|
|
|
# delete $INC{$filename}; |
5297
|
|
|
|
|
|
|
# die "$filename did not return true value"; |
5298
|
|
|
|
|
|
|
# } |
5299
|
|
|
|
|
|
|
# else { |
5300
|
|
|
|
|
|
|
# return $result; |
5301
|
|
|
|
|
|
|
# } |
5302
|
|
|
|
|
|
|
# } |
5303
|
|
|
|
|
|
|
|
5304
|
0
|
0
|
|
0
|
0
|
0
|
sub Egb18030::require(;$) { |
5305
|
|
|
|
|
|
|
|
5306
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5307
|
0
|
0
|
|
|
|
0
|
|
5308
|
0
|
|
|
|
|
0
|
if (exists $INC{$_}) { |
5309
|
|
|
|
|
|
|
return 1 if $INC{$_}; |
5310
|
|
|
|
|
|
|
croak "Compilation failed in require: $_"; |
5311
|
|
|
|
|
|
|
} |
5312
|
|
|
|
|
|
|
|
5313
|
|
|
|
|
|
|
# jcode.pl |
5314
|
|
|
|
|
|
|
# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/ |
5315
|
|
|
|
|
|
|
|
5316
|
|
|
|
|
|
|
# jacode.pl |
5317
|
0
|
0
|
|
|
|
0
|
# http://search.cpan.org/dist/jacode/ |
5318
|
0
|
|
|
|
|
0
|
|
5319
|
|
|
|
|
|
|
if (/ \b (?: jcode\.pl | jacode(?>[0-9]*)\.pl ) \z /oxms) { |
5320
|
|
|
|
|
|
|
return CORE::require($_); |
5321
|
0
|
|
|
|
|
0
|
} |
5322
|
|
|
|
|
|
|
|
5323
|
|
|
|
|
|
|
my $realfilename; |
5324
|
|
|
|
|
|
|
my $result; |
5325
|
0
|
|
|
|
|
0
|
ITER_REQUIRE: |
|
0
|
|
|
|
|
0
|
|
5326
|
0
|
0
|
|
|
|
0
|
{ |
5327
|
0
|
|
|
|
|
0
|
for my $prefix (@INC) { |
5328
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5329
|
|
|
|
|
|
|
$realfilename = "$prefix$_"; |
5330
|
0
|
|
|
|
|
0
|
} |
5331
|
|
|
|
|
|
|
else { |
5332
|
|
|
|
|
|
|
$realfilename = "$prefix/$_"; |
5333
|
0
|
0
|
|
|
|
0
|
} |
5334
|
0
|
|
|
|
|
0
|
|
5335
|
|
|
|
|
|
|
if (Egb18030::f($realfilename)) { |
5336
|
0
|
|
|
|
|
0
|
$INC{$_} = $realfilename; |
5337
|
|
|
|
|
|
|
|
5338
|
0
|
0
|
|
|
|
0
|
my $script = ''; |
5339
|
0
|
|
|
|
|
0
|
|
5340
|
0
|
|
|
|
|
0
|
if (Egb18030::e("$realfilename.e")) { |
5341
|
0
|
|
|
|
|
0
|
my $e_mtime = (Egb18030::stat("$realfilename.e"))[9]; |
5342
|
0
|
0
|
0
|
|
|
0
|
my $mtime = (Egb18030::stat($realfilename))[9]; |
5343
|
0
|
|
|
|
|
0
|
my $module_mtime = (Egb18030::stat(__FILE__))[9]; |
5344
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5345
|
|
|
|
|
|
|
Egb18030::unlink "$realfilename.e"; |
5346
|
|
|
|
|
|
|
} |
5347
|
0
|
0
|
|
|
|
0
|
} |
5348
|
0
|
|
|
|
|
0
|
|
5349
|
0
|
0
|
|
|
|
0
|
if (Egb18030::e("$realfilename.e")) { |
5350
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5351
|
0
|
|
|
|
|
0
|
_open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e"; |
5352
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5353
|
|
|
|
|
|
|
CORE::eval q{ |
5354
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5355
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5356
|
|
|
|
|
|
|
}; |
5357
|
0
|
|
|
|
|
0
|
} |
5358
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5359
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5360
|
|
|
|
|
|
|
if ($@) { |
5361
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5362
|
|
|
|
|
|
|
} |
5363
|
0
|
|
|
|
|
0
|
} |
5364
|
|
|
|
|
|
|
else { |
5365
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5366
|
0
|
|
|
|
|
0
|
} |
5367
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5368
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5369
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5370
|
|
|
|
|
|
|
CORE::eval q{ |
5371
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5372
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5373
|
0
|
0
|
|
|
|
0
|
}; |
5374
|
|
|
|
|
|
|
} |
5375
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename"; |
5376
|
0
|
|
|
|
|
0
|
} |
5377
|
0
|
0
|
|
|
|
0
|
else { |
5378
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5379
|
0
|
|
|
|
|
0
|
_open_r($fh, $realfilename) or croak "Can't open file: $realfilename"; |
5380
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5381
|
|
|
|
|
|
|
CORE::eval q{ |
5382
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5383
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5384
|
|
|
|
|
|
|
}; |
5385
|
0
|
|
|
|
|
0
|
} |
5386
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5387
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5388
|
|
|
|
|
|
|
if ($@) { |
5389
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5390
|
|
|
|
|
|
|
} |
5391
|
0
|
|
|
|
|
0
|
} |
5392
|
|
|
|
|
|
|
else { |
5393
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5394
|
0
|
|
|
|
|
0
|
} |
5395
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5396
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5397
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5398
|
|
|
|
|
|
|
CORE::eval q{ |
5399
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5400
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock($realfilename); |
5401
|
0
|
0
|
|
|
|
0
|
}; |
5402
|
|
|
|
|
|
|
} |
5403
|
0
|
0
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename"; |
5404
|
0
|
|
|
|
|
0
|
|
5405
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
5406
|
0
|
|
|
|
|
0
|
CORE::require GB18030; |
5407
|
0
|
0
|
|
|
|
0
|
$script = GB18030::escape_script($script); |
5408
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5409
|
0
|
|
|
|
|
0
|
open($fh, ">$realfilename.e") or croak "Can't write open file: $realfilename.e"; |
5410
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5411
|
|
|
|
|
|
|
CORE::eval q{ |
5412
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5413
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5414
|
|
|
|
|
|
|
}; |
5415
|
0
|
|
|
|
|
0
|
} |
5416
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5417
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5418
|
|
|
|
|
|
|
if ($@) { |
5419
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5420
|
|
|
|
|
|
|
} |
5421
|
0
|
|
|
|
|
0
|
} |
5422
|
|
|
|
|
|
|
else { |
5423
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5424
|
0
|
0
|
|
|
|
0
|
} |
5425
|
0
|
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
|
0
|
|
|
|
|
0
|
|
5426
|
0
|
0
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5427
|
0
|
|
|
|
|
0
|
print {$fh} $script; |
5428
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5429
|
|
|
|
|
|
|
CORE::eval q{ |
5430
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5431
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5432
|
0
|
0
|
|
|
|
0
|
}; |
5433
|
|
|
|
|
|
|
} |
5434
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename"; |
5435
|
|
|
|
|
|
|
} |
5436
|
|
|
|
|
|
|
} |
5437
|
389
|
|
|
389
|
|
4544
|
|
|
389
|
|
|
|
|
2297
|
|
|
389
|
|
|
|
|
446228
|
|
|
0
|
|
|
|
|
0
|
|
5438
|
0
|
|
|
|
|
0
|
{ |
5439
|
|
|
|
|
|
|
no strict; |
5440
|
0
|
|
|
|
|
0
|
$result = scalar CORE::eval $script; |
5441
|
|
|
|
|
|
|
} |
5442
|
|
|
|
|
|
|
last ITER_REQUIRE; |
5443
|
0
|
|
|
|
|
0
|
} |
5444
|
|
|
|
|
|
|
} |
5445
|
|
|
|
|
|
|
croak "Can't find $_ in \@INC"; |
5446
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5447
|
0
|
|
|
|
|
0
|
|
5448
|
0
|
|
|
|
|
0
|
if ($@) { |
5449
|
|
|
|
|
|
|
$INC{$_} = undef; |
5450
|
|
|
|
|
|
|
croak $@; |
5451
|
0
|
|
|
|
|
0
|
} |
5452
|
0
|
|
|
|
|
0
|
elsif (not $result) { |
5453
|
|
|
|
|
|
|
delete $INC{$_}; |
5454
|
|
|
|
|
|
|
croak "$_ did not return true value"; |
5455
|
0
|
|
|
|
|
0
|
} |
5456
|
|
|
|
|
|
|
else { |
5457
|
|
|
|
|
|
|
return $result; |
5458
|
|
|
|
|
|
|
} |
5459
|
|
|
|
|
|
|
} |
5460
|
|
|
|
|
|
|
|
5461
|
|
|
|
|
|
|
# |
5462
|
|
|
|
|
|
|
# GB18030 telldir avoid warning |
5463
|
|
|
|
|
|
|
# |
5464
|
0
|
|
|
768
|
0
|
0
|
sub Egb18030::telldir(*) { |
5465
|
|
|
|
|
|
|
|
5466
|
768
|
|
|
|
|
2442
|
local $^W = 0; |
5467
|
|
|
|
|
|
|
|
5468
|
|
|
|
|
|
|
return CORE::telldir $_[0]; |
5469
|
|
|
|
|
|
|
} |
5470
|
|
|
|
|
|
|
|
5471
|
|
|
|
|
|
|
# |
5472
|
|
|
|
|
|
|
# ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched |
5473
|
768
|
0
|
|
0
|
0
|
30011
|
# |
5474
|
0
|
0
|
0
|
|
|
0
|
sub Egb18030::PREMATCH { |
5475
|
0
|
|
|
|
|
0
|
if (defined($&)) { |
5476
|
|
|
|
|
|
|
if (defined($1) and (CORE::substr($&,-CORE::length($1),CORE::length($1)) eq $1)) { |
5477
|
|
|
|
|
|
|
return CORE::substr($&,0,CORE::length($&)-CORE::length($1)); |
5478
|
0
|
|
|
|
|
0
|
} |
5479
|
|
|
|
|
|
|
else { |
5480
|
|
|
|
|
|
|
croak 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp'; |
5481
|
|
|
|
|
|
|
} |
5482
|
0
|
|
|
|
|
0
|
} |
5483
|
|
|
|
|
|
|
else { |
5484
|
0
|
|
|
|
|
0
|
return ''; |
5485
|
|
|
|
|
|
|
} |
5486
|
|
|
|
|
|
|
return $`; |
5487
|
|
|
|
|
|
|
} |
5488
|
|
|
|
|
|
|
|
5489
|
|
|
|
|
|
|
# |
5490
|
|
|
|
|
|
|
# ${^MATCH}, $MATCH, $& the string that matched |
5491
|
0
|
0
|
|
0
|
0
|
0
|
# |
5492
|
0
|
0
|
|
|
|
0
|
sub Egb18030::MATCH { |
5493
|
0
|
|
|
|
|
0
|
if (defined($&)) { |
5494
|
|
|
|
|
|
|
if (defined($1)) { |
5495
|
|
|
|
|
|
|
return $1; |
5496
|
0
|
|
|
|
|
0
|
} |
5497
|
|
|
|
|
|
|
else { |
5498
|
|
|
|
|
|
|
croak 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp'; |
5499
|
|
|
|
|
|
|
} |
5500
|
0
|
|
|
|
|
0
|
} |
5501
|
|
|
|
|
|
|
else { |
5502
|
0
|
|
|
|
|
0
|
return ''; |
5503
|
|
|
|
|
|
|
} |
5504
|
|
|
|
|
|
|
return $&; |
5505
|
|
|
|
|
|
|
} |
5506
|
|
|
|
|
|
|
|
5507
|
|
|
|
|
|
|
# |
5508
|
|
|
|
|
|
|
# ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched |
5509
|
0
|
|
|
0
|
0
|
0
|
# |
5510
|
|
|
|
|
|
|
sub Egb18030::POSTMATCH { |
5511
|
|
|
|
|
|
|
return $'; |
5512
|
|
|
|
|
|
|
} |
5513
|
|
|
|
|
|
|
|
5514
|
|
|
|
|
|
|
# |
5515
|
|
|
|
|
|
|
# GB18030 character to order (with parameter) |
5516
|
|
|
|
|
|
|
# |
5517
|
0
|
0
|
|
0
|
1
|
0
|
sub GB18030::ord(;$) { |
5518
|
|
|
|
|
|
|
|
5519
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5520
|
0
|
|
|
|
|
0
|
|
5521
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5522
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5523
|
0
|
|
|
|
|
0
|
my $ord = 0; |
5524
|
|
|
|
|
|
|
while (my $o = shift @ord) { |
5525
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
5526
|
|
|
|
|
|
|
} |
5527
|
|
|
|
|
|
|
return $ord; |
5528
|
0
|
|
|
|
|
0
|
} |
5529
|
|
|
|
|
|
|
else { |
5530
|
|
|
|
|
|
|
return CORE::ord $_; |
5531
|
|
|
|
|
|
|
} |
5532
|
|
|
|
|
|
|
} |
5533
|
|
|
|
|
|
|
|
5534
|
|
|
|
|
|
|
# |
5535
|
|
|
|
|
|
|
# GB18030 character to order (without parameter) |
5536
|
|
|
|
|
|
|
# |
5537
|
0
|
0
|
|
0
|
0
|
0
|
sub GB18030::ord_() { |
5538
|
0
|
|
|
|
|
0
|
|
5539
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5540
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5541
|
0
|
|
|
|
|
0
|
my $ord = 0; |
5542
|
|
|
|
|
|
|
while (my $o = shift @ord) { |
5543
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
5544
|
|
|
|
|
|
|
} |
5545
|
|
|
|
|
|
|
return $ord; |
5546
|
0
|
|
|
|
|
0
|
} |
5547
|
|
|
|
|
|
|
else { |
5548
|
|
|
|
|
|
|
return CORE::ord $_; |
5549
|
|
|
|
|
|
|
} |
5550
|
|
|
|
|
|
|
} |
5551
|
|
|
|
|
|
|
|
5552
|
|
|
|
|
|
|
# |
5553
|
|
|
|
|
|
|
# GB18030 reverse |
5554
|
|
|
|
|
|
|
# |
5555
|
0
|
0
|
|
0
|
0
|
0
|
sub GB18030::reverse(@) { |
5556
|
0
|
|
|
|
|
0
|
|
5557
|
|
|
|
|
|
|
if (wantarray) { |
5558
|
|
|
|
|
|
|
return CORE::reverse @_; |
5559
|
|
|
|
|
|
|
} |
5560
|
|
|
|
|
|
|
else { |
5561
|
|
|
|
|
|
|
|
5562
|
|
|
|
|
|
|
# One of us once cornered Larry in an elevator and asked him what |
5563
|
|
|
|
|
|
|
# problem he was solving with this, but he looked as far off into |
5564
|
|
|
|
|
|
|
# the distance as he could in an elevator and said, "It seemed like |
5565
|
0
|
|
|
|
|
0
|
# a good idea at the time." |
5566
|
|
|
|
|
|
|
|
5567
|
|
|
|
|
|
|
return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg); |
5568
|
|
|
|
|
|
|
} |
5569
|
|
|
|
|
|
|
} |
5570
|
|
|
|
|
|
|
|
5571
|
|
|
|
|
|
|
# |
5572
|
|
|
|
|
|
|
# GB18030 getc (with parameter, without parameter) |
5573
|
|
|
|
|
|
|
# |
5574
|
0
|
|
|
0
|
0
|
0
|
sub GB18030::getc(;*@) { |
5575
|
0
|
0
|
|
|
|
0
|
|
5576
|
0
|
0
|
0
|
|
|
0
|
my($package) = caller; |
5577
|
|
|
|
|
|
|
my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN; |
5578
|
0
|
|
|
|
|
0
|
croak 'Too many arguments for GB18030::getc' if @_ and not wantarray; |
|
0
|
|
|
|
|
0
|
|
5579
|
0
|
|
|
|
|
0
|
|
5580
|
0
|
|
|
|
|
0
|
my @length = sort { $a <=> $b } keys %range_tr; |
5581
|
0
|
|
|
|
|
0
|
my $getc = ''; |
5582
|
0
|
0
|
|
|
|
0
|
for my $length ($length[0] .. $length[-1]) { |
5583
|
0
|
0
|
|
|
|
0
|
$getc .= CORE::getc($fh); |
5584
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{CORE::length($getc)}) { |
5585
|
|
|
|
|
|
|
if ($getc =~ /\A ${Egb18030::dot_s} \z/oxms) { |
5586
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5587
|
|
|
|
|
|
|
} |
5588
|
0
|
0
|
|
|
|
0
|
} |
5589
|
|
|
|
|
|
|
} |
5590
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5591
|
|
|
|
|
|
|
} |
5592
|
|
|
|
|
|
|
|
5593
|
|
|
|
|
|
|
# |
5594
|
|
|
|
|
|
|
# GB18030 length by character |
5595
|
|
|
|
|
|
|
# |
5596
|
0
|
0
|
|
0
|
1
|
0
|
sub GB18030::length(;$) { |
5597
|
|
|
|
|
|
|
|
5598
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5599
|
0
|
|
|
|
|
0
|
|
5600
|
|
|
|
|
|
|
local @_ = /\G ($q_char) /oxmsg; |
5601
|
|
|
|
|
|
|
return scalar @_; |
5602
|
|
|
|
|
|
|
} |
5603
|
|
|
|
|
|
|
|
5604
|
|
|
|
|
|
|
# |
5605
|
|
|
|
|
|
|
# GB18030 substr by character |
5606
|
|
|
|
|
|
|
# |
5607
|
|
|
|
|
|
|
BEGIN { |
5608
|
|
|
|
|
|
|
|
5609
|
|
|
|
|
|
|
# P.232 The lvalue Attribute |
5610
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
5611
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5612
|
|
|
|
|
|
|
|
5613
|
|
|
|
|
|
|
# P.336 The lvalue Attribute |
5614
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
5615
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5616
|
|
|
|
|
|
|
|
5617
|
|
|
|
|
|
|
# P.144 8.4 Lvalue subroutines |
5618
|
|
|
|
|
|
|
# in Chapter 8: perlsub: Perl subroutines |
5619
|
389
|
50
|
0
|
389
|
1
|
237996
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
|
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
|
|
5620
|
|
|
|
|
|
|
|
5621
|
|
|
|
|
|
|
CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : ''); |
5622
|
|
|
|
|
|
|
# vv----------------------******* |
5623
|
|
|
|
|
|
|
sub GB18030::substr($$;$$) %s { |
5624
|
|
|
|
|
|
|
|
5625
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5626
|
|
|
|
|
|
|
|
5627
|
|
|
|
|
|
|
# If the substring is beyond either end of the string, substr() returns the undefined |
5628
|
|
|
|
|
|
|
# value and produces a warning. When used as an lvalue, specifying a substring that |
5629
|
|
|
|
|
|
|
# is entirely outside the string raises an exception. |
5630
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/substr.html |
5631
|
|
|
|
|
|
|
|
5632
|
|
|
|
|
|
|
# A return with no argument returns the scalar value undef in scalar context, |
5633
|
|
|
|
|
|
|
# an empty list () in list context, and (naturally) nothing at all in void |
5634
|
|
|
|
|
|
|
# context. |
5635
|
|
|
|
|
|
|
|
5636
|
|
|
|
|
|
|
my $offset = $_[1]; |
5637
|
|
|
|
|
|
|
if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) { |
5638
|
|
|
|
|
|
|
return; |
5639
|
|
|
|
|
|
|
} |
5640
|
|
|
|
|
|
|
|
5641
|
|
|
|
|
|
|
# substr($string,$offset,$length,$replacement) |
5642
|
|
|
|
|
|
|
if (@_ == 4) { |
5643
|
|
|
|
|
|
|
my(undef,undef,$length,$replacement) = @_; |
5644
|
|
|
|
|
|
|
my $substr = join '', splice(@char, $offset, $length, $replacement); |
5645
|
|
|
|
|
|
|
$_[0] = join '', @char; |
5646
|
|
|
|
|
|
|
|
5647
|
|
|
|
|
|
|
# return $substr; this doesn't work, don't say "return" |
5648
|
|
|
|
|
|
|
$substr; |
5649
|
|
|
|
|
|
|
} |
5650
|
|
|
|
|
|
|
|
5651
|
|
|
|
|
|
|
# substr($string,$offset,$length) |
5652
|
|
|
|
|
|
|
elsif (@_ == 3) { |
5653
|
|
|
|
|
|
|
my(undef,undef,$length) = @_; |
5654
|
|
|
|
|
|
|
my $octet_offset = 0; |
5655
|
|
|
|
|
|
|
my $octet_length = 0; |
5656
|
|
|
|
|
|
|
if ($offset == 0) { |
5657
|
|
|
|
|
|
|
$octet_offset = 0; |
5658
|
|
|
|
|
|
|
} |
5659
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5660
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5661
|
|
|
|
|
|
|
} |
5662
|
|
|
|
|
|
|
else { |
5663
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5664
|
|
|
|
|
|
|
} |
5665
|
|
|
|
|
|
|
if ($length == 0) { |
5666
|
|
|
|
|
|
|
$octet_length = 0; |
5667
|
|
|
|
|
|
|
} |
5668
|
|
|
|
|
|
|
elsif ($length > 0) { |
5669
|
|
|
|
|
|
|
$octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]); |
5670
|
|
|
|
|
|
|
} |
5671
|
|
|
|
|
|
|
else { |
5672
|
|
|
|
|
|
|
$octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]); |
5673
|
|
|
|
|
|
|
} |
5674
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset, $octet_length); |
5675
|
|
|
|
|
|
|
} |
5676
|
|
|
|
|
|
|
|
5677
|
|
|
|
|
|
|
# substr($string,$offset) |
5678
|
|
|
|
|
|
|
else { |
5679
|
|
|
|
|
|
|
my $octet_offset = 0; |
5680
|
|
|
|
|
|
|
if ($offset == 0) { |
5681
|
|
|
|
|
|
|
$octet_offset = 0; |
5682
|
|
|
|
|
|
|
} |
5683
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5684
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5685
|
|
|
|
|
|
|
} |
5686
|
|
|
|
|
|
|
else { |
5687
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5688
|
|
|
|
|
|
|
} |
5689
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset); |
5690
|
|
|
|
|
|
|
} |
5691
|
|
|
|
|
|
|
} |
5692
|
|
|
|
|
|
|
END |
5693
|
|
|
|
|
|
|
} |
5694
|
|
|
|
|
|
|
|
5695
|
|
|
|
|
|
|
# |
5696
|
|
|
|
|
|
|
# GB18030 index by character |
5697
|
|
|
|
|
|
|
# |
5698
|
0
|
|
|
0
|
1
|
0
|
sub GB18030::index($$;$) { |
5699
|
0
|
0
|
|
|
|
0
|
|
5700
|
0
|
|
|
|
|
0
|
my $index; |
5701
|
|
|
|
|
|
|
if (@_ == 3) { |
5702
|
|
|
|
|
|
|
$index = Egb18030::index($_[0], $_[1], CORE::length(GB18030::substr($_[0], 0, $_[2]))); |
5703
|
0
|
|
|
|
|
0
|
} |
5704
|
|
|
|
|
|
|
else { |
5705
|
|
|
|
|
|
|
$index = Egb18030::index($_[0], $_[1]); |
5706
|
0
|
0
|
|
|
|
0
|
} |
5707
|
0
|
|
|
|
|
0
|
|
5708
|
|
|
|
|
|
|
if ($index == -1) { |
5709
|
|
|
|
|
|
|
return -1; |
5710
|
0
|
|
|
|
|
0
|
} |
5711
|
|
|
|
|
|
|
else { |
5712
|
|
|
|
|
|
|
return GB18030::length(CORE::substr $_[0], 0, $index); |
5713
|
|
|
|
|
|
|
} |
5714
|
|
|
|
|
|
|
} |
5715
|
|
|
|
|
|
|
|
5716
|
|
|
|
|
|
|
# |
5717
|
|
|
|
|
|
|
# GB18030 rindex by character |
5718
|
|
|
|
|
|
|
# |
5719
|
0
|
|
|
0
|
1
|
0
|
sub GB18030::rindex($$;$) { |
5720
|
0
|
0
|
|
|
|
0
|
|
5721
|
0
|
|
|
|
|
0
|
my $rindex; |
5722
|
|
|
|
|
|
|
if (@_ == 3) { |
5723
|
|
|
|
|
|
|
$rindex = Egb18030::rindex($_[0], $_[1], CORE::length(GB18030::substr($_[0], 0, $_[2]))); |
5724
|
0
|
|
|
|
|
0
|
} |
5725
|
|
|
|
|
|
|
else { |
5726
|
|
|
|
|
|
|
$rindex = Egb18030::rindex($_[0], $_[1]); |
5727
|
0
|
0
|
|
|
|
0
|
} |
5728
|
0
|
|
|
|
|
0
|
|
5729
|
|
|
|
|
|
|
if ($rindex == -1) { |
5730
|
|
|
|
|
|
|
return -1; |
5731
|
0
|
|
|
|
|
0
|
} |
5732
|
|
|
|
|
|
|
else { |
5733
|
|
|
|
|
|
|
return GB18030::length(CORE::substr $_[0], 0, $rindex); |
5734
|
|
|
|
|
|
|
} |
5735
|
|
|
|
|
|
|
} |
5736
|
|
|
|
|
|
|
|
5737
|
389
|
|
|
389
|
|
5179
|
# when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??' |
|
389
|
|
|
|
|
2740
|
|
|
389
|
|
|
|
|
63816
|
|
5738
|
|
|
|
|
|
|
# when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else) |
5739
|
|
|
|
|
|
|
use vars qw($slash); $slash = 'm//'; |
5740
|
|
|
|
|
|
|
|
5741
|
|
|
|
|
|
|
# ord() to ord() or GB18030::ord() |
5742
|
|
|
|
|
|
|
my $function_ord = 'ord'; |
5743
|
|
|
|
|
|
|
|
5744
|
|
|
|
|
|
|
# ord to ord or GB18030::ord_ |
5745
|
|
|
|
|
|
|
my $function_ord_ = 'ord'; |
5746
|
|
|
|
|
|
|
|
5747
|
|
|
|
|
|
|
# reverse to reverse or GB18030::reverse |
5748
|
|
|
|
|
|
|
my $function_reverse = 'reverse'; |
5749
|
|
|
|
|
|
|
|
5750
|
|
|
|
|
|
|
# getc to getc or GB18030::getc |
5751
|
|
|
|
|
|
|
my $function_getc = 'getc'; |
5752
|
|
|
|
|
|
|
|
5753
|
|
|
|
|
|
|
# P.1023 Appendix W.9 Multibyte Anchoring |
5754
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
5755
|
|
|
|
|
|
|
|
5756
|
|
|
|
|
|
|
my $anchor = ''; |
5757
|
389
|
|
|
389
|
|
4407
|
$anchor = q{${Egb18030::anchor}}; |
|
389
|
|
|
0
|
|
2129
|
|
|
389
|
|
|
|
|
22588923
|
|
5758
|
|
|
|
|
|
|
|
5759
|
|
|
|
|
|
|
use vars qw($nest); |
5760
|
|
|
|
|
|
|
|
5761
|
|
|
|
|
|
|
# regexp of nested parens in qqXX |
5762
|
|
|
|
|
|
|
|
5763
|
|
|
|
|
|
|
# P.340 Matching Nested Constructs with Embedded Code |
5764
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5765
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5766
|
|
|
|
|
|
|
|
5767
|
|
|
|
|
|
|
my $qq_paren = qr{(?{local $nest=0}) (?>(?: |
5768
|
|
|
|
|
|
|
[^\x81-\xFE\\()] | |
5769
|
|
|
|
|
|
|
\( (?{$nest++}) | |
5770
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5771
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5772
|
|
|
|
|
|
|
\\ [^\x81-\xFEc] | |
5773
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5774
|
|
|
|
|
|
|
\\ [\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5775
|
|
|
|
|
|
|
[\x00-\xFF] |
5776
|
|
|
|
|
|
|
}xms; |
5777
|
|
|
|
|
|
|
|
5778
|
|
|
|
|
|
|
my $qq_brace = qr{(?{local $nest=0}) (?>(?: |
5779
|
|
|
|
|
|
|
[^\x81-\xFE\\{}] | |
5780
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
5781
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5782
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5783
|
|
|
|
|
|
|
\\ [^\x81-\xFEc] | |
5784
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5785
|
|
|
|
|
|
|
\\ [\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5786
|
|
|
|
|
|
|
[\x00-\xFF] |
5787
|
|
|
|
|
|
|
}xms; |
5788
|
|
|
|
|
|
|
|
5789
|
|
|
|
|
|
|
my $qq_bracket = qr{(?{local $nest=0}) (?>(?: |
5790
|
|
|
|
|
|
|
[^\x81-\xFE\\\[\]] | |
5791
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
5792
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5793
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5794
|
|
|
|
|
|
|
\\ [^\x81-\xFEc] | |
5795
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5796
|
|
|
|
|
|
|
\\ [\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5797
|
|
|
|
|
|
|
[\x00-\xFF] |
5798
|
|
|
|
|
|
|
}xms; |
5799
|
|
|
|
|
|
|
|
5800
|
|
|
|
|
|
|
my $qq_angle = qr{(?{local $nest=0}) (?>(?: |
5801
|
|
|
|
|
|
|
[^\x81-\xFE\\<>] | |
5802
|
|
|
|
|
|
|
\< (?{$nest++}) | |
5803
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5804
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5805
|
|
|
|
|
|
|
\\ [^\x81-\xFEc] | |
5806
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5807
|
|
|
|
|
|
|
\\ [\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5808
|
|
|
|
|
|
|
[\x00-\xFF] |
5809
|
|
|
|
|
|
|
}xms; |
5810
|
|
|
|
|
|
|
|
5811
|
|
|
|
|
|
|
my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} | |
5812
|
|
|
|
|
|
|
(?: ::)? (?: |
5813
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
5814
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
5815
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
5816
|
|
|
|
|
|
|
)) |
5817
|
|
|
|
|
|
|
}xms; |
5818
|
|
|
|
|
|
|
|
5819
|
|
|
|
|
|
|
my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} | |
5820
|
|
|
|
|
|
|
(?: ::)? (?: |
5821
|
|
|
|
|
|
|
(?>[0-9]+) | |
5822
|
|
|
|
|
|
|
[^\x81-\xFEa-zA-Z_0-9\[\]] | |
5823
|
|
|
|
|
|
|
^[A-Z] | |
5824
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
5825
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
5826
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
5827
|
|
|
|
|
|
|
)) |
5828
|
|
|
|
|
|
|
}xms; |
5829
|
|
|
|
|
|
|
|
5830
|
|
|
|
|
|
|
my $qq_substr = qr{(?> Char::substr | GB18030::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \) |
5831
|
|
|
|
|
|
|
}xms; |
5832
|
|
|
|
|
|
|
|
5833
|
|
|
|
|
|
|
# regexp of nested parens in qXX |
5834
|
|
|
|
|
|
|
my $q_paren = qr{(?{local $nest=0}) (?>(?: |
5835
|
|
|
|
|
|
|
[^\x81-\xFE()] | |
5836
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5837
|
|
|
|
|
|
|
\( (?{$nest++}) | |
5838
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5839
|
|
|
|
|
|
|
[\x00-\xFF] |
5840
|
|
|
|
|
|
|
}xms; |
5841
|
|
|
|
|
|
|
|
5842
|
|
|
|
|
|
|
my $q_brace = qr{(?{local $nest=0}) (?>(?: |
5843
|
|
|
|
|
|
|
[^\x81-\xFE\{\}] | |
5844
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5845
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
5846
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5847
|
|
|
|
|
|
|
[\x00-\xFF] |
5848
|
|
|
|
|
|
|
}xms; |
5849
|
|
|
|
|
|
|
|
5850
|
|
|
|
|
|
|
my $q_bracket = qr{(?{local $nest=0}) (?>(?: |
5851
|
|
|
|
|
|
|
[^\x81-\xFE\[\]] | |
5852
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5853
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
5854
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5855
|
|
|
|
|
|
|
[\x00-\xFF] |
5856
|
|
|
|
|
|
|
}xms; |
5857
|
|
|
|
|
|
|
|
5858
|
|
|
|
|
|
|
my $q_angle = qr{(?{local $nest=0}) (?>(?: |
5859
|
|
|
|
|
|
|
[^\x81-\xFE<>] | |
5860
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
5861
|
|
|
|
|
|
|
\< (?{$nest++}) | |
5862
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5863
|
|
|
|
|
|
|
[\x00-\xFF] |
5864
|
|
|
|
|
|
|
}xms; |
5865
|
|
|
|
|
|
|
|
5866
|
|
|
|
|
|
|
my $matched = ''; |
5867
|
|
|
|
|
|
|
my $s_matched = ''; |
5868
|
|
|
|
|
|
|
$matched = q{$Egb18030::matched}; |
5869
|
|
|
|
|
|
|
$s_matched = q{ Egb18030::s_matched();}; |
5870
|
|
|
|
|
|
|
|
5871
|
|
|
|
|
|
|
my $tr_variable = ''; # variable of tr/// |
5872
|
|
|
|
|
|
|
my $sub_variable = ''; # variable of s/// |
5873
|
|
|
|
|
|
|
my $bind_operator = ''; # =~ or !~ |
5874
|
|
|
|
|
|
|
|
5875
|
|
|
|
|
|
|
my @heredoc = (); # here document |
5876
|
|
|
|
|
|
|
my @heredoc_delimiter = (); |
5877
|
|
|
|
|
|
|
my $here_script = ''; # here script |
5878
|
|
|
|
|
|
|
|
5879
|
|
|
|
|
|
|
# |
5880
|
|
|
|
|
|
|
# escape GB18030 script |
5881
|
0
|
50
|
|
384
|
0
|
0
|
# |
5882
|
|
|
|
|
|
|
sub GB18030::escape(;$) { |
5883
|
|
|
|
|
|
|
local($_) = $_[0] if @_; |
5884
|
|
|
|
|
|
|
|
5885
|
|
|
|
|
|
|
# P.359 The Study Function |
5886
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5887
|
384
|
|
|
|
|
1344
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5888
|
|
|
|
|
|
|
|
5889
|
|
|
|
|
|
|
study $_; # Yes, I studied study yesterday. |
5890
|
|
|
|
|
|
|
|
5891
|
|
|
|
|
|
|
# while all script |
5892
|
|
|
|
|
|
|
|
5893
|
|
|
|
|
|
|
# 6.14. Matching from Where the Last Pattern Left Off |
5894
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
5895
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
5896
|
|
|
|
|
|
|
# (and so on) |
5897
|
|
|
|
|
|
|
|
5898
|
|
|
|
|
|
|
# one member of Tag-team |
5899
|
|
|
|
|
|
|
# |
5900
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
5901
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
5902
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
5903
|
|
|
|
|
|
|
# P.255 Use leading anchors |
5904
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front expressions |
5905
|
|
|
|
|
|
|
# in Chapter 6: Crafting an Efficient Expression |
5906
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
5907
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5908
|
384
|
|
|
|
|
783
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5909
|
384
|
|
|
|
|
735
|
|
5910
|
384
|
|
|
|
|
2033
|
my $e_script = ''; |
5911
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { # member |
5912
|
|
|
|
|
|
|
$e_script .= GB18030::escape_token(); |
5913
|
189679
|
|
|
|
|
300384
|
} |
5914
|
|
|
|
|
|
|
|
5915
|
|
|
|
|
|
|
return $e_script; |
5916
|
|
|
|
|
|
|
} |
5917
|
|
|
|
|
|
|
|
5918
|
|
|
|
|
|
|
# |
5919
|
|
|
|
|
|
|
# escape GB18030 token of script |
5920
|
|
|
|
|
|
|
# |
5921
|
|
|
|
|
|
|
sub GB18030::escape_token { |
5922
|
|
|
|
|
|
|
|
5923
|
384
|
|
|
189679
|
0
|
6654
|
# \n output here document |
5924
|
|
|
|
|
|
|
|
5925
|
|
|
|
|
|
|
my $ignore_modules = join('|', qw( |
5926
|
|
|
|
|
|
|
utf8 |
5927
|
|
|
|
|
|
|
bytes |
5928
|
|
|
|
|
|
|
charnames |
5929
|
|
|
|
|
|
|
I18N::Japanese |
5930
|
|
|
|
|
|
|
I18N::Collate |
5931
|
|
|
|
|
|
|
I18N::JExt |
5932
|
|
|
|
|
|
|
File::DosGlob |
5933
|
|
|
|
|
|
|
Wild |
5934
|
|
|
|
|
|
|
Wildcard |
5935
|
|
|
|
|
|
|
Japanese |
5936
|
|
|
|
|
|
|
)); |
5937
|
|
|
|
|
|
|
|
5938
|
|
|
|
|
|
|
# another member of Tag-team |
5939
|
|
|
|
|
|
|
# |
5940
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
5941
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5942
|
189679
|
100
|
100
|
|
|
229010
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
|
|
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
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5943
|
189679
|
|
|
|
|
14784529
|
|
5944
|
31714
|
100
|
|
|
|
41081
|
if (/\G ( \n ) /oxgc) { # another member (and so on) |
5945
|
31714
|
|
|
|
|
56788
|
my $heredoc = ''; |
5946
|
|
|
|
|
|
|
if (scalar(@heredoc_delimiter) >= 1) { |
5947
|
203
|
|
|
|
|
275
|
$slash = 'm//'; |
5948
|
203
|
|
|
|
|
411
|
|
5949
|
|
|
|
|
|
|
$heredoc = join '', @heredoc; |
5950
|
|
|
|
|
|
|
@heredoc = (); |
5951
|
203
|
|
|
|
|
420
|
|
5952
|
203
|
|
|
|
|
424
|
# skip here document |
5953
|
|
|
|
|
|
|
for my $heredoc_delimiter (@heredoc_delimiter) { |
5954
|
211
|
|
|
|
|
1280
|
/\G .*? \n $heredoc_delimiter \n/xmsgc; |
5955
|
|
|
|
|
|
|
} |
5956
|
203
|
|
|
|
|
376
|
@heredoc_delimiter = (); |
5957
|
|
|
|
|
|
|
|
5958
|
203
|
|
|
|
|
550
|
$here_script = ''; |
5959
|
|
|
|
|
|
|
} |
5960
|
|
|
|
|
|
|
return "\n" . $heredoc; |
5961
|
|
|
|
|
|
|
} |
5962
|
31714
|
|
|
|
|
98253
|
|
5963
|
|
|
|
|
|
|
# ignore space, comment |
5964
|
|
|
|
|
|
|
elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; } |
5965
|
|
|
|
|
|
|
|
5966
|
|
|
|
|
|
|
# if (, elsif (, unless (, while (, until (, given (, and when ( |
5967
|
|
|
|
|
|
|
|
5968
|
|
|
|
|
|
|
# given, when |
5969
|
|
|
|
|
|
|
|
5970
|
|
|
|
|
|
|
# P.225 The given Statement |
5971
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
5972
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
5973
|
|
|
|
|
|
|
|
5974
|
|
|
|
|
|
|
# P.133 The given Statement |
5975
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
5976
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5977
|
43291
|
|
|
|
|
134512
|
|
5978
|
3802
|
|
|
|
|
5873
|
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) { |
5979
|
|
|
|
|
|
|
$slash = 'm//'; |
5980
|
|
|
|
|
|
|
return $1; |
5981
|
|
|
|
|
|
|
} |
5982
|
|
|
|
|
|
|
|
5983
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ tr///; |
5984
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ s///; |
5985
|
|
|
|
|
|
|
|
5986
|
|
|
|
|
|
|
# state |
5987
|
|
|
|
|
|
|
|
5988
|
|
|
|
|
|
|
# P.68 Persistent, Private Variables |
5989
|
|
|
|
|
|
|
# in Chapter 4: Subroutines |
5990
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
5991
|
|
|
|
|
|
|
|
5992
|
|
|
|
|
|
|
# P.160 Persistent Lexically Scoped Variables: state |
5993
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
5994
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5995
|
|
|
|
|
|
|
|
5996
|
|
|
|
|
|
|
# (and so on) |
5997
|
3802
|
|
|
|
|
11715
|
|
5998
|
|
|
|
|
|
|
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) { |
5999
|
187
|
50
|
|
|
|
539
|
my $e_string = e_string($1); |
|
|
50
|
|
|
|
|
|
6000
|
187
|
|
|
|
|
8652
|
|
6001
|
0
|
|
|
|
|
0
|
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6002
|
0
|
|
|
|
|
0
|
$tr_variable = $e_string . e_string($1); |
6003
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
6004
|
|
|
|
|
|
|
$slash = 'm//'; |
6005
|
|
|
|
|
|
|
return ''; |
6006
|
0
|
|
|
|
|
0
|
} |
6007
|
0
|
|
|
|
|
0
|
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6008
|
0
|
|
|
|
|
0
|
$sub_variable = $e_string . e_string($1); |
6009
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
6010
|
|
|
|
|
|
|
$slash = 'm//'; |
6011
|
|
|
|
|
|
|
return ''; |
6012
|
0
|
|
|
|
|
0
|
} |
6013
|
187
|
|
|
|
|
385
|
else { |
6014
|
|
|
|
|
|
|
$slash = 'div'; |
6015
|
|
|
|
|
|
|
return $e_string; |
6016
|
|
|
|
|
|
|
} |
6017
|
|
|
|
|
|
|
} |
6018
|
|
|
|
|
|
|
|
6019
|
187
|
|
|
|
|
765
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
6020
|
4
|
|
|
|
|
11
|
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
6021
|
|
|
|
|
|
|
$slash = 'div'; |
6022
|
|
|
|
|
|
|
return q{Egb18030::PREMATCH()}; |
6023
|
|
|
|
|
|
|
} |
6024
|
|
|
|
|
|
|
|
6025
|
4
|
|
|
|
|
12
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
6026
|
28
|
|
|
|
|
61
|
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
6027
|
|
|
|
|
|
|
$slash = 'div'; |
6028
|
|
|
|
|
|
|
return q{Egb18030::MATCH()}; |
6029
|
|
|
|
|
|
|
} |
6030
|
|
|
|
|
|
|
|
6031
|
28
|
|
|
|
|
89
|
# $', ${'} --> $', ${'} |
6032
|
1
|
|
|
|
|
4
|
elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) { |
6033
|
|
|
|
|
|
|
$slash = 'div'; |
6034
|
|
|
|
|
|
|
return $1; |
6035
|
|
|
|
|
|
|
} |
6036
|
|
|
|
|
|
|
|
6037
|
1
|
|
|
|
|
3
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
6038
|
3
|
|
|
|
|
7
|
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
6039
|
|
|
|
|
|
|
$slash = 'div'; |
6040
|
|
|
|
|
|
|
return q{Egb18030::POSTMATCH()}; |
6041
|
|
|
|
|
|
|
} |
6042
|
|
|
|
|
|
|
|
6043
|
|
|
|
|
|
|
# scalar variable $scalar =~ tr///; |
6044
|
|
|
|
|
|
|
# scalar variable $scalar =~ s///; |
6045
|
|
|
|
|
|
|
# substr() =~ tr///; |
6046
|
3
|
|
|
|
|
10
|
# substr() =~ s///; |
6047
|
|
|
|
|
|
|
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) { |
6048
|
3043
|
100
|
|
|
|
7083
|
my $scalar = e_string($1); |
|
|
100
|
|
|
|
|
|
6049
|
3043
|
|
|
|
|
12703
|
|
6050
|
9
|
|
|
|
|
13
|
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6051
|
9
|
|
|
|
|
18
|
$tr_variable = $scalar; |
6052
|
9
|
|
|
|
|
12
|
$bind_operator = $1; |
6053
|
|
|
|
|
|
|
$slash = 'm//'; |
6054
|
|
|
|
|
|
|
return ''; |
6055
|
9
|
|
|
|
|
22
|
} |
6056
|
255
|
|
|
|
|
436
|
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6057
|
255
|
|
|
|
|
473
|
$sub_variable = $scalar; |
6058
|
255
|
|
|
|
|
339
|
$bind_operator = $1; |
6059
|
|
|
|
|
|
|
$slash = 'm//'; |
6060
|
|
|
|
|
|
|
return ''; |
6061
|
255
|
|
|
|
|
696
|
} |
6062
|
2779
|
|
|
|
|
4856
|
else { |
6063
|
|
|
|
|
|
|
$slash = 'div'; |
6064
|
|
|
|
|
|
|
return $scalar; |
6065
|
|
|
|
|
|
|
} |
6066
|
|
|
|
|
|
|
} |
6067
|
|
|
|
|
|
|
|
6068
|
2779
|
|
|
|
|
11788
|
# end of statement |
6069
|
|
|
|
|
|
|
elsif (/\G ( [,;] ) /oxgc) { |
6070
|
|
|
|
|
|
|
$slash = 'm//'; |
6071
|
12417
|
|
|
|
|
19271
|
|
6072
|
|
|
|
|
|
|
# clear tr/// variable |
6073
|
|
|
|
|
|
|
$tr_variable = ''; |
6074
|
12417
|
|
|
|
|
15287
|
|
6075
|
|
|
|
|
|
|
# clear s/// variable |
6076
|
12417
|
|
|
|
|
13940
|
$sub_variable = ''; |
6077
|
|
|
|
|
|
|
|
6078
|
12417
|
|
|
|
|
14136
|
$bind_operator = ''; |
6079
|
|
|
|
|
|
|
|
6080
|
|
|
|
|
|
|
return $1; |
6081
|
|
|
|
|
|
|
} |
6082
|
|
|
|
|
|
|
|
6083
|
12417
|
|
|
|
|
42452
|
# bareword |
6084
|
|
|
|
|
|
|
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
6085
|
|
|
|
|
|
|
return $1; |
6086
|
|
|
|
|
|
|
} |
6087
|
|
|
|
|
|
|
|
6088
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
6089
|
2
|
|
|
|
|
5
|
elsif (/\G ( \$ 0 ) /oxmsgc) { |
6090
|
|
|
|
|
|
|
$slash = 'div'; |
6091
|
|
|
|
|
|
|
return $1; |
6092
|
2
|
|
|
|
|
9
|
} |
6093
|
0
|
|
|
|
|
0
|
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
6094
|
|
|
|
|
|
|
$slash = 'div'; |
6095
|
|
|
|
|
|
|
return $1; |
6096
|
|
|
|
|
|
|
} |
6097
|
|
|
|
|
|
|
|
6098
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
6099
|
1
|
|
|
|
|
5
|
elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
6100
|
|
|
|
|
|
|
$slash = 'div'; |
6101
|
|
|
|
|
|
|
return $1; |
6102
|
|
|
|
|
|
|
} |
6103
|
|
|
|
|
|
|
|
6104
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6105
|
1
|
|
|
|
|
5
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6106
|
221
|
|
|
|
|
378
|
elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
6107
|
|
|
|
|
|
|
$slash = 'div'; |
6108
|
|
|
|
|
|
|
return e_capture($1); |
6109
|
221
|
|
|
|
|
576
|
} |
6110
|
0
|
|
|
|
|
0
|
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
6111
|
|
|
|
|
|
|
$slash = 'div'; |
6112
|
|
|
|
|
|
|
return e_capture($1); |
6113
|
|
|
|
|
|
|
} |
6114
|
|
|
|
|
|
|
|
6115
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6116
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
6117
|
|
|
|
|
|
|
$slash = 'div'; |
6118
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6119
|
|
|
|
|
|
|
} |
6120
|
|
|
|
|
|
|
|
6121
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
6122
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
6123
|
|
|
|
|
|
|
$slash = 'div'; |
6124
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6125
|
|
|
|
|
|
|
} |
6126
|
|
|
|
|
|
|
|
6127
|
0
|
|
|
|
|
0
|
# $$foo |
6128
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
6129
|
|
|
|
|
|
|
$slash = 'div'; |
6130
|
|
|
|
|
|
|
return e_capture($1); |
6131
|
|
|
|
|
|
|
} |
6132
|
|
|
|
|
|
|
|
6133
|
0
|
|
|
|
|
0
|
# ${ foo } |
6134
|
0
|
|
|
|
|
0
|
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) { |
6135
|
|
|
|
|
|
|
$slash = 'div'; |
6136
|
|
|
|
|
|
|
return '${' . $1 . '}'; |
6137
|
|
|
|
|
|
|
} |
6138
|
|
|
|
|
|
|
|
6139
|
0
|
|
|
|
|
0
|
# ${ ... } |
6140
|
0
|
|
|
|
|
0
|
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
6141
|
|
|
|
|
|
|
$slash = 'div'; |
6142
|
|
|
|
|
|
|
return e_capture($1); |
6143
|
|
|
|
|
|
|
} |
6144
|
|
|
|
|
|
|
|
6145
|
|
|
|
|
|
|
# variable or function |
6146
|
0
|
|
|
|
|
0
|
# $ @ % & * $ # |
6147
|
605
|
|
|
|
|
906
|
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) { |
6148
|
|
|
|
|
|
|
$slash = 'div'; |
6149
|
|
|
|
|
|
|
return $1; |
6150
|
|
|
|
|
|
|
} |
6151
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
6152
|
605
|
|
|
|
|
1907
|
# $ @ # \ ' " / ? ( ) [ ] < > |
6153
|
103
|
|
|
|
|
206
|
elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
6154
|
|
|
|
|
|
|
$slash = 'div'; |
6155
|
|
|
|
|
|
|
return $1; |
6156
|
|
|
|
|
|
|
} |
6157
|
|
|
|
|
|
|
|
6158
|
103
|
|
|
|
|
349
|
# while () |
6159
|
|
|
|
|
|
|
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) { |
6160
|
|
|
|
|
|
|
return $1; |
6161
|
|
|
|
|
|
|
} |
6162
|
|
|
|
|
|
|
|
6163
|
|
|
|
|
|
|
# while () --- glob |
6164
|
|
|
|
|
|
|
|
6165
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6166
|
0
|
|
|
|
|
0
|
|
6167
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^\x81-\xFE>\0\a\e\f\n\r\t]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])+?) > (?>\s*) \) \b /oxgc) { |
6168
|
|
|
|
|
|
|
return 'while ($_ = Egb18030::glob("' . $1 . '"))'; |
6169
|
|
|
|
|
|
|
} |
6170
|
|
|
|
|
|
|
|
6171
|
0
|
|
|
|
|
0
|
# while (glob) |
6172
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) { |
6173
|
|
|
|
|
|
|
return 'while ($_ = Egb18030::glob_)'; |
6174
|
|
|
|
|
|
|
} |
6175
|
|
|
|
|
|
|
|
6176
|
0
|
|
|
|
|
0
|
# while (glob(WILDCARD)) |
6177
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) { |
6178
|
|
|
|
|
|
|
return 'while ($_ = Egb18030::glob'; |
6179
|
|
|
|
|
|
|
} |
6180
|
0
|
|
|
|
|
0
|
|
|
482
|
|
|
|
|
1165
|
|
6181
|
|
|
|
|
|
|
# doit if, doit unless, doit while, doit until, doit for, doit when |
6182
|
|
|
|
|
|
|
elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; } |
6183
|
482
|
|
|
|
|
1966
|
|
|
19
|
|
|
|
|
37
|
|
6184
|
19
|
|
|
|
|
65
|
# subroutines of package Egb18030 |
|
0
|
|
|
|
|
0
|
|
6185
|
0
|
|
|
|
|
0
|
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; } |
|
13
|
|
|
|
|
21
|
|
6186
|
13
|
|
|
|
|
37
|
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
0
|
|
|
|
|
0
|
|
6187
|
0
|
|
|
|
|
0
|
elsif (/\G \b GB18030::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
114
|
|
|
|
|
175
|
|
6188
|
114
|
|
|
|
|
326
|
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; } |
|
2
|
|
|
|
|
4
|
|
6189
|
2
|
|
|
|
|
5
|
elsif (/\G \b GB18030::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval GB18030::escape'; } |
|
2
|
|
|
|
|
6
|
|
6190
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; } |
|
2
|
|
|
|
|
4
|
|
6191
|
2
|
|
|
|
|
5
|
elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::chop'; } |
|
0
|
|
|
|
|
0
|
|
6192
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; } |
|
2
|
|
|
|
|
4
|
|
6193
|
2
|
|
|
|
|
5
|
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; } |
|
2
|
|
|
|
|
5
|
|
6194
|
2
|
|
|
|
|
5
|
elsif (/\G \b GB18030::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'GB18030::index'; } |
|
2
|
|
|
|
|
4
|
|
6195
|
2
|
|
|
|
|
7
|
elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::index'; } |
|
0
|
|
|
|
|
0
|
|
6196
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; } |
|
2
|
|
|
|
|
4
|
|
6197
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; } |
|
2
|
|
|
|
|
5
|
|
6198
|
2
|
|
|
|
|
5
|
elsif (/\G \b GB18030::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'GB18030::rindex'; } |
|
1
|
|
|
|
|
2
|
|
6199
|
1
|
|
|
|
|
5
|
elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6200
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::lc'; } |
|
0
|
|
|
|
|
0
|
|
6201
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::lcfirst'; } |
|
0
|
|
|
|
|
0
|
|
6202
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::uc'; } |
|
3
|
|
|
|
|
8
|
|
6203
|
|
|
|
|
|
|
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::ucfirst'; } |
6204
|
|
|
|
|
|
|
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::fc'; } |
6205
|
|
|
|
|
|
|
|
6206
|
|
|
|
|
|
|
# stacked file test operators |
6207
|
|
|
|
|
|
|
|
6208
|
|
|
|
|
|
|
# P.179 File Test Operators |
6209
|
|
|
|
|
|
|
# in Chapter 12: File Tests |
6210
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6211
|
|
|
|
|
|
|
|
6212
|
|
|
|
|
|
|
# P.106 Named Unary and File Test Operators |
6213
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
6214
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6215
|
|
|
|
|
|
|
|
6216
|
|
|
|
|
|
|
# (and so on) |
6217
|
3
|
|
|
|
|
15
|
|
|
0
|
|
|
|
|
0
|
|
6218
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6219
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6220
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6221
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6222
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6223
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
2
|
|
6224
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6225
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6226
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
11
|
|
6227
|
5
|
|
|
|
|
19
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6228
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6229
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6230
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6231
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6232
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
3
|
|
6233
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6234
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6235
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
6236
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6237
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Egb18030::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6238
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6239
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $slash = 'm//'; return "Egb18030::filetest qw($1),"; } |
6240
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Egb18030::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6241
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6242
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6243
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6244
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6245
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6246
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
4
|
|
6247
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
6248
|
2
|
|
|
|
|
6
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
103
|
|
|
|
|
231
|
|
6249
|
103
|
|
|
|
|
393
|
|
|
0
|
|
|
|
|
0
|
|
6250
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6251
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6252
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6253
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6254
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
3
|
|
6255
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6256
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6257
|
2
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
15
|
|
6258
|
6
|
|
|
|
|
27
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6259
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Egb18030::$1($2)"; } |
|
0
|
|
|
|
|
0
|
|
6260
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Egb18030::$1($2)"; } |
|
50
|
|
|
|
|
130
|
|
6261
|
50
|
|
|
|
|
347
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return "Egb18030::$1"; } |
|
2
|
|
|
|
|
7
|
|
6262
|
2
|
|
|
|
|
10
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Egb18030::$1(::"."$2)"; } |
|
1
|
|
|
|
|
2
|
|
6263
|
1
|
|
|
|
|
6
|
elsif (/\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-t $2"; } |
|
3
|
|
|
|
|
10
|
|
6264
|
|
|
|
|
|
|
elsif (/\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::lstat'; } |
6265
|
|
|
|
|
|
|
elsif (/\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::stat'; } |
6266
|
3
|
|
|
|
|
13
|
|
|
0
|
|
|
|
|
0
|
|
6267
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
6268
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6269
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6270
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6271
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6272
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6273
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
6274
|
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
|
|
6275
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6276
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6277
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6278
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6279
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6280
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6281
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6282
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6283
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6284
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6285
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
6286
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; } |
|
0
|
|
|
|
|
0
|
|
6287
|
|
|
|
|
|
|
elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; } |
6288
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; } |
|
2
|
|
|
|
|
5
|
|
6289
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
5
|
|
6290
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; } |
|
36
|
|
|
|
|
81
|
|
6291
|
36
|
|
|
|
|
141
|
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
5
|
|
6292
|
2
|
|
|
|
|
8
|
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::chr'; } |
|
2
|
|
|
|
|
6
|
|
6293
|
2
|
|
|
|
|
8
|
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; } |
|
8
|
|
|
|
|
25
|
|
6294
|
8
|
|
|
|
|
33
|
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; } |
|
0
|
|
|
|
|
0
|
|
6295
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Egb18030::glob'; } |
|
0
|
|
|
|
|
0
|
|
6296
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::lc_'; } |
|
0
|
|
|
|
|
0
|
|
6297
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::lcfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6298
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::uc_'; } |
|
0
|
|
|
|
|
0
|
|
6299
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::ucfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6300
|
0
|
|
|
|
|
0
|
elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::fc_'; } |
|
0
|
|
|
|
|
0
|
|
6301
|
|
|
|
|
|
|
elsif (/\G \b lstat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::lstat_'; } |
6302
|
0
|
|
|
|
|
0
|
elsif (/\G \b stat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::stat_'; } |
|
0
|
|
|
|
|
0
|
|
6303
|
|
|
|
|
|
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
6304
|
0
|
|
|
|
|
0
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Egb18030::filetest_(qw($1))"; } |
|
0
|
|
|
|
|
0
|
|
6305
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) |
6306
|
0
|
|
|
|
|
0
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Egb18030::${1}_"; } |
|
0
|
|
|
|
|
0
|
|
6307
|
|
|
|
|
|
|
|
6308
|
0
|
|
|
|
|
0
|
elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; } |
|
0
|
|
|
|
|
0
|
|
6309
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6310
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; } |
|
0
|
|
|
|
|
0
|
|
6311
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
0
|
|
|
|
|
0
|
|
6312
|
0
|
|
|
|
|
0
|
elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::chr_'; } |
|
2
|
|
|
|
|
6
|
|
6313
|
2
|
|
|
|
|
8
|
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; } |
|
0
|
|
|
|
|
0
|
|
6314
|
0
|
|
|
|
|
0
|
elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; } |
|
4
|
|
|
|
|
9
|
|
6315
|
4
|
|
|
|
|
31
|
elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::glob_'; } |
|
8
|
|
|
|
|
24
|
|
6316
|
8
|
|
|
|
|
38
|
elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; } |
|
2
|
|
|
|
|
7
|
|
6317
|
2
|
|
|
|
|
13
|
elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; } |
|
0
|
|
|
|
|
0
|
|
6318
|
0
|
|
|
|
|
0
|
elsif (/\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Egb18030::opendir$1*"; } |
|
87
|
|
|
|
|
239
|
|
6319
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Egb18030::opendir$1*"; } |
6320
|
|
|
|
|
|
|
elsif (/\G \b unlink \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Egb18030::unlink'; } |
6321
|
|
|
|
|
|
|
|
6322
|
87
|
|
|
|
|
361
|
# chdir |
6323
|
|
|
|
|
|
|
elsif (/\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
6324
|
3
|
|
|
|
|
7
|
$slash = 'm//'; |
6325
|
|
|
|
|
|
|
|
6326
|
3
|
|
|
|
|
5
|
my $e = 'Egb18030::chdir'; |
6327
|
3
|
|
|
|
|
9
|
|
6328
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6329
|
|
|
|
|
|
|
$e .= $1; |
6330
|
|
|
|
|
|
|
} |
6331
|
3
|
50
|
|
|
|
13
|
|
|
3
|
100
|
|
|
|
263
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6332
|
|
|
|
|
|
|
# end of chdir |
6333
|
|
|
|
|
|
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return $e; } |
6334
|
0
|
|
|
|
|
0
|
|
6335
|
|
|
|
|
|
|
# chdir scalar value |
6336
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return $e . e_string($1); } |
6337
|
|
|
|
|
|
|
|
6338
|
1
|
0
|
|
|
|
5
|
# chdir qq// |
|
0
|
|
|
|
|
0
|
|
6339
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6340
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq# # --> qr # # |
6341
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6342
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6343
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6344
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq ( ) --> qr ( ) |
6345
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq { } --> qr { } |
6346
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq [ ] --> qr [ ] |
6347
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq < > --> qr < > |
6348
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq','{','}',$2); } # qq | | --> qr { } |
6349
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq * * --> qr * * |
6350
|
|
|
|
|
|
|
} |
6351
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6352
|
|
|
|
|
|
|
} |
6353
|
|
|
|
|
|
|
} |
6354
|
|
|
|
|
|
|
|
6355
|
0
|
0
|
|
|
|
0
|
# chdir q// |
|
0
|
|
|
|
|
0
|
|
6356
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6357
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q# # --> qr # # |
6358
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6359
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6360
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6361
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q ( ) --> qr ( ) |
6362
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q { } --> qr { } |
6363
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q [ ] --> qr [ ] |
6364
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q < > --> qr < > |
6365
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q','{','}',$2); } # q | | --> qr { } |
6366
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q * * --> qr * * |
6367
|
|
|
|
|
|
|
} |
6368
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6369
|
|
|
|
|
|
|
} |
6370
|
|
|
|
|
|
|
} |
6371
|
|
|
|
|
|
|
|
6372
|
0
|
|
|
|
|
0
|
# chdir '' |
6373
|
2
|
|
|
|
|
5
|
elsif (/\G (\') /oxgc) { |
6374
|
2
|
50
|
|
|
|
6
|
my $q_string = ''; |
|
13
|
50
|
|
|
|
65
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6375
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6376
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6377
|
2
|
|
|
|
|
6
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
6378
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return $e . e_chdir_q('',"'","'",$q_string); } |
6379
|
11
|
|
|
|
|
23
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6380
|
|
|
|
|
|
|
} |
6381
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6382
|
|
|
|
|
|
|
} |
6383
|
|
|
|
|
|
|
|
6384
|
0
|
|
|
|
|
0
|
# chdir "" |
6385
|
0
|
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
6386
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6387
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6388
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6389
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
6390
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return $e . e_chdir('','"','"',$qq_string); } |
6391
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6392
|
|
|
|
|
|
|
} |
6393
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6394
|
|
|
|
|
|
|
} |
6395
|
|
|
|
|
|
|
} |
6396
|
|
|
|
|
|
|
|
6397
|
0
|
|
|
|
|
0
|
# split |
6398
|
|
|
|
|
|
|
elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
6399
|
419
|
|
|
|
|
998
|
$slash = 'm//'; |
6400
|
419
|
|
|
|
|
653
|
|
6401
|
419
|
|
|
|
|
1512
|
my $e = ''; |
6402
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6403
|
|
|
|
|
|
|
$e .= $1; |
6404
|
|
|
|
|
|
|
} |
6405
|
416
|
100
|
|
|
|
1598
|
|
|
419
|
100
|
|
|
|
20080
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6406
|
|
|
|
|
|
|
# end of split |
6407
|
|
|
|
|
|
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Egb18030::split' . $e; } |
6408
|
3
|
|
|
|
|
18
|
|
6409
|
|
|
|
|
|
|
# split scalar value |
6410
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Egb18030::split' . $e . e_string($1); } |
6411
|
1
|
|
|
|
|
6
|
|
6412
|
0
|
|
|
|
|
0
|
# split literal space |
6413
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Egb18030::split' . $e . qq {qq$1 $2}; } |
6414
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Egb18030::split' . $e . qq{$1qq$2 $3}; } |
6415
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Egb18030::split' . $e . qq{$1qq$2 $3}; } |
6416
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Egb18030::split' . $e . qq{$1qq$2 $3}; } |
6417
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Egb18030::split' . $e . qq{$1qq$2 $3}; } |
6418
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Egb18030::split' . $e . qq{$1qq$2 $3}; } |
6419
|
0
|
|
|
|
|
0
|
elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Egb18030::split' . $e . qq {q$1 $2}; } |
6420
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Egb18030::split' . $e . qq {$1q$2 $3}; } |
6421
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Egb18030::split' . $e . qq {$1q$2 $3}; } |
6422
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Egb18030::split' . $e . qq {$1q$2 $3}; } |
6423
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Egb18030::split' . $e . qq {$1q$2 $3}; } |
6424
|
16
|
|
|
|
|
104
|
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Egb18030::split' . $e . qq {$1q$2 $3}; } |
6425
|
|
|
|
|
|
|
elsif (/\G ' [ ] ' /oxgc) { return 'Egb18030::split' . $e . qq {' '}; } |
6426
|
|
|
|
|
|
|
elsif (/\G " [ ] " /oxgc) { return 'Egb18030::split' . $e . qq {" "}; } |
6427
|
|
|
|
|
|
|
|
6428
|
2
|
0
|
|
|
|
9
|
# split qq// |
|
0
|
|
|
|
|
0
|
|
6429
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6430
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # # |
6431
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6432
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6433
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6434
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( ) |
6435
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { } |
6436
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ] |
6437
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < > |
6438
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { } |
6439
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * * |
6440
|
|
|
|
|
|
|
} |
6441
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6442
|
|
|
|
|
|
|
} |
6443
|
|
|
|
|
|
|
} |
6444
|
|
|
|
|
|
|
|
6445
|
0
|
50
|
|
|
|
0
|
# split qr// |
|
124
|
|
|
|
|
917
|
|
6446
|
|
|
|
|
|
|
elsif (/\G \b (qr) \b /oxgc) { |
6447
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# # |
6448
|
124
|
50
|
|
|
|
358
|
else { |
|
124
|
50
|
|
|
|
7238
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6449
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6450
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6451
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( ) |
6452
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { } |
6453
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ] |
6454
|
56
|
|
|
|
|
207
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < > |
6455
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' ' |
6456
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { } |
6457
|
68
|
|
|
|
|
394
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * * |
6458
|
|
|
|
|
|
|
} |
6459
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6460
|
|
|
|
|
|
|
} |
6461
|
|
|
|
|
|
|
} |
6462
|
|
|
|
|
|
|
|
6463
|
0
|
0
|
|
|
|
0
|
# split q// |
|
0
|
|
|
|
|
0
|
|
6464
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6465
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # # |
6466
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6467
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6468
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6469
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( ) |
6470
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { } |
6471
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ] |
6472
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < > |
6473
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { } |
6474
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * * |
6475
|
|
|
|
|
|
|
} |
6476
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6477
|
|
|
|
|
|
|
} |
6478
|
|
|
|
|
|
|
} |
6479
|
|
|
|
|
|
|
|
6480
|
0
|
50
|
|
|
|
0
|
# split m// |
|
136
|
|
|
|
|
1048
|
|
6481
|
|
|
|
|
|
|
elsif (/\G \b (m) \b /oxgc) { |
6482
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # # |
6483
|
136
|
50
|
|
|
|
335
|
else { |
|
136
|
50
|
|
|
|
7715
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6484
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6485
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6486
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( ) |
6487
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { } |
6488
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ] |
6489
|
56
|
|
|
|
|
207
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < > |
6490
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' ' |
6491
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { } |
6492
|
80
|
|
|
|
|
412
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * * |
6493
|
|
|
|
|
|
|
} |
6494
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6495
|
|
|
|
|
|
|
} |
6496
|
|
|
|
|
|
|
} |
6497
|
|
|
|
|
|
|
|
6498
|
0
|
|
|
|
|
0
|
# split '' |
6499
|
0
|
|
|
|
|
0
|
elsif (/\G (\') /oxgc) { |
6500
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6501
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6502
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6503
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
6504
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' ' |
6505
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6506
|
|
|
|
|
|
|
} |
6507
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6508
|
|
|
|
|
|
|
} |
6509
|
|
|
|
|
|
|
|
6510
|
0
|
|
|
|
|
0
|
# split "" |
6511
|
0
|
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
6512
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6513
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6514
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6515
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
6516
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " " |
6517
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6518
|
|
|
|
|
|
|
} |
6519
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6520
|
|
|
|
|
|
|
} |
6521
|
|
|
|
|
|
|
|
6522
|
0
|
|
|
|
|
0
|
# split // |
6523
|
137
|
|
|
|
|
335
|
elsif (/\G (\/) /oxgc) { |
6524
|
137
|
50
|
|
|
|
421
|
my $regexp = ''; |
|
582
|
50
|
|
|
|
2994
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6525
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6526
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
6527
|
137
|
|
|
|
|
558
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
6528
|
|
|
|
|
|
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / / |
6529
|
445
|
|
|
|
|
1013
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
6530
|
|
|
|
|
|
|
} |
6531
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6532
|
|
|
|
|
|
|
} |
6533
|
|
|
|
|
|
|
} |
6534
|
|
|
|
|
|
|
|
6535
|
|
|
|
|
|
|
# tr/// or y/// |
6536
|
|
|
|
|
|
|
|
6537
|
|
|
|
|
|
|
# about [cdsrbB]* (/B modifier) |
6538
|
|
|
|
|
|
|
# |
6539
|
|
|
|
|
|
|
# P.559 appendix C |
6540
|
|
|
|
|
|
|
# of ISBN 4-89052-384-7 Programming perl |
6541
|
|
|
|
|
|
|
# (Japanese title is: Perl puroguramingu) |
6542
|
0
|
|
|
|
|
0
|
|
6543
|
|
|
|
|
|
|
elsif (/\G \b ( tr | y ) \b /oxgc) { |
6544
|
|
|
|
|
|
|
my $ope = $1; |
6545
|
11
|
50
|
|
|
|
36
|
|
6546
|
11
|
|
|
|
|
185
|
# $1 $2 $3 $4 $5 $6 |
6547
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # # |
6548
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6549
|
|
|
|
|
|
|
return e_tr(@tr,'',$4,$6); |
6550
|
0
|
|
|
|
|
0
|
} |
6551
|
11
|
|
|
|
|
18
|
else { |
6552
|
11
|
50
|
|
|
|
28
|
my $e = ''; |
|
11
|
50
|
|
|
|
947
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6553
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6554
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6555
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
6556
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6557
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6558
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6559
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( ) |
6560
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { } |
6561
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ] |
6562
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < > |
6563
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * * |
6564
|
|
|
|
|
|
|
} |
6565
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6566
|
0
|
|
|
|
|
0
|
} |
6567
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
6568
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6569
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6570
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6571
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( ) |
6572
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { } |
6573
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ] |
6574
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < > |
6575
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * * |
6576
|
|
|
|
|
|
|
} |
6577
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6578
|
0
|
|
|
|
|
0
|
} |
6579
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
6580
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6581
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6582
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6583
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( ) |
6584
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { } |
6585
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ] |
6586
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < > |
6587
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * * |
6588
|
|
|
|
|
|
|
} |
6589
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6590
|
0
|
|
|
|
|
0
|
} |
6591
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
6592
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6593
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6594
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6595
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( ) |
6596
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { } |
6597
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ] |
6598
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < > |
6599
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * * |
6600
|
|
|
|
|
|
|
} |
6601
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6602
|
|
|
|
|
|
|
} |
6603
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
6604
|
11
|
|
|
|
|
44
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * * |
6605
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6606
|
|
|
|
|
|
|
return e_tr(@tr,'',$4,$6); |
6607
|
11
|
|
|
|
|
35
|
} |
6608
|
|
|
|
|
|
|
} |
6609
|
|
|
|
|
|
|
die __FILE__, ": Transliteration pattern not terminated\n"; |
6610
|
|
|
|
|
|
|
} |
6611
|
|
|
|
|
|
|
} |
6612
|
|
|
|
|
|
|
|
6613
|
0
|
|
|
|
|
0
|
# qq// |
6614
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6615
|
|
|
|
|
|
|
my $ope = $1; |
6616
|
5927
|
100
|
|
|
|
18342
|
|
6617
|
5927
|
|
|
|
|
12247
|
# if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# # |
6618
|
40
|
|
|
|
|
56
|
if (/\G (\#) /oxgc) { # qq# # |
6619
|
40
|
100
|
|
|
|
103
|
my $qq_string = ''; |
|
1948
|
50
|
|
|
|
5697
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6620
|
80
|
|
|
|
|
166
|
while (not /\G \z/oxgc) { |
6621
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6622
|
40
|
|
|
|
|
107
|
elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; } |
6623
|
|
|
|
|
|
|
elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); } |
6624
|
1828
|
|
|
|
|
3626
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6625
|
|
|
|
|
|
|
} |
6626
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6627
|
|
|
|
|
|
|
} |
6628
|
0
|
|
|
|
|
0
|
|
6629
|
5887
|
|
|
|
|
7890
|
else { |
6630
|
5887
|
50
|
|
|
|
15000
|
my $e = ''; |
|
5887
|
50
|
|
|
|
34990
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6631
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6632
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6633
|
|
|
|
|
|
|
|
6634
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( ) |
6635
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { # qq ( ) |
6636
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6637
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6638
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6639
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6640
|
|
|
|
|
|
|
elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; } |
6641
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6642
|
0
|
|
|
|
|
0
|
elsif (/\G (\)) /oxgc) { |
6643
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); } |
6644
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
6645
|
|
|
|
|
|
|
} |
6646
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6647
|
|
|
|
|
|
|
} |
6648
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6649
|
|
|
|
|
|
|
} |
6650
|
|
|
|
|
|
|
|
6651
|
0
|
|
|
|
|
0
|
# elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { } |
6652
|
5805
|
|
|
|
|
8179
|
elsif (/\G (\{) /oxgc) { # qq { } |
6653
|
5805
|
|
|
|
|
8310
|
my $qq_string = ''; |
6654
|
5805
|
100
|
|
|
|
12393
|
local $nest = 1; |
|
246837
|
50
|
|
|
|
778368
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6655
|
720
|
|
|
|
|
1430
|
while (not /\G \z/oxgc) { |
6656
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
1384
|
|
|
|
|
2009
|
|
6657
|
|
|
|
|
|
|
elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; } |
6658
|
1384
|
100
|
|
|
|
18685
|
elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; } |
|
7189
|
|
|
|
|
11508
|
|
6659
|
5805
|
|
|
|
|
12464
|
elsif (/\G (\}) /oxgc) { |
6660
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); } |
6661
|
1384
|
|
|
|
|
2624
|
else { $qq_string .= $1; } |
6662
|
|
|
|
|
|
|
} |
6663
|
237544
|
|
|
|
|
462526
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6664
|
|
|
|
|
|
|
} |
6665
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6666
|
|
|
|
|
|
|
} |
6667
|
|
|
|
|
|
|
|
6668
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ] |
6669
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # qq [ ] |
6670
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6671
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6672
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6673
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6674
|
|
|
|
|
|
|
elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; } |
6675
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6676
|
0
|
|
|
|
|
0
|
elsif (/\G (\]) /oxgc) { |
6677
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); } |
6678
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
6679
|
|
|
|
|
|
|
} |
6680
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6681
|
|
|
|
|
|
|
} |
6682
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6683
|
|
|
|
|
|
|
} |
6684
|
|
|
|
|
|
|
|
6685
|
0
|
|
|
|
|
0
|
# elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < > |
6686
|
62
|
|
|
|
|
111
|
elsif (/\G (\<) /oxgc) { # qq < > |
6687
|
62
|
|
|
|
|
110
|
my $qq_string = ''; |
6688
|
62
|
100
|
|
|
|
169
|
local $nest = 1; |
|
2040
|
50
|
|
|
|
8045
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6689
|
22
|
|
|
|
|
52
|
while (not /\G \z/oxgc) { |
6690
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
2
|
|
|
|
|
3
|
|
6691
|
|
|
|
|
|
|
elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; } |
6692
|
2
|
100
|
|
|
|
4
|
elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; } |
|
64
|
|
|
|
|
201
|
|
6693
|
62
|
|
|
|
|
184
|
elsif (/\G (\>) /oxgc) { |
6694
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); } |
6695
|
2
|
|
|
|
|
5
|
else { $qq_string .= $1; } |
6696
|
|
|
|
|
|
|
} |
6697
|
1952
|
|
|
|
|
3969
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6698
|
|
|
|
|
|
|
} |
6699
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6700
|
|
|
|
|
|
|
} |
6701
|
|
|
|
|
|
|
|
6702
|
0
|
|
|
|
|
0
|
# elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * * |
6703
|
20
|
|
|
|
|
45
|
elsif (/\G (\S) /oxgc) { # qq * * |
6704
|
20
|
|
|
|
|
28
|
my $delimiter = $1; |
6705
|
20
|
50
|
|
|
|
94
|
my $qq_string = ''; |
|
840
|
50
|
|
|
|
3956
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6706
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6707
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6708
|
20
|
|
|
|
|
58
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; } |
6709
|
|
|
|
|
|
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); } |
6710
|
820
|
|
|
|
|
3414
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6711
|
|
|
|
|
|
|
} |
6712
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6713
|
0
|
|
|
|
|
0
|
} |
6714
|
|
|
|
|
|
|
} |
6715
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6716
|
|
|
|
|
|
|
} |
6717
|
|
|
|
|
|
|
} |
6718
|
|
|
|
|
|
|
|
6719
|
0
|
|
|
|
|
0
|
# qr// |
6720
|
184
|
50
|
|
|
|
495
|
elsif (/\G \b (qr) \b /oxgc) { |
6721
|
184
|
|
|
|
|
806
|
my $ope = $1; |
6722
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # # |
6723
|
|
|
|
|
|
|
return e_qr($ope,$1,$3,$2,$4); |
6724
|
0
|
|
|
|
|
0
|
} |
6725
|
184
|
|
|
|
|
281
|
else { |
6726
|
184
|
50
|
|
|
|
438
|
my $e = ''; |
|
184
|
50
|
|
|
|
5185
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6727
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6728
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6729
|
1
|
|
|
|
|
13
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( ) |
6730
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { } |
6731
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ] |
6732
|
76
|
|
|
|
|
225
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < > |
6733
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' ' |
6734
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { } |
6735
|
107
|
|
|
|
|
312
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * * |
6736
|
|
|
|
|
|
|
} |
6737
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6738
|
|
|
|
|
|
|
} |
6739
|
|
|
|
|
|
|
} |
6740
|
|
|
|
|
|
|
|
6741
|
0
|
|
|
|
|
0
|
# qw// |
6742
|
34
|
50
|
|
|
|
104
|
elsif (/\G \b (qw) \b /oxgc) { |
6743
|
34
|
|
|
|
|
103
|
my $ope = $1; |
6744
|
|
|
|
|
|
|
if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# # |
6745
|
|
|
|
|
|
|
return e_qw($ope,$1,$3,$2); |
6746
|
0
|
|
|
|
|
0
|
} |
6747
|
34
|
|
|
|
|
62
|
else { |
6748
|
34
|
50
|
|
|
|
117
|
my $e = ''; |
|
34
|
50
|
|
|
|
198
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6749
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6750
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6751
|
34
|
|
|
|
|
111
|
|
6752
|
|
|
|
|
|
|
elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
6753
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
6754
|
0
|
|
|
|
|
0
|
|
6755
|
|
|
|
|
|
|
elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
6756
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
6757
|
0
|
|
|
|
|
0
|
|
6758
|
|
|
|
|
|
|
elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
6759
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
6760
|
0
|
|
|
|
|
0
|
|
6761
|
|
|
|
|
|
|
elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
6762
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
6763
|
0
|
|
|
|
|
0
|
|
6764
|
|
|
|
|
|
|
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
6765
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
6766
|
|
|
|
|
|
|
} |
6767
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6768
|
|
|
|
|
|
|
} |
6769
|
|
|
|
|
|
|
} |
6770
|
|
|
|
|
|
|
|
6771
|
0
|
|
|
|
|
0
|
# qx// |
6772
|
3
|
50
|
|
|
|
10
|
elsif (/\G \b (qx) \b /oxgc) { |
6773
|
3
|
|
|
|
|
76
|
my $ope = $1; |
6774
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
6775
|
|
|
|
|
|
|
return e_qq($ope,$1,$3,$2); |
6776
|
0
|
|
|
|
|
0
|
} |
6777
|
3
|
|
|
|
|
8
|
else { |
6778
|
3
|
50
|
|
|
|
10
|
my $e = ''; |
|
3
|
50
|
|
|
|
408
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6779
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6780
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6781
|
2
|
|
|
|
|
6
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( ) |
6782
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { } |
6783
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ] |
6784
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < > |
6785
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' ' |
6786
|
1
|
|
|
|
|
4
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * * |
6787
|
|
|
|
|
|
|
} |
6788
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6789
|
|
|
|
|
|
|
} |
6790
|
|
|
|
|
|
|
} |
6791
|
|
|
|
|
|
|
|
6792
|
0
|
|
|
|
|
0
|
# q// |
6793
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6794
|
|
|
|
|
|
|
my $ope = $1; |
6795
|
|
|
|
|
|
|
|
6796
|
|
|
|
|
|
|
# if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# # |
6797
|
|
|
|
|
|
|
|
6798
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6799
|
606
|
50
|
|
|
|
1975
|
# (and so on) |
6800
|
606
|
|
|
|
|
1976
|
|
6801
|
0
|
|
|
|
|
0
|
if (/\G (\#) /oxgc) { # q# # |
6802
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6803
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6804
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6805
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\#) /oxgc) { $q_string .= $1; } |
6806
|
|
|
|
|
|
|
elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); } |
6807
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6808
|
|
|
|
|
|
|
} |
6809
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6810
|
|
|
|
|
|
|
} |
6811
|
0
|
|
|
|
|
0
|
|
6812
|
606
|
|
|
|
|
1259
|
else { |
6813
|
606
|
50
|
|
|
|
2257
|
my $e = ''; |
|
606
|
100
|
|
|
|
4209
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6814
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6815
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6816
|
|
|
|
|
|
|
|
6817
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( ) |
6818
|
1
|
|
|
|
|
2
|
elsif (/\G (\() /oxgc) { # q ( ) |
6819
|
1
|
|
|
|
|
2
|
my $q_string = ''; |
6820
|
1
|
50
|
|
|
|
5
|
local $nest = 1; |
|
7
|
50
|
|
|
|
60
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6821
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6822
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6823
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6824
|
|
|
|
|
|
|
elsif (/\G (\\\() /oxgc) { $q_string .= $1; } |
6825
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; } |
|
1
|
|
|
|
|
4
|
|
6826
|
1
|
|
|
|
|
4
|
elsif (/\G (\)) /oxgc) { |
6827
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); } |
6828
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6829
|
|
|
|
|
|
|
} |
6830
|
6
|
|
|
|
|
25
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6831
|
|
|
|
|
|
|
} |
6832
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6833
|
|
|
|
|
|
|
} |
6834
|
|
|
|
|
|
|
|
6835
|
0
|
|
|
|
|
0
|
# elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { } |
6836
|
599
|
|
|
|
|
1214
|
elsif (/\G (\{) /oxgc) { # q { } |
6837
|
599
|
|
|
|
|
1178
|
my $q_string = ''; |
6838
|
599
|
50
|
|
|
|
1844
|
local $nest = 1; |
|
8241
|
50
|
|
|
|
39146
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6839
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6840
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6841
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\}) /oxgc) { $q_string .= $1; } |
|
114
|
|
|
|
|
177
|
|
6842
|
|
|
|
|
|
|
elsif (/\G (\\\{) /oxgc) { $q_string .= $1; } |
6843
|
114
|
100
|
|
|
|
218
|
elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; } |
|
713
|
|
|
|
|
1818
|
|
6844
|
599
|
|
|
|
|
2108
|
elsif (/\G (\}) /oxgc) { |
6845
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); } |
6846
|
114
|
|
|
|
|
243
|
else { $q_string .= $1; } |
6847
|
|
|
|
|
|
|
} |
6848
|
7414
|
|
|
|
|
15394
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6849
|
|
|
|
|
|
|
} |
6850
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6851
|
|
|
|
|
|
|
} |
6852
|
|
|
|
|
|
|
|
6853
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ] |
6854
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # q [ ] |
6855
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6856
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6857
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6858
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6859
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6860
|
|
|
|
|
|
|
elsif (/\G (\\\[) /oxgc) { $q_string .= $1; } |
6861
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6862
|
0
|
|
|
|
|
0
|
elsif (/\G (\]) /oxgc) { |
6863
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); } |
6864
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6865
|
|
|
|
|
|
|
} |
6866
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6867
|
|
|
|
|
|
|
} |
6868
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6869
|
|
|
|
|
|
|
} |
6870
|
|
|
|
|
|
|
|
6871
|
0
|
|
|
|
|
0
|
# elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < > |
6872
|
5
|
|
|
|
|
12
|
elsif (/\G (\<) /oxgc) { # q < > |
6873
|
5
|
|
|
|
|
10
|
my $q_string = ''; |
6874
|
5
|
50
|
|
|
|
19
|
local $nest = 1; |
|
82
|
50
|
|
|
|
441
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6875
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6876
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6877
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\>) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6878
|
|
|
|
|
|
|
elsif (/\G (\\\<) /oxgc) { $q_string .= $1; } |
6879
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; } |
|
5
|
|
|
|
|
16
|
|
6880
|
5
|
|
|
|
|
15
|
elsif (/\G (\>) /oxgc) { |
6881
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); } |
6882
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6883
|
|
|
|
|
|
|
} |
6884
|
77
|
|
|
|
|
161
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6885
|
|
|
|
|
|
|
} |
6886
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6887
|
|
|
|
|
|
|
} |
6888
|
|
|
|
|
|
|
|
6889
|
0
|
|
|
|
|
0
|
# elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * * |
6890
|
1
|
|
|
|
|
2
|
elsif (/\G (\S) /oxgc) { # q * * |
6891
|
1
|
|
|
|
|
3
|
my $delimiter = $1; |
6892
|
1
|
50
|
|
|
|
4
|
my $q_string = ''; |
|
14
|
50
|
|
|
|
142
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6893
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6894
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6895
|
1
|
|
|
|
|
4
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; } |
6896
|
|
|
|
|
|
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); } |
6897
|
13
|
|
|
|
|
29
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6898
|
|
|
|
|
|
|
} |
6899
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6900
|
0
|
|
|
|
|
0
|
} |
6901
|
|
|
|
|
|
|
} |
6902
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6903
|
|
|
|
|
|
|
} |
6904
|
|
|
|
|
|
|
} |
6905
|
|
|
|
|
|
|
|
6906
|
0
|
|
|
|
|
0
|
# m// |
6907
|
491
|
50
|
|
|
|
1402
|
elsif (/\G \b (m) \b /oxgc) { |
6908
|
491
|
|
|
|
|
3019
|
my $ope = $1; |
6909
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# # |
6910
|
|
|
|
|
|
|
return e_qr($ope,$1,$3,$2,$4); |
6911
|
0
|
|
|
|
|
0
|
} |
6912
|
491
|
|
|
|
|
766
|
else { |
6913
|
491
|
50
|
|
|
|
1388
|
my $e = ''; |
|
491
|
50
|
|
|
|
23525
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6914
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6915
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6916
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( ) |
6917
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { } |
6918
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ] |
6919
|
92
|
|
|
|
|
250
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < > |
6920
|
87
|
|
|
|
|
243
|
elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ? |
6921
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' ' |
6922
|
|
|
|
|
|
|
elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { } |
6923
|
312
|
|
|
|
|
1134
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * * |
6924
|
|
|
|
|
|
|
} |
6925
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6926
|
|
|
|
|
|
|
} |
6927
|
|
|
|
|
|
|
} |
6928
|
|
|
|
|
|
|
|
6929
|
|
|
|
|
|
|
# s/// |
6930
|
|
|
|
|
|
|
|
6931
|
|
|
|
|
|
|
# about [cegimosxpradlunbB]* (/cg modifier) |
6932
|
|
|
|
|
|
|
# |
6933
|
|
|
|
|
|
|
# P.67 Pattern-Matching Operators |
6934
|
|
|
|
|
|
|
# of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition. |
6935
|
0
|
|
|
|
|
0
|
|
6936
|
|
|
|
|
|
|
elsif (/\G \b (s) \b /oxgc) { |
6937
|
|
|
|
|
|
|
my $ope = $1; |
6938
|
292
|
100
|
|
|
|
958
|
|
6939
|
292
|
|
|
|
|
4846
|
# $1 $2 $3 $4 $5 $6 |
6940
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # # |
6941
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
6942
|
1
|
|
|
|
|
5
|
} |
6943
|
291
|
|
|
|
|
507
|
else { |
6944
|
291
|
50
|
|
|
|
1002
|
my $e = ''; |
|
291
|
50
|
|
|
|
32681
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6945
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6946
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6947
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
6948
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6949
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6950
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6951
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6952
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6953
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6954
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6955
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6956
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6957
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6958
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6959
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6960
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6961
|
|
|
|
|
|
|
} |
6962
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6963
|
0
|
|
|
|
|
0
|
} |
6964
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
6965
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6966
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6967
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6968
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6969
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6970
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6971
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6972
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6973
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6974
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6975
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6976
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6977
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6978
|
|
|
|
|
|
|
} |
6979
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6980
|
0
|
|
|
|
|
0
|
} |
6981
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
6982
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6983
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6984
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6985
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6986
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6987
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6988
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6989
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6990
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6991
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6992
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6993
|
|
|
|
|
|
|
} |
6994
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6995
|
0
|
|
|
|
|
0
|
} |
6996
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
6997
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6998
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6999
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7000
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7001
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7002
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7003
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7004
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7005
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7006
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7007
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7008
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7009
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7010
|
|
|
|
|
|
|
} |
7011
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7012
|
|
|
|
|
|
|
} |
7013
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
7014
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { |
7015
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7016
|
|
|
|
|
|
|
} |
7017
|
96
|
|
|
|
|
313
|
# $1 $2 $3 $4 $5 $6 |
7018
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7019
|
|
|
|
|
|
|
return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { } |
7020
|
|
|
|
|
|
|
} |
7021
|
4
|
|
|
|
|
33
|
# $1 $2 $3 $4 $5 $6 |
7022
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7023
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7024
|
|
|
|
|
|
|
} |
7025
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
7026
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7027
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7028
|
191
|
|
|
|
|
764
|
} |
7029
|
|
|
|
|
|
|
} |
7030
|
|
|
|
|
|
|
die __FILE__, ": Substitution pattern not terminated\n"; |
7031
|
|
|
|
|
|
|
} |
7032
|
|
|
|
|
|
|
} |
7033
|
0
|
|
|
|
|
0
|
|
7034
|
1
|
|
|
|
|
17
|
# do |
7035
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s*) \{ ) /oxmsgc) { return 'do'; } |
7036
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?: q | qq | qx ) \b) /oxmsgc) { return 'Egb18030::do'; } |
7037
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?>\w+)) /oxmsgc) { return 'do'; } |
7038
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s*) \$ (?> \w+ (?: ::\w+)* ) \( ) /oxmsgc) { return 'do'; } |
7039
|
|
|
|
|
|
|
elsif (/\G \b do \b /oxmsgc) { return 'Egb18030::do'; } |
7040
|
2
|
|
|
|
|
11
|
|
7041
|
0
|
|
|
|
|
0
|
# require ignore module |
7042
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; } |
7043
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\xFE#]) /oxmsgc) { return "# require$1\n$2"; } |
7044
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; } |
7045
|
0
|
|
|
|
|
0
|
|
7046
|
0
|
|
|
|
|
0
|
# require version number |
7047
|
0
|
|
|
|
|
0
|
elsif (/\G \b require (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7048
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7049
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7050
|
0
|
|
|
|
|
0
|
|
7051
|
|
|
|
|
|
|
# require bare package name |
7052
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[A-Za-z_]\w* (?: :: [A-Za-z_]\w*)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7053
|
18
|
|
|
|
|
173
|
|
7054
|
0
|
|
|
|
|
0
|
# require else |
7055
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s*) ; /oxmsgc) { return 'Egb18030::require;'; } |
7056
|
|
|
|
|
|
|
elsif (/\G \b require \b /oxmsgc) { return 'Egb18030::require'; } |
7057
|
1
|
|
|
|
|
5
|
|
7058
|
70
|
|
|
|
|
625
|
# use strict; --> use strict; no strict qw(refs); |
7059
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; } |
7060
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^\x81-\xFE#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; } |
7061
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; } |
7062
|
|
|
|
|
|
|
|
7063
|
0
|
50
|
33
|
|
|
0
|
# use 5.12.0; --> use 5.12.0; no strict qw(refs); |
|
|
|
33
|
|
|
|
|
7064
|
3
|
|
|
|
|
40
|
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7065
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) { |
7066
|
|
|
|
|
|
|
return "use $1; no strict qw(refs);"; |
7067
|
0
|
|
|
|
|
0
|
} |
7068
|
|
|
|
|
|
|
else { |
7069
|
|
|
|
|
|
|
return "use $1;"; |
7070
|
|
|
|
|
|
|
} |
7071
|
3
|
0
|
0
|
|
|
20
|
} |
|
|
|
0
|
|
|
|
|
7072
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7073
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) { |
7074
|
|
|
|
|
|
|
return "use $1; no strict qw(refs);"; |
7075
|
0
|
|
|
|
|
0
|
} |
7076
|
|
|
|
|
|
|
else { |
7077
|
|
|
|
|
|
|
return "use $1;"; |
7078
|
|
|
|
|
|
|
} |
7079
|
|
|
|
|
|
|
} |
7080
|
0
|
|
|
|
|
0
|
|
7081
|
2
|
|
|
|
|
16
|
# ignore use module |
7082
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; } |
7083
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\xFE#]) /oxmsgc) { return "# use$1\n$2"; } |
7084
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; } |
7085
|
0
|
|
|
|
|
0
|
|
7086
|
0
|
|
|
|
|
0
|
# ignore no module |
7087
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; } |
7088
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\xFE#]) /oxmsgc) { return "# no$1\n$2"; } |
7089
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; } |
7090
|
0
|
|
|
|
|
0
|
|
7091
|
0
|
|
|
|
|
0
|
# use without import |
7092
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7093
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7094
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7095
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7096
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7097
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7098
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7099
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7100
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7101
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7102
|
0
|
|
|
|
|
0
|
|
7103
|
|
|
|
|
|
|
# use with import no parameter |
7104
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_use_noparam($1); } |
7105
|
0
|
|
|
|
|
0
|
|
7106
|
0
|
|
|
|
|
0
|
# use with import parameters |
7107
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7108
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\xFE']* \') (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7109
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\xFE"]* \") (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7110
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x81-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7111
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\{) (?:$q_char)*? \}) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7112
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\[) (?:$q_char)*? \]) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7113
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x81-\xFE>]* \>) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7114
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7115
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\S) (?:$q_char)*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7116
|
0
|
|
|
|
|
0
|
|
7117
|
0
|
|
|
|
|
0
|
# no without unimport |
7118
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7119
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7120
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7121
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7122
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7123
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7124
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7125
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7126
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7127
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7128
|
0
|
|
|
|
|
0
|
|
7129
|
|
|
|
|
|
|
# no with unimport no parameter |
7130
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_no_noparam($1); } |
7131
|
0
|
|
|
|
|
0
|
|
7132
|
0
|
|
|
|
|
0
|
# no with unimport parameters |
7133
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7134
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\xFE']* \') (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7135
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\xFE"]* \") (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7136
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x81-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7137
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\{) (?:$q_char)*? \}) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7138
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\[) (?:$q_char)*? \]) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7139
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x81-\xFE>]* \>) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7140
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7141
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\S) (?:$q_char)*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7142
|
0
|
|
|
|
|
0
|
|
7143
|
|
|
|
|
|
|
# use else |
7144
|
|
|
|
|
|
|
elsif (/\G \b use \b /oxmsgc) { return "use"; } |
7145
|
0
|
|
|
|
|
0
|
|
7146
|
|
|
|
|
|
|
# use else |
7147
|
|
|
|
|
|
|
elsif (/\G \b no \b /oxmsgc) { return "no"; } |
7148
|
|
|
|
|
|
|
|
7149
|
2
|
|
|
|
|
10
|
# '' |
7150
|
3249
|
|
|
|
|
7854
|
elsif (/\G (?
|
7151
|
3249
|
100
|
|
|
|
9160
|
my $q_string = ''; |
|
16060
|
100
|
|
|
|
58699
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7152
|
8
|
|
|
|
|
19
|
while (not /\G \z/oxgc) { |
7153
|
48
|
|
|
|
|
93
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7154
|
3249
|
|
|
|
|
8303
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
7155
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); } |
7156
|
12755
|
|
|
|
|
28569
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7157
|
|
|
|
|
|
|
} |
7158
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7159
|
|
|
|
|
|
|
} |
7160
|
|
|
|
|
|
|
|
7161
|
0
|
|
|
|
|
0
|
# "" |
7162
|
3465
|
|
|
|
|
8393
|
elsif (/\G (\") /oxgc) { |
7163
|
3465
|
100
|
|
|
|
9859
|
my $qq_string = ''; |
|
72501
|
100
|
|
|
|
239510
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7164
|
109
|
|
|
|
|
241
|
while (not /\G \z/oxgc) { |
7165
|
14
|
|
|
|
|
32
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7166
|
3465
|
|
|
|
|
9789
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
7167
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); } |
7168
|
68913
|
|
|
|
|
136305
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
7169
|
|
|
|
|
|
|
} |
7170
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7171
|
|
|
|
|
|
|
} |
7172
|
|
|
|
|
|
|
|
7173
|
0
|
|
|
|
|
0
|
# `` |
7174
|
38
|
|
|
|
|
122
|
elsif (/\G (\`) /oxgc) { |
7175
|
38
|
50
|
|
|
|
155
|
my $qx_string = ''; |
|
318
|
50
|
|
|
|
2625
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7176
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7177
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qx_string .= $1; } |
7178
|
38
|
|
|
|
|
150
|
elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; } |
7179
|
|
|
|
|
|
|
elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); } |
7180
|
280
|
|
|
|
|
653
|
elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; } |
7181
|
|
|
|
|
|
|
} |
7182
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7183
|
|
|
|
|
|
|
} |
7184
|
|
|
|
|
|
|
|
7185
|
0
|
|
|
|
|
0
|
# // --- not divide operator (num / num), not defined-or |
7186
|
1239
|
|
|
|
|
3193
|
elsif (($slash eq 'm//') and /\G (\/) /oxgc) { |
7187
|
1239
|
100
|
|
|
|
4936
|
my $regexp = ''; |
|
12674
|
50
|
|
|
|
49711
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7188
|
11
|
|
|
|
|
33
|
while (not /\G \z/oxgc) { |
7189
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7190
|
1239
|
|
|
|
|
3400
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } |
7191
|
|
|
|
|
|
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); } |
7192
|
11424
|
|
|
|
|
23434
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7193
|
|
|
|
|
|
|
} |
7194
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7195
|
|
|
|
|
|
|
} |
7196
|
|
|
|
|
|
|
|
7197
|
0
|
|
|
|
|
0
|
# ?? --- not conditional operator (condition ? then : else) |
7198
|
92
|
|
|
|
|
338
|
elsif (($slash eq 'm//') and /\G (\?) /oxgc) { |
7199
|
92
|
50
|
|
|
|
287
|
my $regexp = ''; |
|
266
|
50
|
|
|
|
1096
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7200
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7201
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7202
|
92
|
|
|
|
|
305
|
elsif (/\G (\\\?) /oxgc) { $regexp .= $1; } |
7203
|
|
|
|
|
|
|
elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); } |
7204
|
174
|
|
|
|
|
439
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7205
|
|
|
|
|
|
|
} |
7206
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7207
|
|
|
|
|
|
|
} |
7208
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7209
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
7210
|
|
|
|
|
|
|
elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; } |
7211
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7212
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
7213
|
|
|
|
|
|
|
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; } |
7214
|
|
|
|
|
|
|
|
7215
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
7216
|
6
|
|
|
|
|
11
|
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
7217
|
6
|
|
|
|
|
12
|
$slash = 'm//'; |
7218
|
|
|
|
|
|
|
my $here_quote = $1; |
7219
|
|
|
|
|
|
|
my $delimiter = $2; |
7220
|
6
|
50
|
|
|
|
10
|
|
7221
|
6
|
|
|
|
|
11
|
# get here document |
7222
|
6
|
|
|
|
|
54
|
if ($here_script eq '') { |
7223
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7224
|
6
|
50
|
|
|
|
31
|
$here_script =~ s/.*?\n//oxm; |
7225
|
6
|
|
|
|
|
66
|
} |
7226
|
6
|
|
|
|
|
13
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7227
|
6
|
|
|
|
|
11
|
my $heredoc = $1; |
7228
|
6
|
|
|
|
|
48
|
my $indent = $2; |
7229
|
6
|
|
|
|
|
18
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7230
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7231
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7232
|
6
|
|
|
|
|
13
|
} |
7233
|
|
|
|
|
|
|
else { |
7234
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7235
|
|
|
|
|
|
|
} |
7236
|
|
|
|
|
|
|
return qq{<<'$delimiter'}; |
7237
|
|
|
|
|
|
|
} |
7238
|
|
|
|
|
|
|
|
7239
|
|
|
|
|
|
|
# <<~\HEREDOC |
7240
|
|
|
|
|
|
|
|
7241
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7242
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7243
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7244
|
|
|
|
|
|
|
|
7245
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7246
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7247
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7248
|
6
|
|
|
|
|
33
|
|
7249
|
3
|
|
|
|
|
7
|
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
7250
|
3
|
|
|
|
|
9
|
$slash = 'm//'; |
7251
|
|
|
|
|
|
|
my $here_quote = $1; |
7252
|
|
|
|
|
|
|
my $delimiter = $2; |
7253
|
3
|
50
|
|
|
|
8
|
|
7254
|
3
|
|
|
|
|
8
|
# get here document |
7255
|
3
|
|
|
|
|
15
|
if ($here_script eq '') { |
7256
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7257
|
3
|
50
|
|
|
|
16
|
$here_script =~ s/.*?\n//oxm; |
7258
|
3
|
|
|
|
|
40
|
} |
7259
|
3
|
|
|
|
|
8
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7260
|
3
|
|
|
|
|
4
|
my $heredoc = $1; |
7261
|
3
|
|
|
|
|
38
|
my $indent = $2; |
7262
|
3
|
|
|
|
|
12
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7263
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7264
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7265
|
3
|
|
|
|
|
7
|
} |
7266
|
|
|
|
|
|
|
else { |
7267
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7268
|
|
|
|
|
|
|
} |
7269
|
|
|
|
|
|
|
return qq{<<\\$delimiter}; |
7270
|
|
|
|
|
|
|
} |
7271
|
|
|
|
|
|
|
|
7272
|
3
|
|
|
|
|
13
|
# <<~"HEREDOC" |
7273
|
6
|
|
|
|
|
26
|
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
7274
|
6
|
|
|
|
|
15
|
$slash = 'm//'; |
7275
|
|
|
|
|
|
|
my $here_quote = $1; |
7276
|
|
|
|
|
|
|
my $delimiter = $2; |
7277
|
6
|
50
|
|
|
|
9
|
|
7278
|
6
|
|
|
|
|
13
|
# get here document |
7279
|
6
|
|
|
|
|
19
|
if ($here_script eq '') { |
7280
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7281
|
6
|
50
|
|
|
|
32
|
$here_script =~ s/.*?\n//oxm; |
7282
|
6
|
|
|
|
|
53
|
} |
7283
|
6
|
|
|
|
|
15
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7284
|
6
|
|
|
|
|
14
|
my $heredoc = $1; |
7285
|
6
|
|
|
|
|
47
|
my $indent = $2; |
7286
|
6
|
|
|
|
|
16
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7287
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7288
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7289
|
6
|
|
|
|
|
15
|
} |
7290
|
|
|
|
|
|
|
else { |
7291
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7292
|
|
|
|
|
|
|
} |
7293
|
|
|
|
|
|
|
return qq{<<"$delimiter"}; |
7294
|
|
|
|
|
|
|
} |
7295
|
|
|
|
|
|
|
|
7296
|
6
|
|
|
|
|
22
|
# <<~HEREDOC |
7297
|
3
|
|
|
|
|
8
|
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
7298
|
3
|
|
|
|
|
9
|
$slash = 'm//'; |
7299
|
|
|
|
|
|
|
my $here_quote = $1; |
7300
|
|
|
|
|
|
|
my $delimiter = $2; |
7301
|
3
|
50
|
|
|
|
5
|
|
7302
|
3
|
|
|
|
|
9
|
# get here document |
7303
|
3
|
|
|
|
|
25
|
if ($here_script eq '') { |
7304
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7305
|
3
|
50
|
|
|
|
17
|
$here_script =~ s/.*?\n//oxm; |
7306
|
3
|
|
|
|
|
39
|
} |
7307
|
3
|
|
|
|
|
6
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7308
|
3
|
|
|
|
|
6
|
my $heredoc = $1; |
7309
|
3
|
|
|
|
|
36
|
my $indent = $2; |
7310
|
3
|
|
|
|
|
10
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7311
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7312
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7313
|
3
|
|
|
|
|
8
|
} |
7314
|
|
|
|
|
|
|
else { |
7315
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7316
|
|
|
|
|
|
|
} |
7317
|
|
|
|
|
|
|
return qq{<<$delimiter}; |
7318
|
|
|
|
|
|
|
} |
7319
|
|
|
|
|
|
|
|
7320
|
3
|
|
|
|
|
14
|
# <<~`HEREDOC` |
7321
|
6
|
|
|
|
|
13
|
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
7322
|
6
|
|
|
|
|
12
|
$slash = 'm//'; |
7323
|
|
|
|
|
|
|
my $here_quote = $1; |
7324
|
|
|
|
|
|
|
my $delimiter = $2; |
7325
|
6
|
50
|
|
|
|
10
|
|
7326
|
6
|
|
|
|
|
14
|
# get here document |
7327
|
6
|
|
|
|
|
26
|
if ($here_script eq '') { |
7328
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7329
|
6
|
50
|
|
|
|
29
|
$here_script =~ s/.*?\n//oxm; |
7330
|
6
|
|
|
|
|
74
|
} |
7331
|
6
|
|
|
|
|
22
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7332
|
6
|
|
|
|
|
8
|
my $heredoc = $1; |
7333
|
6
|
|
|
|
|
49
|
my $indent = $2; |
7334
|
6
|
|
|
|
|
16
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7335
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7336
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7337
|
6
|
|
|
|
|
13
|
} |
7338
|
|
|
|
|
|
|
else { |
7339
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7340
|
|
|
|
|
|
|
} |
7341
|
|
|
|
|
|
|
return qq{<<`$delimiter`}; |
7342
|
|
|
|
|
|
|
} |
7343
|
|
|
|
|
|
|
|
7344
|
6
|
|
|
|
|
21
|
# <<'HEREDOC' |
7345
|
86
|
|
|
|
|
196
|
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
7346
|
86
|
|
|
|
|
194
|
$slash = 'm//'; |
7347
|
|
|
|
|
|
|
my $here_quote = $1; |
7348
|
|
|
|
|
|
|
my $delimiter = $2; |
7349
|
86
|
100
|
|
|
|
146
|
|
7350
|
86
|
|
|
|
|
254
|
# get here document |
7351
|
83
|
|
|
|
|
409
|
if ($here_script eq '') { |
7352
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7353
|
83
|
50
|
|
|
|
463
|
$here_script =~ s/.*?\n//oxm; |
7354
|
86
|
|
|
|
|
678
|
} |
7355
|
86
|
|
|
|
|
281
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7356
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7357
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7358
|
86
|
|
|
|
|
136
|
} |
7359
|
|
|
|
|
|
|
else { |
7360
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7361
|
|
|
|
|
|
|
} |
7362
|
|
|
|
|
|
|
return $here_quote; |
7363
|
|
|
|
|
|
|
} |
7364
|
|
|
|
|
|
|
|
7365
|
|
|
|
|
|
|
# <<\HEREDOC |
7366
|
|
|
|
|
|
|
|
7367
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7368
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7369
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7370
|
|
|
|
|
|
|
|
7371
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7372
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7373
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7374
|
86
|
|
|
|
|
330
|
|
7375
|
2
|
|
|
|
|
6
|
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
7376
|
2
|
|
|
|
|
5
|
$slash = 'm//'; |
7377
|
|
|
|
|
|
|
my $here_quote = $1; |
7378
|
|
|
|
|
|
|
my $delimiter = $2; |
7379
|
2
|
100
|
|
|
|
4
|
|
7380
|
2
|
|
|
|
|
5
|
# get here document |
7381
|
1
|
|
|
|
|
6
|
if ($here_script eq '') { |
7382
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7383
|
1
|
50
|
|
|
|
6
|
$here_script =~ s/.*?\n//oxm; |
7384
|
2
|
|
|
|
|
26
|
} |
7385
|
2
|
|
|
|
|
7
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7386
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7387
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7388
|
2
|
|
|
|
|
10
|
} |
7389
|
|
|
|
|
|
|
else { |
7390
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7391
|
|
|
|
|
|
|
} |
7392
|
|
|
|
|
|
|
return $here_quote; |
7393
|
|
|
|
|
|
|
} |
7394
|
|
|
|
|
|
|
|
7395
|
2
|
|
|
|
|
12
|
# <<"HEREDOC" |
7396
|
39
|
|
|
|
|
131
|
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
7397
|
39
|
|
|
|
|
101
|
$slash = 'm//'; |
7398
|
|
|
|
|
|
|
my $here_quote = $1; |
7399
|
|
|
|
|
|
|
my $delimiter = $2; |
7400
|
39
|
100
|
|
|
|
74
|
|
7401
|
39
|
|
|
|
|
100
|
# get here document |
7402
|
38
|
|
|
|
|
242
|
if ($here_script eq '') { |
7403
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7404
|
38
|
50
|
|
|
|
214
|
$here_script =~ s/.*?\n//oxm; |
7405
|
39
|
|
|
|
|
467
|
} |
7406
|
39
|
|
|
|
|
128
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7407
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7408
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7409
|
39
|
|
|
|
|
93
|
} |
7410
|
|
|
|
|
|
|
else { |
7411
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7412
|
|
|
|
|
|
|
} |
7413
|
|
|
|
|
|
|
return $here_quote; |
7414
|
|
|
|
|
|
|
} |
7415
|
|
|
|
|
|
|
|
7416
|
39
|
|
|
|
|
167
|
# <
|
7417
|
60
|
|
|
|
|
156
|
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
7418
|
60
|
|
|
|
|
144
|
$slash = 'm//'; |
7419
|
|
|
|
|
|
|
my $here_quote = $1; |
7420
|
|
|
|
|
|
|
my $delimiter = $2; |
7421
|
60
|
100
|
|
|
|
109
|
|
7422
|
60
|
|
|
|
|
162
|
# get here document |
7423
|
57
|
|
|
|
|
350
|
if ($here_script eq '') { |
7424
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7425
|
57
|
50
|
|
|
|
448
|
$here_script =~ s/.*?\n//oxm; |
7426
|
60
|
|
|
|
|
730
|
} |
7427
|
60
|
|
|
|
|
204
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7428
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7429
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7430
|
60
|
|
|
|
|
128
|
} |
7431
|
|
|
|
|
|
|
else { |
7432
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7433
|
|
|
|
|
|
|
} |
7434
|
|
|
|
|
|
|
return $here_quote; |
7435
|
|
|
|
|
|
|
} |
7436
|
|
|
|
|
|
|
|
7437
|
60
|
|
|
|
|
348
|
# <<`HEREDOC` |
7438
|
0
|
|
|
|
|
0
|
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
7439
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7440
|
|
|
|
|
|
|
my $here_quote = $1; |
7441
|
|
|
|
|
|
|
my $delimiter = $2; |
7442
|
0
|
0
|
|
|
|
0
|
|
7443
|
0
|
|
|
|
|
0
|
# get here document |
7444
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
7445
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7446
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
7447
|
0
|
|
|
|
|
0
|
} |
7448
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7449
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7450
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7451
|
0
|
|
|
|
|
0
|
} |
7452
|
|
|
|
|
|
|
else { |
7453
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7454
|
|
|
|
|
|
|
} |
7455
|
|
|
|
|
|
|
return $here_quote; |
7456
|
|
|
|
|
|
|
} |
7457
|
|
|
|
|
|
|
|
7458
|
0
|
|
|
|
|
0
|
# <<= <=> <= < operator |
7459
|
|
|
|
|
|
|
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { |
7460
|
|
|
|
|
|
|
return $1; |
7461
|
|
|
|
|
|
|
} |
7462
|
|
|
|
|
|
|
|
7463
|
13
|
|
|
|
|
82
|
# |
7464
|
|
|
|
|
|
|
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { |
7465
|
|
|
|
|
|
|
return $1; |
7466
|
|
|
|
|
|
|
} |
7467
|
|
|
|
|
|
|
|
7468
|
|
|
|
|
|
|
# --- glob |
7469
|
|
|
|
|
|
|
|
7470
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7471
|
0
|
|
|
|
|
0
|
|
7472
|
|
|
|
|
|
|
elsif (/\G < ((?:[^\x81-\xFE>\0\a\e\f\n\r\t]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF])+?) > /oxgc) { |
7473
|
|
|
|
|
|
|
return 'Egb18030::glob("' . $1 . '")'; |
7474
|
|
|
|
|
|
|
} |
7475
|
0
|
|
|
|
|
0
|
|
7476
|
|
|
|
|
|
|
# __DATA__ |
7477
|
|
|
|
|
|
|
elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; } |
7478
|
0
|
|
|
|
|
0
|
|
7479
|
|
|
|
|
|
|
# __END__ |
7480
|
|
|
|
|
|
|
elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; } |
7481
|
|
|
|
|
|
|
|
7482
|
|
|
|
|
|
|
# \cD Control-D |
7483
|
|
|
|
|
|
|
|
7484
|
|
|
|
|
|
|
# P.68 2.6.8. Other Literal Tokens |
7485
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7486
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7487
|
|
|
|
|
|
|
|
7488
|
|
|
|
|
|
|
# P.76 Other Literal Tokens |
7489
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7490
|
384
|
|
|
|
|
3209
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7491
|
|
|
|
|
|
|
|
7492
|
|
|
|
|
|
|
elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; } |
7493
|
0
|
|
|
|
|
0
|
|
7494
|
|
|
|
|
|
|
# \cZ Control-Z |
7495
|
|
|
|
|
|
|
elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; } |
7496
|
|
|
|
|
|
|
|
7497
|
|
|
|
|
|
|
# any operator before div |
7498
|
|
|
|
|
|
|
elsif (/\G ( |
7499
|
|
|
|
|
|
|
-- | \+\+ | |
7500
|
0
|
|
|
|
|
0
|
[\)\}\]] |
|
14318
|
|
|
|
|
32193
|
|
7501
|
|
|
|
|
|
|
|
7502
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; return $1; } |
7503
|
|
|
|
|
|
|
|
7504
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
7505
|
|
|
|
|
|
|
elsif (/\G ( |
7506
|
14318
|
|
|
|
|
73225
|
\.\.\. |
|
7
|
|
|
|
|
16
|
|
7507
|
|
|
|
|
|
|
|
7508
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; } |
7509
|
|
|
|
|
|
|
|
7510
|
|
|
|
|
|
|
# any operator before m// |
7511
|
|
|
|
|
|
|
|
7512
|
|
|
|
|
|
|
# //, //= (defined-or) |
7513
|
|
|
|
|
|
|
|
7514
|
|
|
|
|
|
|
# P.164 Logical Operators |
7515
|
|
|
|
|
|
|
# in Chapter 10: More Control Structures |
7516
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7517
|
|
|
|
|
|
|
|
7518
|
|
|
|
|
|
|
# P.119 C-Style Logical (Short-Circuit) Operators |
7519
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7520
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7521
|
|
|
|
|
|
|
|
7522
|
|
|
|
|
|
|
# (and so on) |
7523
|
|
|
|
|
|
|
|
7524
|
|
|
|
|
|
|
# ~~ |
7525
|
|
|
|
|
|
|
|
7526
|
|
|
|
|
|
|
# P.221 The Smart Match Operator |
7527
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
7528
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7529
|
|
|
|
|
|
|
|
7530
|
|
|
|
|
|
|
# P.112 Smartmatch Operator |
7531
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7532
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7533
|
|
|
|
|
|
|
|
7534
|
|
|
|
|
|
|
# (and so on) |
7535
|
|
|
|
|
|
|
|
7536
|
|
|
|
|
|
|
elsif (/\G ((?> |
7537
|
|
|
|
|
|
|
|
7538
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
7539
|
|
|
|
|
|
|
%= | % | |
7540
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
7541
|
|
|
|
|
|
|
-= | -> | - | |
7542
|
|
|
|
|
|
|
:(?>\s*)= | |
7543
|
|
|
|
|
|
|
: | |
7544
|
|
|
|
|
|
|
<<>> | |
7545
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
7546
|
|
|
|
|
|
|
== | => | =~ | = | |
7547
|
|
|
|
|
|
|
>>= | >> | >= | > | |
7548
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
7549
|
|
|
|
|
|
|
\+= | \+ | |
7550
|
|
|
|
|
|
|
\.\. | \.= | \. | |
7551
|
|
|
|
|
|
|
\/\/= | \/\/ | |
7552
|
|
|
|
|
|
|
\/= | \/ | |
7553
|
|
|
|
|
|
|
\? | |
7554
|
|
|
|
|
|
|
\\ | |
7555
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
7556
|
|
|
|
|
|
|
\b x= | |
7557
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
7558
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
7559
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
7560
|
|
|
|
|
|
|
\b(?: print )\b | |
7561
|
|
|
|
|
|
|
|
7562
|
7
|
|
|
|
|
27
|
[,;\(\{\[] |
|
24138
|
|
|
|
|
55258
|
|
7563
|
|
|
|
|
|
|
|
7564
|
|
|
|
|
|
|
)) /oxgc) { $slash = 'm//'; return $1; } |
7565
|
24138
|
|
|
|
|
117599
|
|
|
38055
|
|
|
|
|
83725
|
|
7566
|
|
|
|
|
|
|
# other any character |
7567
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; } |
7568
|
|
|
|
|
|
|
|
7569
|
38055
|
|
|
|
|
224906
|
# system error |
7570
|
|
|
|
|
|
|
else { |
7571
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
7572
|
|
|
|
|
|
|
} |
7573
|
|
|
|
|
|
|
} |
7574
|
|
|
|
|
|
|
|
7575
|
0
|
|
|
3279
|
0
|
0
|
# escape GB18030 string |
7576
|
3279
|
|
|
|
|
7813
|
sub e_string { |
7577
|
|
|
|
|
|
|
my($string) = @_; |
7578
|
3279
|
|
|
|
|
4751
|
my $e_string = ''; |
7579
|
|
|
|
|
|
|
|
7580
|
|
|
|
|
|
|
local $slash = 'm//'; |
7581
|
|
|
|
|
|
|
|
7582
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
7583
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
7584
|
3279
|
|
|
|
|
5082
|
# (and so on) |
7585
|
|
|
|
|
|
|
|
7586
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>[^\x81-\xFE\\]|\\$q_char|$q_char) /oxmsg; |
7587
|
3279
|
100
|
66
|
|
|
33040
|
|
7588
|
3279
|
50
|
|
|
|
16451
|
# without { ... } |
7589
|
3200
|
|
|
|
|
7093
|
if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) { |
7590
|
|
|
|
|
|
|
if ($string !~ /<
|
7591
|
|
|
|
|
|
|
return $string; |
7592
|
|
|
|
|
|
|
} |
7593
|
|
|
|
|
|
|
} |
7594
|
3200
|
|
|
|
|
8404
|
|
7595
|
79
|
50
|
|
|
|
231
|
E_STRING_LOOP: |
|
|
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
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7596
|
|
|
|
|
|
|
while ($string !~ /\G \z/oxgc) { |
7597
|
|
|
|
|
|
|
if (0) { |
7598
|
|
|
|
|
|
|
} |
7599
|
606
|
|
|
|
|
121459
|
|
7600
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Egb18030::PREMATCH()]} |
7601
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
7602
|
|
|
|
|
|
|
$e_string .= q{Egb18030::PREMATCH()}; |
7603
|
|
|
|
|
|
|
$slash = 'div'; |
7604
|
|
|
|
|
|
|
} |
7605
|
|
|
|
|
|
|
|
7606
|
0
|
|
|
|
|
0
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Egb18030::MATCH()]} |
7607
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
7608
|
|
|
|
|
|
|
$e_string .= q{Egb18030::MATCH()}; |
7609
|
|
|
|
|
|
|
$slash = 'div'; |
7610
|
|
|
|
|
|
|
} |
7611
|
|
|
|
|
|
|
|
7612
|
0
|
|
|
|
|
0
|
# $', ${'} --> $', ${'} |
7613
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) { |
7614
|
|
|
|
|
|
|
$e_string .= $1; |
7615
|
|
|
|
|
|
|
$slash = 'div'; |
7616
|
|
|
|
|
|
|
} |
7617
|
|
|
|
|
|
|
|
7618
|
0
|
|
|
|
|
0
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Egb18030::POSTMATCH()]} |
7619
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
7620
|
|
|
|
|
|
|
$e_string .= q{Egb18030::POSTMATCH()}; |
7621
|
|
|
|
|
|
|
$slash = 'div'; |
7622
|
|
|
|
|
|
|
} |
7623
|
|
|
|
|
|
|
|
7624
|
0
|
|
|
|
|
0
|
# bareword |
7625
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
7626
|
|
|
|
|
|
|
$e_string .= $1; |
7627
|
|
|
|
|
|
|
$slash = 'div'; |
7628
|
|
|
|
|
|
|
} |
7629
|
|
|
|
|
|
|
|
7630
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
7631
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) { |
7632
|
|
|
|
|
|
|
$e_string .= $1; |
7633
|
|
|
|
|
|
|
$slash = 'div'; |
7634
|
0
|
|
|
|
|
0
|
} |
7635
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
7636
|
|
|
|
|
|
|
$e_string .= $1; |
7637
|
|
|
|
|
|
|
$slash = 'div'; |
7638
|
|
|
|
|
|
|
} |
7639
|
|
|
|
|
|
|
|
7640
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
7641
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
7642
|
|
|
|
|
|
|
$e_string .= $1; |
7643
|
|
|
|
|
|
|
$slash = 'div'; |
7644
|
|
|
|
|
|
|
} |
7645
|
|
|
|
|
|
|
|
7646
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
7647
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
7648
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
7649
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7650
|
|
|
|
|
|
|
$slash = 'div'; |
7651
|
0
|
|
|
|
|
0
|
} |
7652
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
7653
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7654
|
|
|
|
|
|
|
$slash = 'div'; |
7655
|
|
|
|
|
|
|
} |
7656
|
|
|
|
|
|
|
|
7657
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
7658
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
7659
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7660
|
|
|
|
|
|
|
$slash = 'div'; |
7661
|
|
|
|
|
|
|
} |
7662
|
|
|
|
|
|
|
|
7663
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
7664
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
7665
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7666
|
|
|
|
|
|
|
$slash = 'div'; |
7667
|
|
|
|
|
|
|
} |
7668
|
|
|
|
|
|
|
|
7669
|
0
|
|
|
|
|
0
|
# $$foo |
7670
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
7671
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7672
|
|
|
|
|
|
|
$slash = 'div'; |
7673
|
|
|
|
|
|
|
} |
7674
|
|
|
|
|
|
|
|
7675
|
0
|
|
|
|
|
0
|
# ${ foo } |
7676
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) { |
7677
|
|
|
|
|
|
|
$e_string .= '${' . $1 . '}'; |
7678
|
|
|
|
|
|
|
$slash = 'div'; |
7679
|
|
|
|
|
|
|
} |
7680
|
|
|
|
|
|
|
|
7681
|
0
|
|
|
|
|
0
|
# ${ ... } |
7682
|
3
|
|
|
|
|
9
|
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
7683
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7684
|
|
|
|
|
|
|
$slash = 'div'; |
7685
|
|
|
|
|
|
|
} |
7686
|
|
|
|
|
|
|
|
7687
|
|
|
|
|
|
|
# variable or function |
7688
|
3
|
|
|
|
|
14
|
# $ @ % & * $ # |
7689
|
0
|
|
|
|
|
0
|
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) { |
7690
|
|
|
|
|
|
|
$e_string .= $1; |
7691
|
|
|
|
|
|
|
$slash = 'div'; |
7692
|
|
|
|
|
|
|
} |
7693
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
7694
|
0
|
|
|
|
|
0
|
# $ @ # \ ' " / ? ( ) [ ] < > |
7695
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
7696
|
|
|
|
|
|
|
$e_string .= $1; |
7697
|
|
|
|
|
|
|
$slash = 'div'; |
7698
|
|
|
|
|
|
|
} |
7699
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7700
|
0
|
|
|
|
|
0
|
# subroutines of package Egb18030 |
|
0
|
|
|
|
|
0
|
|
7701
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7702
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7703
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b GB18030::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7704
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7705
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b GB18030::eval \b /oxgc) { $e_string .= 'eval GB18030::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7706
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7707
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Egb18030::chop'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7708
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7709
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7710
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b GB18030::index \b /oxgc) { $e_string .= 'GB18030::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7711
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Egb18030::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7712
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7713
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7714
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b GB18030::rindex \b /oxgc) { $e_string .= 'GB18030::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7715
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Egb18030::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7716
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::lc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7717
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::lcfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7718
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::uc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7719
|
|
|
|
|
|
|
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::ucfirst'; $slash = 'm//'; } |
7720
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::fc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7721
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7722
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7723
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7724
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7725
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7726
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
9
|
|
7727
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7728
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7729
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
7730
|
1
|
|
|
|
|
4
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7731
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7732
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7733
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7734
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7735
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
8
|
|
7736
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7737
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Egb18030::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7738
|
1
|
|
|
|
|
4
|
|
|
0
|
|
|
|
|
0
|
|
7739
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7740
|
0
|
|
|
|
|
0
|
{ $e_string .= "Egb18030::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7741
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Egb18030::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7742
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $e_string .= "Egb18030::filetest qw($1),"; $slash = 'm//'; } |
7743
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $e_string .= "Egb18030::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7744
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7745
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7746
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7747
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7748
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7749
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
10
|
|
7750
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7751
|
2
|
|
|
|
|
8
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Egb18030::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
6
|
|
7752
|
1
|
|
|
|
|
4
|
|
|
0
|
|
|
|
|
0
|
|
7753
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7754
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7755
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7756
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7757
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
16
|
|
7758
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7759
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Egb18030::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7760
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
7761
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7762
|
0
|
|
|
|
|
0
|
{ $e_string .= "Egb18030::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7763
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Egb18030::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7764
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= "Egb18030::$1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7765
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "Egb18030::$1(::"."$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7766
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-t $2"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7767
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::lstat'; $slash = 'm//'; } |
7768
|
|
|
|
|
|
|
elsif ($string =~ /\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::stat'; $slash = 'm//'; } |
7769
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7770
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
7771
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7772
|
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
|
|
7773
|
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
|
|
7774
|
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
|
|
7775
|
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
|
|
7776
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
7777
|
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
|
|
7778
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7779
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7780
|
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
|
|
7781
|
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
|
|
7782
|
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
|
|
7783
|
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
|
|
7784
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
7785
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
7786
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7787
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7788
|
0
|
|
|
|
|
0
|
{ $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7789
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7790
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; } |
7791
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7792
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7793
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7794
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7795
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7796
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7797
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7798
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Egb18030::glob'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7799
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Egb18030::lc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7800
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Egb18030::lcfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7801
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Egb18030::uc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7802
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Egb18030::ucfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7803
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Egb18030::fc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7804
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat \b /oxgc) { $e_string .= 'Egb18030::lstat_'; $slash = 'm//'; } |
7805
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat \b /oxgc) { $e_string .= 'Egb18030::stat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7806
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7807
|
0
|
|
|
|
|
0
|
\b /oxgc) { $e_string .= "Egb18030::filetest_(qw($1))"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7808
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) \b /oxgc) { $e_string .= "Egb18030::${1}_"; $slash = 'm//'; } |
7809
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7810
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7811
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7812
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7813
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Egb18030::chr_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7814
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7815
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7816
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Egb18030::glob_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7817
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7818
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7819
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Egb18030::opendir$1*"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7820
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Egb18030::opendir$1*"; $slash = 'm//'; } |
7821
|
|
|
|
|
|
|
elsif ($string =~ /\G \b unlink \b /oxgc) { $e_string .= 'Egb18030::unlink'; $slash = 'm//'; } |
7822
|
|
|
|
|
|
|
|
7823
|
0
|
|
|
|
|
0
|
# chdir |
7824
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
7825
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7826
|
|
|
|
|
|
|
|
7827
|
0
|
|
|
|
|
0
|
$e_string .= 'Egb18030::chdir'; |
7828
|
0
|
|
|
|
|
0
|
|
7829
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
7830
|
|
|
|
|
|
|
$e_string .= $1; |
7831
|
|
|
|
|
|
|
} |
7832
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7833
|
|
|
|
|
|
|
# end of chdir |
7834
|
|
|
|
|
|
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return $e_string; } |
7835
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7836
|
|
|
|
|
|
|
# chdir scalar value |
7837
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= e_string($1); next E_STRING_LOOP; } |
7838
|
|
|
|
|
|
|
|
7839
|
0
|
0
|
|
|
|
0
|
# chdir qq// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7840
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
7841
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq# # --> qr # # |
7842
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7843
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7844
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7845
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7846
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7847
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7848
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7849
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq','{','}',$2); next E_STRING_LOOP; } # qq | | --> qr { } |
7850
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq * * --> qr * * |
7851
|
|
|
|
|
|
|
} |
7852
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7853
|
|
|
|
|
|
|
} |
7854
|
|
|
|
|
|
|
} |
7855
|
|
|
|
|
|
|
|
7856
|
0
|
0
|
|
|
|
0
|
# chdir q// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7857
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
7858
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q# # --> qr # # |
7859
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7860
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7861
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7862
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7863
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7864
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7865
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7866
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q','{','}',$2); next E_STRING_LOOP; } # q | | --> qr { } |
7867
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q * * --> qr * * |
7868
|
|
|
|
|
|
|
} |
7869
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7870
|
|
|
|
|
|
|
} |
7871
|
|
|
|
|
|
|
} |
7872
|
|
|
|
|
|
|
|
7873
|
0
|
|
|
|
|
0
|
# chdir '' |
7874
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
7875
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7876
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
7877
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7878
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } |
7879
|
|
|
|
|
|
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_chdir_q('',"'","'",$q_string); next E_STRING_LOOP; } |
7880
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
7881
|
|
|
|
|
|
|
} |
7882
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7883
|
|
|
|
|
|
|
} |
7884
|
|
|
|
|
|
|
|
7885
|
0
|
|
|
|
|
0
|
# chdir "" |
7886
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
7887
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7888
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
7889
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7890
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } |
7891
|
|
|
|
|
|
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_chdir('','"','"',$qq_string); next E_STRING_LOOP; } |
7892
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
7893
|
|
|
|
|
|
|
} |
7894
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7895
|
|
|
|
|
|
|
} |
7896
|
|
|
|
|
|
|
} |
7897
|
|
|
|
|
|
|
|
7898
|
0
|
|
|
|
|
0
|
# split |
7899
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
7900
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7901
|
0
|
|
|
|
|
0
|
|
7902
|
0
|
|
|
|
|
0
|
my $e = ''; |
7903
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
7904
|
|
|
|
|
|
|
$e .= $1; |
7905
|
|
|
|
|
|
|
} |
7906
|
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
|
|
|
|
|
|
7907
|
|
|
|
|
|
|
# end of split |
7908
|
|
|
|
|
|
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Egb18030::split' . $e; } |
7909
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7910
|
|
|
|
|
|
|
# split scalar value |
7911
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Egb18030::split' . $e . e_string($1); next E_STRING_LOOP; } |
7912
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7913
|
0
|
|
|
|
|
0
|
# split literal space |
|
0
|
|
|
|
|
0
|
|
7914
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7915
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7916
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7917
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7918
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7919
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7920
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7921
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7922
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7923
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7924
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7925
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7926
|
|
|
|
|
|
|
elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {' '}; next E_STRING_LOOP; } |
7927
|
|
|
|
|
|
|
elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Egb18030::split' . $e . qq {" "}; next E_STRING_LOOP; } |
7928
|
|
|
|
|
|
|
|
7929
|
0
|
0
|
|
|
|
0
|
# split qq// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7930
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
7931
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq# # --> qr # # |
7932
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7933
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7934
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7935
|
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
|
|
7936
|
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
|
|
7937
|
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
|
|
7938
|
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
|
|
7939
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { } |
7940
|
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 * * |
7941
|
|
|
|
|
|
|
} |
7942
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7943
|
|
|
|
|
|
|
} |
7944
|
|
|
|
|
|
|
} |
7945
|
|
|
|
|
|
|
|
7946
|
0
|
0
|
|
|
|
0
|
# split qr// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7947
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qr) \b /oxgc) { |
7948
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # qr# # |
7949
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7950
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7951
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7952
|
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
|
|
7953
|
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
|
|
7954
|
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
|
|
7955
|
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
|
|
7956
|
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
|
|
7957
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { } |
7958
|
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 * * |
7959
|
|
|
|
|
|
|
} |
7960
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7961
|
|
|
|
|
|
|
} |
7962
|
|
|
|
|
|
|
} |
7963
|
|
|
|
|
|
|
|
7964
|
0
|
0
|
|
|
|
0
|
# split q// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7965
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
7966
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q# # --> qr # # |
7967
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7968
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7969
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7970
|
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
|
|
7971
|
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
|
|
7972
|
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
|
|
7973
|
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
|
|
7974
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { } |
7975
|
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 * * |
7976
|
|
|
|
|
|
|
} |
7977
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7978
|
|
|
|
|
|
|
} |
7979
|
|
|
|
|
|
|
} |
7980
|
|
|
|
|
|
|
|
7981
|
0
|
0
|
|
|
|
0
|
# split m// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7982
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (m) \b /oxgc) { |
7983
|
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 # # |
7984
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7985
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7986
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7987
|
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
|
|
7988
|
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
|
|
7989
|
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
|
|
7990
|
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
|
|
7991
|
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
|
|
7992
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { } |
7993
|
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 * * |
7994
|
|
|
|
|
|
|
} |
7995
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7996
|
|
|
|
|
|
|
} |
7997
|
|
|
|
|
|
|
} |
7998
|
|
|
|
|
|
|
|
7999
|
0
|
|
|
|
|
0
|
# split '' |
8000
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
8001
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8002
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
8003
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8004
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
8005
|
|
|
|
|
|
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' ' |
8006
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
8007
|
|
|
|
|
|
|
} |
8008
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8009
|
|
|
|
|
|
|
} |
8010
|
|
|
|
|
|
|
|
8011
|
0
|
|
|
|
|
0
|
# split "" |
8012
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
8013
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8014
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
8015
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8016
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
8017
|
|
|
|
|
|
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " " |
8018
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8019
|
|
|
|
|
|
|
} |
8020
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8021
|
|
|
|
|
|
|
} |
8022
|
|
|
|
|
|
|
|
8023
|
0
|
|
|
|
|
0
|
# split // |
8024
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\/) /oxgc) { |
8025
|
0
|
0
|
|
|
|
0
|
my $regexp = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8026
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
8027
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; } |
|
0
|
|
|
|
|
0
|
|
8028
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
8029
|
|
|
|
|
|
|
elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / / |
8030
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; } |
8031
|
|
|
|
|
|
|
} |
8032
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8033
|
|
|
|
|
|
|
} |
8034
|
|
|
|
|
|
|
} |
8035
|
|
|
|
|
|
|
|
8036
|
0
|
|
|
|
|
0
|
# qq// |
8037
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8038
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8039
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# # |
8040
|
|
|
|
|
|
|
$e_string .= e_qq($ope,$1,$3,$2); |
8041
|
0
|
|
|
|
|
0
|
} |
8042
|
0
|
|
|
|
|
0
|
else { |
8043
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8044
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8045
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8046
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( ) |
|
0
|
|
|
|
|
0
|
|
8047
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { } |
|
0
|
|
|
|
|
0
|
|
8048
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ] |
|
0
|
|
|
|
|
0
|
|
8049
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < > |
8050
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * * |
8051
|
|
|
|
|
|
|
} |
8052
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8053
|
|
|
|
|
|
|
} |
8054
|
|
|
|
|
|
|
} |
8055
|
|
|
|
|
|
|
|
8056
|
0
|
|
|
|
|
0
|
# qx// |
8057
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (qx) \b /oxgc) { |
8058
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8059
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
8060
|
|
|
|
|
|
|
$e_string .= e_qq($ope,$1,$3,$2); |
8061
|
0
|
|
|
|
|
0
|
} |
8062
|
0
|
|
|
|
|
0
|
else { |
8063
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8064
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8065
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8066
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( ) |
|
0
|
|
|
|
|
0
|
|
8067
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { } |
|
0
|
|
|
|
|
0
|
|
8068
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ] |
|
0
|
|
|
|
|
0
|
|
8069
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < > |
|
0
|
|
|
|
|
0
|
|
8070
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' ' |
8071
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * * |
8072
|
|
|
|
|
|
|
} |
8073
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8074
|
|
|
|
|
|
|
} |
8075
|
|
|
|
|
|
|
} |
8076
|
|
|
|
|
|
|
|
8077
|
0
|
|
|
|
|
0
|
# q// |
8078
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8079
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8080
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# # |
8081
|
|
|
|
|
|
|
$e_string .= e_q($ope,$1,$3,$2); |
8082
|
0
|
|
|
|
|
0
|
} |
8083
|
0
|
|
|
|
|
0
|
else { |
8084
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8085
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8086
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8087
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( ) |
|
0
|
|
|
|
|
0
|
|
8088
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { } |
|
0
|
|
|
|
|
0
|
|
8089
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ] |
|
0
|
|
|
|
|
0
|
|
8090
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < > |
8091
|
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 * * |
8092
|
|
|
|
|
|
|
} |
8093
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8094
|
|
|
|
|
|
|
} |
8095
|
|
|
|
|
|
|
} |
8096
|
0
|
|
|
|
|
0
|
|
8097
|
|
|
|
|
|
|
# '' |
8098
|
|
|
|
|
|
|
elsif ($string =~ /\G (?
|
8099
|
44
|
|
|
|
|
182
|
|
8100
|
|
|
|
|
|
|
# "" |
8101
|
|
|
|
|
|
|
elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8102
|
6
|
|
|
|
|
84
|
|
8103
|
|
|
|
|
|
|
# `` |
8104
|
|
|
|
|
|
|
elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8105
|
0
|
|
|
|
|
0
|
|
8106
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
8107
|
|
|
|
|
|
|
elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; } |
8108
|
0
|
|
|
|
|
0
|
|
8109
|
|
|
|
|
|
|
# <<= <=> <= < operator |
8110
|
|
|
|
|
|
|
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; } |
8111
|
0
|
|
|
|
|
0
|
|
8112
|
|
|
|
|
|
|
# |
8113
|
|
|
|
|
|
|
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; } |
8114
|
|
|
|
|
|
|
|
8115
|
0
|
|
|
|
|
0
|
# --- glob |
8116
|
|
|
|
|
|
|
elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) { |
8117
|
|
|
|
|
|
|
$e_string .= 'Egb18030::glob("' . $1 . '")'; |
8118
|
|
|
|
|
|
|
} |
8119
|
|
|
|
|
|
|
|
8120
|
0
|
|
|
|
|
0
|
# << (bit shift) --- not here document |
8121
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { |
8122
|
|
|
|
|
|
|
$slash = 'm//'; |
8123
|
|
|
|
|
|
|
$e_string .= $1; |
8124
|
|
|
|
|
|
|
} |
8125
|
|
|
|
|
|
|
|
8126
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
8127
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
8128
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8129
|
|
|
|
|
|
|
my $here_quote = $1; |
8130
|
|
|
|
|
|
|
my $delimiter = $2; |
8131
|
0
|
0
|
|
|
|
0
|
|
8132
|
0
|
|
|
|
|
0
|
# get here document |
8133
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8134
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8135
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8136
|
0
|
|
|
|
|
0
|
} |
8137
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8138
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8139
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8140
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8141
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8142
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8143
|
0
|
|
|
|
|
0
|
} |
8144
|
|
|
|
|
|
|
else { |
8145
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8146
|
|
|
|
|
|
|
} |
8147
|
|
|
|
|
|
|
$e_string .= qq{<<'$delimiter'}; |
8148
|
|
|
|
|
|
|
} |
8149
|
|
|
|
|
|
|
|
8150
|
0
|
|
|
|
|
0
|
# <<~\HEREDOC |
8151
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
8152
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8153
|
|
|
|
|
|
|
my $here_quote = $1; |
8154
|
|
|
|
|
|
|
my $delimiter = $2; |
8155
|
0
|
0
|
|
|
|
0
|
|
8156
|
0
|
|
|
|
|
0
|
# get here document |
8157
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8158
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8159
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8160
|
0
|
|
|
|
|
0
|
} |
8161
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8162
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8163
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8164
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8165
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8166
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8167
|
0
|
|
|
|
|
0
|
} |
8168
|
|
|
|
|
|
|
else { |
8169
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8170
|
|
|
|
|
|
|
} |
8171
|
|
|
|
|
|
|
$e_string .= qq{<<\\$delimiter}; |
8172
|
|
|
|
|
|
|
} |
8173
|
|
|
|
|
|
|
|
8174
|
0
|
|
|
|
|
0
|
# <<~"HEREDOC" |
8175
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
8176
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8177
|
|
|
|
|
|
|
my $here_quote = $1; |
8178
|
|
|
|
|
|
|
my $delimiter = $2; |
8179
|
0
|
0
|
|
|
|
0
|
|
8180
|
0
|
|
|
|
|
0
|
# get here document |
8181
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8182
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8183
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8184
|
0
|
|
|
|
|
0
|
} |
8185
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8186
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8187
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8188
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8189
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8190
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8191
|
0
|
|
|
|
|
0
|
} |
8192
|
|
|
|
|
|
|
else { |
8193
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8194
|
|
|
|
|
|
|
} |
8195
|
|
|
|
|
|
|
$e_string .= qq{<<"$delimiter"}; |
8196
|
|
|
|
|
|
|
} |
8197
|
|
|
|
|
|
|
|
8198
|
0
|
|
|
|
|
0
|
# <<~HEREDOC |
8199
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
8200
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8201
|
|
|
|
|
|
|
my $here_quote = $1; |
8202
|
|
|
|
|
|
|
my $delimiter = $2; |
8203
|
0
|
0
|
|
|
|
0
|
|
8204
|
0
|
|
|
|
|
0
|
# get here document |
8205
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8206
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8207
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8208
|
0
|
|
|
|
|
0
|
} |
8209
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8210
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8211
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8212
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8213
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8214
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8215
|
0
|
|
|
|
|
0
|
} |
8216
|
|
|
|
|
|
|
else { |
8217
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8218
|
|
|
|
|
|
|
} |
8219
|
|
|
|
|
|
|
$e_string .= qq{<<$delimiter}; |
8220
|
|
|
|
|
|
|
} |
8221
|
|
|
|
|
|
|
|
8222
|
0
|
|
|
|
|
0
|
# <<~`HEREDOC` |
8223
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
8224
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8225
|
|
|
|
|
|
|
my $here_quote = $1; |
8226
|
|
|
|
|
|
|
my $delimiter = $2; |
8227
|
0
|
0
|
|
|
|
0
|
|
8228
|
0
|
|
|
|
|
0
|
# get here document |
8229
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8230
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8231
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8232
|
0
|
|
|
|
|
0
|
} |
8233
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8234
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8235
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8236
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8237
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8238
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8239
|
0
|
|
|
|
|
0
|
} |
8240
|
|
|
|
|
|
|
else { |
8241
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8242
|
|
|
|
|
|
|
} |
8243
|
|
|
|
|
|
|
$e_string .= qq{<<`$delimiter`}; |
8244
|
|
|
|
|
|
|
} |
8245
|
|
|
|
|
|
|
|
8246
|
0
|
|
|
|
|
0
|
# <<'HEREDOC' |
8247
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
8248
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8249
|
|
|
|
|
|
|
my $here_quote = $1; |
8250
|
|
|
|
|
|
|
my $delimiter = $2; |
8251
|
0
|
0
|
|
|
|
0
|
|
8252
|
0
|
|
|
|
|
0
|
# get here document |
8253
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8254
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8255
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8256
|
0
|
|
|
|
|
0
|
} |
8257
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8258
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8259
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8260
|
0
|
|
|
|
|
0
|
} |
8261
|
|
|
|
|
|
|
else { |
8262
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8263
|
|
|
|
|
|
|
} |
8264
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8265
|
|
|
|
|
|
|
} |
8266
|
|
|
|
|
|
|
|
8267
|
0
|
|
|
|
|
0
|
# <<\HEREDOC |
8268
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
8269
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8270
|
|
|
|
|
|
|
my $here_quote = $1; |
8271
|
|
|
|
|
|
|
my $delimiter = $2; |
8272
|
0
|
0
|
|
|
|
0
|
|
8273
|
0
|
|
|
|
|
0
|
# get here document |
8274
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8275
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8276
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8277
|
0
|
|
|
|
|
0
|
} |
8278
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8279
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8280
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8281
|
0
|
|
|
|
|
0
|
} |
8282
|
|
|
|
|
|
|
else { |
8283
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8284
|
|
|
|
|
|
|
} |
8285
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8286
|
|
|
|
|
|
|
} |
8287
|
|
|
|
|
|
|
|
8288
|
0
|
|
|
|
|
0
|
# <<"HEREDOC" |
8289
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
8290
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8291
|
|
|
|
|
|
|
my $here_quote = $1; |
8292
|
|
|
|
|
|
|
my $delimiter = $2; |
8293
|
0
|
0
|
|
|
|
0
|
|
8294
|
0
|
|
|
|
|
0
|
# get here document |
8295
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8296
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8297
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8298
|
0
|
|
|
|
|
0
|
} |
8299
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8300
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8301
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8302
|
0
|
|
|
|
|
0
|
} |
8303
|
|
|
|
|
|
|
else { |
8304
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8305
|
|
|
|
|
|
|
} |
8306
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8307
|
|
|
|
|
|
|
} |
8308
|
|
|
|
|
|
|
|
8309
|
0
|
|
|
|
|
0
|
# <
|
8310
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
8311
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8312
|
|
|
|
|
|
|
my $here_quote = $1; |
8313
|
|
|
|
|
|
|
my $delimiter = $2; |
8314
|
0
|
0
|
|
|
|
0
|
|
8315
|
0
|
|
|
|
|
0
|
# get here document |
8316
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8317
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8318
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8319
|
0
|
|
|
|
|
0
|
} |
8320
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8321
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8322
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8323
|
0
|
|
|
|
|
0
|
} |
8324
|
|
|
|
|
|
|
else { |
8325
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8326
|
|
|
|
|
|
|
} |
8327
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8328
|
|
|
|
|
|
|
} |
8329
|
|
|
|
|
|
|
|
8330
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
8331
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
8332
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8333
|
|
|
|
|
|
|
my $here_quote = $1; |
8334
|
|
|
|
|
|
|
my $delimiter = $2; |
8335
|
0
|
0
|
|
|
|
0
|
|
8336
|
0
|
|
|
|
|
0
|
# get here document |
8337
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8338
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8339
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8340
|
0
|
|
|
|
|
0
|
} |
8341
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8342
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8343
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8344
|
0
|
|
|
|
|
0
|
} |
8345
|
|
|
|
|
|
|
else { |
8346
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8347
|
|
|
|
|
|
|
} |
8348
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8349
|
|
|
|
|
|
|
} |
8350
|
|
|
|
|
|
|
|
8351
|
|
|
|
|
|
|
# any operator before div |
8352
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8353
|
|
|
|
|
|
|
-- | \+\+ | |
8354
|
0
|
|
|
|
|
0
|
[\)\}\]] |
|
80
|
|
|
|
|
168
|
|
8355
|
|
|
|
|
|
|
|
8356
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; $e_string .= $1; } |
8357
|
|
|
|
|
|
|
|
8358
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
8359
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8360
|
80
|
|
|
|
|
323
|
\.\.\. |
|
0
|
|
|
|
|
0
|
|
8361
|
|
|
|
|
|
|
|
8362
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; } |
8363
|
|
|
|
|
|
|
|
8364
|
|
|
|
|
|
|
# any operator before m// |
8365
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?> |
8366
|
|
|
|
|
|
|
|
8367
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
8368
|
|
|
|
|
|
|
%= | % | |
8369
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
8370
|
|
|
|
|
|
|
-= | -> | - | |
8371
|
|
|
|
|
|
|
:(?>\s*)= | |
8372
|
|
|
|
|
|
|
: | |
8373
|
|
|
|
|
|
|
<<>> | |
8374
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
8375
|
|
|
|
|
|
|
== | => | =~ | = | |
8376
|
|
|
|
|
|
|
>>= | >> | >= | > | |
8377
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
8378
|
|
|
|
|
|
|
\+= | \+ | |
8379
|
|
|
|
|
|
|
\.\. | \.= | \. | |
8380
|
|
|
|
|
|
|
\/\/= | \/\/ | |
8381
|
|
|
|
|
|
|
\/= | \/ | |
8382
|
|
|
|
|
|
|
\? | |
8383
|
|
|
|
|
|
|
\\ | |
8384
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
8385
|
|
|
|
|
|
|
\b x= | |
8386
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
8387
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
8388
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
8389
|
|
|
|
|
|
|
\b(?: print )\b | |
8390
|
|
|
|
|
|
|
|
8391
|
0
|
|
|
|
|
0
|
[,;\(\{\[] |
|
112
|
|
|
|
|
255
|
|
8392
|
|
|
|
|
|
|
|
8393
|
|
|
|
|
|
|
)) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
8394
|
112
|
|
|
|
|
1031
|
|
8395
|
|
|
|
|
|
|
# other any character |
8396
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; } |
8397
|
|
|
|
|
|
|
|
8398
|
353
|
|
|
|
|
2185
|
# system error |
8399
|
|
|
|
|
|
|
else { |
8400
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
8401
|
|
|
|
|
|
|
} |
8402
|
0
|
|
|
|
|
0
|
} |
8403
|
|
|
|
|
|
|
|
8404
|
|
|
|
|
|
|
return $e_string; |
8405
|
|
|
|
|
|
|
} |
8406
|
|
|
|
|
|
|
|
8407
|
|
|
|
|
|
|
# |
8408
|
|
|
|
|
|
|
# character class |
8409
|
79
|
|
|
5494
|
0
|
709
|
# |
8410
|
|
|
|
|
|
|
sub character_class { |
8411
|
5494
|
100
|
|
|
|
11020
|
my($char,$modifier) = @_; |
8412
|
5494
|
100
|
|
|
|
8842
|
|
8413
|
115
|
|
|
|
|
231
|
if ($char eq '.') { |
8414
|
|
|
|
|
|
|
if ($modifier =~ /s/) { |
8415
|
|
|
|
|
|
|
return '${Egb18030::dot_s}'; |
8416
|
23
|
|
|
|
|
61
|
} |
8417
|
|
|
|
|
|
|
else { |
8418
|
|
|
|
|
|
|
return '${Egb18030::dot}'; |
8419
|
|
|
|
|
|
|
} |
8420
|
92
|
|
|
|
|
208
|
} |
8421
|
|
|
|
|
|
|
else { |
8422
|
|
|
|
|
|
|
return Egb18030::classic_character_class($char); |
8423
|
|
|
|
|
|
|
} |
8424
|
|
|
|
|
|
|
} |
8425
|
|
|
|
|
|
|
|
8426
|
|
|
|
|
|
|
# |
8427
|
|
|
|
|
|
|
# escape capture ($1, $2, $3, ...) |
8428
|
|
|
|
|
|
|
# |
8429
|
5379
|
|
|
641
|
0
|
9553
|
sub e_capture { |
8430
|
641
|
|
|
|
|
2681
|
|
8431
|
|
|
|
|
|
|
return join '', '${Egb18030::capture(', $_[0], ')}'; |
8432
|
|
|
|
|
|
|
return join '', '${', $_[0], '}'; |
8433
|
|
|
|
|
|
|
} |
8434
|
|
|
|
|
|
|
|
8435
|
|
|
|
|
|
|
# |
8436
|
|
|
|
|
|
|
# escape transliteration (tr/// or y///) |
8437
|
0
|
|
|
11
|
0
|
0
|
# |
8438
|
11
|
|
|
|
|
61
|
sub e_tr { |
8439
|
11
|
|
100
|
|
|
18
|
my($variable,$charclass,$e,$charclass2,$modifier) = @_; |
8440
|
|
|
|
|
|
|
my $e_tr = ''; |
8441
|
11
|
|
|
|
|
32
|
$modifier ||= ''; |
8442
|
|
|
|
|
|
|
|
8443
|
|
|
|
|
|
|
$slash = 'div'; |
8444
|
11
|
|
|
|
|
16
|
|
8445
|
|
|
|
|
|
|
# quote character class 1 |
8446
|
|
|
|
|
|
|
$charclass = q_tr($charclass); |
8447
|
11
|
|
|
|
|
21
|
|
8448
|
|
|
|
|
|
|
# quote character class 2 |
8449
|
|
|
|
|
|
|
$charclass2 = q_tr($charclass2); |
8450
|
11
|
50
|
|
|
|
23
|
|
8451
|
11
|
0
|
|
|
|
29
|
# /b /B modifier |
8452
|
0
|
|
|
|
|
0
|
if ($modifier =~ tr/bB//d) { |
8453
|
|
|
|
|
|
|
if ($variable eq '') { |
8454
|
|
|
|
|
|
|
$e_tr = qq{tr$charclass$e$charclass2$modifier}; |
8455
|
0
|
|
|
|
|
0
|
} |
8456
|
|
|
|
|
|
|
else { |
8457
|
|
|
|
|
|
|
$e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier}; |
8458
|
|
|
|
|
|
|
} |
8459
|
0
|
100
|
|
|
|
0
|
} |
8460
|
11
|
|
|
|
|
30
|
else { |
8461
|
|
|
|
|
|
|
if ($variable eq '') { |
8462
|
|
|
|
|
|
|
$e_tr = qq{Egb18030::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}; |
8463
|
2
|
|
|
|
|
8
|
} |
8464
|
|
|
|
|
|
|
else { |
8465
|
|
|
|
|
|
|
$e_tr = qq{Egb18030::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}; |
8466
|
|
|
|
|
|
|
} |
8467
|
|
|
|
|
|
|
} |
8468
|
9
|
|
|
|
|
27
|
|
8469
|
11
|
|
|
|
|
18
|
# clear tr/// variable |
8470
|
|
|
|
|
|
|
$tr_variable = ''; |
8471
|
11
|
|
|
|
|
13
|
$bind_operator = ''; |
8472
|
|
|
|
|
|
|
|
8473
|
|
|
|
|
|
|
return $e_tr; |
8474
|
|
|
|
|
|
|
} |
8475
|
|
|
|
|
|
|
|
8476
|
|
|
|
|
|
|
# |
8477
|
|
|
|
|
|
|
# quote for escape transliteration (tr/// or y///) |
8478
|
11
|
|
|
22
|
0
|
69
|
# |
8479
|
|
|
|
|
|
|
sub q_tr { |
8480
|
|
|
|
|
|
|
my($charclass) = @_; |
8481
|
22
|
50
|
|
|
|
32
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8482
|
22
|
|
|
|
|
45
|
# quote character class |
8483
|
|
|
|
|
|
|
if ($charclass !~ /'/oxms) { |
8484
|
|
|
|
|
|
|
return e_q('', "'", "'", $charclass); # --> q' ' |
8485
|
22
|
|
|
|
|
37
|
} |
8486
|
|
|
|
|
|
|
elsif ($charclass !~ /\//oxms) { |
8487
|
|
|
|
|
|
|
return e_q('q', '/', '/', $charclass); # --> q/ / |
8488
|
0
|
|
|
|
|
0
|
} |
8489
|
|
|
|
|
|
|
elsif ($charclass !~ /\#/oxms) { |
8490
|
|
|
|
|
|
|
return e_q('q', '#', '#', $charclass); # --> q# # |
8491
|
0
|
|
|
|
|
0
|
} |
8492
|
|
|
|
|
|
|
elsif ($charclass !~ /[\<\>]/oxms) { |
8493
|
|
|
|
|
|
|
return e_q('q', '<', '>', $charclass); # --> q< > |
8494
|
0
|
|
|
|
|
0
|
} |
8495
|
|
|
|
|
|
|
elsif ($charclass !~ /[\(\)]/oxms) { |
8496
|
|
|
|
|
|
|
return e_q('q', '(', ')', $charclass); # --> q( ) |
8497
|
0
|
|
|
|
|
0
|
} |
8498
|
|
|
|
|
|
|
elsif ($charclass !~ /[\{\}]/oxms) { |
8499
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); # --> q{ } |
8500
|
0
|
|
|
|
|
0
|
} |
8501
|
0
|
0
|
|
|
|
0
|
else { |
8502
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8503
|
|
|
|
|
|
|
if ($charclass !~ /\Q$char\E/xms) { |
8504
|
|
|
|
|
|
|
return e_q('q', $char, $char, $charclass); |
8505
|
|
|
|
|
|
|
} |
8506
|
|
|
|
|
|
|
} |
8507
|
0
|
|
|
|
|
0
|
} |
8508
|
|
|
|
|
|
|
|
8509
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); |
8510
|
|
|
|
|
|
|
} |
8511
|
|
|
|
|
|
|
|
8512
|
|
|
|
|
|
|
# |
8513
|
|
|
|
|
|
|
# escape q string (q//, '') |
8514
|
0
|
|
|
4039
|
0
|
0
|
# |
8515
|
|
|
|
|
|
|
sub e_q { |
8516
|
4039
|
|
|
|
|
11789
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8517
|
|
|
|
|
|
|
|
8518
|
4039
|
|
|
|
|
7100
|
$slash = 'div'; |
8519
|
4039
|
|
|
|
|
41396
|
|
8520
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>$q_char) /oxmsg; |
8521
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8522
|
4039
|
100
|
100
|
|
|
12058
|
|
|
|
100
|
100
|
|
|
|
|
8523
|
21555
|
|
|
|
|
126297
|
# escape last octet of multiple-octet |
8524
|
|
|
|
|
|
|
if ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
8525
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8526
|
1
|
|
|
|
|
6
|
} |
8527
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8528
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8529
|
22
|
100
|
100
|
|
|
99
|
} |
8530
|
4039
|
|
|
|
|
16207
|
} |
8531
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8532
|
|
|
|
|
|
|
$char[-1] = $1 . '\\' . $2; |
8533
|
204
|
|
|
|
|
723
|
} |
8534
|
4039
|
|
|
|
|
22396
|
|
8535
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8536
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8537
|
|
|
|
|
|
|
} |
8538
|
|
|
|
|
|
|
|
8539
|
|
|
|
|
|
|
# |
8540
|
|
|
|
|
|
|
# escape qq string (qq//, "", qx//, ``) |
8541
|
0
|
|
|
9646
|
0
|
0
|
# |
8542
|
|
|
|
|
|
|
sub e_qq { |
8543
|
9646
|
|
|
|
|
23288
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8544
|
|
|
|
|
|
|
|
8545
|
9646
|
|
|
|
|
18027
|
$slash = 'div'; |
8546
|
9646
|
|
|
|
|
13971
|
|
8547
|
|
|
|
|
|
|
my $left_e = 0; |
8548
|
|
|
|
|
|
|
my $right_e = 0; |
8549
|
9646
|
|
|
|
|
11511
|
|
8550
|
|
|
|
|
|
|
# split regexp |
8551
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8552
|
|
|
|
|
|
|
[^\x81-\xFE\\\$]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
8553
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8554
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8555
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} | |
8556
|
|
|
|
|
|
|
\\ $q_char | |
8557
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8558
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8559
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8560
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8561
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8562
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8563
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8564
|
|
|
|
|
|
|
$q_char |
8565
|
9646
|
|
|
|
|
414284
|
))/oxmsg; |
8566
|
|
|
|
|
|
|
|
8567
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8568
|
9646
|
50
|
66
|
|
|
30883
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8569
|
311085
|
|
|
|
|
1010206
|
# "\L\u" --> "\u\L" |
8570
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8571
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8572
|
|
|
|
|
|
|
} |
8573
|
|
|
|
|
|
|
|
8574
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
8575
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8576
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8577
|
|
|
|
|
|
|
} |
8578
|
|
|
|
|
|
|
|
8579
|
0
|
|
|
|
|
0
|
# octal escape sequence |
8580
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8581
|
|
|
|
|
|
|
$char[$i] = Egb18030::octchr($1); |
8582
|
|
|
|
|
|
|
} |
8583
|
|
|
|
|
|
|
|
8584
|
1
|
|
|
|
|
4
|
# hexadecimal escape sequence |
8585
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8586
|
|
|
|
|
|
|
$char[$i] = Egb18030::hexchr($1); |
8587
|
|
|
|
|
|
|
} |
8588
|
|
|
|
|
|
|
|
8589
|
1
|
|
|
|
|
5
|
# \N{CHARNAME} --> N{CHARNAME} |
8590
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
8591
|
|
|
|
|
|
|
$char[$i] = $1; |
8592
|
0
|
100
|
|
|
|
0
|
} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8593
|
|
|
|
|
|
|
|
8594
|
|
|
|
|
|
|
if (0) { |
8595
|
|
|
|
|
|
|
} |
8596
|
|
|
|
|
|
|
|
8597
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
8598
|
311085
|
|
|
|
|
2915279
|
# my $metachar = qr/[\@\\\|]/oxms; # '|' is for qx//, ``, open(), and system() |
8599
|
0
|
|
|
|
|
0
|
# variable $delimiter and $end_delimiter can be '' |
8600
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\@\\\|$delimiter$end_delimiter]) \z/xms) { |
8601
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8602
|
|
|
|
|
|
|
} |
8603
|
|
|
|
|
|
|
|
8604
|
|
|
|
|
|
|
# \F |
8605
|
|
|
|
|
|
|
# |
8606
|
|
|
|
|
|
|
# P.69 Table 2-6. Translation escapes |
8607
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
8608
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8609
|
|
|
|
|
|
|
# (and so on) |
8610
|
|
|
|
|
|
|
|
8611
|
1342
|
50
|
|
|
|
5984
|
# \u \l \U \L \F \Q \E |
8612
|
655
|
|
|
|
|
2037
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8613
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8614
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8615
|
|
|
|
|
|
|
} |
8616
|
|
|
|
|
|
|
} |
8617
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
8618
|
|
|
|
|
|
|
|
8619
|
|
|
|
|
|
|
# "STRING @{[ LIST EXPR ]} MORE STRING" |
8620
|
|
|
|
|
|
|
|
8621
|
|
|
|
|
|
|
# P.257 Other Tricks You Can Do with Hard References |
8622
|
|
|
|
|
|
|
# in Chapter 8: References |
8623
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
8624
|
|
|
|
|
|
|
|
8625
|
|
|
|
|
|
|
# P.353 Other Tricks You Can Do with Hard References |
8626
|
|
|
|
|
|
|
# in Chapter 8: References |
8627
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8628
|
|
|
|
|
|
|
|
8629
|
0
|
|
|
|
|
0
|
# (and so on) |
8630
|
0
|
|
|
|
|
0
|
|
8631
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ucfirst qq<'; |
8632
|
|
|
|
|
|
|
$left_e++; |
8633
|
0
|
|
|
|
|
0
|
} |
8634
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
8635
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lcfirst qq<'; |
8636
|
|
|
|
|
|
|
$left_e++; |
8637
|
0
|
|
|
|
|
0
|
} |
8638
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
8639
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::uc qq<'; |
8640
|
|
|
|
|
|
|
$left_e++; |
8641
|
0
|
|
|
|
|
0
|
} |
8642
|
6
|
|
|
|
|
7
|
elsif ($char[$i] eq '\L') { |
8643
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lc qq<'; |
8644
|
|
|
|
|
|
|
$left_e++; |
8645
|
6
|
|
|
|
|
12
|
} |
8646
|
9
|
|
|
|
|
112
|
elsif ($char[$i] eq '\F') { |
8647
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::fc qq<'; |
8648
|
|
|
|
|
|
|
$left_e++; |
8649
|
9
|
|
|
|
|
28
|
} |
8650
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8651
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8652
|
|
|
|
|
|
|
$left_e++; |
8653
|
0
|
50
|
|
|
|
0
|
} |
8654
|
12
|
|
|
|
|
26
|
elsif ($char[$i] eq '\E') { |
8655
|
12
|
|
|
|
|
23
|
if ($right_e < $left_e) { |
8656
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8657
|
|
|
|
|
|
|
$right_e++; |
8658
|
12
|
|
|
|
|
29
|
} |
8659
|
|
|
|
|
|
|
else { |
8660
|
|
|
|
|
|
|
$char[$i] = ''; |
8661
|
|
|
|
|
|
|
} |
8662
|
0
|
|
|
|
|
0
|
} |
8663
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8664
|
0
|
|
|
|
|
0
|
while (1) { |
8665
|
|
|
|
|
|
|
if (++$i > $#char) { |
8666
|
0
|
0
|
|
|
|
0
|
last; |
8667
|
0
|
|
|
|
|
0
|
} |
8668
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8669
|
|
|
|
|
|
|
last; |
8670
|
|
|
|
|
|
|
} |
8671
|
|
|
|
|
|
|
} |
8672
|
|
|
|
|
|
|
} |
8673
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
8674
|
|
|
|
|
|
|
} |
8675
|
|
|
|
|
|
|
|
8676
|
|
|
|
|
|
|
# $0 --> $0 |
8677
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
8678
|
|
|
|
|
|
|
} |
8679
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
8680
|
|
|
|
|
|
|
} |
8681
|
|
|
|
|
|
|
|
8682
|
|
|
|
|
|
|
# $$ --> $$ |
8683
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
8684
|
|
|
|
|
|
|
} |
8685
|
|
|
|
|
|
|
|
8686
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
8687
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
8688
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
8689
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8690
|
417
|
|
|
|
|
1204
|
} |
8691
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
8692
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8693
|
|
|
|
|
|
|
} |
8694
|
|
|
|
|
|
|
|
8695
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
8696
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
8697
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8698
|
|
|
|
|
|
|
} |
8699
|
|
|
|
|
|
|
|
8700
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
8701
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
8702
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8703
|
|
|
|
|
|
|
} |
8704
|
|
|
|
|
|
|
|
8705
|
0
|
|
|
|
|
0
|
# $$foo |
8706
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
8707
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8708
|
|
|
|
|
|
|
} |
8709
|
|
|
|
|
|
|
|
8710
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
8711
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
8712
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::PREMATCH()]}'; |
8713
|
|
|
|
|
|
|
} |
8714
|
|
|
|
|
|
|
|
8715
|
44
|
|
|
|
|
145
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
8716
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
8717
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::MATCH()]}'; |
8718
|
|
|
|
|
|
|
} |
8719
|
|
|
|
|
|
|
|
8720
|
45
|
|
|
|
|
142
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
8721
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
8722
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::POSTMATCH()]}'; |
8723
|
|
|
|
|
|
|
} |
8724
|
|
|
|
|
|
|
|
8725
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
8726
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
8727
|
|
|
|
|
|
|
} |
8728
|
|
|
|
|
|
|
|
8729
|
33
|
|
|
|
|
108
|
# ${ ... } |
8730
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
8731
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8732
|
|
|
|
|
|
|
} |
8733
|
|
|
|
|
|
|
} |
8734
|
0
|
100
|
|
|
|
0
|
|
8735
|
9646
|
|
|
|
|
20178
|
# return string |
8736
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
8737
|
3
|
|
|
|
|
20
|
return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter; |
8738
|
|
|
|
|
|
|
} |
8739
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8740
|
|
|
|
|
|
|
} |
8741
|
|
|
|
|
|
|
|
8742
|
|
|
|
|
|
|
# |
8743
|
|
|
|
|
|
|
# escape qw string (qw//) |
8744
|
9643
|
|
|
34
|
0
|
81268
|
# |
8745
|
|
|
|
|
|
|
sub e_qw { |
8746
|
34
|
|
|
|
|
160
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8747
|
|
|
|
|
|
|
|
8748
|
|
|
|
|
|
|
$slash = 'div'; |
8749
|
34
|
|
|
|
|
74
|
|
|
34
|
|
|
|
|
300
|
|
8750
|
621
|
50
|
|
|
|
940
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8751
|
34
|
|
|
|
|
166
|
my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg); |
8752
|
|
|
|
|
|
|
if (not $octet{$end_delimiter}) { |
8753
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8754
|
34
|
|
|
|
|
220
|
} |
8755
|
|
|
|
|
|
|
elsif (not $octet{')'}) { |
8756
|
|
|
|
|
|
|
return join '', $ope, '(', $string, ')'; |
8757
|
0
|
|
|
|
|
0
|
} |
8758
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
8759
|
|
|
|
|
|
|
return join '', $ope, '{', $string, '}'; |
8760
|
0
|
|
|
|
|
0
|
} |
8761
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
8762
|
|
|
|
|
|
|
return join '', $ope, '[', $string, ']'; |
8763
|
0
|
|
|
|
|
0
|
} |
8764
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
8765
|
|
|
|
|
|
|
return join '', $ope, '<', $string, '>'; |
8766
|
0
|
|
|
|
|
0
|
} |
8767
|
0
|
0
|
|
|
|
0
|
else { |
8768
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8769
|
|
|
|
|
|
|
if (not $octet{$char}) { |
8770
|
|
|
|
|
|
|
return join '', $ope, $char, $string, $char; |
8771
|
|
|
|
|
|
|
} |
8772
|
|
|
|
|
|
|
} |
8773
|
|
|
|
|
|
|
} |
8774
|
0
|
|
|
|
|
0
|
|
8775
|
0
|
|
|
|
|
0
|
# qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC') |
8776
|
0
|
|
|
|
|
0
|
my @string = CORE::split(/\s+/, $string); |
8777
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
8778
|
0
|
0
|
|
|
|
0
|
my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
8779
|
0
|
|
|
|
|
0
|
for my $octet (@octet) { |
8780
|
|
|
|
|
|
|
if ($octet =~ /\A (['\\]) \z/oxms) { |
8781
|
|
|
|
|
|
|
$octet = '\\' . $1; |
8782
|
0
|
|
|
|
|
0
|
} |
8783
|
|
|
|
|
|
|
} |
8784
|
0
|
|
|
|
|
0
|
$string = join '', @octet; |
|
0
|
|
|
|
|
0
|
|
8785
|
|
|
|
|
|
|
} |
8786
|
|
|
|
|
|
|
return join '', '(', (join ', ', map { "'$_'" } @string), ')'; |
8787
|
|
|
|
|
|
|
} |
8788
|
|
|
|
|
|
|
|
8789
|
|
|
|
|
|
|
# |
8790
|
|
|
|
|
|
|
# escape here document (<<"HEREDOC", <
|
8791
|
0
|
|
|
114
|
0
|
0
|
# |
8792
|
|
|
|
|
|
|
sub e_heredoc { |
8793
|
114
|
|
|
|
|
408
|
my($string) = @_; |
8794
|
|
|
|
|
|
|
|
8795
|
114
|
|
|
|
|
195
|
$slash = 'm//'; |
8796
|
|
|
|
|
|
|
|
8797
|
114
|
|
|
|
|
391
|
my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC` |
8798
|
114
|
|
|
|
|
183
|
|
8799
|
|
|
|
|
|
|
my $left_e = 0; |
8800
|
|
|
|
|
|
|
my $right_e = 0; |
8801
|
114
|
|
|
|
|
161
|
|
8802
|
|
|
|
|
|
|
# split regexp |
8803
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8804
|
|
|
|
|
|
|
[^\x81-\xFE\\\$]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
8805
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8806
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8807
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} | |
8808
|
|
|
|
|
|
|
\\ $q_char | |
8809
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8810
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8811
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8812
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8813
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8814
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8815
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8816
|
|
|
|
|
|
|
$q_char |
8817
|
114
|
|
|
|
|
28210
|
))/oxmsg; |
8818
|
|
|
|
|
|
|
|
8819
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8820
|
114
|
50
|
66
|
|
|
599
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8821
|
3529
|
|
|
|
|
10588
|
# "\L\u" --> "\u\L" |
8822
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8823
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8824
|
|
|
|
|
|
|
} |
8825
|
|
|
|
|
|
|
|
8826
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
8827
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8828
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8829
|
|
|
|
|
|
|
} |
8830
|
|
|
|
|
|
|
|
8831
|
0
|
|
|
|
|
0
|
# octal escape sequence |
8832
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8833
|
|
|
|
|
|
|
$char[$i] = Egb18030::octchr($1); |
8834
|
|
|
|
|
|
|
} |
8835
|
|
|
|
|
|
|
|
8836
|
1
|
|
|
|
|
4
|
# hexadecimal escape sequence |
8837
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8838
|
|
|
|
|
|
|
$char[$i] = Egb18030::hexchr($1); |
8839
|
|
|
|
|
|
|
} |
8840
|
|
|
|
|
|
|
|
8841
|
1
|
|
|
|
|
4
|
# \N{CHARNAME} --> N{CHARNAME} |
8842
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
8843
|
|
|
|
|
|
|
$char[$i] = $1; |
8844
|
0
|
100
|
|
|
|
0
|
} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8845
|
|
|
|
|
|
|
|
8846
|
|
|
|
|
|
|
if (0) { |
8847
|
|
|
|
|
|
|
} |
8848
|
3529
|
|
|
|
|
30567
|
|
8849
|
0
|
|
|
|
|
0
|
# escape character |
8850
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
8851
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8852
|
|
|
|
|
|
|
} |
8853
|
|
|
|
|
|
|
|
8854
|
57
|
50
|
|
|
|
215
|
# \u \l \U \L \F \Q \E |
8855
|
144
|
|
|
|
|
270
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8856
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8857
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8858
|
|
|
|
|
|
|
} |
8859
|
0
|
|
|
|
|
0
|
} |
8860
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
8861
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ucfirst qq<'; |
8862
|
|
|
|
|
|
|
$left_e++; |
8863
|
0
|
|
|
|
|
0
|
} |
8864
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
8865
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lcfirst qq<'; |
8866
|
|
|
|
|
|
|
$left_e++; |
8867
|
0
|
|
|
|
|
0
|
} |
8868
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
8869
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::uc qq<'; |
8870
|
|
|
|
|
|
|
$left_e++; |
8871
|
0
|
|
|
|
|
0
|
} |
8872
|
6
|
|
|
|
|
11
|
elsif ($char[$i] eq '\L') { |
8873
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lc qq<'; |
8874
|
|
|
|
|
|
|
$left_e++; |
8875
|
6
|
|
|
|
|
8
|
} |
8876
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
8877
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::fc qq<'; |
8878
|
|
|
|
|
|
|
$left_e++; |
8879
|
0
|
|
|
|
|
0
|
} |
8880
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8881
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8882
|
|
|
|
|
|
|
$left_e++; |
8883
|
0
|
50
|
|
|
|
0
|
} |
8884
|
3
|
|
|
|
|
6
|
elsif ($char[$i] eq '\E') { |
8885
|
3
|
|
|
|
|
3
|
if ($right_e < $left_e) { |
8886
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8887
|
|
|
|
|
|
|
$right_e++; |
8888
|
3
|
|
|
|
|
6
|
} |
8889
|
|
|
|
|
|
|
else { |
8890
|
|
|
|
|
|
|
$char[$i] = ''; |
8891
|
|
|
|
|
|
|
} |
8892
|
0
|
|
|
|
|
0
|
} |
8893
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8894
|
0
|
|
|
|
|
0
|
while (1) { |
8895
|
|
|
|
|
|
|
if (++$i > $#char) { |
8896
|
0
|
0
|
|
|
|
0
|
last; |
8897
|
0
|
|
|
|
|
0
|
} |
8898
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8899
|
|
|
|
|
|
|
last; |
8900
|
|
|
|
|
|
|
} |
8901
|
|
|
|
|
|
|
} |
8902
|
|
|
|
|
|
|
} |
8903
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
8904
|
|
|
|
|
|
|
} |
8905
|
|
|
|
|
|
|
|
8906
|
|
|
|
|
|
|
# $0 --> $0 |
8907
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
8908
|
|
|
|
|
|
|
} |
8909
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
8910
|
|
|
|
|
|
|
} |
8911
|
|
|
|
|
|
|
|
8912
|
|
|
|
|
|
|
# $$ --> $$ |
8913
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
8914
|
|
|
|
|
|
|
} |
8915
|
|
|
|
|
|
|
|
8916
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
8917
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
8918
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
8919
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8920
|
0
|
|
|
|
|
0
|
} |
8921
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
8922
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8923
|
|
|
|
|
|
|
} |
8924
|
|
|
|
|
|
|
|
8925
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
8926
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
8927
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8928
|
|
|
|
|
|
|
} |
8929
|
|
|
|
|
|
|
|
8930
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
8931
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
8932
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8933
|
|
|
|
|
|
|
} |
8934
|
|
|
|
|
|
|
|
8935
|
0
|
|
|
|
|
0
|
# $$foo |
8936
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
8937
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8938
|
|
|
|
|
|
|
} |
8939
|
|
|
|
|
|
|
|
8940
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
8941
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
8942
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::PREMATCH()]}'; |
8943
|
|
|
|
|
|
|
} |
8944
|
|
|
|
|
|
|
|
8945
|
8
|
|
|
|
|
50
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
8946
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
8947
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::MATCH()]}'; |
8948
|
|
|
|
|
|
|
} |
8949
|
|
|
|
|
|
|
|
8950
|
8
|
|
|
|
|
54
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
8951
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
8952
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::POSTMATCH()]}'; |
8953
|
|
|
|
|
|
|
} |
8954
|
|
|
|
|
|
|
|
8955
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
8956
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
8957
|
|
|
|
|
|
|
} |
8958
|
|
|
|
|
|
|
|
8959
|
6
|
|
|
|
|
39
|
# ${ ... } |
8960
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
8961
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8962
|
|
|
|
|
|
|
} |
8963
|
|
|
|
|
|
|
} |
8964
|
0
|
100
|
|
|
|
0
|
|
8965
|
114
|
|
|
|
|
372
|
# return string |
8966
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
8967
|
3
|
|
|
|
|
22
|
return join '', @char, '>]}' x ($left_e - $right_e); |
8968
|
|
|
|
|
|
|
} |
8969
|
|
|
|
|
|
|
return join '', @char; |
8970
|
|
|
|
|
|
|
} |
8971
|
|
|
|
|
|
|
|
8972
|
|
|
|
|
|
|
# |
8973
|
|
|
|
|
|
|
# escape regexp (m//, qr//) |
8974
|
111
|
|
|
1843
|
0
|
937
|
# |
8975
|
1843
|
|
100
|
|
|
8026
|
sub e_qr { |
8976
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
8977
|
1843
|
|
|
|
|
6759
|
$modifier ||= ''; |
8978
|
1843
|
50
|
|
|
|
3721
|
|
8979
|
1843
|
|
|
|
|
4651
|
$modifier =~ tr/p//d; |
8980
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
8981
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
8982
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
8983
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
8984
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
8985
|
|
|
|
|
|
|
last; |
8986
|
0
|
|
|
|
|
0
|
} |
8987
|
|
|
|
|
|
|
} |
8988
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
8989
|
0
|
|
|
|
|
0
|
} |
8990
|
|
|
|
|
|
|
|
8991
|
|
|
|
|
|
|
$slash = 'div'; |
8992
|
1843
|
100
|
|
|
|
2977
|
|
|
|
100
|
|
|
|
|
|
8993
|
1843
|
|
|
|
|
5425
|
# literal null string pattern |
8994
|
8
|
|
|
|
|
12
|
if ($string eq '') { |
8995
|
8
|
|
|
|
|
10
|
$modifier =~ tr/bB//d; |
8996
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
8997
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
8998
|
|
|
|
|
|
|
} |
8999
|
|
|
|
|
|
|
|
9000
|
|
|
|
|
|
|
# /b /B modifier |
9001
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9002
|
8
|
50
|
|
|
|
38
|
|
9003
|
240
|
|
|
|
|
554
|
# choice again delimiter |
9004
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
0
|
|
|
|
|
0
|
|
9005
|
0
|
0
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9006
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9007
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9008
|
|
|
|
|
|
|
$delimiter = '('; |
9009
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9010
|
0
|
|
|
|
|
0
|
} |
9011
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9012
|
|
|
|
|
|
|
$delimiter = '{'; |
9013
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9014
|
0
|
|
|
|
|
0
|
} |
9015
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9016
|
|
|
|
|
|
|
$delimiter = '['; |
9017
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9018
|
0
|
|
|
|
|
0
|
} |
9019
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9020
|
|
|
|
|
|
|
$delimiter = '<'; |
9021
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9022
|
0
|
|
|
|
|
0
|
} |
9023
|
0
|
0
|
|
|
|
0
|
else { |
9024
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9025
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9026
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9027
|
|
|
|
|
|
|
$end_delimiter = $char; |
9028
|
|
|
|
|
|
|
last; |
9029
|
|
|
|
|
|
|
} |
9030
|
|
|
|
|
|
|
} |
9031
|
|
|
|
|
|
|
} |
9032
|
0
|
100
|
100
|
|
|
0
|
} |
9033
|
240
|
|
|
|
|
1393
|
|
9034
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9035
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier; |
9036
|
90
|
|
|
|
|
511
|
} |
9037
|
|
|
|
|
|
|
else { |
9038
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9039
|
|
|
|
|
|
|
} |
9040
|
150
|
100
|
|
|
|
879
|
} |
9041
|
1595
|
|
|
|
|
3837
|
|
9042
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9043
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9044
|
1595
|
|
|
|
|
5489
|
|
9045
|
|
|
|
|
|
|
# split regexp |
9046
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9047
|
|
|
|
|
|
|
[^\x81-\xFE\\\$\@\[\(]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
9048
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9049
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9050
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9051
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9052
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9053
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} | |
9054
|
|
|
|
|
|
|
\\ $q_char | |
9055
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9056
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9057
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9058
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9059
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9060
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9061
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9062
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9063
|
|
|
|
|
|
|
\[\^ | |
9064
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9065
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9066
|
|
|
|
|
|
|
\(\? | |
9067
|
|
|
|
|
|
|
$q_char |
9068
|
|
|
|
|
|
|
))/oxmsg; |
9069
|
1595
|
50
|
|
|
|
152603
|
|
9070
|
1595
|
|
|
|
|
8059
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9071
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9072
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9073
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9074
|
|
|
|
|
|
|
$delimiter = '('; |
9075
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9076
|
0
|
|
|
|
|
0
|
} |
9077
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9078
|
|
|
|
|
|
|
$delimiter = '{'; |
9079
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9080
|
0
|
|
|
|
|
0
|
} |
9081
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9082
|
|
|
|
|
|
|
$delimiter = '['; |
9083
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9084
|
0
|
|
|
|
|
0
|
} |
9085
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9086
|
|
|
|
|
|
|
$delimiter = '<'; |
9087
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9088
|
0
|
|
|
|
|
0
|
} |
9089
|
0
|
0
|
|
|
|
0
|
else { |
9090
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9091
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9092
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9093
|
|
|
|
|
|
|
$end_delimiter = $char; |
9094
|
|
|
|
|
|
|
last; |
9095
|
|
|
|
|
|
|
} |
9096
|
|
|
|
|
|
|
} |
9097
|
|
|
|
|
|
|
} |
9098
|
0
|
|
|
|
|
0
|
} |
9099
|
1595
|
|
|
|
|
2597
|
|
9100
|
1595
|
|
|
|
|
2275
|
my $left_e = 0; |
9101
|
|
|
|
|
|
|
my $right_e = 0; |
9102
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9103
|
1595
|
50
|
66
|
|
|
4017
|
|
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9104
|
5546
|
|
|
|
|
31136
|
# "\L\u" --> "\u\L" |
9105
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9106
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9107
|
|
|
|
|
|
|
} |
9108
|
|
|
|
|
|
|
|
9109
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
9110
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9111
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9112
|
|
|
|
|
|
|
} |
9113
|
|
|
|
|
|
|
|
9114
|
0
|
|
|
|
|
0
|
# octal escape sequence |
9115
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9116
|
|
|
|
|
|
|
$char[$i] = Egb18030::octchr($1); |
9117
|
|
|
|
|
|
|
} |
9118
|
|
|
|
|
|
|
|
9119
|
1
|
|
|
|
|
4
|
# hexadecimal escape sequence |
9120
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9121
|
|
|
|
|
|
|
$char[$i] = Egb18030::hexchr($1); |
9122
|
|
|
|
|
|
|
} |
9123
|
|
|
|
|
|
|
|
9124
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9125
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9126
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9127
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
9128
|
1
|
|
|
|
|
5
|
# \P{PROPERTY} --> P\{PROPERTY} |
9129
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
9130
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9131
|
|
|
|
|
|
|
} |
9132
|
|
|
|
|
|
|
|
9133
|
6
|
|
|
|
|
19
|
# \p, \P, \X --> p, P, X |
9134
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9135
|
|
|
|
|
|
|
$char[$i] = $1; |
9136
|
4
|
100
|
100
|
|
|
13
|
} |
|
|
100
|
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
|
|
|
|
|
|
9137
|
|
|
|
|
|
|
|
9138
|
|
|
|
|
|
|
if (0) { |
9139
|
|
|
|
|
|
|
} |
9140
|
5546
|
|
|
|
|
37347
|
|
9141
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9142
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9143
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9144
|
|
|
|
|
|
|
} |
9145
|
|
|
|
|
|
|
|
9146
|
77
|
50
|
33
|
|
|
379
|
# join separated multiple-octet |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
9147
|
6
|
|
|
|
|
176
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9148
|
|
|
|
|
|
|
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)) { |
9149
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9150
|
0
|
|
|
|
|
0
|
} |
9151
|
|
|
|
|
|
|
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)) { |
9152
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9153
|
0
|
|
|
|
|
0
|
} |
9154
|
|
|
|
|
|
|
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)) { |
9155
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9156
|
|
|
|
|
|
|
} |
9157
|
|
|
|
|
|
|
} |
9158
|
|
|
|
|
|
|
|
9159
|
0
|
|
|
|
|
0
|
# open character class [...] |
9160
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
9161
|
|
|
|
|
|
|
my $left = $i; |
9162
|
|
|
|
|
|
|
|
9163
|
|
|
|
|
|
|
# [] make die "Unmatched [] in regexp ...\n" |
9164
|
594
|
100
|
|
|
|
935
|
# (and so on) |
9165
|
594
|
|
|
|
|
1455
|
|
9166
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9167
|
|
|
|
|
|
|
$i++; |
9168
|
3
|
|
|
|
|
5
|
} |
9169
|
594
|
50
|
|
|
|
814
|
|
9170
|
2615
|
|
|
|
|
4287
|
while (1) { |
9171
|
|
|
|
|
|
|
if (++$i > $#char) { |
9172
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9173
|
2615
|
|
|
|
|
4022
|
} |
9174
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9175
|
|
|
|
|
|
|
my $right = $i; |
9176
|
594
|
100
|
|
|
|
752
|
|
9177
|
594
|
|
|
|
|
3224
|
# [...] |
|
90
|
|
|
|
|
203
|
|
9178
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9179
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9180
|
270
|
|
|
|
|
541
|
} |
9181
|
|
|
|
|
|
|
else { |
9182
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
9183
|
504
|
|
|
|
|
1917
|
} |
9184
|
594
|
|
|
|
|
1181
|
|
9185
|
|
|
|
|
|
|
$i = $left; |
9186
|
|
|
|
|
|
|
last; |
9187
|
|
|
|
|
|
|
} |
9188
|
|
|
|
|
|
|
} |
9189
|
|
|
|
|
|
|
} |
9190
|
|
|
|
|
|
|
|
9191
|
594
|
|
|
|
|
1659
|
# open character class [^...] |
9192
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
9193
|
|
|
|
|
|
|
my $left = $i; |
9194
|
|
|
|
|
|
|
|
9195
|
|
|
|
|
|
|
# [^] make die "Unmatched [] in regexp ...\n" |
9196
|
328
|
100
|
|
|
|
478
|
# (and so on) |
9197
|
328
|
|
|
|
|
708
|
|
9198
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9199
|
|
|
|
|
|
|
$i++; |
9200
|
5
|
|
|
|
|
10
|
} |
9201
|
328
|
50
|
|
|
|
387
|
|
9202
|
1447
|
|
|
|
|
1943
|
while (1) { |
9203
|
|
|
|
|
|
|
if (++$i > $#char) { |
9204
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9205
|
1447
|
|
|
|
|
2097
|
} |
9206
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9207
|
|
|
|
|
|
|
my $right = $i; |
9208
|
328
|
100
|
|
|
|
370
|
|
9209
|
328
|
|
|
|
|
1779
|
# [^...] |
|
90
|
|
|
|
|
194
|
|
9210
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9211
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9212
|
270
|
|
|
|
|
506
|
} |
9213
|
|
|
|
|
|
|
else { |
9214
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9215
|
238
|
|
|
|
|
837
|
} |
9216
|
328
|
|
|
|
|
598
|
|
9217
|
|
|
|
|
|
|
$i = $left; |
9218
|
|
|
|
|
|
|
last; |
9219
|
|
|
|
|
|
|
} |
9220
|
|
|
|
|
|
|
} |
9221
|
|
|
|
|
|
|
} |
9222
|
|
|
|
|
|
|
|
9223
|
328
|
|
|
|
|
823
|
# rewrite character class or escape character |
9224
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9225
|
|
|
|
|
|
|
$char[$i] = $char; |
9226
|
|
|
|
|
|
|
} |
9227
|
|
|
|
|
|
|
|
9228
|
215
|
50
|
|
|
|
568
|
# /i modifier |
9229
|
238
|
|
|
|
|
460
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
9230
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
9231
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
9232
|
238
|
|
|
|
|
505
|
} |
9233
|
|
|
|
|
|
|
else { |
9234
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
9235
|
|
|
|
|
|
|
} |
9236
|
|
|
|
|
|
|
} |
9237
|
|
|
|
|
|
|
|
9238
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
9239
|
1
|
|
|
|
|
4
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9240
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9241
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9242
|
|
|
|
|
|
|
} |
9243
|
0
|
|
|
|
|
0
|
} |
9244
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
9245
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ucfirst qq<'; |
9246
|
|
|
|
|
|
|
$left_e++; |
9247
|
0
|
|
|
|
|
0
|
} |
9248
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
9249
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lcfirst qq<'; |
9250
|
|
|
|
|
|
|
$left_e++; |
9251
|
0
|
|
|
|
|
0
|
} |
9252
|
1
|
|
|
|
|
3
|
elsif ($char[$i] eq '\U') { |
9253
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::uc qq<'; |
9254
|
|
|
|
|
|
|
$left_e++; |
9255
|
1
|
|
|
|
|
4
|
} |
9256
|
1
|
|
|
|
|
2
|
elsif ($char[$i] eq '\L') { |
9257
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lc qq<'; |
9258
|
|
|
|
|
|
|
$left_e++; |
9259
|
1
|
|
|
|
|
3
|
} |
9260
|
9
|
|
|
|
|
17
|
elsif ($char[$i] eq '\F') { |
9261
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::fc qq<'; |
9262
|
|
|
|
|
|
|
$left_e++; |
9263
|
9
|
|
|
|
|
25
|
} |
9264
|
22
|
|
|
|
|
43
|
elsif ($char[$i] eq '\Q') { |
9265
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9266
|
|
|
|
|
|
|
$left_e++; |
9267
|
22
|
50
|
|
|
|
61
|
} |
9268
|
33
|
|
|
|
|
91
|
elsif ($char[$i] eq '\E') { |
9269
|
33
|
|
|
|
|
60
|
if ($right_e < $left_e) { |
9270
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9271
|
|
|
|
|
|
|
$right_e++; |
9272
|
33
|
|
|
|
|
84
|
} |
9273
|
|
|
|
|
|
|
else { |
9274
|
|
|
|
|
|
|
$char[$i] = ''; |
9275
|
|
|
|
|
|
|
} |
9276
|
0
|
|
|
|
|
0
|
} |
9277
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9278
|
0
|
|
|
|
|
0
|
while (1) { |
9279
|
|
|
|
|
|
|
if (++$i > $#char) { |
9280
|
0
|
0
|
|
|
|
0
|
last; |
9281
|
0
|
|
|
|
|
0
|
} |
9282
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9283
|
|
|
|
|
|
|
last; |
9284
|
|
|
|
|
|
|
} |
9285
|
|
|
|
|
|
|
} |
9286
|
|
|
|
|
|
|
} |
9287
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9288
|
|
|
|
|
|
|
} |
9289
|
|
|
|
|
|
|
|
9290
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
9291
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9292
|
|
|
|
|
|
|
if ($ignorecase) { |
9293
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9294
|
|
|
|
|
|
|
} |
9295
|
0
|
0
|
|
|
|
0
|
} |
9296
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9297
|
|
|
|
|
|
|
if ($ignorecase) { |
9298
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9299
|
|
|
|
|
|
|
} |
9300
|
|
|
|
|
|
|
} |
9301
|
|
|
|
|
|
|
|
9302
|
|
|
|
|
|
|
# $$ --> $$ |
9303
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9304
|
|
|
|
|
|
|
} |
9305
|
|
|
|
|
|
|
|
9306
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9307
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9308
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9309
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9310
|
|
|
|
|
|
|
if ($ignorecase) { |
9311
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9312
|
|
|
|
|
|
|
} |
9313
|
0
|
|
|
|
|
0
|
} |
9314
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9315
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9316
|
|
|
|
|
|
|
if ($ignorecase) { |
9317
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9318
|
|
|
|
|
|
|
} |
9319
|
|
|
|
|
|
|
} |
9320
|
|
|
|
|
|
|
|
9321
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9322
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9323
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
9324
|
|
|
|
|
|
|
if ($ignorecase) { |
9325
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9326
|
|
|
|
|
|
|
} |
9327
|
|
|
|
|
|
|
} |
9328
|
|
|
|
|
|
|
|
9329
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
9330
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9331
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
9332
|
|
|
|
|
|
|
if ($ignorecase) { |
9333
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9334
|
|
|
|
|
|
|
} |
9335
|
|
|
|
|
|
|
} |
9336
|
|
|
|
|
|
|
|
9337
|
0
|
|
|
|
|
0
|
# $$foo |
9338
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9339
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9340
|
|
|
|
|
|
|
if ($ignorecase) { |
9341
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9342
|
|
|
|
|
|
|
} |
9343
|
|
|
|
|
|
|
} |
9344
|
|
|
|
|
|
|
|
9345
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
9346
|
8
|
|
|
|
|
25
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9347
|
|
|
|
|
|
|
if ($ignorecase) { |
9348
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::PREMATCH())]}'; |
9349
|
0
|
|
|
|
|
0
|
} |
9350
|
|
|
|
|
|
|
else { |
9351
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::PREMATCH()]}'; |
9352
|
|
|
|
|
|
|
} |
9353
|
|
|
|
|
|
|
} |
9354
|
|
|
|
|
|
|
|
9355
|
8
|
50
|
|
|
|
28
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
9356
|
8
|
|
|
|
|
56
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9357
|
|
|
|
|
|
|
if ($ignorecase) { |
9358
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::MATCH())]}'; |
9359
|
0
|
|
|
|
|
0
|
} |
9360
|
|
|
|
|
|
|
else { |
9361
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::MATCH()]}'; |
9362
|
|
|
|
|
|
|
} |
9363
|
|
|
|
|
|
|
} |
9364
|
|
|
|
|
|
|
|
9365
|
8
|
50
|
|
|
|
28
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
9366
|
6
|
|
|
|
|
18
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9367
|
|
|
|
|
|
|
if ($ignorecase) { |
9368
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::POSTMATCH())]}'; |
9369
|
0
|
|
|
|
|
0
|
} |
9370
|
|
|
|
|
|
|
else { |
9371
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::POSTMATCH()]}'; |
9372
|
|
|
|
|
|
|
} |
9373
|
|
|
|
|
|
|
} |
9374
|
|
|
|
|
|
|
|
9375
|
6
|
0
|
|
|
|
33
|
# ${ foo } |
9376
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
9377
|
|
|
|
|
|
|
if ($ignorecase) { |
9378
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9379
|
|
|
|
|
|
|
} |
9380
|
|
|
|
|
|
|
} |
9381
|
|
|
|
|
|
|
|
9382
|
0
|
|
|
|
|
0
|
# ${ ... } |
9383
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9384
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9385
|
|
|
|
|
|
|
if ($ignorecase) { |
9386
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9387
|
|
|
|
|
|
|
} |
9388
|
|
|
|
|
|
|
} |
9389
|
|
|
|
|
|
|
|
9390
|
0
|
|
|
|
|
0
|
# $scalar or @array |
9391
|
31
|
100
|
|
|
|
136
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
9392
|
31
|
|
|
|
|
133
|
$char[$i] = e_string($char[$i]); |
9393
|
|
|
|
|
|
|
if ($ignorecase) { |
9394
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9395
|
|
|
|
|
|
|
} |
9396
|
|
|
|
|
|
|
} |
9397
|
|
|
|
|
|
|
|
9398
|
4
|
100
|
66
|
|
|
17
|
# quote character before ? + * { |
|
|
50
|
|
|
|
|
|
9399
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9400
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
9401
|
196
|
|
|
|
|
1684
|
} |
9402
|
0
|
0
|
|
|
|
0
|
elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9403
|
0
|
|
|
|
|
0
|
my $char = $char[$i-1]; |
9404
|
|
|
|
|
|
|
if ($char[$i] eq '{') { |
9405
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n}; |
9406
|
0
|
|
|
|
|
0
|
} |
9407
|
|
|
|
|
|
|
else { |
9408
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n}; |
9409
|
|
|
|
|
|
|
} |
9410
|
0
|
|
|
|
|
0
|
} |
9411
|
|
|
|
|
|
|
else { |
9412
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9413
|
|
|
|
|
|
|
} |
9414
|
|
|
|
|
|
|
} |
9415
|
|
|
|
|
|
|
} |
9416
|
195
|
|
|
|
|
851
|
|
9417
|
1595
|
50
|
|
|
|
3021
|
# make regexp string |
9418
|
1595
|
0
|
0
|
|
|
3620
|
$modifier =~ tr/i//d; |
9419
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
9420
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9421
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier; |
9422
|
0
|
|
|
|
|
0
|
} |
9423
|
|
|
|
|
|
|
else { |
9424
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
9425
|
0
|
100
|
100
|
|
|
0
|
} |
9426
|
1595
|
|
|
|
|
8623
|
} |
9427
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9428
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier; |
9429
|
94
|
|
|
|
|
863
|
} |
9430
|
|
|
|
|
|
|
else { |
9431
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9432
|
|
|
|
|
|
|
} |
9433
|
|
|
|
|
|
|
} |
9434
|
|
|
|
|
|
|
|
9435
|
|
|
|
|
|
|
# |
9436
|
|
|
|
|
|
|
# double quote stuff |
9437
|
1501
|
|
|
540
|
0
|
13200
|
# |
9438
|
|
|
|
|
|
|
sub qq_stuff { |
9439
|
|
|
|
|
|
|
my($delimiter,$end_delimiter,$stuff) = @_; |
9440
|
540
|
100
|
|
|
|
965
|
|
9441
|
540
|
|
|
|
|
1103
|
# scalar variable or array variable |
9442
|
|
|
|
|
|
|
if ($stuff =~ /\A [\$\@] /oxms) { |
9443
|
|
|
|
|
|
|
return $stuff; |
9444
|
|
|
|
|
|
|
} |
9445
|
300
|
|
|
|
|
1140
|
|
|
240
|
|
|
|
|
561
|
|
9446
|
280
|
|
|
|
|
1248
|
# quote by delimiter |
9447
|
240
|
50
|
|
|
|
688
|
my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg); |
9448
|
240
|
50
|
|
|
|
447
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9449
|
240
|
50
|
|
|
|
386
|
next if $char eq $delimiter; |
9450
|
240
|
|
|
|
|
404
|
next if $char eq $end_delimiter; |
9451
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9452
|
|
|
|
|
|
|
return join '', 'qq', $char, $stuff, $char; |
9453
|
240
|
|
|
|
|
910
|
} |
9454
|
|
|
|
|
|
|
} |
9455
|
|
|
|
|
|
|
return join '', 'qq', '<', $stuff, '>'; |
9456
|
|
|
|
|
|
|
} |
9457
|
|
|
|
|
|
|
|
9458
|
|
|
|
|
|
|
# |
9459
|
|
|
|
|
|
|
# escape regexp (m'', qr'', and m''b, qr''b) |
9460
|
0
|
|
|
163
|
0
|
0
|
# |
9461
|
163
|
|
100
|
|
|
744
|
sub e_qr_q { |
9462
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9463
|
163
|
|
|
|
|
498
|
$modifier ||= ''; |
9464
|
163
|
50
|
|
|
|
338
|
|
9465
|
163
|
|
|
|
|
364
|
$modifier =~ tr/p//d; |
9466
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9467
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
9468
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9469
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
9470
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9471
|
|
|
|
|
|
|
last; |
9472
|
0
|
|
|
|
|
0
|
} |
9473
|
|
|
|
|
|
|
} |
9474
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9475
|
0
|
|
|
|
|
0
|
} |
9476
|
|
|
|
|
|
|
|
9477
|
|
|
|
|
|
|
$slash = 'div'; |
9478
|
163
|
100
|
|
|
|
237
|
|
|
|
100
|
|
|
|
|
|
9479
|
163
|
|
|
|
|
391
|
# literal null string pattern |
9480
|
8
|
|
|
|
|
11
|
if ($string eq '') { |
9481
|
8
|
|
|
|
|
11
|
$modifier =~ tr/bB//d; |
9482
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9483
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9484
|
|
|
|
|
|
|
} |
9485
|
|
|
|
|
|
|
|
9486
|
8
|
|
|
|
|
40
|
# with /b /B modifier |
9487
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9488
|
|
|
|
|
|
|
return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
9489
|
|
|
|
|
|
|
} |
9490
|
|
|
|
|
|
|
|
9491
|
89
|
|
|
|
|
250
|
# without /b /B modifier |
9492
|
|
|
|
|
|
|
else { |
9493
|
|
|
|
|
|
|
return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
9494
|
|
|
|
|
|
|
} |
9495
|
|
|
|
|
|
|
} |
9496
|
|
|
|
|
|
|
|
9497
|
|
|
|
|
|
|
# |
9498
|
|
|
|
|
|
|
# escape regexp (m'', qr'') |
9499
|
66
|
|
|
66
|
0
|
148
|
# |
9500
|
|
|
|
|
|
|
sub e_qr_qt { |
9501
|
66
|
100
|
|
|
|
142
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9502
|
|
|
|
|
|
|
|
9503
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9504
|
66
|
|
|
|
|
165
|
|
9505
|
|
|
|
|
|
|
# split regexp |
9506
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9507
|
|
|
|
|
|
|
[^\x81-\xFE\\\[\$\@\/] | |
9508
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
9509
|
|
|
|
|
|
|
\[\^ | |
9510
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
9511
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
9512
|
|
|
|
|
|
|
[\$\@\/] | |
9513
|
|
|
|
|
|
|
\\ (?:$q_char) | |
9514
|
|
|
|
|
|
|
(?:$q_char) |
9515
|
|
|
|
|
|
|
))/oxmsg; |
9516
|
66
|
|
|
|
|
767
|
|
9517
|
66
|
100
|
100
|
|
|
242
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9518
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9519
|
|
|
|
|
|
|
if (0) { |
9520
|
|
|
|
|
|
|
} |
9521
|
79
|
|
|
|
|
844
|
|
9522
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9523
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9524
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9525
|
|
|
|
|
|
|
} |
9526
|
|
|
|
|
|
|
|
9527
|
2
|
|
|
|
|
15
|
# open character class [...] |
9528
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
9529
|
0
|
|
|
|
|
0
|
my $left = $i; |
9530
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9531
|
0
|
|
|
|
|
0
|
$i++; |
9532
|
0
|
0
|
|
|
|
0
|
} |
9533
|
0
|
|
|
|
|
0
|
while (1) { |
9534
|
|
|
|
|
|
|
if (++$i > $#char) { |
9535
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9536
|
0
|
|
|
|
|
0
|
} |
9537
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9538
|
|
|
|
|
|
|
my $right = $i; |
9539
|
0
|
|
|
|
|
0
|
|
9540
|
|
|
|
|
|
|
# [...] |
9541
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
9542
|
0
|
|
|
|
|
0
|
|
9543
|
|
|
|
|
|
|
$i = $left; |
9544
|
|
|
|
|
|
|
last; |
9545
|
|
|
|
|
|
|
} |
9546
|
|
|
|
|
|
|
} |
9547
|
|
|
|
|
|
|
} |
9548
|
|
|
|
|
|
|
|
9549
|
0
|
|
|
|
|
0
|
# open character class [^...] |
9550
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9551
|
0
|
|
|
|
|
0
|
my $left = $i; |
9552
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9553
|
0
|
|
|
|
|
0
|
$i++; |
9554
|
0
|
0
|
|
|
|
0
|
} |
9555
|
0
|
|
|
|
|
0
|
while (1) { |
9556
|
|
|
|
|
|
|
if (++$i > $#char) { |
9557
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9558
|
0
|
|
|
|
|
0
|
} |
9559
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9560
|
|
|
|
|
|
|
my $right = $i; |
9561
|
0
|
|
|
|
|
0
|
|
9562
|
|
|
|
|
|
|
# [^...] |
9563
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9564
|
0
|
|
|
|
|
0
|
|
9565
|
|
|
|
|
|
|
$i = $left; |
9566
|
|
|
|
|
|
|
last; |
9567
|
|
|
|
|
|
|
} |
9568
|
|
|
|
|
|
|
} |
9569
|
|
|
|
|
|
|
} |
9570
|
|
|
|
|
|
|
|
9571
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
9572
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9573
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9574
|
|
|
|
|
|
|
} |
9575
|
|
|
|
|
|
|
|
9576
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
9577
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9578
|
|
|
|
|
|
|
$char[$i] = $char; |
9579
|
|
|
|
|
|
|
} |
9580
|
|
|
|
|
|
|
|
9581
|
0
|
50
|
|
|
|
0
|
# /i modifier |
9582
|
16
|
|
|
|
|
40
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
9583
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
9584
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
9585
|
16
|
|
|
|
|
42
|
} |
9586
|
|
|
|
|
|
|
else { |
9587
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
9588
|
|
|
|
|
|
|
} |
9589
|
|
|
|
|
|
|
} |
9590
|
|
|
|
|
|
|
|
9591
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
9592
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9593
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
9594
|
0
|
|
|
|
|
0
|
} |
9595
|
|
|
|
|
|
|
else { |
9596
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9597
|
|
|
|
|
|
|
} |
9598
|
|
|
|
|
|
|
} |
9599
|
0
|
|
|
|
|
0
|
} |
9600
|
66
|
|
|
|
|
120
|
|
9601
|
|
|
|
|
|
|
$delimiter = '/'; |
9602
|
66
|
|
|
|
|
84
|
$end_delimiter = '/'; |
9603
|
66
|
|
|
|
|
111
|
|
9604
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9605
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9606
|
|
|
|
|
|
|
} |
9607
|
|
|
|
|
|
|
|
9608
|
|
|
|
|
|
|
# |
9609
|
|
|
|
|
|
|
# escape regexp (m''b, qr''b) |
9610
|
66
|
|
|
89
|
0
|
434
|
# |
9611
|
|
|
|
|
|
|
sub e_qr_qb { |
9612
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9613
|
89
|
|
|
|
|
211
|
|
9614
|
|
|
|
|
|
|
# split regexp |
9615
|
|
|
|
|
|
|
my @char = $string =~ /\G ((?>[^\\]|\\\\|[\x00-\xFF])) /oxmsg; |
9616
|
89
|
|
|
|
|
341
|
|
9617
|
89
|
50
|
|
|
|
248
|
# unescape character |
|
|
50
|
|
|
|
|
|
9618
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9619
|
|
|
|
|
|
|
if (0) { |
9620
|
|
|
|
|
|
|
} |
9621
|
199
|
|
|
|
|
719
|
|
9622
|
|
|
|
|
|
|
# remain \\ |
9623
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
9624
|
|
|
|
|
|
|
} |
9625
|
|
|
|
|
|
|
|
9626
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
9627
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9628
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9629
|
|
|
|
|
|
|
} |
9630
|
0
|
|
|
|
|
0
|
} |
9631
|
89
|
|
|
|
|
156
|
|
9632
|
89
|
|
|
|
|
114
|
$delimiter = '/'; |
9633
|
|
|
|
|
|
|
$end_delimiter = '/'; |
9634
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9635
|
|
|
|
|
|
|
} |
9636
|
|
|
|
|
|
|
|
9637
|
|
|
|
|
|
|
# |
9638
|
|
|
|
|
|
|
# escape regexp (s/here//) |
9639
|
89
|
|
|
196
|
0
|
513
|
# |
9640
|
196
|
|
100
|
|
|
667
|
sub e_s1 { |
9641
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9642
|
196
|
|
|
|
|
766
|
$modifier ||= ''; |
9643
|
196
|
50
|
|
|
|
303
|
|
9644
|
196
|
|
|
|
|
626
|
$modifier =~ tr/p//d; |
9645
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9646
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
9647
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9648
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
9649
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9650
|
|
|
|
|
|
|
last; |
9651
|
0
|
|
|
|
|
0
|
} |
9652
|
|
|
|
|
|
|
} |
9653
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9654
|
0
|
|
|
|
|
0
|
} |
9655
|
|
|
|
|
|
|
|
9656
|
|
|
|
|
|
|
$slash = 'div'; |
9657
|
196
|
100
|
|
|
|
404
|
|
|
|
100
|
|
|
|
|
|
9658
|
196
|
|
|
|
|
681
|
# literal null string pattern |
9659
|
8
|
|
|
|
|
10
|
if ($string eq '') { |
9660
|
8
|
|
|
|
|
9
|
$modifier =~ tr/bB//d; |
9661
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9662
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9663
|
|
|
|
|
|
|
} |
9664
|
|
|
|
|
|
|
|
9665
|
|
|
|
|
|
|
# /b /B modifier |
9666
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9667
|
8
|
50
|
|
|
|
48
|
|
9668
|
44
|
|
|
|
|
95
|
# choice again delimiter |
9669
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
0
|
|
|
|
|
0
|
|
9670
|
0
|
0
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9671
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9672
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9673
|
|
|
|
|
|
|
$delimiter = '('; |
9674
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9675
|
0
|
|
|
|
|
0
|
} |
9676
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9677
|
|
|
|
|
|
|
$delimiter = '{'; |
9678
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9679
|
0
|
|
|
|
|
0
|
} |
9680
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9681
|
|
|
|
|
|
|
$delimiter = '['; |
9682
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9683
|
0
|
|
|
|
|
0
|
} |
9684
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9685
|
|
|
|
|
|
|
$delimiter = '<'; |
9686
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9687
|
0
|
|
|
|
|
0
|
} |
9688
|
0
|
0
|
|
|
|
0
|
else { |
9689
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9690
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9691
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9692
|
|
|
|
|
|
|
$end_delimiter = $char; |
9693
|
|
|
|
|
|
|
last; |
9694
|
|
|
|
|
|
|
} |
9695
|
|
|
|
|
|
|
} |
9696
|
|
|
|
|
|
|
} |
9697
|
0
|
|
|
|
|
0
|
} |
9698
|
44
|
|
|
|
|
64
|
|
9699
|
44
|
|
|
|
|
62
|
my $prematch = ''; |
9700
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
9701
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9702
|
44
|
100
|
|
|
|
265
|
} |
9703
|
144
|
|
|
|
|
427
|
|
9704
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9705
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9706
|
144
|
|
|
|
|
629
|
|
9707
|
|
|
|
|
|
|
# split regexp |
9708
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9709
|
|
|
|
|
|
|
[^\x81-\xFE\\\$\@\[\(]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
9710
|
|
|
|
|
|
|
\\ (?>[1-9][0-9]*) | |
9711
|
|
|
|
|
|
|
\\g (?>\s*) (?>[1-9][0-9]*) | |
9712
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
9713
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
9714
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9715
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9716
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9717
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9718
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9719
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} | |
9720
|
|
|
|
|
|
|
\\ $q_char | |
9721
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9722
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9723
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9724
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9725
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9726
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9727
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9728
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9729
|
|
|
|
|
|
|
\[\^ | |
9730
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9731
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9732
|
|
|
|
|
|
|
\(\? | |
9733
|
|
|
|
|
|
|
$q_char |
9734
|
|
|
|
|
|
|
))/oxmsg; |
9735
|
144
|
50
|
|
|
|
60619
|
|
9736
|
144
|
|
|
|
|
1497
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9737
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9738
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9739
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9740
|
|
|
|
|
|
|
$delimiter = '('; |
9741
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9742
|
0
|
|
|
|
|
0
|
} |
9743
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9744
|
|
|
|
|
|
|
$delimiter = '{'; |
9745
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9746
|
0
|
|
|
|
|
0
|
} |
9747
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9748
|
|
|
|
|
|
|
$delimiter = '['; |
9749
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9750
|
0
|
|
|
|
|
0
|
} |
9751
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9752
|
|
|
|
|
|
|
$delimiter = '<'; |
9753
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9754
|
0
|
|
|
|
|
0
|
} |
9755
|
0
|
0
|
|
|
|
0
|
else { |
9756
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9757
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9758
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9759
|
|
|
|
|
|
|
$end_delimiter = $char; |
9760
|
|
|
|
|
|
|
last; |
9761
|
|
|
|
|
|
|
} |
9762
|
|
|
|
|
|
|
} |
9763
|
|
|
|
|
|
|
} |
9764
|
|
|
|
|
|
|
} |
9765
|
0
|
|
|
|
|
0
|
|
|
144
|
|
|
|
|
322
|
|
9766
|
|
|
|
|
|
|
# count '(' |
9767
|
500
|
|
|
|
|
918
|
my $parens = grep { $_ eq '(' } @char; |
9768
|
144
|
|
|
|
|
266
|
|
9769
|
144
|
|
|
|
|
247
|
my $left_e = 0; |
9770
|
|
|
|
|
|
|
my $right_e = 0; |
9771
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9772
|
144
|
50
|
33
|
|
|
491
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9773
|
421
|
|
|
|
|
2736
|
# "\L\u" --> "\u\L" |
9774
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9775
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9776
|
|
|
|
|
|
|
} |
9777
|
|
|
|
|
|
|
|
9778
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
9779
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9780
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9781
|
|
|
|
|
|
|
} |
9782
|
|
|
|
|
|
|
|
9783
|
0
|
|
|
|
|
0
|
# octal escape sequence |
9784
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9785
|
|
|
|
|
|
|
$char[$i] = Egb18030::octchr($1); |
9786
|
|
|
|
|
|
|
} |
9787
|
|
|
|
|
|
|
|
9788
|
1
|
|
|
|
|
3
|
# hexadecimal escape sequence |
9789
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9790
|
|
|
|
|
|
|
$char[$i] = Egb18030::hexchr($1); |
9791
|
|
|
|
|
|
|
} |
9792
|
|
|
|
|
|
|
|
9793
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9794
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9795
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9796
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
9797
|
1
|
|
|
|
|
5
|
# \P{PROPERTY} --> P\{PROPERTY} |
9798
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
9799
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9800
|
|
|
|
|
|
|
} |
9801
|
|
|
|
|
|
|
|
9802
|
0
|
|
|
|
|
0
|
# \p, \P, \X --> p, P, X |
9803
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9804
|
|
|
|
|
|
|
$char[$i] = $1; |
9805
|
0
|
100
|
100
|
|
|
0
|
} |
|
|
50
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
9806
|
|
|
|
|
|
|
|
9807
|
|
|
|
|
|
|
if (0) { |
9808
|
|
|
|
|
|
|
} |
9809
|
421
|
|
|
|
|
4609
|
|
9810
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9811
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9812
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9813
|
|
|
|
|
|
|
} |
9814
|
|
|
|
|
|
|
|
9815
|
23
|
0
|
0
|
|
|
151
|
# join separated multiple-octet |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
9816
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9817
|
|
|
|
|
|
|
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)) { |
9818
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9819
|
0
|
|
|
|
|
0
|
} |
9820
|
|
|
|
|
|
|
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)) { |
9821
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9822
|
0
|
|
|
|
|
0
|
} |
9823
|
|
|
|
|
|
|
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)) { |
9824
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9825
|
|
|
|
|
|
|
} |
9826
|
|
|
|
|
|
|
} |
9827
|
|
|
|
|
|
|
|
9828
|
0
|
|
|
|
|
0
|
# open character class [...] |
9829
|
20
|
50
|
|
|
|
45
|
elsif ($char[$i] eq '[') { |
9830
|
20
|
|
|
|
|
73
|
my $left = $i; |
9831
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9832
|
0
|
|
|
|
|
0
|
$i++; |
9833
|
20
|
50
|
|
|
|
32
|
} |
9834
|
79
|
|
|
|
|
171
|
while (1) { |
9835
|
|
|
|
|
|
|
if (++$i > $#char) { |
9836
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9837
|
79
|
|
|
|
|
211
|
} |
9838
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9839
|
|
|
|
|
|
|
my $right = $i; |
9840
|
20
|
50
|
|
|
|
99
|
|
9841
|
20
|
|
|
|
|
174
|
# [...] |
|
0
|
|
|
|
|
0
|
|
9842
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9843
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9844
|
0
|
|
|
|
|
0
|
} |
9845
|
|
|
|
|
|
|
else { |
9846
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
9847
|
20
|
|
|
|
|
126
|
} |
9848
|
20
|
|
|
|
|
42
|
|
9849
|
|
|
|
|
|
|
$i = $left; |
9850
|
|
|
|
|
|
|
last; |
9851
|
|
|
|
|
|
|
} |
9852
|
|
|
|
|
|
|
} |
9853
|
|
|
|
|
|
|
} |
9854
|
|
|
|
|
|
|
|
9855
|
20
|
|
|
|
|
65
|
# open character class [^...] |
9856
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9857
|
0
|
|
|
|
|
0
|
my $left = $i; |
9858
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9859
|
0
|
|
|
|
|
0
|
$i++; |
9860
|
0
|
0
|
|
|
|
0
|
} |
9861
|
0
|
|
|
|
|
0
|
while (1) { |
9862
|
|
|
|
|
|
|
if (++$i > $#char) { |
9863
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9864
|
0
|
|
|
|
|
0
|
} |
9865
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9866
|
|
|
|
|
|
|
my $right = $i; |
9867
|
0
|
0
|
|
|
|
0
|
|
9868
|
0
|
|
|
|
|
0
|
# [^...] |
|
0
|
|
|
|
|
0
|
|
9869
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9870
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9871
|
0
|
|
|
|
|
0
|
} |
9872
|
|
|
|
|
|
|
else { |
9873
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9874
|
0
|
|
|
|
|
0
|
} |
9875
|
0
|
|
|
|
|
0
|
|
9876
|
|
|
|
|
|
|
$i = $left; |
9877
|
|
|
|
|
|
|
last; |
9878
|
|
|
|
|
|
|
} |
9879
|
|
|
|
|
|
|
} |
9880
|
|
|
|
|
|
|
} |
9881
|
|
|
|
|
|
|
|
9882
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
9883
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9884
|
|
|
|
|
|
|
$char[$i] = $char; |
9885
|
|
|
|
|
|
|
} |
9886
|
|
|
|
|
|
|
|
9887
|
11
|
50
|
|
|
|
26
|
# /i modifier |
9888
|
11
|
|
|
|
|
36
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
9889
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
9890
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
9891
|
11
|
|
|
|
|
24
|
} |
9892
|
|
|
|
|
|
|
else { |
9893
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
9894
|
|
|
|
|
|
|
} |
9895
|
|
|
|
|
|
|
} |
9896
|
|
|
|
|
|
|
|
9897
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
9898
|
16
|
|
|
|
|
46
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9899
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9900
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9901
|
|
|
|
|
|
|
} |
9902
|
0
|
|
|
|
|
0
|
} |
9903
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
9904
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ucfirst qq<'; |
9905
|
|
|
|
|
|
|
$left_e++; |
9906
|
0
|
|
|
|
|
0
|
} |
9907
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
9908
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lcfirst qq<'; |
9909
|
|
|
|
|
|
|
$left_e++; |
9910
|
0
|
|
|
|
|
0
|
} |
9911
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
9912
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::uc qq<'; |
9913
|
|
|
|
|
|
|
$left_e++; |
9914
|
0
|
|
|
|
|
0
|
} |
9915
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\L') { |
9916
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lc qq<'; |
9917
|
|
|
|
|
|
|
$left_e++; |
9918
|
0
|
|
|
|
|
0
|
} |
9919
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
9920
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::fc qq<'; |
9921
|
|
|
|
|
|
|
$left_e++; |
9922
|
0
|
|
|
|
|
0
|
} |
9923
|
7
|
|
|
|
|
14
|
elsif ($char[$i] eq '\Q') { |
9924
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9925
|
|
|
|
|
|
|
$left_e++; |
9926
|
7
|
50
|
|
|
|
15
|
} |
9927
|
7
|
|
|
|
|
17
|
elsif ($char[$i] eq '\E') { |
9928
|
7
|
|
|
|
|
12
|
if ($right_e < $left_e) { |
9929
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9930
|
|
|
|
|
|
|
$right_e++; |
9931
|
7
|
|
|
|
|
16
|
} |
9932
|
|
|
|
|
|
|
else { |
9933
|
|
|
|
|
|
|
$char[$i] = ''; |
9934
|
|
|
|
|
|
|
} |
9935
|
0
|
|
|
|
|
0
|
} |
9936
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9937
|
0
|
|
|
|
|
0
|
while (1) { |
9938
|
|
|
|
|
|
|
if (++$i > $#char) { |
9939
|
0
|
0
|
|
|
|
0
|
last; |
9940
|
0
|
|
|
|
|
0
|
} |
9941
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9942
|
|
|
|
|
|
|
last; |
9943
|
|
|
|
|
|
|
} |
9944
|
|
|
|
|
|
|
} |
9945
|
|
|
|
|
|
|
} |
9946
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9947
|
|
|
|
|
|
|
} |
9948
|
|
|
|
|
|
|
|
9949
|
|
|
|
|
|
|
# \0 --> \0 |
9950
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) { |
9951
|
|
|
|
|
|
|
} |
9952
|
|
|
|
|
|
|
|
9953
|
|
|
|
|
|
|
# \g{N}, \g{-N} |
9954
|
|
|
|
|
|
|
|
9955
|
|
|
|
|
|
|
# P.108 Using Simple Patterns |
9956
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
9957
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
9958
|
|
|
|
|
|
|
|
9959
|
|
|
|
|
|
|
# P.221 Capturing |
9960
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
9961
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
9962
|
|
|
|
|
|
|
|
9963
|
|
|
|
|
|
|
# \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3} |
9964
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9965
|
|
|
|
|
|
|
} |
9966
|
|
|
|
|
|
|
|
9967
|
0
|
0
|
|
|
|
0
|
# \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable) |
9968
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9969
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9970
|
|
|
|
|
|
|
$char[$i] = '\\g{' . ($1 + 1) . '}'; |
9971
|
|
|
|
|
|
|
} |
9972
|
|
|
|
|
|
|
} |
9973
|
|
|
|
|
|
|
|
9974
|
0
|
0
|
|
|
|
0
|
# \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable) |
9975
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
9976
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9977
|
|
|
|
|
|
|
$char[$i] = '\\g' . ($1 + 1); |
9978
|
|
|
|
|
|
|
} |
9979
|
|
|
|
|
|
|
} |
9980
|
|
|
|
|
|
|
|
9981
|
0
|
0
|
|
|
|
0
|
# \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable) |
9982
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
9983
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9984
|
|
|
|
|
|
|
$char[$i] = '\\' . ($1 + 1); |
9985
|
|
|
|
|
|
|
} |
9986
|
|
|
|
|
|
|
} |
9987
|
|
|
|
|
|
|
|
9988
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
9989
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9990
|
|
|
|
|
|
|
if ($ignorecase) { |
9991
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9992
|
|
|
|
|
|
|
} |
9993
|
0
|
0
|
|
|
|
0
|
} |
9994
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9995
|
|
|
|
|
|
|
if ($ignorecase) { |
9996
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
9997
|
|
|
|
|
|
|
} |
9998
|
|
|
|
|
|
|
} |
9999
|
|
|
|
|
|
|
|
10000
|
|
|
|
|
|
|
# $$ --> $$ |
10001
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
10002
|
|
|
|
|
|
|
} |
10003
|
|
|
|
|
|
|
|
10004
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
10005
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
10006
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
10007
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10008
|
|
|
|
|
|
|
if ($ignorecase) { |
10009
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10010
|
|
|
|
|
|
|
} |
10011
|
0
|
|
|
|
|
0
|
} |
10012
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10013
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10014
|
|
|
|
|
|
|
if ($ignorecase) { |
10015
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10016
|
|
|
|
|
|
|
} |
10017
|
|
|
|
|
|
|
} |
10018
|
|
|
|
|
|
|
|
10019
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10020
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10021
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10022
|
|
|
|
|
|
|
if ($ignorecase) { |
10023
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10024
|
|
|
|
|
|
|
} |
10025
|
|
|
|
|
|
|
} |
10026
|
|
|
|
|
|
|
|
10027
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10028
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10029
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10030
|
|
|
|
|
|
|
if ($ignorecase) { |
10031
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10032
|
|
|
|
|
|
|
} |
10033
|
|
|
|
|
|
|
} |
10034
|
|
|
|
|
|
|
|
10035
|
0
|
|
|
|
|
0
|
# $$foo |
10036
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10037
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10038
|
|
|
|
|
|
|
if ($ignorecase) { |
10039
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10040
|
|
|
|
|
|
|
} |
10041
|
|
|
|
|
|
|
} |
10042
|
|
|
|
|
|
|
|
10043
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
10044
|
4
|
|
|
|
|
17
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10045
|
|
|
|
|
|
|
if ($ignorecase) { |
10046
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::PREMATCH())]}'; |
10047
|
0
|
|
|
|
|
0
|
} |
10048
|
|
|
|
|
|
|
else { |
10049
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::PREMATCH()]}'; |
10050
|
|
|
|
|
|
|
} |
10051
|
|
|
|
|
|
|
} |
10052
|
|
|
|
|
|
|
|
10053
|
4
|
50
|
|
|
|
18
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
10054
|
4
|
|
|
|
|
16
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10055
|
|
|
|
|
|
|
if ($ignorecase) { |
10056
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::MATCH())]}'; |
10057
|
0
|
|
|
|
|
0
|
} |
10058
|
|
|
|
|
|
|
else { |
10059
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::MATCH()]}'; |
10060
|
|
|
|
|
|
|
} |
10061
|
|
|
|
|
|
|
} |
10062
|
|
|
|
|
|
|
|
10063
|
4
|
50
|
|
|
|
16
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
10064
|
3
|
|
|
|
|
14
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10065
|
|
|
|
|
|
|
if ($ignorecase) { |
10066
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::POSTMATCH())]}'; |
10067
|
0
|
|
|
|
|
0
|
} |
10068
|
|
|
|
|
|
|
else { |
10069
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::POSTMATCH()]}'; |
10070
|
|
|
|
|
|
|
} |
10071
|
|
|
|
|
|
|
} |
10072
|
|
|
|
|
|
|
|
10073
|
3
|
0
|
|
|
|
12
|
# ${ foo } |
10074
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10075
|
|
|
|
|
|
|
if ($ignorecase) { |
10076
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10077
|
|
|
|
|
|
|
} |
10078
|
|
|
|
|
|
|
} |
10079
|
|
|
|
|
|
|
|
10080
|
0
|
|
|
|
|
0
|
# ${ ... } |
10081
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10082
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10083
|
|
|
|
|
|
|
if ($ignorecase) { |
10084
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10085
|
|
|
|
|
|
|
} |
10086
|
|
|
|
|
|
|
} |
10087
|
|
|
|
|
|
|
|
10088
|
0
|
|
|
|
|
0
|
# $scalar or @array |
10089
|
13
|
50
|
|
|
|
52
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10090
|
13
|
|
|
|
|
61
|
$char[$i] = e_string($char[$i]); |
10091
|
|
|
|
|
|
|
if ($ignorecase) { |
10092
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10093
|
|
|
|
|
|
|
} |
10094
|
|
|
|
|
|
|
} |
10095
|
|
|
|
|
|
|
|
10096
|
0
|
50
|
|
|
|
0
|
# quote character before ? + * { |
10097
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10098
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10099
|
23
|
|
|
|
|
139
|
} |
10100
|
|
|
|
|
|
|
else { |
10101
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10102
|
|
|
|
|
|
|
} |
10103
|
|
|
|
|
|
|
} |
10104
|
|
|
|
|
|
|
} |
10105
|
23
|
|
|
|
|
131
|
|
10106
|
144
|
|
|
|
|
495
|
# make regexp string |
10107
|
144
|
|
|
|
|
371
|
my $prematch = ''; |
10108
|
144
|
50
|
|
|
|
231
|
$prematch = "($anchor)"; |
10109
|
144
|
|
|
|
|
413
|
$modifier =~ tr/i//d; |
10110
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
10111
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
10112
|
|
|
|
|
|
|
} |
10113
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10114
|
|
|
|
|
|
|
} |
10115
|
|
|
|
|
|
|
|
10116
|
|
|
|
|
|
|
# |
10117
|
|
|
|
|
|
|
# escape regexp (s'here'' or s'here''b) |
10118
|
144
|
|
|
96
|
0
|
1624
|
# |
10119
|
96
|
|
100
|
|
|
201
|
sub e_s1_q { |
10120
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10121
|
96
|
|
|
|
|
241
|
$modifier ||= ''; |
10122
|
96
|
50
|
|
|
|
195
|
|
10123
|
96
|
|
|
|
|
219
|
$modifier =~ tr/p//d; |
10124
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10125
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10126
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10127
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10128
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10129
|
|
|
|
|
|
|
last; |
10130
|
0
|
|
|
|
|
0
|
} |
10131
|
|
|
|
|
|
|
} |
10132
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10133
|
0
|
|
|
|
|
0
|
} |
10134
|
|
|
|
|
|
|
|
10135
|
|
|
|
|
|
|
$slash = 'div'; |
10136
|
96
|
100
|
|
|
|
158
|
|
|
|
100
|
|
|
|
|
|
10137
|
96
|
|
|
|
|
208
|
# literal null string pattern |
10138
|
8
|
|
|
|
|
10
|
if ($string eq '') { |
10139
|
8
|
|
|
|
|
9
|
$modifier =~ tr/bB//d; |
10140
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10141
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
10142
|
|
|
|
|
|
|
} |
10143
|
|
|
|
|
|
|
|
10144
|
8
|
|
|
|
|
44
|
# with /b /B modifier |
10145
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
10146
|
|
|
|
|
|
|
return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
10147
|
|
|
|
|
|
|
} |
10148
|
|
|
|
|
|
|
|
10149
|
44
|
|
|
|
|
94
|
# without /b /B modifier |
10150
|
|
|
|
|
|
|
else { |
10151
|
|
|
|
|
|
|
return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
10152
|
|
|
|
|
|
|
} |
10153
|
|
|
|
|
|
|
} |
10154
|
|
|
|
|
|
|
|
10155
|
|
|
|
|
|
|
# |
10156
|
|
|
|
|
|
|
# escape regexp (s'here'') |
10157
|
44
|
|
|
44
|
0
|
106
|
# |
10158
|
|
|
|
|
|
|
sub e_s1_qt { |
10159
|
44
|
100
|
|
|
|
114
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10160
|
|
|
|
|
|
|
|
10161
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10162
|
44
|
|
|
|
|
133
|
|
10163
|
|
|
|
|
|
|
# split regexp |
10164
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10165
|
|
|
|
|
|
|
[^\x81-\xFE\\\[\$\@\/] | |
10166
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
10167
|
|
|
|
|
|
|
\[\^ | |
10168
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
10169
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
10170
|
|
|
|
|
|
|
[\$\@\/] | |
10171
|
|
|
|
|
|
|
\\ (?:$q_char) | |
10172
|
|
|
|
|
|
|
(?:$q_char) |
10173
|
|
|
|
|
|
|
))/oxmsg; |
10174
|
44
|
|
|
|
|
565
|
|
10175
|
44
|
50
|
100
|
|
|
136
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10176
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10177
|
|
|
|
|
|
|
if (0) { |
10178
|
|
|
|
|
|
|
} |
10179
|
62
|
|
|
|
|
740
|
|
10180
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10181
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10182
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10183
|
|
|
|
|
|
|
} |
10184
|
|
|
|
|
|
|
|
10185
|
0
|
|
|
|
|
0
|
# open character class [...] |
10186
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
10187
|
0
|
|
|
|
|
0
|
my $left = $i; |
10188
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10189
|
0
|
|
|
|
|
0
|
$i++; |
10190
|
0
|
0
|
|
|
|
0
|
} |
10191
|
0
|
|
|
|
|
0
|
while (1) { |
10192
|
|
|
|
|
|
|
if (++$i > $#char) { |
10193
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10194
|
0
|
|
|
|
|
0
|
} |
10195
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10196
|
|
|
|
|
|
|
my $right = $i; |
10197
|
0
|
|
|
|
|
0
|
|
10198
|
|
|
|
|
|
|
# [...] |
10199
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
10200
|
0
|
|
|
|
|
0
|
|
10201
|
|
|
|
|
|
|
$i = $left; |
10202
|
|
|
|
|
|
|
last; |
10203
|
|
|
|
|
|
|
} |
10204
|
|
|
|
|
|
|
} |
10205
|
|
|
|
|
|
|
} |
10206
|
|
|
|
|
|
|
|
10207
|
0
|
|
|
|
|
0
|
# open character class [^...] |
10208
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10209
|
0
|
|
|
|
|
0
|
my $left = $i; |
10210
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10211
|
0
|
|
|
|
|
0
|
$i++; |
10212
|
0
|
0
|
|
|
|
0
|
} |
10213
|
0
|
|
|
|
|
0
|
while (1) { |
10214
|
|
|
|
|
|
|
if (++$i > $#char) { |
10215
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10216
|
0
|
|
|
|
|
0
|
} |
10217
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10218
|
|
|
|
|
|
|
my $right = $i; |
10219
|
0
|
|
|
|
|
0
|
|
10220
|
|
|
|
|
|
|
# [^...] |
10221
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10222
|
0
|
|
|
|
|
0
|
|
10223
|
|
|
|
|
|
|
$i = $left; |
10224
|
|
|
|
|
|
|
last; |
10225
|
|
|
|
|
|
|
} |
10226
|
|
|
|
|
|
|
} |
10227
|
|
|
|
|
|
|
} |
10228
|
|
|
|
|
|
|
|
10229
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10230
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10231
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10232
|
|
|
|
|
|
|
} |
10233
|
|
|
|
|
|
|
|
10234
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
10235
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10236
|
|
|
|
|
|
|
$char[$i] = $char; |
10237
|
|
|
|
|
|
|
} |
10238
|
|
|
|
|
|
|
|
10239
|
6
|
50
|
|
|
|
11
|
# /i modifier |
10240
|
8
|
|
|
|
|
24
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
10241
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
10242
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
10243
|
8
|
|
|
|
|
20
|
} |
10244
|
|
|
|
|
|
|
else { |
10245
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
10246
|
|
|
|
|
|
|
} |
10247
|
|
|
|
|
|
|
} |
10248
|
|
|
|
|
|
|
|
10249
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
10250
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10251
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
10252
|
0
|
|
|
|
|
0
|
} |
10253
|
|
|
|
|
|
|
else { |
10254
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10255
|
|
|
|
|
|
|
} |
10256
|
|
|
|
|
|
|
} |
10257
|
0
|
|
|
|
|
0
|
} |
10258
|
44
|
|
|
|
|
85
|
|
10259
|
44
|
|
|
|
|
77
|
$modifier =~ tr/i//d; |
10260
|
44
|
|
|
|
|
61
|
$delimiter = '/'; |
10261
|
44
|
|
|
|
|
55
|
$end_delimiter = '/'; |
10262
|
44
|
|
|
|
|
98
|
my $prematch = ''; |
10263
|
|
|
|
|
|
|
$prematch = "($anchor)"; |
10264
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10265
|
|
|
|
|
|
|
} |
10266
|
|
|
|
|
|
|
|
10267
|
|
|
|
|
|
|
# |
10268
|
|
|
|
|
|
|
# escape regexp (s'here''b) |
10269
|
44
|
|
|
44
|
0
|
304
|
# |
10270
|
|
|
|
|
|
|
sub e_s1_qb { |
10271
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10272
|
44
|
|
|
|
|
96
|
|
10273
|
|
|
|
|
|
|
# split regexp |
10274
|
|
|
|
|
|
|
my @char = $string =~ /\G (?>[^\\]|\\\\|[\x00-\xFF]) /oxmsg; |
10275
|
44
|
|
|
|
|
154
|
|
10276
|
44
|
50
|
|
|
|
126
|
# unescape character |
|
|
50
|
|
|
|
|
|
10277
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10278
|
|
|
|
|
|
|
if (0) { |
10279
|
|
|
|
|
|
|
} |
10280
|
98
|
|
|
|
|
327
|
|
10281
|
|
|
|
|
|
|
# remain \\ |
10282
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
10283
|
|
|
|
|
|
|
} |
10284
|
|
|
|
|
|
|
|
10285
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10286
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10287
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10288
|
|
|
|
|
|
|
} |
10289
|
0
|
|
|
|
|
0
|
} |
10290
|
44
|
|
|
|
|
92
|
|
10291
|
44
|
|
|
|
|
59
|
$delimiter = '/'; |
10292
|
44
|
|
|
|
|
59
|
$end_delimiter = '/'; |
10293
|
44
|
|
|
|
|
54
|
my $prematch = ''; |
10294
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10295
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10296
|
|
|
|
|
|
|
} |
10297
|
|
|
|
|
|
|
|
10298
|
|
|
|
|
|
|
# |
10299
|
|
|
|
|
|
|
# escape regexp (s''here') |
10300
|
44
|
|
|
91
|
0
|
314
|
# |
10301
|
|
|
|
|
|
|
sub e_s2_q { |
10302
|
91
|
|
|
|
|
184
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10303
|
|
|
|
|
|
|
|
10304
|
91
|
|
|
|
|
118
|
$slash = 'div'; |
10305
|
91
|
|
|
|
|
402
|
|
10306
|
91
|
50
|
66
|
|
|
264
|
my @char = $string =~ / \G (?>[^\x81-\xFE\\]|\\\\|$q_char) /oxmsg; |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
10307
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10308
|
|
|
|
|
|
|
if (0) { |
10309
|
|
|
|
|
|
|
} |
10310
|
9
|
|
|
|
|
100
|
|
10311
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10312
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10313
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10314
|
0
|
|
|
|
|
0
|
} |
10315
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10316
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10317
|
|
|
|
|
|
|
} |
10318
|
|
|
|
|
|
|
|
10319
|
|
|
|
|
|
|
# not escape \\ |
10320
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\\\ \z/oxms) { |
10321
|
|
|
|
|
|
|
} |
10322
|
|
|
|
|
|
|
|
10323
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10324
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10325
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10326
|
5
|
50
|
66
|
|
|
17
|
} |
10327
|
91
|
|
|
|
|
239
|
} |
10328
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10329
|
|
|
|
|
|
|
$char[-1] = $1 . '\\' . $2; |
10330
|
0
|
|
|
|
|
0
|
} |
10331
|
|
|
|
|
|
|
|
10332
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
10333
|
|
|
|
|
|
|
} |
10334
|
|
|
|
|
|
|
|
10335
|
|
|
|
|
|
|
# |
10336
|
|
|
|
|
|
|
# escape regexp (s/here/and here/modifier) |
10337
|
91
|
|
|
292
|
0
|
258
|
# |
10338
|
292
|
|
100
|
|
|
2482
|
sub e_sub { |
10339
|
|
|
|
|
|
|
my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_; |
10340
|
292
|
|
|
|
|
1165
|
$modifier ||= ''; |
10341
|
292
|
50
|
|
|
|
536
|
|
10342
|
292
|
|
|
|
|
1381
|
$modifier =~ tr/p//d; |
10343
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10344
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10345
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10346
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10347
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10348
|
|
|
|
|
|
|
last; |
10349
|
0
|
|
|
|
|
0
|
} |
10350
|
|
|
|
|
|
|
} |
10351
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10352
|
0
|
100
|
|
|
|
0
|
} |
10353
|
292
|
|
|
|
|
682
|
|
10354
|
37
|
|
|
|
|
44
|
if ($variable eq '') { |
10355
|
|
|
|
|
|
|
$variable = '$_'; |
10356
|
|
|
|
|
|
|
$bind_operator = ' =~ '; |
10357
|
37
|
|
|
|
|
56
|
} |
10358
|
|
|
|
|
|
|
|
10359
|
|
|
|
|
|
|
$slash = 'div'; |
10360
|
|
|
|
|
|
|
|
10361
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
10362
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
10363
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
10364
|
|
|
|
|
|
|
# P.312 Iterative Matching: Scalar Context, with /g |
10365
|
|
|
|
|
|
|
# in Chapter 7: Perl |
10366
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
10367
|
|
|
|
|
|
|
|
10368
|
|
|
|
|
|
|
# P.181 Where You Left Off: The \G Assertion |
10369
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10370
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10371
|
|
|
|
|
|
|
|
10372
|
|
|
|
|
|
|
# P.220 Where You Left Off: The \G Assertion |
10373
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10374
|
292
|
|
|
|
|
445
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10375
|
292
|
|
|
|
|
455
|
|
10376
|
|
|
|
|
|
|
my $e_modifier = $modifier =~ tr/e//d; |
10377
|
292
|
|
|
|
|
419
|
my $r_modifier = $modifier =~ tr/r//d; |
10378
|
292
|
50
|
|
|
|
467
|
|
10379
|
292
|
|
|
|
|
807
|
my $my = ''; |
10380
|
0
|
|
|
|
|
0
|
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) { |
10381
|
0
|
|
|
|
|
0
|
$my = $variable; |
10382
|
|
|
|
|
|
|
$variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms; |
10383
|
|
|
|
|
|
|
$variable =~ s/ = .+ \z//oxms; |
10384
|
0
|
|
|
|
|
0
|
} |
10385
|
292
|
|
|
|
|
928
|
|
10386
|
|
|
|
|
|
|
(my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms; |
10387
|
|
|
|
|
|
|
$variable_basename =~ s/ \s+ \z//oxms; |
10388
|
292
|
|
|
|
|
509
|
|
10389
|
292
|
100
|
|
|
|
420
|
# quote replacement string |
10390
|
292
|
|
|
|
|
624
|
my $e_replacement = ''; |
10391
|
17
|
|
|
|
|
38
|
if ($e_modifier >= 1) { |
10392
|
|
|
|
|
|
|
$e_replacement = e_qq('', '', '', $replacement); |
10393
|
|
|
|
|
|
|
$e_modifier--; |
10394
|
17
|
100
|
|
|
|
33
|
} |
10395
|
275
|
|
|
|
|
549
|
else { |
10396
|
|
|
|
|
|
|
if ($delimiter2 eq "'") { |
10397
|
|
|
|
|
|
|
$e_replacement = e_s2_q('qq', '/', '/', $replacement); |
10398
|
91
|
|
|
|
|
170
|
} |
10399
|
|
|
|
|
|
|
else { |
10400
|
|
|
|
|
|
|
$e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement); |
10401
|
|
|
|
|
|
|
} |
10402
|
184
|
|
|
|
|
442
|
} |
10403
|
|
|
|
|
|
|
|
10404
|
|
|
|
|
|
|
my $sub = ''; |
10405
|
292
|
100
|
|
|
|
554
|
|
10406
|
292
|
100
|
|
|
|
571
|
# with /r |
|
|
50
|
|
|
|
|
|
10407
|
|
|
|
|
|
|
if ($r_modifier) { |
10408
|
|
|
|
|
|
|
if (0) { |
10409
|
|
|
|
|
|
|
} |
10410
|
8
|
|
|
|
|
31
|
|
10411
|
0
|
50
|
|
|
|
0
|
# s///gr with multibyte anchoring |
10412
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10413
|
|
|
|
|
|
|
$sub = sprintf( |
10414
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10415
|
|
|
|
|
|
|
q, |
10416
|
|
|
|
|
|
|
|
10417
|
|
|
|
|
|
|
$variable, # 1 |
10418
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10419
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10420
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10421
|
|
|
|
|
|
|
$s_matched, # 3 |
10422
|
|
|
|
|
|
|
$e_replacement, # 4 |
10423
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 5 |
10424
|
|
|
|
|
|
|
); |
10425
|
|
|
|
|
|
|
} |
10426
|
|
|
|
|
|
|
|
10427
|
4
|
0
|
|
|
|
21
|
# s///gr without multibyte anchoring |
10428
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10429
|
|
|
|
|
|
|
$sub = sprintf( |
10430
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10431
|
|
|
|
|
|
|
q, |
10432
|
|
|
|
|
|
|
|
10433
|
|
|
|
|
|
|
$variable, # 1 |
10434
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10435
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10436
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10437
|
|
|
|
|
|
|
$s_matched, # 3 |
10438
|
|
|
|
|
|
|
$e_replacement, # 4 |
10439
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 5 |
10440
|
|
|
|
|
|
|
); |
10441
|
|
|
|
|
|
|
} |
10442
|
|
|
|
|
|
|
|
10443
|
|
|
|
|
|
|
# s///r |
10444
|
0
|
|
|
|
|
0
|
else { |
10445
|
4
|
|
|
|
|
8
|
|
10446
|
|
|
|
|
|
|
my $prematch = q{$`}; |
10447
|
4
|
50
|
|
|
|
4
|
$prematch = q{${1}}; |
10448
|
|
|
|
|
|
|
|
10449
|
|
|
|
|
|
|
$sub = sprintf( |
10450
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 |
10451
|
|
|
|
|
|
|
q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Egb18030::re_r=%s; %s"%s$Egb18030::re_r$'" } : %s>, |
10452
|
|
|
|
|
|
|
|
10453
|
|
|
|
|
|
|
$variable, # 1 |
10454
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10455
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10456
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10457
|
|
|
|
|
|
|
$s_matched, # 3 |
10458
|
|
|
|
|
|
|
$e_replacement, # 4 |
10459
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 5 |
10460
|
|
|
|
|
|
|
$prematch, # 6 |
10461
|
|
|
|
|
|
|
$variable, # 7 |
10462
|
|
|
|
|
|
|
); |
10463
|
|
|
|
|
|
|
} |
10464
|
4
|
50
|
|
|
|
19
|
|
10465
|
8
|
|
|
|
|
25
|
# $var !~ s///r doesn't make sense |
10466
|
|
|
|
|
|
|
if ($bind_operator =~ / !~ /oxms) { |
10467
|
|
|
|
|
|
|
$sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub; |
10468
|
|
|
|
|
|
|
} |
10469
|
|
|
|
|
|
|
} |
10470
|
|
|
|
|
|
|
|
10471
|
0
|
100
|
|
|
|
0
|
# without /r |
|
|
50
|
|
|
|
|
|
10472
|
|
|
|
|
|
|
else { |
10473
|
|
|
|
|
|
|
if (0) { |
10474
|
|
|
|
|
|
|
} |
10475
|
284
|
|
|
|
|
934
|
|
10476
|
0
|
100
|
|
|
|
0
|
# s///g with multibyte anchoring |
|
|
100
|
|
|
|
|
|
10477
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10478
|
|
|
|
|
|
|
$sub = sprintf( |
10479
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 |
10480
|
|
|
|
|
|
|
q, |
10481
|
|
|
|
|
|
|
|
10482
|
|
|
|
|
|
|
$variable, # 1 |
10483
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10484
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10485
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10486
|
|
|
|
|
|
|
$s_matched, # 3 |
10487
|
|
|
|
|
|
|
$e_replacement, # 4 |
10488
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 5 |
10489
|
|
|
|
|
|
|
$variable, # 6 |
10490
|
|
|
|
|
|
|
$variable, # 7 |
10491
|
|
|
|
|
|
|
$variable, # 8 |
10492
|
|
|
|
|
|
|
$variable, # 9 |
10493
|
|
|
|
|
|
|
|
10494
|
|
|
|
|
|
|
# Binary "!~" is just like "=~" except the return value is negated in the logical sense. |
10495
|
|
|
|
|
|
|
# It returns false if the match succeeds, and true if it fails. |
10496
|
|
|
|
|
|
|
# (and so on) |
10497
|
|
|
|
|
|
|
|
10498
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 10 |
10499
|
|
|
|
|
|
|
); |
10500
|
|
|
|
|
|
|
} |
10501
|
|
|
|
|
|
|
|
10502
|
35
|
0
|
|
|
|
157
|
# s///g without multibyte anchoring |
|
|
0
|
|
|
|
|
|
10503
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10504
|
|
|
|
|
|
|
$sub = sprintf( |
10505
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10506
|
|
|
|
|
|
|
q, |
10507
|
|
|
|
|
|
|
|
10508
|
|
|
|
|
|
|
$variable, # 1 |
10509
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10510
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10511
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10512
|
|
|
|
|
|
|
$s_matched, # 3 |
10513
|
|
|
|
|
|
|
$e_replacement, # 4 |
10514
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 5 |
10515
|
|
|
|
|
|
|
$variable, # 6 |
10516
|
|
|
|
|
|
|
$variable, # 7 |
10517
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 8 |
10518
|
|
|
|
|
|
|
); |
10519
|
|
|
|
|
|
|
} |
10520
|
|
|
|
|
|
|
|
10521
|
|
|
|
|
|
|
# s/// |
10522
|
0
|
|
|
|
|
0
|
else { |
10523
|
249
|
|
|
|
|
384
|
|
10524
|
|
|
|
|
|
|
my $prematch = q{$`}; |
10525
|
249
|
100
|
|
|
|
335
|
$prematch = q{${1}}; |
|
|
100
|
|
|
|
|
|
10526
|
|
|
|
|
|
|
|
10527
|
|
|
|
|
|
|
$sub = sprintf( |
10528
|
|
|
|
|
|
|
|
10529
|
|
|
|
|
|
|
($bind_operator =~ / =~ /oxms) ? |
10530
|
|
|
|
|
|
|
|
10531
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10532
|
|
|
|
|
|
|
q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Egb18030::re_r=%s; %s%s="%s$Egb18030::re_r$'"; 1 } : undef> : |
10533
|
|
|
|
|
|
|
|
10534
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10535
|
|
|
|
|
|
|
q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Egb18030::re_r=%s; %s%s="%s$Egb18030::re_r$'"; undef }>, |
10536
|
|
|
|
|
|
|
|
10537
|
|
|
|
|
|
|
$variable, # 1 |
10538
|
|
|
|
|
|
|
$bind_operator, # 2 |
10539
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 3 |
10540
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10541
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10542
|
|
|
|
|
|
|
$s_matched, # 4 |
10543
|
|
|
|
|
|
|
$e_replacement, # 5 |
10544
|
|
|
|
|
|
|
'$Egb18030::re_r=CORE::eval $Egb18030::re_r; ' x $e_modifier, # 6 |
10545
|
|
|
|
|
|
|
$variable, # 7 |
10546
|
|
|
|
|
|
|
$prematch, # 8 |
10547
|
|
|
|
|
|
|
); |
10548
|
|
|
|
|
|
|
} |
10549
|
|
|
|
|
|
|
} |
10550
|
249
|
50
|
|
|
|
1218
|
|
10551
|
292
|
|
|
|
|
798
|
# (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1] |
10552
|
|
|
|
|
|
|
if ($my ne '') { |
10553
|
|
|
|
|
|
|
$sub = "($my, $sub)[1]"; |
10554
|
|
|
|
|
|
|
} |
10555
|
0
|
|
|
|
|
0
|
|
10556
|
292
|
|
|
|
|
455
|
# clear s/// variable |
10557
|
|
|
|
|
|
|
$sub_variable = ''; |
10558
|
292
|
|
|
|
|
376
|
$bind_operator = ''; |
10559
|
|
|
|
|
|
|
|
10560
|
|
|
|
|
|
|
return $sub; |
10561
|
|
|
|
|
|
|
} |
10562
|
|
|
|
|
|
|
|
10563
|
|
|
|
|
|
|
# |
10564
|
|
|
|
|
|
|
# escape chdir (qq//, "") |
10565
|
292
|
|
|
0
|
0
|
2603
|
# |
10566
|
|
|
|
|
|
|
sub e_chdir { |
10567
|
0
|
0
|
|
|
|
0
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10568
|
0
|
0
|
|
|
|
0
|
|
10569
|
0
|
0
|
|
|
|
0
|
if ($^W) { |
10570
|
0
|
|
|
|
|
0
|
if (Egb18030::_MSWin32_5Cended_path($string)) { |
10571
|
0
|
|
|
|
|
0
|
if ($] !~ /^5\.005/oxms) { |
10572
|
|
|
|
|
|
|
warn <
|
10573
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10574
|
|
|
|
|
|
|
|
10575
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10576
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10577
|
|
|
|
|
|
|
END |
10578
|
|
|
|
|
|
|
} |
10579
|
|
|
|
|
|
|
} |
10580
|
0
|
|
|
|
|
0
|
} |
10581
|
|
|
|
|
|
|
|
10582
|
|
|
|
|
|
|
return e_qq($ope,$delimiter,$end_delimiter,$string); |
10583
|
|
|
|
|
|
|
} |
10584
|
|
|
|
|
|
|
|
10585
|
|
|
|
|
|
|
# |
10586
|
|
|
|
|
|
|
# escape chdir (q//, '') |
10587
|
0
|
|
|
2
|
0
|
0
|
# |
10588
|
|
|
|
|
|
|
sub e_chdir_q { |
10589
|
2
|
50
|
|
|
|
7
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10590
|
2
|
0
|
|
|
|
6
|
|
10591
|
0
|
0
|
|
|
|
0
|
if ($^W) { |
10592
|
0
|
|
|
|
|
0
|
if (Egb18030::_MSWin32_5Cended_path($string)) { |
10593
|
0
|
|
|
|
|
0
|
if ($] !~ /^5\.005/oxms) { |
10594
|
|
|
|
|
|
|
warn <
|
10595
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10596
|
|
|
|
|
|
|
|
10597
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10598
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10599
|
|
|
|
|
|
|
END |
10600
|
|
|
|
|
|
|
} |
10601
|
|
|
|
|
|
|
} |
10602
|
0
|
|
|
|
|
0
|
} |
10603
|
|
|
|
|
|
|
|
10604
|
|
|
|
|
|
|
return e_q($ope,$delimiter,$end_delimiter,$string); |
10605
|
|
|
|
|
|
|
} |
10606
|
|
|
|
|
|
|
|
10607
|
|
|
|
|
|
|
# |
10608
|
|
|
|
|
|
|
# escape regexp of split qr// |
10609
|
2
|
|
|
285
|
0
|
21
|
# |
10610
|
285
|
|
100
|
|
|
1359
|
sub e_split { |
10611
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10612
|
285
|
|
|
|
|
1082
|
$modifier ||= ''; |
10613
|
285
|
50
|
|
|
|
540
|
|
10614
|
285
|
|
|
|
|
759
|
$modifier =~ tr/p//d; |
10615
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10616
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10617
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10618
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10619
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10620
|
|
|
|
|
|
|
last; |
10621
|
0
|
|
|
|
|
0
|
} |
10622
|
|
|
|
|
|
|
} |
10623
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10624
|
0
|
|
|
|
|
0
|
} |
10625
|
|
|
|
|
|
|
|
10626
|
|
|
|
|
|
|
$slash = 'div'; |
10627
|
285
|
100
|
|
|
|
479
|
|
10628
|
285
|
|
|
|
|
657
|
# /b /B modifier |
10629
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
10630
|
|
|
|
|
|
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
10631
|
84
|
100
|
|
|
|
475
|
} |
10632
|
201
|
|
|
|
|
681
|
|
10633
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10634
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10635
|
201
|
|
|
|
|
708
|
|
10636
|
|
|
|
|
|
|
# split regexp |
10637
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10638
|
|
|
|
|
|
|
[^\x81-\xFE\\\$\@\[\(]|[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
10639
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10640
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10641
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10642
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10643
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10644
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} | |
10645
|
|
|
|
|
|
|
\\ $q_char | |
10646
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10647
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10648
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10649
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10650
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10651
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10652
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10653
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10654
|
|
|
|
|
|
|
\[\^ | |
10655
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10656
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10657
|
|
|
|
|
|
|
\(\? | |
10658
|
|
|
|
|
|
|
$q_char |
10659
|
201
|
|
|
|
|
21408
|
))/oxmsg; |
10660
|
201
|
|
|
|
|
1194
|
|
10661
|
201
|
|
|
|
|
366
|
my $left_e = 0; |
10662
|
|
|
|
|
|
|
my $right_e = 0; |
10663
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10664
|
201
|
50
|
33
|
|
|
5584
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10665
|
384
|
|
|
|
|
2836
|
# "\L\u" --> "\u\L" |
10666
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10667
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10668
|
|
|
|
|
|
|
} |
10669
|
|
|
|
|
|
|
|
10670
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
10671
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
10672
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10673
|
|
|
|
|
|
|
} |
10674
|
|
|
|
|
|
|
|
10675
|
0
|
|
|
|
|
0
|
# octal escape sequence |
10676
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
10677
|
|
|
|
|
|
|
$char[$i] = Egb18030::octchr($1); |
10678
|
|
|
|
|
|
|
} |
10679
|
|
|
|
|
|
|
|
10680
|
1
|
|
|
|
|
3
|
# hexadecimal escape sequence |
10681
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
10682
|
|
|
|
|
|
|
$char[$i] = Egb18030::hexchr($1); |
10683
|
|
|
|
|
|
|
} |
10684
|
|
|
|
|
|
|
|
10685
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
10686
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
10687
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
10688
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
10689
|
1
|
|
|
|
|
4
|
# \P{PROPERTY} --> P\{PROPERTY} |
10690
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\xFE0-9\}][^\x81-\xFE\}]*) \} ) \z/oxms) { |
10691
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10692
|
|
|
|
|
|
|
} |
10693
|
|
|
|
|
|
|
|
10694
|
0
|
|
|
|
|
0
|
# \p, \P, \X --> p, P, X |
10695
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
10696
|
|
|
|
|
|
|
$char[$i] = $1; |
10697
|
0
|
50
|
100
|
|
|
0
|
} |
|
|
50
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
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
|
|
|
|
|
|
10698
|
|
|
|
|
|
|
|
10699
|
|
|
|
|
|
|
if (0) { |
10700
|
|
|
|
|
|
|
} |
10701
|
384
|
|
|
|
|
3929
|
|
10702
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10703
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10704
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10705
|
|
|
|
|
|
|
} |
10706
|
|
|
|
|
|
|
|
10707
|
0
|
0
|
0
|
|
|
0
|
# join separated multiple-octet |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
10708
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
10709
|
|
|
|
|
|
|
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)) { |
10710
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
10711
|
0
|
|
|
|
|
0
|
} |
10712
|
|
|
|
|
|
|
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)) { |
10713
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
10714
|
0
|
|
|
|
|
0
|
} |
10715
|
|
|
|
|
|
|
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)) { |
10716
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
10717
|
|
|
|
|
|
|
} |
10718
|
|
|
|
|
|
|
} |
10719
|
|
|
|
|
|
|
|
10720
|
0
|
|
|
|
|
0
|
# open character class [...] |
10721
|
3
|
50
|
|
|
|
6
|
elsif ($char[$i] eq '[') { |
10722
|
3
|
|
|
|
|
11
|
my $left = $i; |
10723
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10724
|
0
|
|
|
|
|
0
|
$i++; |
10725
|
3
|
50
|
|
|
|
83
|
} |
10726
|
7
|
|
|
|
|
16
|
while (1) { |
10727
|
|
|
|
|
|
|
if (++$i > $#char) { |
10728
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10729
|
7
|
|
|
|
|
16
|
} |
10730
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10731
|
|
|
|
|
|
|
my $right = $i; |
10732
|
3
|
50
|
|
|
|
33
|
|
10733
|
3
|
|
|
|
|
22
|
# [...] |
|
0
|
|
|
|
|
0
|
|
10734
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10735
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10736
|
0
|
|
|
|
|
0
|
} |
10737
|
|
|
|
|
|
|
else { |
10738
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
10739
|
3
|
|
|
|
|
17
|
} |
10740
|
3
|
|
|
|
|
7
|
|
10741
|
|
|
|
|
|
|
$i = $left; |
10742
|
|
|
|
|
|
|
last; |
10743
|
|
|
|
|
|
|
} |
10744
|
|
|
|
|
|
|
} |
10745
|
|
|
|
|
|
|
} |
10746
|
|
|
|
|
|
|
|
10747
|
3
|
|
|
|
|
9
|
# open character class [^...] |
10748
|
1
|
50
|
|
|
|
2
|
elsif ($char[$i] eq '[^') { |
10749
|
1
|
|
|
|
|
5
|
my $left = $i; |
10750
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10751
|
0
|
|
|
|
|
0
|
$i++; |
10752
|
1
|
50
|
|
|
|
2
|
} |
10753
|
2
|
|
|
|
|
6
|
while (1) { |
10754
|
|
|
|
|
|
|
if (++$i > $#char) { |
10755
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10756
|
2
|
|
|
|
|
6
|
} |
10757
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10758
|
|
|
|
|
|
|
my $right = $i; |
10759
|
1
|
50
|
|
|
|
1
|
|
10760
|
1
|
|
|
|
|
9
|
# [^...] |
|
0
|
|
|
|
|
0
|
|
10761
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10762
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Egb18030::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10763
|
0
|
|
|
|
|
0
|
} |
10764
|
|
|
|
|
|
|
else { |
10765
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10766
|
1
|
|
|
|
|
23
|
} |
10767
|
1
|
|
|
|
|
3
|
|
10768
|
|
|
|
|
|
|
$i = $left; |
10769
|
|
|
|
|
|
|
last; |
10770
|
|
|
|
|
|
|
} |
10771
|
|
|
|
|
|
|
} |
10772
|
|
|
|
|
|
|
} |
10773
|
|
|
|
|
|
|
|
10774
|
1
|
|
|
|
|
4
|
# rewrite character class or escape character |
10775
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10776
|
|
|
|
|
|
|
$char[$i] = $char; |
10777
|
|
|
|
|
|
|
} |
10778
|
|
|
|
|
|
|
|
10779
|
|
|
|
|
|
|
# P.794 29.2.161. split |
10780
|
|
|
|
|
|
|
# in Chapter 29: Functions |
10781
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10782
|
|
|
|
|
|
|
|
10783
|
|
|
|
|
|
|
# P.951 split |
10784
|
|
|
|
|
|
|
# in Chapter 27: Functions |
10785
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10786
|
|
|
|
|
|
|
|
10787
|
|
|
|
|
|
|
# said "The //m modifier is assumed when you split on the pattern /^/", |
10788
|
|
|
|
|
|
|
# but perl5.008 is not so. Therefore, this software adds //m. |
10789
|
|
|
|
|
|
|
# (and so on) |
10790
|
|
|
|
|
|
|
|
10791
|
5
|
|
|
|
|
17
|
# split(m/^/) --> split(m/^/m) |
10792
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
10793
|
|
|
|
|
|
|
$modifier .= 'm'; |
10794
|
|
|
|
|
|
|
} |
10795
|
|
|
|
|
|
|
|
10796
|
14
|
50
|
|
|
|
46
|
# /i modifier |
10797
|
18
|
|
|
|
|
40
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
10798
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
10799
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
10800
|
18
|
|
|
|
|
48
|
} |
10801
|
|
|
|
|
|
|
else { |
10802
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
10803
|
|
|
|
|
|
|
} |
10804
|
|
|
|
|
|
|
} |
10805
|
|
|
|
|
|
|
|
10806
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
10807
|
2
|
|
|
|
|
8
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
10808
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10809
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10810
|
|
|
|
|
|
|
} |
10811
|
0
|
|
|
|
|
0
|
} |
10812
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
10813
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ucfirst qq<'; |
10814
|
|
|
|
|
|
|
$left_e++; |
10815
|
0
|
|
|
|
|
0
|
} |
10816
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
10817
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lcfirst qq<'; |
10818
|
|
|
|
|
|
|
$left_e++; |
10819
|
0
|
|
|
|
|
0
|
} |
10820
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
10821
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::uc qq<'; |
10822
|
|
|
|
|
|
|
$left_e++; |
10823
|
0
|
|
|
|
|
0
|
} |
10824
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\L') { |
10825
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::lc qq<'; |
10826
|
|
|
|
|
|
|
$left_e++; |
10827
|
0
|
|
|
|
|
0
|
} |
10828
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
10829
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::fc qq<'; |
10830
|
|
|
|
|
|
|
$left_e++; |
10831
|
0
|
|
|
|
|
0
|
} |
10832
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10833
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
10834
|
|
|
|
|
|
|
$left_e++; |
10835
|
0
|
0
|
|
|
|
0
|
} |
10836
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\E') { |
10837
|
0
|
|
|
|
|
0
|
if ($right_e < $left_e) { |
10838
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
10839
|
|
|
|
|
|
|
$right_e++; |
10840
|
0
|
|
|
|
|
0
|
} |
10841
|
|
|
|
|
|
|
else { |
10842
|
|
|
|
|
|
|
$char[$i] = ''; |
10843
|
|
|
|
|
|
|
} |
10844
|
0
|
|
|
|
|
0
|
} |
10845
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10846
|
0
|
|
|
|
|
0
|
while (1) { |
10847
|
|
|
|
|
|
|
if (++$i > $#char) { |
10848
|
0
|
0
|
|
|
|
0
|
last; |
10849
|
0
|
|
|
|
|
0
|
} |
10850
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
10851
|
|
|
|
|
|
|
last; |
10852
|
|
|
|
|
|
|
} |
10853
|
|
|
|
|
|
|
} |
10854
|
|
|
|
|
|
|
} |
10855
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
10856
|
|
|
|
|
|
|
} |
10857
|
|
|
|
|
|
|
|
10858
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
10859
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
10860
|
|
|
|
|
|
|
if ($ignorecase) { |
10861
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10862
|
|
|
|
|
|
|
} |
10863
|
0
|
0
|
|
|
|
0
|
} |
10864
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
10865
|
|
|
|
|
|
|
if ($ignorecase) { |
10866
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10867
|
|
|
|
|
|
|
} |
10868
|
|
|
|
|
|
|
} |
10869
|
|
|
|
|
|
|
|
10870
|
|
|
|
|
|
|
# $$ --> $$ |
10871
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
10872
|
|
|
|
|
|
|
} |
10873
|
|
|
|
|
|
|
|
10874
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
10875
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
10876
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
10877
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10878
|
|
|
|
|
|
|
if ($ignorecase) { |
10879
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10880
|
|
|
|
|
|
|
} |
10881
|
0
|
|
|
|
|
0
|
} |
10882
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10883
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10884
|
|
|
|
|
|
|
if ($ignorecase) { |
10885
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10886
|
|
|
|
|
|
|
} |
10887
|
|
|
|
|
|
|
} |
10888
|
|
|
|
|
|
|
|
10889
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10890
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10891
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10892
|
|
|
|
|
|
|
if ($ignorecase) { |
10893
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10894
|
|
|
|
|
|
|
} |
10895
|
|
|
|
|
|
|
} |
10896
|
|
|
|
|
|
|
|
10897
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10898
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10899
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10900
|
|
|
|
|
|
|
if ($ignorecase) { |
10901
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10902
|
|
|
|
|
|
|
} |
10903
|
|
|
|
|
|
|
} |
10904
|
|
|
|
|
|
|
|
10905
|
0
|
|
|
|
|
0
|
# $$foo |
10906
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10907
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10908
|
|
|
|
|
|
|
if ($ignorecase) { |
10909
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10910
|
|
|
|
|
|
|
} |
10911
|
|
|
|
|
|
|
} |
10912
|
|
|
|
|
|
|
|
10913
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Egb18030::PREMATCH() |
10914
|
12
|
|
|
|
|
54
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10915
|
|
|
|
|
|
|
if ($ignorecase) { |
10916
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::PREMATCH())]}'; |
10917
|
0
|
|
|
|
|
0
|
} |
10918
|
|
|
|
|
|
|
else { |
10919
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::PREMATCH()]}'; |
10920
|
|
|
|
|
|
|
} |
10921
|
|
|
|
|
|
|
} |
10922
|
|
|
|
|
|
|
|
10923
|
12
|
50
|
|
|
|
67
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Egb18030::MATCH() |
10924
|
12
|
|
|
|
|
36
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10925
|
|
|
|
|
|
|
if ($ignorecase) { |
10926
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::MATCH())]}'; |
10927
|
0
|
|
|
|
|
0
|
} |
10928
|
|
|
|
|
|
|
else { |
10929
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::MATCH()]}'; |
10930
|
|
|
|
|
|
|
} |
10931
|
|
|
|
|
|
|
} |
10932
|
|
|
|
|
|
|
|
10933
|
12
|
50
|
|
|
|
67
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Egb18030::POSTMATCH() |
10934
|
9
|
|
|
|
|
25
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10935
|
|
|
|
|
|
|
if ($ignorecase) { |
10936
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(Egb18030::POSTMATCH())]}'; |
10937
|
0
|
|
|
|
|
0
|
} |
10938
|
|
|
|
|
|
|
else { |
10939
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::POSTMATCH()]}'; |
10940
|
|
|
|
|
|
|
} |
10941
|
|
|
|
|
|
|
} |
10942
|
|
|
|
|
|
|
|
10943
|
9
|
0
|
|
|
|
47
|
# ${ foo } |
10944
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10945
|
|
|
|
|
|
|
if ($ignorecase) { |
10946
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $1 . ')]}'; |
10947
|
|
|
|
|
|
|
} |
10948
|
|
|
|
|
|
|
} |
10949
|
|
|
|
|
|
|
|
10950
|
0
|
|
|
|
|
0
|
# ${ ... } |
10951
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10952
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10953
|
|
|
|
|
|
|
if ($ignorecase) { |
10954
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10955
|
|
|
|
|
|
|
} |
10956
|
|
|
|
|
|
|
} |
10957
|
|
|
|
|
|
|
|
10958
|
0
|
|
|
|
|
0
|
# $scalar or @array |
10959
|
3
|
50
|
|
|
|
12
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10960
|
3
|
|
|
|
|
19
|
$char[$i] = e_string($char[$i]); |
10961
|
|
|
|
|
|
|
if ($ignorecase) { |
10962
|
|
|
|
|
|
|
$char[$i] = '@{[Egb18030::ignorecase(' . $char[$i] . ')]}'; |
10963
|
|
|
|
|
|
|
} |
10964
|
|
|
|
|
|
|
} |
10965
|
|
|
|
|
|
|
|
10966
|
0
|
100
|
|
|
|
0
|
# quote character before ? + * { |
10967
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10968
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10969
|
7
|
|
|
|
|
41
|
} |
10970
|
|
|
|
|
|
|
else { |
10971
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10972
|
|
|
|
|
|
|
} |
10973
|
|
|
|
|
|
|
} |
10974
|
|
|
|
|
|
|
} |
10975
|
4
|
|
|
|
|
20
|
|
10976
|
201
|
50
|
|
|
|
436
|
# make regexp string |
10977
|
201
|
|
|
|
|
441
|
$modifier =~ tr/i//d; |
10978
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
10979
|
0
|
|
|
|
|
0
|
return join '', 'Egb18030::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier; |
10980
|
|
|
|
|
|
|
} |
10981
|
|
|
|
|
|
|
return join '', 'Egb18030::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
10982
|
|
|
|
|
|
|
} |
10983
|
|
|
|
|
|
|
|
10984
|
|
|
|
|
|
|
# |
10985
|
|
|
|
|
|
|
# escape regexp of split qr'' |
10986
|
201
|
|
|
112
|
0
|
1954
|
# |
10987
|
112
|
|
100
|
|
|
527
|
sub e_split_q { |
10988
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10989
|
112
|
|
|
|
|
314
|
$modifier ||= ''; |
10990
|
112
|
50
|
|
|
|
210
|
|
10991
|
112
|
|
|
|
|
284
|
$modifier =~ tr/p//d; |
10992
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10993
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10994
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10995
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10996
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10997
|
|
|
|
|
|
|
last; |
10998
|
0
|
|
|
|
|
0
|
} |
10999
|
|
|
|
|
|
|
} |
11000
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
11001
|
0
|
|
|
|
|
0
|
} |
11002
|
|
|
|
|
|
|
|
11003
|
|
|
|
|
|
|
$slash = 'div'; |
11004
|
112
|
100
|
|
|
|
168
|
|
11005
|
112
|
|
|
|
|
209
|
# /b /B modifier |
11006
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
11007
|
|
|
|
|
|
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
11008
|
56
|
100
|
|
|
|
304
|
} |
11009
|
|
|
|
|
|
|
|
11010
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
11011
|
56
|
|
|
|
|
134
|
|
11012
|
|
|
|
|
|
|
# split regexp |
11013
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
11014
|
|
|
|
|
|
|
[^\x81-\xFE\\\[] | |
11015
|
|
|
|
|
|
|
[\x81-\xFE][^\x30-\x39]|[\x81-\xFE][\x30-\x39][\x81-\xFE][\x00-\xFF] | |
11016
|
|
|
|
|
|
|
\[\^ | |
11017
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
11018
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
11019
|
|
|
|
|
|
|
\\ (?:$q_char) | |
11020
|
|
|
|
|
|
|
(?:$q_char) |
11021
|
|
|
|
|
|
|
))/oxmsg; |
11022
|
56
|
|
|
|
|
349
|
|
11023
|
56
|
50
|
33
|
|
|
169
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
11024
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
11025
|
|
|
|
|
|
|
if (0) { |
11026
|
|
|
|
|
|
|
} |
11027
|
56
|
|
|
|
|
476
|
|
11028
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
11029
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11030
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11031
|
|
|
|
|
|
|
} |
11032
|
|
|
|
|
|
|
|
11033
|
0
|
|
|
|
|
0
|
# open character class [...] |
11034
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
11035
|
0
|
|
|
|
|
0
|
my $left = $i; |
11036
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
11037
|
0
|
|
|
|
|
0
|
$i++; |
11038
|
0
|
0
|
|
|
|
0
|
} |
11039
|
0
|
|
|
|
|
0
|
while (1) { |
11040
|
|
|
|
|
|
|
if (++$i > $#char) { |
11041
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11042
|
0
|
|
|
|
|
0
|
} |
11043
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11044
|
|
|
|
|
|
|
my $right = $i; |
11045
|
0
|
|
|
|
|
0
|
|
11046
|
|
|
|
|
|
|
# [...] |
11047
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_qr(@char[$left+1..$right-1], $modifier); |
11048
|
0
|
|
|
|
|
0
|
|
11049
|
|
|
|
|
|
|
$i = $left; |
11050
|
|
|
|
|
|
|
last; |
11051
|
|
|
|
|
|
|
} |
11052
|
|
|
|
|
|
|
} |
11053
|
|
|
|
|
|
|
} |
11054
|
|
|
|
|
|
|
|
11055
|
0
|
|
|
|
|
0
|
# open character class [^...] |
11056
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
11057
|
0
|
|
|
|
|
0
|
my $left = $i; |
11058
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
11059
|
0
|
|
|
|
|
0
|
$i++; |
11060
|
0
|
0
|
|
|
|
0
|
} |
11061
|
0
|
|
|
|
|
0
|
while (1) { |
11062
|
|
|
|
|
|
|
if (++$i > $#char) { |
11063
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11064
|
0
|
|
|
|
|
0
|
} |
11065
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11066
|
|
|
|
|
|
|
my $right = $i; |
11067
|
0
|
|
|
|
|
0
|
|
11068
|
|
|
|
|
|
|
# [^...] |
11069
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Egb18030::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11070
|
0
|
|
|
|
|
0
|
|
11071
|
|
|
|
|
|
|
$i = $left; |
11072
|
|
|
|
|
|
|
last; |
11073
|
|
|
|
|
|
|
} |
11074
|
|
|
|
|
|
|
} |
11075
|
|
|
|
|
|
|
} |
11076
|
|
|
|
|
|
|
|
11077
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
11078
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11079
|
|
|
|
|
|
|
$char[$i] = $char; |
11080
|
|
|
|
|
|
|
} |
11081
|
|
|
|
|
|
|
|
11082
|
0
|
|
|
|
|
0
|
# split(m/^/) --> split(m/^/m) |
11083
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11084
|
|
|
|
|
|
|
$modifier .= 'm'; |
11085
|
|
|
|
|
|
|
} |
11086
|
|
|
|
|
|
|
|
11087
|
0
|
50
|
|
|
|
0
|
# /i modifier |
11088
|
12
|
|
|
|
|
29
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Egb18030::uc($char[$i]) ne Egb18030::fc($char[$i]))) { |
11089
|
|
|
|
|
|
|
if (CORE::length(Egb18030::fc($char[$i])) == 1) { |
11090
|
|
|
|
|
|
|
$char[$i] = '[' . Egb18030::uc($char[$i]) . Egb18030::fc($char[$i]) . ']'; |
11091
|
12
|
|
|
|
|
32
|
} |
11092
|
|
|
|
|
|
|
else { |
11093
|
|
|
|
|
|
|
$char[$i] = '(?:' . Egb18030::uc($char[$i]) . '|' . Egb18030::fc($char[$i]) . ')'; |
11094
|
|
|
|
|
|
|
} |
11095
|
|
|
|
|
|
|
} |
11096
|
|
|
|
|
|
|
|
11097
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
11098
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11099
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
11100
|
0
|
|
|
|
|
0
|
} |
11101
|
|
|
|
|
|
|
else { |
11102
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11103
|
|
|
|
|
|
|
} |
11104
|
|
|
|
|
|
|
} |
11105
|
0
|
|
|
|
|
0
|
} |
11106
|
56
|
|
|
|
|
106
|
|
11107
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11108
|
|
|
|
|
|
|
return join '', 'Egb18030::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11109
|
|
|
|
|
|
|
} |
11110
|
|
|
|
|
|
|
|
11111
|
|
|
|
|
|
|
# |
11112
|
|
|
|
|
|
|
# escape use without import |
11113
|
56
|
|
|
0
|
0
|
325
|
# |
11114
|
|
|
|
|
|
|
sub e_use_noimport { |
11115
|
0
|
|
|
|
|
|
my($module) = @_; |
11116
|
|
|
|
|
|
|
|
11117
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11118
|
0
|
|
|
|
|
|
|
11119
|
|
|
|
|
|
|
my $fh = gensym(); |
11120
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11121
|
0
|
|
|
|
|
|
|
11122
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11123
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11124
|
|
|
|
|
|
|
my $script = <$fh>; |
11125
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11126
|
0
|
|
|
|
|
|
|
11127
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11128
|
0
|
|
|
|
|
|
return qq; |
11129
|
|
|
|
|
|
|
} |
11130
|
|
|
|
|
|
|
last; |
11131
|
|
|
|
|
|
|
} |
11132
|
0
|
|
|
|
|
|
} |
11133
|
|
|
|
|
|
|
|
11134
|
|
|
|
|
|
|
return qq |
11135
|
|
|
|
|
|
|
} |
11136
|
|
|
|
|
|
|
|
11137
|
|
|
|
|
|
|
# |
11138
|
|
|
|
|
|
|
# escape no without unimport |
11139
|
0
|
|
|
0
|
0
|
|
# |
11140
|
|
|
|
|
|
|
sub e_no_nounimport { |
11141
|
0
|
|
|
|
|
|
my($module) = @_; |
11142
|
|
|
|
|
|
|
|
11143
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11144
|
0
|
|
|
|
|
|
|
11145
|
|
|
|
|
|
|
my $fh = gensym(); |
11146
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11147
|
0
|
|
|
|
|
|
|
11148
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11149
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11150
|
|
|
|
|
|
|
my $script = <$fh>; |
11151
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11152
|
0
|
|
|
|
|
|
|
11153
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11154
|
0
|
|
|
|
|
|
return qq; |
11155
|
|
|
|
|
|
|
} |
11156
|
|
|
|
|
|
|
last; |
11157
|
|
|
|
|
|
|
} |
11158
|
0
|
|
|
|
|
|
} |
11159
|
|
|
|
|
|
|
|
11160
|
|
|
|
|
|
|
return qq; |
11161
|
|
|
|
|
|
|
} |
11162
|
|
|
|
|
|
|
|
11163
|
|
|
|
|
|
|
# |
11164
|
|
|
|
|
|
|
# escape use with import no parameter |
11165
|
0
|
|
|
0
|
0
|
|
# |
11166
|
|
|
|
|
|
|
sub e_use_noparam { |
11167
|
0
|
|
|
|
|
|
my($module) = @_; |
11168
|
|
|
|
|
|
|
|
11169
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11170
|
0
|
|
|
|
|
|
|
11171
|
|
|
|
|
|
|
my $fh = gensym(); |
11172
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11173
|
0
|
|
|
|
|
|
|
11174
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11175
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11176
|
|
|
|
|
|
|
my $script = <$fh>; |
11177
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11178
|
|
|
|
|
|
|
|
11179
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11180
|
|
|
|
|
|
|
|
11181
|
|
|
|
|
|
|
# P.326 UNIVERSAL: The Ultimate Ancestor Class |
11182
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11183
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11184
|
|
|
|
|
|
|
|
11185
|
|
|
|
|
|
|
# P.435 UNIVERSAL: The Ultimate Ancestor Class |
11186
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11187
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11188
|
|
|
|
|
|
|
|
11189
|
0
|
|
|
|
|
|
# (and so on) |
11190
|
|
|
|
|
|
|
|
11191
|
0
|
|
|
|
|
|
return qq[BEGIN { Egb18030::require '$expr'; $module->import() if $module->can('import'); }]; |
11192
|
|
|
|
|
|
|
} |
11193
|
|
|
|
|
|
|
last; |
11194
|
|
|
|
|
|
|
} |
11195
|
0
|
|
|
|
|
|
} |
11196
|
|
|
|
|
|
|
|
11197
|
|
|
|
|
|
|
return qq |
11198
|
|
|
|
|
|
|
} |
11199
|
|
|
|
|
|
|
|
11200
|
|
|
|
|
|
|
# |
11201
|
|
|
|
|
|
|
# escape no with unimport no parameter |
11202
|
0
|
|
|
0
|
0
|
|
# |
11203
|
|
|
|
|
|
|
sub e_no_noparam { |
11204
|
0
|
|
|
|
|
|
my($module) = @_; |
11205
|
|
|
|
|
|
|
|
11206
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11207
|
0
|
|
|
|
|
|
|
11208
|
|
|
|
|
|
|
my $fh = gensym(); |
11209
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11210
|
0
|
|
|
|
|
|
|
11211
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11212
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11213
|
|
|
|
|
|
|
my $script = <$fh>; |
11214
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11215
|
0
|
|
|
|
|
|
|
11216
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11217
|
0
|
|
|
|
|
|
return qq[BEGIN { Egb18030::require '$expr'; $module->unimport() if $module->can('unimport'); }]; |
11218
|
|
|
|
|
|
|
} |
11219
|
|
|
|
|
|
|
last; |
11220
|
|
|
|
|
|
|
} |
11221
|
0
|
|
|
|
|
|
} |
11222
|
|
|
|
|
|
|
|
11223
|
|
|
|
|
|
|
return qq; |
11224
|
|
|
|
|
|
|
} |
11225
|
|
|
|
|
|
|
|
11226
|
|
|
|
|
|
|
# |
11227
|
|
|
|
|
|
|
# escape use with import parameters |
11228
|
0
|
|
|
0
|
0
|
|
# |
11229
|
|
|
|
|
|
|
sub e_use { |
11230
|
0
|
|
|
|
|
|
my($module,$list) = @_; |
11231
|
|
|
|
|
|
|
|
11232
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11233
|
0
|
|
|
|
|
|
|
11234
|
|
|
|
|
|
|
my $fh = gensym(); |
11235
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11236
|
0
|
|
|
|
|
|
|
11237
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11238
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11239
|
|
|
|
|
|
|
my $script = <$fh>; |
11240
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11241
|
0
|
|
|
|
|
|
|
11242
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11243
|
0
|
|
|
|
|
|
return qq[BEGIN { Egb18030::require '$expr'; $module->import($list) if $module->can('import'); }]; |
11244
|
|
|
|
|
|
|
} |
11245
|
|
|
|
|
|
|
last; |
11246
|
|
|
|
|
|
|
} |
11247
|
0
|
|
|
|
|
|
} |
11248
|
|
|
|
|
|
|
|
11249
|
|
|
|
|
|
|
return qq |
11250
|
|
|
|
|
|
|
} |
11251
|
|
|
|
|
|
|
|
11252
|
|
|
|
|
|
|
# |
11253
|
|
|
|
|
|
|
# escape no with unimport parameters |
11254
|
0
|
|
|
0
|
0
|
|
# |
11255
|
|
|
|
|
|
|
sub e_no { |
11256
|
0
|
|
|
|
|
|
my($module,$list) = @_; |
11257
|
|
|
|
|
|
|
|
11258
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11259
|
0
|
|
|
|
|
|
|
11260
|
|
|
|
|
|
|
my $fh = gensym(); |
11261
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11262
|
0
|
|
|
|
|
|
|
11263
|
0
|
|
|
|
|
|
if (Egb18030::_open_r($fh, $realfilename)) { |
11264
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11265
|
|
|
|
|
|
|
my $script = <$fh>; |
11266
|
0
|
0
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11267
|
0
|
|
|
|
|
|
|
11268
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) GB18030 (?>\s*) ([^\x81-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11269
|
0
|
|
|
|
|
|
return qq[BEGIN { Egb18030::require '$expr'; $module->unimport($list) if $module->can('unimport'); }]; |
11270
|
|
|
|
|
|
|
} |
11271
|
|
|
|
|
|
|
last; |
11272
|
|
|
|
|
|
|
} |
11273
|
0
|
|
|
|
|
|
} |
11274
|
|
|
|
|
|
|
|
11275
|
|
|
|
|
|
|
return qq; |
11276
|
|
|
|
|
|
|
} |
11277
|
|
|
|
|
|
|
|
11278
|
|
|
|
|
|
|
# |
11279
|
|
|
|
|
|
|
# file path of module |
11280
|
0
|
|
|
0
|
|
|
# |
11281
|
|
|
|
|
|
|
sub _pathof { |
11282
|
0
|
0
|
|
|
|
|
my($expr) = @_; |
11283
|
0
|
|
|
|
|
|
|
11284
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11285
|
|
|
|
|
|
|
$expr =~ s#::#:#g; |
11286
|
0
|
|
|
|
|
|
} |
11287
|
|
|
|
|
|
|
else { |
11288
|
0
|
0
|
|
|
|
|
$expr =~ s#::#/#g; |
11289
|
|
|
|
|
|
|
} |
11290
|
0
|
|
|
|
|
|
$expr .= '.pm' if $expr !~ / \.pm \z/oxmsi; |
11291
|
|
|
|
|
|
|
|
11292
|
|
|
|
|
|
|
return $expr; |
11293
|
|
|
|
|
|
|
} |
11294
|
|
|
|
|
|
|
|
11295
|
|
|
|
|
|
|
# |
11296
|
|
|
|
|
|
|
# real file name of module |
11297
|
0
|
|
|
0
|
|
|
# |
11298
|
|
|
|
|
|
|
sub _realfilename { |
11299
|
0
|
0
|
|
|
|
|
my($expr) = @_; |
11300
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11301
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11302
|
|
|
|
|
|
|
return map {"$_$expr"} @INC; |
11303
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
11304
|
|
|
|
|
|
|
else { |
11305
|
|
|
|
|
|
|
return map {"$_/$expr"} @INC; |
11306
|
|
|
|
|
|
|
} |
11307
|
|
|
|
|
|
|
} |
11308
|
|
|
|
|
|
|
|
11309
|
|
|
|
|
|
|
# |
11310
|
|
|
|
|
|
|
# instead of Carp::carp |
11311
|
0
|
|
|
0
|
0
|
|
# |
11312
|
0
|
|
|
|
|
|
sub carp { |
11313
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11314
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11315
|
|
|
|
|
|
|
} |
11316
|
|
|
|
|
|
|
|
11317
|
|
|
|
|
|
|
# |
11318
|
|
|
|
|
|
|
# instead of Carp::croak |
11319
|
0
|
|
|
0
|
0
|
|
# |
11320
|
0
|
|
|
|
|
|
sub croak { |
11321
|
0
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11322
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11323
|
|
|
|
|
|
|
die "\n"; |
11324
|
|
|
|
|
|
|
} |
11325
|
|
|
|
|
|
|
|
11326
|
|
|
|
|
|
|
# |
11327
|
|
|
|
|
|
|
# instead of Carp::cluck |
11328
|
0
|
|
|
0
|
0
|
|
# |
11329
|
0
|
|
|
|
|
|
sub cluck { |
11330
|
0
|
|
|
|
|
|
my $i = 0; |
11331
|
0
|
|
|
|
|
|
my @cluck = (); |
11332
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11333
|
|
|
|
|
|
|
push @cluck, "[$i] $filename($line) $package::$subroutine\n"; |
11334
|
0
|
|
|
|
|
|
$i++; |
11335
|
0
|
|
|
|
|
|
} |
11336
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @cluck; |
11337
|
|
|
|
|
|
|
print STDERR "\n"; |
11338
|
|
|
|
|
|
|
print STDERR @_; |
11339
|
|
|
|
|
|
|
} |
11340
|
|
|
|
|
|
|
|
11341
|
|
|
|
|
|
|
# |
11342
|
|
|
|
|
|
|
# instead of Carp::confess |
11343
|
0
|
|
|
0
|
0
|
|
# |
11344
|
0
|
|
|
|
|
|
sub confess { |
11345
|
0
|
|
|
|
|
|
my $i = 0; |
11346
|
0
|
|
|
|
|
|
my @confess = (); |
11347
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11348
|
|
|
|
|
|
|
push @confess, "[$i] $filename($line) $package::$subroutine\n"; |
11349
|
0
|
|
|
|
|
|
$i++; |
11350
|
0
|
|
|
|
|
|
} |
11351
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @confess; |
11352
|
0
|
|
|
|
|
|
print STDERR "\n"; |
11353
|
|
|
|
|
|
|
print STDERR @_; |
11354
|
|
|
|
|
|
|
die "\n"; |
11355
|
|
|
|
|
|
|
} |
11356
|
|
|
|
|
|
|
|
11357
|
|
|
|
|
|
|
1; |
11358
|
|
|
|
|
|
|
|
11359
|
|
|
|
|
|
|
__END__ |