line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Esjis; |
2
|
390
|
|
|
390
|
|
12293
|
use strict; |
|
390
|
|
|
|
|
6171
|
|
|
390
|
|
|
|
|
15118
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Esjis - Run-time routines for Sjis.pm |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Char-Sjis/ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi |
10
|
|
|
|
|
|
|
###################################################################### |
11
|
|
|
|
|
|
|
|
12
|
390
|
|
|
390
|
|
8298
|
use 5.00503; # Galapagos Consensus 1998 for primetools |
|
390
|
|
|
|
|
4665
|
|
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
|
390
|
|
|
390
|
|
5541
|
use vars qw($VERSION); |
|
390
|
|
|
|
|
2574
|
|
|
390
|
|
|
|
|
60087
|
|
28
|
|
|
|
|
|
|
$VERSION = '1.13'; |
29
|
|
|
|
|
|
|
$VERSION = $VERSION; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BEGIN { |
32
|
390
|
50
|
|
390
|
|
6394
|
if ($^X =~ / jperl /oxmsi) { |
33
|
0
|
|
|
|
|
0
|
die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n"; |
34
|
|
|
|
|
|
|
} |
35
|
390
|
|
|
|
|
2353
|
if (CORE::ord('A') == 193) { |
36
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n"; |
37
|
|
|
|
|
|
|
} |
38
|
390
|
|
|
|
|
60974
|
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
|
390
|
|
|
390
|
|
49397
|
CORE::eval q{ |
|
390
|
|
|
390
|
|
8150
|
|
|
390
|
|
|
150
|
|
2746
|
|
|
390
|
|
|
|
|
49030
|
|
|
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
|
390
|
50
|
|
|
|
145101
|
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
|
|
|
1155
|
0
|
0
|
my($name) = @_; |
73
|
|
|
|
|
|
|
|
74
|
1155
|
50
|
|
|
|
2868
|
if (ref $name) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
75
|
1155
|
|
|
|
|
4936
|
return $name; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif (Esjis::index($name,'::') >= 0) { |
78
|
0
|
|
|
|
|
0
|
return $name; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif (Esjis::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
|
1155
|
|
|
|
|
9128
|
return (caller)[0] . '::' . $name; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub qualify_to_ref ($;$) { |
111
|
0
|
50
|
|
1155
|
0
|
0
|
if (defined $_[1]) { |
112
|
390
|
|
|
390
|
|
2919
|
no strict qw(refs); |
|
390
|
|
|
|
|
3694
|
|
|
390
|
|
|
|
|
27430
|
|
113
|
1155
|
|
|
|
|
3569
|
return \*{ qualify $_[0], $_[1] }; |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else { |
116
|
390
|
|
|
390
|
|
5347
|
no strict qw(refs); |
|
390
|
|
|
0
|
|
3843
|
|
|
390
|
|
|
|
|
74734
|
|
117
|
0
|
|
|
|
|
0
|
return \*{ qualify $_[0], (caller)[0] }; |
|
1155
|
|
|
|
|
1887
|
|
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-\x9F\xE0-\xFC][\x00-\xFF]|[\x00-\xFF]}; |
148
|
390
|
|
|
390
|
|
3757
|
use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms; |
|
390
|
|
|
|
|
4540
|
|
|
390
|
|
|
|
|
47806
|
|
149
|
390
|
|
|
390
|
|
4165
|
use vars qw($q_char); $q_char = qr/$your_char/oxms; |
|
390
|
|
|
|
|
715
|
|
|
390
|
|
|
|
|
652740
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# ShiftJIS character range per length |
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
my %range_tr = (); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# |
157
|
|
|
|
|
|
|
# ShiftJIS 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 E s j i s \z/oxms) { # escape from build system |
173
|
|
|
|
|
|
|
%range_tr = ( |
174
|
|
|
|
|
|
|
1 => [ [0x00..0x80], |
175
|
|
|
|
|
|
|
[0xA0..0xDF], |
176
|
|
|
|
|
|
|
[0xFD..0xFF], |
177
|
|
|
|
|
|
|
], |
178
|
|
|
|
|
|
|
2 => [ [0x81..0x9F],[0x40..0x7E], |
179
|
|
|
|
|
|
|
[0x81..0x9F],[0x80..0xFC], |
180
|
|
|
|
|
|
|
[0xE0..0xFC],[0x40..0x7E], |
181
|
|
|
|
|
|
|
[0xE0..0xFC],[0x80..0xFC], |
182
|
|
|
|
|
|
|
], |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
else { |
187
|
|
|
|
|
|
|
croak "Don't know my package name '@{[__PACKAGE__]}'"; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# |
191
|
|
|
|
|
|
|
# @ARGV wildcard globbing |
192
|
|
|
|
|
|
|
# |
193
|
|
|
|
|
|
|
sub import { |
194
|
|
|
|
|
|
|
|
195
|
1155
|
50
|
|
5
|
|
6333
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
196
|
5
|
|
|
|
|
99
|
my @argv = (); |
197
|
0
|
|
|
|
|
0
|
for (@ARGV) { |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# has space |
200
|
0
|
0
|
|
|
|
0
|
if (/\A (?:$q_char)*? [ ] /oxms) { |
|
|
0
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
0
|
if (my @glob = Esjis::glob(qq{"$_"})) { |
202
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
else { |
205
|
0
|
|
|
|
|
0
|
push @argv, $_; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# has wildcard metachar |
210
|
|
|
|
|
|
|
elsif (/\A (?:$q_char)*? [*?] /oxms) { |
211
|
0
|
0
|
|
|
|
0
|
if (my @glob = Esjis::glob($_)) { |
212
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
else { |
215
|
0
|
|
|
|
|
0
|
push @argv, $_; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# no wildcard globbing |
220
|
|
|
|
|
|
|
else { |
221
|
0
|
|
|
|
|
0
|
push @argv, $_; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
} |
224
|
0
|
|
|
|
|
0
|
@ARGV = @argv; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
0
|
*Char::ord = \&Sjis::ord; |
228
|
5
|
|
|
|
|
31
|
*Char::ord_ = \&Sjis::ord_; |
229
|
5
|
|
|
|
|
14
|
*Char::reverse = \&Sjis::reverse; |
230
|
5
|
|
|
|
|
11
|
*Char::getc = \&Sjis::getc; |
231
|
5
|
|
|
|
|
12
|
*Char::length = \&Sjis::length; |
232
|
5
|
|
|
|
|
11
|
*Char::substr = \&Sjis::substr; |
233
|
5
|
|
|
|
|
11
|
*Char::index = \&Sjis::index; |
234
|
5
|
|
|
|
|
10
|
*Char::rindex = \&Sjis::rindex; |
235
|
5
|
|
|
|
|
11
|
*Char::eval = \&Sjis::eval; |
236
|
5
|
|
|
|
|
21
|
*Char::escape = \&Sjis::escape; |
237
|
5
|
|
|
|
|
13
|
*Char::escape_token = \&Sjis::escape_token; |
238
|
5
|
|
|
|
|
11
|
*Char::escape_script = \&Sjis::escape_script; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# P.230 Care with Prototypes |
242
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
243
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
244
|
|
|
|
|
|
|
# |
245
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
246
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
247
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
248
|
|
|
|
|
|
|
# the world a better place. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# P.332 Care with Prototypes |
251
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
252
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
253
|
|
|
|
|
|
|
# |
254
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
255
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
256
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
257
|
|
|
|
|
|
|
# the world a better place. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# |
260
|
|
|
|
|
|
|
# Prototypes of subroutines |
261
|
|
|
|
|
|
|
# |
262
|
|
|
|
0
|
|
|
sub unimport {} |
263
|
|
|
|
|
|
|
sub Esjis::split(;$$$); |
264
|
|
|
|
|
|
|
sub Esjis::tr($$$$;$); |
265
|
|
|
|
|
|
|
sub Esjis::chop(@); |
266
|
|
|
|
|
|
|
sub Esjis::index($$;$); |
267
|
|
|
|
|
|
|
sub Esjis::rindex($$;$); |
268
|
|
|
|
|
|
|
sub Esjis::lcfirst(@); |
269
|
|
|
|
|
|
|
sub Esjis::lcfirst_(); |
270
|
|
|
|
|
|
|
sub Esjis::lc(@); |
271
|
|
|
|
|
|
|
sub Esjis::lc_(); |
272
|
|
|
|
|
|
|
sub Esjis::ucfirst(@); |
273
|
|
|
|
|
|
|
sub Esjis::ucfirst_(); |
274
|
|
|
|
|
|
|
sub Esjis::uc(@); |
275
|
|
|
|
|
|
|
sub Esjis::uc_(); |
276
|
|
|
|
|
|
|
sub Esjis::fc(@); |
277
|
|
|
|
|
|
|
sub Esjis::fc_(); |
278
|
|
|
|
|
|
|
sub Esjis::ignorecase; |
279
|
|
|
|
|
|
|
sub Esjis::classic_character_class; |
280
|
|
|
|
|
|
|
sub Esjis::capture; |
281
|
|
|
|
|
|
|
sub Esjis::chr(;$); |
282
|
|
|
|
|
|
|
sub Esjis::chr_(); |
283
|
|
|
|
|
|
|
sub Esjis::filetest; |
284
|
|
|
|
|
|
|
sub Esjis::r(;*@); |
285
|
|
|
|
|
|
|
sub Esjis::w(;*@); |
286
|
|
|
|
|
|
|
sub Esjis::x(;*@); |
287
|
|
|
|
|
|
|
sub Esjis::o(;*@); |
288
|
|
|
|
|
|
|
sub Esjis::R(;*@); |
289
|
|
|
|
|
|
|
sub Esjis::W(;*@); |
290
|
|
|
|
|
|
|
sub Esjis::X(;*@); |
291
|
|
|
|
|
|
|
sub Esjis::O(;*@); |
292
|
|
|
|
|
|
|
sub Esjis::e(;*@); |
293
|
|
|
|
|
|
|
sub Esjis::z(;*@); |
294
|
|
|
|
|
|
|
sub Esjis::s(;*@); |
295
|
|
|
|
|
|
|
sub Esjis::f(;*@); |
296
|
|
|
|
|
|
|
sub Esjis::d(;*@); |
297
|
|
|
|
|
|
|
sub Esjis::l(;*@); |
298
|
|
|
|
|
|
|
sub Esjis::p(;*@); |
299
|
|
|
|
|
|
|
sub Esjis::S(;*@); |
300
|
|
|
|
|
|
|
sub Esjis::b(;*@); |
301
|
|
|
|
|
|
|
sub Esjis::c(;*@); |
302
|
|
|
|
|
|
|
sub Esjis::u(;*@); |
303
|
|
|
|
|
|
|
sub Esjis::g(;*@); |
304
|
|
|
|
|
|
|
sub Esjis::k(;*@); |
305
|
|
|
|
|
|
|
sub Esjis::T(;*@); |
306
|
|
|
|
|
|
|
sub Esjis::B(;*@); |
307
|
|
|
|
|
|
|
sub Esjis::M(;*@); |
308
|
|
|
|
|
|
|
sub Esjis::A(;*@); |
309
|
|
|
|
|
|
|
sub Esjis::C(;*@); |
310
|
|
|
|
|
|
|
sub Esjis::filetest_; |
311
|
|
|
|
|
|
|
sub Esjis::r_(); |
312
|
|
|
|
|
|
|
sub Esjis::w_(); |
313
|
|
|
|
|
|
|
sub Esjis::x_(); |
314
|
|
|
|
|
|
|
sub Esjis::o_(); |
315
|
|
|
|
|
|
|
sub Esjis::R_(); |
316
|
|
|
|
|
|
|
sub Esjis::W_(); |
317
|
|
|
|
|
|
|
sub Esjis::X_(); |
318
|
|
|
|
|
|
|
sub Esjis::O_(); |
319
|
|
|
|
|
|
|
sub Esjis::e_(); |
320
|
|
|
|
|
|
|
sub Esjis::z_(); |
321
|
|
|
|
|
|
|
sub Esjis::s_(); |
322
|
|
|
|
|
|
|
sub Esjis::f_(); |
323
|
|
|
|
|
|
|
sub Esjis::d_(); |
324
|
|
|
|
|
|
|
sub Esjis::l_(); |
325
|
|
|
|
|
|
|
sub Esjis::p_(); |
326
|
|
|
|
|
|
|
sub Esjis::S_(); |
327
|
|
|
|
|
|
|
sub Esjis::b_(); |
328
|
|
|
|
|
|
|
sub Esjis::c_(); |
329
|
|
|
|
|
|
|
sub Esjis::u_(); |
330
|
|
|
|
|
|
|
sub Esjis::g_(); |
331
|
|
|
|
|
|
|
sub Esjis::k_(); |
332
|
|
|
|
|
|
|
sub Esjis::T_(); |
333
|
|
|
|
|
|
|
sub Esjis::B_(); |
334
|
|
|
|
|
|
|
sub Esjis::M_(); |
335
|
|
|
|
|
|
|
sub Esjis::A_(); |
336
|
|
|
|
|
|
|
sub Esjis::C_(); |
337
|
|
|
|
|
|
|
sub Esjis::glob($); |
338
|
|
|
|
|
|
|
sub Esjis::glob_(); |
339
|
|
|
|
|
|
|
sub Esjis::lstat(*); |
340
|
|
|
|
|
|
|
sub Esjis::lstat_(); |
341
|
|
|
|
|
|
|
sub Esjis::opendir(*$); |
342
|
|
|
|
|
|
|
sub Esjis::stat(*); |
343
|
|
|
|
|
|
|
sub Esjis::stat_(); |
344
|
|
|
|
|
|
|
sub Esjis::unlink(@); |
345
|
|
|
|
|
|
|
sub Esjis::chdir(;$); |
346
|
|
|
|
|
|
|
sub Esjis::do($); |
347
|
|
|
|
|
|
|
sub Esjis::require(;$); |
348
|
|
|
|
|
|
|
sub Esjis::telldir(*); |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
sub Sjis::ord(;$); |
351
|
|
|
|
|
|
|
sub Sjis::ord_(); |
352
|
|
|
|
|
|
|
sub Sjis::reverse(@); |
353
|
|
|
|
|
|
|
sub Sjis::getc(;*@); |
354
|
|
|
|
|
|
|
sub Sjis::length(;$); |
355
|
|
|
|
|
|
|
sub Sjis::substr($$;$$); |
356
|
|
|
|
|
|
|
sub Sjis::index($$;$); |
357
|
|
|
|
|
|
|
sub Sjis::rindex($$;$); |
358
|
|
|
|
|
|
|
sub Sjis::escape(;$); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# |
361
|
|
|
|
|
|
|
# Regexp work |
362
|
|
|
|
|
|
|
# |
363
|
390
|
|
|
|
|
42080
|
use vars qw( |
364
|
|
|
|
|
|
|
$re_a |
365
|
|
|
|
|
|
|
$re_t |
366
|
|
|
|
|
|
|
$re_n |
367
|
|
|
|
|
|
|
$re_r |
368
|
390
|
|
|
390
|
|
6635
|
); |
|
390
|
|
|
|
|
684
|
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# |
371
|
|
|
|
|
|
|
# Character class |
372
|
|
|
|
|
|
|
# |
373
|
390
|
|
|
|
|
107153
|
use vars qw( |
374
|
|
|
|
|
|
|
$dot |
375
|
|
|
|
|
|
|
$dot_s |
376
|
|
|
|
|
|
|
$eD |
377
|
|
|
|
|
|
|
$eS |
378
|
|
|
|
|
|
|
$eW |
379
|
|
|
|
|
|
|
$eH |
380
|
|
|
|
|
|
|
$eV |
381
|
|
|
|
|
|
|
$eR |
382
|
|
|
|
|
|
|
$eN |
383
|
|
|
|
|
|
|
$not_alnum |
384
|
|
|
|
|
|
|
$not_alpha |
385
|
|
|
|
|
|
|
$not_ascii |
386
|
|
|
|
|
|
|
$not_blank |
387
|
|
|
|
|
|
|
$not_cntrl |
388
|
|
|
|
|
|
|
$not_digit |
389
|
|
|
|
|
|
|
$not_graph |
390
|
|
|
|
|
|
|
$not_lower |
391
|
|
|
|
|
|
|
$not_lower_i |
392
|
|
|
|
|
|
|
$not_print |
393
|
|
|
|
|
|
|
$not_punct |
394
|
|
|
|
|
|
|
$not_space |
395
|
|
|
|
|
|
|
$not_upper |
396
|
|
|
|
|
|
|
$not_upper_i |
397
|
|
|
|
|
|
|
$not_word |
398
|
|
|
|
|
|
|
$not_xdigit |
399
|
|
|
|
|
|
|
$eb |
400
|
|
|
|
|
|
|
$eB |
401
|
390
|
|
|
390
|
|
2594
|
); |
|
390
|
|
|
|
|
745
|
|
402
|
|
|
|
|
|
|
|
403
|
390
|
|
|
|
|
4518442
|
use vars qw( |
404
|
|
|
|
|
|
|
$anchor |
405
|
|
|
|
|
|
|
$matched |
406
|
390
|
|
|
390
|
|
2440
|
); |
|
390
|
|
|
|
|
674
|
|
407
|
|
|
|
|
|
|
${Esjis::anchor} = qr{\G(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?}oxms; |
408
|
|
|
|
|
|
|
my $q_char_SADAHIRO_Tomoyuki_2002_01_17 = ''; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
# Quantifiers |
411
|
|
|
|
|
|
|
# {n,m} --- Match at least n but not more than m times |
412
|
|
|
|
|
|
|
# |
413
|
|
|
|
|
|
|
# n and m are limited to non-negative integral values less than a |
414
|
|
|
|
|
|
|
# preset limit defined when perl is built. This is usually 32766 on |
415
|
|
|
|
|
|
|
# the most common platforms. |
416
|
|
|
|
|
|
|
# |
417
|
|
|
|
|
|
|
# The following code is an attempt to solve the above limitations |
418
|
|
|
|
|
|
|
# in a multi-byte anchoring. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
# avoid "Segmentation fault" and "Error: Parse exception" |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
# perl5101delta |
423
|
|
|
|
|
|
|
# http://perldoc.perl.org/perl5101delta.html |
424
|
|
|
|
|
|
|
# In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767} |
425
|
|
|
|
|
|
|
# [RT #60034, #60464]. For example, this match would fail: |
426
|
|
|
|
|
|
|
# ("ab" x 32768) =~ /^(ab)*$/ |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
# SEE ALSO |
429
|
|
|
|
|
|
|
# |
430
|
|
|
|
|
|
|
# Complex regular subexpression recursion limit |
431
|
|
|
|
|
|
|
# http://www.perlmonks.org/?node_id=810857 |
432
|
|
|
|
|
|
|
# |
433
|
|
|
|
|
|
|
# regexp iteration limits |
434
|
|
|
|
|
|
|
# http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html |
435
|
|
|
|
|
|
|
# |
436
|
|
|
|
|
|
|
# latest Perl won't match certain regexes more than 32768 characters long |
437
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long |
438
|
|
|
|
|
|
|
# |
439
|
|
|
|
|
|
|
# Break through the limitations of regular expressions of Perl |
440
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20110212/1297512479 |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
if (($] >= 5.010001) or |
443
|
|
|
|
|
|
|
# ActivePerl 5.6 or later (include 5.10.0) |
444
|
|
|
|
|
|
|
(defined($ActivePerl::VERSION) and ($ActivePerl::VERSION > 800)) or |
445
|
|
|
|
|
|
|
(($^O eq 'MSWin32') and ($] =~ /\A 5\.006/oxms)) |
446
|
|
|
|
|
|
|
) { |
447
|
|
|
|
|
|
|
my $sbcs = ''; # Single Byte Character Set |
448
|
|
|
|
|
|
|
for my $range (@{ $range_tr{1} }) { |
449
|
|
|
|
|
|
|
$sbcs .= sprintf('\\x%02X-\\x%02X', $range->[0], $range->[-1]); |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
if (0) { |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# other encoding |
456
|
|
|
|
|
|
|
else { |
457
|
|
|
|
|
|
|
${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[$sbcs](?:[^$sbcs][^$sbcs])*?}oxms; |
458
|
|
|
|
|
|
|
# ******* octets not in multiple octet char (always char boundary) |
459
|
|
|
|
|
|
|
# **************** 2 octet chars |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17} = |
463
|
|
|
|
|
|
|
qr{\G(?(?=.{0,32766}\z)(?:[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?|(?(?=[$sbcs]+\z).*?|(?:${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17})))}oxms; |
464
|
|
|
|
|
|
|
# qr{ |
465
|
|
|
|
|
|
|
# \G # (1), (2) |
466
|
|
|
|
|
|
|
# (? # (3) |
467
|
|
|
|
|
|
|
# (?=.{0,32766}\z) # (4) |
468
|
|
|
|
|
|
|
# (?:[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?| # (5) |
469
|
|
|
|
|
|
|
# (?(?=[$sbcs]+\z) # (6) |
470
|
|
|
|
|
|
|
# .*?| #(7) |
471
|
|
|
|
|
|
|
# (?:${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}) # (8) |
472
|
|
|
|
|
|
|
# ))}oxms; |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
# avoid: Complex regular subexpression recursion limit (32766) exceeded at here. |
475
|
|
|
|
|
|
|
local $^W = 0; |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
if (((('A' x 32768).'B') !~ / ${Esjis::anchor} B /oxms) and |
478
|
|
|
|
|
|
|
((('A' x 32768).'B') =~ / ${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17} B /oxms) |
479
|
|
|
|
|
|
|
) { |
480
|
|
|
|
|
|
|
${Esjis::anchor} = ${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17}; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
else { |
483
|
|
|
|
|
|
|
undef ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
# (1) |
488
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
489
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
490
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
491
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
# (2) |
494
|
|
|
|
|
|
|
# P.255 Use leading anchors |
495
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front of expressions |
496
|
|
|
|
|
|
|
# in Chapter6: Crafting an Efficient Expression |
497
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
# (3) |
500
|
|
|
|
|
|
|
# P.138 Conditional: (? if then| else) |
501
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
502
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
# (4) |
505
|
|
|
|
|
|
|
# perlre |
506
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
507
|
|
|
|
|
|
|
# The "*" quantifier is equivalent to {0,} , the "+" quantifier to {1,} , |
508
|
|
|
|
|
|
|
# and the "?" quantifier to {0,1}, ., n, and m are limited to non-negative |
509
|
|
|
|
|
|
|
# integral values less than a preset limit defined when perl is built. |
510
|
|
|
|
|
|
|
# This is usually 32766 on the most common platforms. The actual limit |
511
|
|
|
|
|
|
|
# can be seen in the error message generated by code such as this: |
512
|
|
|
|
|
|
|
# $_ **= $_ , / {$_} / for 2 .. 42; |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
# (5) |
515
|
|
|
|
|
|
|
# P.1023 Multiple-Byte Anchoring |
516
|
|
|
|
|
|
|
# in Appendix W Perl Code Examples |
517
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
# (6) |
520
|
|
|
|
|
|
|
# if string has only SBCS (Single Byte Character Set) |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
# (7) |
523
|
|
|
|
|
|
|
# then .*? (isn't limited to 32766) |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
# (8) |
526
|
|
|
|
|
|
|
# else ShiftJIS::Regexp::Const (SADAHIRO Tomoyuki) |
527
|
|
|
|
|
|
|
# http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#long |
528
|
|
|
|
|
|
|
# http://search.cpan.org/~sadahiro/ShiftJIS-Regexp/ |
529
|
|
|
|
|
|
|
# $PadA = ' (?:\A| [\x00-\x80\xA0-\xDF])(?:[\x81-\x9F\xE0-\xFC]{2})*?'; |
530
|
|
|
|
|
|
|
# $PadG = '\G(?: |[\x00-\xFF]*?[\x00-\x80\xA0-\xDF])(?:[\x81-\x9F\xE0-\xFC]{2})*?'; |
531
|
|
|
|
|
|
|
# $PadGA = '\G(?:\A|(?:[\x81-\x9F\xE0-\xFC]{2})+?|[\x00-\xFF]*?[\x00-\x80\xA0-\xDF] (?:[\x81-\x9F\xE0-\xFC]{2})*?)'; |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
${Esjis::dot} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
534
|
|
|
|
|
|
|
${Esjis::dot_s} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
535
|
|
|
|
|
|
|
${Esjis::eD} = qr{(?>[^\x81-\x9F\xE0-\xFC0-9]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
538
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
539
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
540
|
|
|
|
|
|
|
# ${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x0A \x0C\x0D\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
541
|
|
|
|
|
|
|
# ${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x0A\x0B\x0C\x0D\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
542
|
|
|
|
|
|
|
${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\s]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
${Esjis::eW} = qr{(?>[^\x81-\x9F\xE0-\xFC0-9A-Z_a-z]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
545
|
|
|
|
|
|
|
${Esjis::eH} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
546
|
|
|
|
|
|
|
${Esjis::eV} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A\x0B\x0C\x0D]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
547
|
|
|
|
|
|
|
${Esjis::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])}; |
548
|
|
|
|
|
|
|
${Esjis::eN} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
549
|
|
|
|
|
|
|
${Esjis::not_alnum} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
550
|
|
|
|
|
|
|
${Esjis::not_alpha} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
551
|
|
|
|
|
|
|
${Esjis::not_ascii} = qr{(?>[^\x81-\x9F\xE0-\xFC\x00-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
552
|
|
|
|
|
|
|
${Esjis::not_blank} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
553
|
|
|
|
|
|
|
${Esjis::not_cntrl} = qr{(?>[^\x81-\x9F\xE0-\xFC\x00-\x1F\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
554
|
|
|
|
|
|
|
${Esjis::not_digit} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
555
|
|
|
|
|
|
|
${Esjis::not_graph} = qr{(?>[^\x81-\x9F\xE0-\xFC\x21-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
556
|
|
|
|
|
|
|
${Esjis::not_lower} = qr{(?>[^\x81-\x9F\xE0-\xFC\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
557
|
|
|
|
|
|
|
${Esjis::not_lower_i} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # Perl 5.16 compatible |
558
|
|
|
|
|
|
|
# ${Esjis::not_lower_i} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # older Perl compatible |
559
|
|
|
|
|
|
|
${Esjis::not_print} = qr{(?>[^\x81-\x9F\xE0-\xFC\x20-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
560
|
|
|
|
|
|
|
${Esjis::not_punct} = qr{(?>[^\x81-\x9F\xE0-\xFC\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
561
|
|
|
|
|
|
|
${Esjis::not_space} = qr{(?>[^\x81-\x9F\xE0-\xFC\s\x0B]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
562
|
|
|
|
|
|
|
${Esjis::not_upper} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
563
|
|
|
|
|
|
|
${Esjis::not_upper_i} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # Perl 5.16 compatible |
564
|
|
|
|
|
|
|
# ${Esjis::not_upper_i} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # older Perl compatible |
565
|
|
|
|
|
|
|
${Esjis::not_word} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x5A\x5F\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
566
|
|
|
|
|
|
|
${Esjis::not_xdigit} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x46\x61-\x66]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
567
|
|
|
|
|
|
|
${Esjis::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))}; |
568
|
|
|
|
|
|
|
${Esjis::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]))}; |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
# avoid: Name "Esjis::foo" used only once: possible typo at here. |
571
|
|
|
|
|
|
|
${Esjis::dot} = ${Esjis::dot}; |
572
|
|
|
|
|
|
|
${Esjis::dot_s} = ${Esjis::dot_s}; |
573
|
|
|
|
|
|
|
${Esjis::eD} = ${Esjis::eD}; |
574
|
|
|
|
|
|
|
${Esjis::eS} = ${Esjis::eS}; |
575
|
|
|
|
|
|
|
${Esjis::eW} = ${Esjis::eW}; |
576
|
|
|
|
|
|
|
${Esjis::eH} = ${Esjis::eH}; |
577
|
|
|
|
|
|
|
${Esjis::eV} = ${Esjis::eV}; |
578
|
|
|
|
|
|
|
${Esjis::eR} = ${Esjis::eR}; |
579
|
|
|
|
|
|
|
${Esjis::eN} = ${Esjis::eN}; |
580
|
|
|
|
|
|
|
${Esjis::not_alnum} = ${Esjis::not_alnum}; |
581
|
|
|
|
|
|
|
${Esjis::not_alpha} = ${Esjis::not_alpha}; |
582
|
|
|
|
|
|
|
${Esjis::not_ascii} = ${Esjis::not_ascii}; |
583
|
|
|
|
|
|
|
${Esjis::not_blank} = ${Esjis::not_blank}; |
584
|
|
|
|
|
|
|
${Esjis::not_cntrl} = ${Esjis::not_cntrl}; |
585
|
|
|
|
|
|
|
${Esjis::not_digit} = ${Esjis::not_digit}; |
586
|
|
|
|
|
|
|
${Esjis::not_graph} = ${Esjis::not_graph}; |
587
|
|
|
|
|
|
|
${Esjis::not_lower} = ${Esjis::not_lower}; |
588
|
|
|
|
|
|
|
${Esjis::not_lower_i} = ${Esjis::not_lower_i}; |
589
|
|
|
|
|
|
|
${Esjis::not_print} = ${Esjis::not_print}; |
590
|
|
|
|
|
|
|
${Esjis::not_punct} = ${Esjis::not_punct}; |
591
|
|
|
|
|
|
|
${Esjis::not_space} = ${Esjis::not_space}; |
592
|
|
|
|
|
|
|
${Esjis::not_upper} = ${Esjis::not_upper}; |
593
|
|
|
|
|
|
|
${Esjis::not_upper_i} = ${Esjis::not_upper_i}; |
594
|
|
|
|
|
|
|
${Esjis::not_word} = ${Esjis::not_word}; |
595
|
|
|
|
|
|
|
${Esjis::not_xdigit} = ${Esjis::not_xdigit}; |
596
|
|
|
|
|
|
|
${Esjis::eb} = ${Esjis::eb}; |
597
|
|
|
|
|
|
|
${Esjis::eB} = ${Esjis::eB}; |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
# |
600
|
|
|
|
|
|
|
# ShiftJIS split |
601
|
|
|
|
|
|
|
# |
602
|
|
|
|
|
|
|
sub Esjis::split(;$$$) { |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
# P.794 29.2.161. split |
605
|
|
|
|
|
|
|
# in Chapter 29: Functions |
606
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
# P.951 split |
609
|
|
|
|
|
|
|
# in Chapter 27: Functions |
610
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
611
|
|
|
|
|
|
|
|
612
|
5
|
|
|
0
|
0
|
14741
|
my $pattern = $_[0]; |
613
|
0
|
|
|
|
|
0
|
my $string = $_[1]; |
614
|
0
|
|
|
|
|
0
|
my $limit = $_[2]; |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " " |
617
|
0
|
0
|
|
|
|
0
|
if (not defined $pattern) { |
618
|
0
|
|
|
|
|
0
|
$pattern = ' '; |
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# if $string is omitted, the function splits the $_ string |
622
|
0
|
0
|
|
|
|
0
|
if (not defined $string) { |
623
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
624
|
0
|
|
|
|
|
0
|
$string = $_; |
625
|
|
|
|
|
|
|
} |
626
|
|
|
|
|
|
|
else { |
627
|
0
|
|
|
|
|
0
|
$string = ''; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
|
631
|
0
|
|
|
|
|
0
|
my @split = (); |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# when string is empty |
634
|
0
|
0
|
|
|
|
0
|
if ($string eq '') { |
|
|
0
|
|
|
|
|
|
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
# resulting list value in list context |
637
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
638
|
0
|
|
|
|
|
0
|
return @split; |
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
# count of substrings in scalar context |
642
|
|
|
|
|
|
|
else { |
643
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
644
|
0
|
|
|
|
|
0
|
@_ = @split; |
645
|
0
|
|
|
|
|
0
|
return scalar @_; |
646
|
|
|
|
|
|
|
} |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
# split's first argument is more consistently interpreted |
650
|
|
|
|
|
|
|
# |
651
|
|
|
|
|
|
|
# After some changes earlier in v5.17, split's behavior has been simplified: |
652
|
|
|
|
|
|
|
# if the PATTERN argument evaluates to a string containing one space, it is |
653
|
|
|
|
|
|
|
# treated the way that a literal string containing one space once was. |
654
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " ", the function splits |
657
|
|
|
|
|
|
|
# on whitespace, /\s+/, after skipping any leading whitespace |
658
|
|
|
|
|
|
|
# (and so on) |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
elsif ($pattern eq ' ') { |
661
|
0
|
0
|
|
|
|
0
|
if (not defined $limit) { |
662
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string); |
663
|
|
|
|
|
|
|
} |
664
|
|
|
|
|
|
|
else { |
665
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string, $limit); |
666
|
|
|
|
|
|
|
} |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
0
|
|
|
|
|
0
|
local $q_char = $q_char; |
670
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 32766) { |
671
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\A [\x00-\x7F]+ \z/oxms) { |
|
|
0
|
|
|
|
|
|
672
|
0
|
|
|
|
|
0
|
$q_char = qr{.}s; |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
elsif (defined ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}) { |
675
|
0
|
|
|
|
|
0
|
$q_char = ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
} |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
# if $limit is negative, it is treated as if an arbitrarily large $limit has been specified |
680
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $limit) or ($limit <= 0)) { |
|
|
0
|
|
|
|
|
|
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# a pattern capable of matching either the null string or something longer than the |
683
|
|
|
|
|
|
|
# null string will split the value of $string into separate characters wherever it |
684
|
|
|
|
|
|
|
# matches the null string between characters |
685
|
|
|
|
|
|
|
# (and so on) |
686
|
|
|
|
|
|
|
|
687
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
688
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
689
|
0
|
|
|
|
|
0
|
my $limit = scalar(() = $string =~ /($pattern)/oxmsg); |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
692
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
693
|
|
|
|
|
|
|
# (and so on) |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
# the //m modifier is assumed when you split on the pattern /^/ |
696
|
|
|
|
|
|
|
# (and so on) |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
# V |
699
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) { |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
# if the $pattern contains parentheses, then the substring matched by each pair of parentheses |
702
|
|
|
|
|
|
|
# is included in the resulting list, interspersed with the fields that are ordinarily returned |
703
|
|
|
|
|
|
|
# (and so on) |
704
|
|
|
|
|
|
|
|
705
|
0
|
|
|
|
|
0
|
local $@; |
706
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
707
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
} |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
else { |
713
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
# V |
716
|
0
|
|
|
|
|
0
|
while ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
717
|
0
|
|
|
|
|
0
|
local $@; |
718
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
719
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
} |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
elsif ($limit > 0) { |
726
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
727
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
728
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
# V |
731
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)+?)$pattern//m) { |
732
|
0
|
|
|
|
|
0
|
local $@; |
733
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
734
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
} |
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
} |
739
|
|
|
|
|
|
|
else { |
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
|
|
|
|
|
|
|
} |
753
|
|
|
|
|
|
|
|
754
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 0) { |
755
|
0
|
|
|
|
|
0
|
push @split, $string; |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
# if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result |
759
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $_[2]) or ($_[2] == 0)) { |
760
|
0
|
|
0
|
|
|
0
|
while ((scalar(@split) >= 1) and ($split[-1] eq '')) { |
761
|
0
|
|
|
|
|
0
|
pop @split; |
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
} |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
# resulting list value in list context |
766
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
767
|
0
|
|
|
|
|
0
|
return @split; |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
# count of substrings in scalar context |
771
|
|
|
|
|
|
|
else { |
772
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
773
|
0
|
|
|
|
|
0
|
@_ = @split; |
774
|
0
|
|
|
|
|
0
|
return scalar @_; |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
# |
779
|
|
|
|
|
|
|
# get last subexpression offsets |
780
|
|
|
|
|
|
|
# |
781
|
|
|
|
|
|
|
sub _last_subexpression_offsets { |
782
|
0
|
|
|
0
|
|
0
|
my $pattern = $_[0]; |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
# remove comment |
785
|
0
|
|
|
|
|
0
|
$pattern =~ s/\(\?\# .*? \)//oxmsg; |
786
|
|
|
|
|
|
|
|
787
|
0
|
|
|
|
|
0
|
my $modifier = ''; |
788
|
0
|
0
|
|
|
|
0
|
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) { |
789
|
0
|
|
|
|
|
0
|
$modifier = $1; |
790
|
0
|
|
|
|
|
0
|
$modifier =~ s/-[A-Za-z]*//; |
791
|
|
|
|
|
|
|
} |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
# with /x modifier |
794
|
0
|
|
|
|
|
0
|
my @char = (); |
795
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /x/oxms) { |
796
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
797
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\#\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
798
|
|
|
|
|
|
|
\\ $q_char | |
799
|
|
|
|
|
|
|
\# (?>[^\n]*) $ | |
800
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\x9F\xE0-\xFC\\\]]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
801
|
|
|
|
|
|
|
\(\? | |
802
|
|
|
|
|
|
|
$q_char |
803
|
|
|
|
|
|
|
))/oxmsg; |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
# without /x modifier |
807
|
|
|
|
|
|
|
else { |
808
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
809
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
810
|
|
|
|
|
|
|
\\ $q_char | |
811
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\x9F\xE0-\xFC\\\]]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
812
|
|
|
|
|
|
|
\(\? | |
813
|
|
|
|
|
|
|
$q_char |
814
|
|
|
|
|
|
|
))/oxmsg; |
815
|
|
|
|
|
|
|
} |
816
|
|
|
|
|
|
|
|
817
|
0
|
|
|
|
|
0
|
return scalar grep { $_ eq '(' } @char; |
|
0
|
|
|
|
|
0
|
|
818
|
|
|
|
|
|
|
} |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
# |
821
|
|
|
|
|
|
|
# ShiftJIS transliteration (tr///) |
822
|
|
|
|
|
|
|
# |
823
|
|
|
|
|
|
|
sub Esjis::tr($$$$;$) { |
824
|
|
|
|
|
|
|
|
825
|
0
|
|
|
0
|
0
|
0
|
my $bind_operator = $_[1]; |
826
|
0
|
|
|
|
|
0
|
my $searchlist = $_[2]; |
827
|
0
|
|
|
|
|
0
|
my $replacementlist = $_[3]; |
828
|
0
|
|
0
|
|
|
0
|
my $modifier = $_[4] || ''; |
829
|
|
|
|
|
|
|
|
830
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
831
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
832
|
0
|
|
|
|
|
0
|
croak "Using !~ with tr///r doesn't make sense"; |
833
|
|
|
|
|
|
|
} |
834
|
|
|
|
|
|
|
} |
835
|
|
|
|
|
|
|
|
836
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
837
|
0
|
|
|
|
|
0
|
my @searchlist = _charlist_tr($searchlist); |
838
|
0
|
|
|
|
|
0
|
my @replacementlist = _charlist_tr($replacementlist); |
839
|
|
|
|
|
|
|
|
840
|
0
|
|
|
|
|
0
|
my %tr = (); |
841
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#searchlist; $i++) { |
842
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$searchlist[$i]}) { |
843
|
0
|
0
|
0
|
|
|
0
|
if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
844
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[$i]; |
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
elsif ($modifier =~ /d/oxms) { |
847
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = ''; |
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) { |
850
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[-1]; |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
else { |
853
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $searchlist[$i]; |
854
|
|
|
|
|
|
|
} |
855
|
|
|
|
|
|
|
} |
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
|
858
|
0
|
|
|
|
|
0
|
my $tr = 0; |
859
|
0
|
|
|
|
|
0
|
my $replaced = ''; |
860
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /c/oxms) { |
861
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
862
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$char}) { |
863
|
0
|
0
|
|
|
|
0
|
if (defined $replacementlist[0]) { |
864
|
0
|
|
|
|
|
0
|
$replaced .= $replacementlist[0]; |
865
|
|
|
|
|
|
|
} |
866
|
0
|
|
|
|
|
0
|
$tr++; |
867
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
868
|
0
|
|
0
|
|
|
0
|
while (@char and (not exists $tr{$char[0]})) { |
869
|
0
|
|
|
|
|
0
|
shift @char; |
870
|
0
|
|
|
|
|
0
|
$tr++; |
871
|
|
|
|
|
|
|
} |
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
} |
874
|
|
|
|
|
|
|
else { |
875
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
876
|
|
|
|
|
|
|
} |
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
else { |
880
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
881
|
0
|
0
|
|
|
|
0
|
if (exists $tr{$char}) { |
882
|
0
|
|
|
|
|
0
|
$replaced .= $tr{$char}; |
883
|
0
|
|
|
|
|
0
|
$tr++; |
884
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
885
|
0
|
|
0
|
|
|
0
|
while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) { |
|
|
|
0
|
|
|
|
|
886
|
0
|
|
|
|
|
0
|
shift @char; |
887
|
0
|
|
|
|
|
0
|
$tr++; |
888
|
|
|
|
|
|
|
} |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
else { |
892
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
893
|
|
|
|
|
|
|
} |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
|
897
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
898
|
0
|
|
|
|
|
0
|
return $replaced; |
899
|
|
|
|
|
|
|
} |
900
|
|
|
|
|
|
|
else { |
901
|
0
|
|
|
|
|
0
|
$_[0] = $replaced; |
902
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
903
|
0
|
|
|
|
|
0
|
return not $tr; |
904
|
|
|
|
|
|
|
} |
905
|
|
|
|
|
|
|
else { |
906
|
0
|
|
|
|
|
0
|
return $tr; |
907
|
|
|
|
|
|
|
} |
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
# |
912
|
|
|
|
|
|
|
# ShiftJIS chop |
913
|
|
|
|
|
|
|
# |
914
|
|
|
|
|
|
|
sub Esjis::chop(@) { |
915
|
|
|
|
|
|
|
|
916
|
0
|
|
|
0
|
0
|
0
|
my $chop; |
917
|
0
|
0
|
|
|
|
0
|
if (@_ == 0) { |
918
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
919
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
920
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
921
|
|
|
|
|
|
|
} |
922
|
|
|
|
|
|
|
else { |
923
|
0
|
|
|
|
|
0
|
for (@_) { |
924
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
925
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
926
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
927
|
|
|
|
|
|
|
} |
928
|
|
|
|
|
|
|
} |
929
|
0
|
|
|
|
|
0
|
return $chop; |
930
|
|
|
|
|
|
|
} |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
# |
933
|
|
|
|
|
|
|
# ShiftJIS index by octet |
934
|
|
|
|
|
|
|
# |
935
|
|
|
|
|
|
|
sub Esjis::index($$;$) { |
936
|
|
|
|
|
|
|
|
937
|
0
|
|
|
2310
|
1
|
0
|
my($str,$substr,$position) = @_; |
938
|
2310
|
|
50
|
|
|
4801
|
$position ||= 0; |
939
|
2310
|
|
|
|
|
8772
|
my $pos = 0; |
940
|
|
|
|
|
|
|
|
941
|
2310
|
|
|
|
|
3174
|
while ($pos < CORE::length($str)) { |
942
|
2310
|
50
|
|
|
|
5263
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
943
|
52466
|
0
|
|
|
|
78669
|
if ($pos >= $position) { |
944
|
0
|
|
|
|
|
0
|
return $pos; |
945
|
|
|
|
|
|
|
} |
946
|
|
|
|
|
|
|
} |
947
|
0
|
50
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
948
|
52466
|
|
|
|
|
119116
|
$pos += CORE::length($1); |
949
|
|
|
|
|
|
|
} |
950
|
|
|
|
|
|
|
else { |
951
|
52466
|
|
|
|
|
94737
|
$pos += 1; |
952
|
|
|
|
|
|
|
} |
953
|
|
|
|
|
|
|
} |
954
|
0
|
|
|
|
|
0
|
return -1; |
955
|
|
|
|
|
|
|
} |
956
|
|
|
|
|
|
|
|
957
|
|
|
|
|
|
|
# |
958
|
|
|
|
|
|
|
# ShiftJIS reverse index |
959
|
|
|
|
|
|
|
# |
960
|
|
|
|
|
|
|
sub Esjis::rindex($$;$) { |
961
|
|
|
|
|
|
|
|
962
|
2310
|
|
|
0
|
0
|
13498
|
my($str,$substr,$position) = @_; |
963
|
0
|
|
0
|
|
|
0
|
$position ||= CORE::length($str) - 1; |
964
|
0
|
|
|
|
|
0
|
my $pos = 0; |
965
|
0
|
|
|
|
|
0
|
my $rindex = -1; |
966
|
|
|
|
|
|
|
|
967
|
0
|
|
0
|
|
|
0
|
while (($pos < CORE::length($str)) and ($pos <= $position)) { |
968
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
969
|
0
|
|
|
|
|
0
|
$rindex = $pos; |
970
|
|
|
|
|
|
|
} |
971
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
972
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
973
|
|
|
|
|
|
|
} |
974
|
|
|
|
|
|
|
else { |
975
|
0
|
|
|
|
|
0
|
$pos += 1; |
976
|
|
|
|
|
|
|
} |
977
|
|
|
|
|
|
|
} |
978
|
0
|
|
|
|
|
0
|
return $rindex; |
979
|
|
|
|
|
|
|
} |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
# |
982
|
|
|
|
|
|
|
# ShiftJIS lower case first with parameter |
983
|
|
|
|
|
|
|
# |
984
|
|
|
|
|
|
|
sub Esjis::lcfirst(@) { |
985
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
986
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
987
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
988
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
989
|
|
|
|
|
|
|
} |
990
|
|
|
|
|
|
|
else { |
991
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
992
|
|
|
|
|
|
|
} |
993
|
|
|
|
|
|
|
} |
994
|
|
|
|
|
|
|
else { |
995
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
# |
1000
|
|
|
|
|
|
|
# ShiftJIS lower case first without parameter |
1001
|
|
|
|
|
|
|
# |
1002
|
|
|
|
|
|
|
sub Esjis::lcfirst_() { |
1003
|
0
|
|
|
0
|
0
|
0
|
return Esjis::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1004
|
|
|
|
|
|
|
} |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
# |
1007
|
|
|
|
|
|
|
# ShiftJIS lower case with parameter |
1008
|
|
|
|
|
|
|
# |
1009
|
|
|
|
|
|
|
sub Esjis::lc(@) { |
1010
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1011
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1012
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1013
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
else { |
1016
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
0
|
|
|
|
|
0
|
|
1017
|
|
|
|
|
|
|
} |
1018
|
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
else { |
1020
|
0
|
|
|
|
|
0
|
return Esjis::lc_(); |
1021
|
|
|
|
|
|
|
} |
1022
|
|
|
|
|
|
|
} |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
# |
1025
|
|
|
|
|
|
|
# ShiftJIS lower case without parameter |
1026
|
|
|
|
|
|
|
# |
1027
|
|
|
|
|
|
|
sub Esjis::lc_() { |
1028
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1029
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1030
|
|
|
|
|
|
|
} |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
# |
1033
|
|
|
|
|
|
|
# ShiftJIS upper case first with parameter |
1034
|
|
|
|
|
|
|
# |
1035
|
|
|
|
|
|
|
sub Esjis::ucfirst(@) { |
1036
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1037
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1038
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1039
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
1040
|
|
|
|
|
|
|
} |
1041
|
|
|
|
|
|
|
else { |
1042
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
1043
|
|
|
|
|
|
|
} |
1044
|
|
|
|
|
|
|
} |
1045
|
|
|
|
|
|
|
else { |
1046
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1047
|
|
|
|
|
|
|
} |
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
# |
1051
|
|
|
|
|
|
|
# ShiftJIS upper case first without parameter |
1052
|
|
|
|
|
|
|
# |
1053
|
|
|
|
|
|
|
sub Esjis::ucfirst_() { |
1054
|
0
|
|
|
0
|
0
|
0
|
return Esjis::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1055
|
|
|
|
|
|
|
} |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
# |
1058
|
|
|
|
|
|
|
# ShiftJIS upper case with parameter |
1059
|
|
|
|
|
|
|
# |
1060
|
|
|
|
|
|
|
sub Esjis::uc(@) { |
1061
|
0
|
50
|
|
3628
|
0
|
0
|
if (@_) { |
1062
|
3628
|
|
|
|
|
5103
|
my $s = shift @_; |
1063
|
3628
|
50
|
33
|
|
|
4314
|
if (@_ and wantarray) { |
1064
|
3628
|
0
|
|
|
|
5968
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1065
|
|
|
|
|
|
|
} |
1066
|
|
|
|
|
|
|
else { |
1067
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3628
|
|
|
|
|
9608
|
|
1068
|
|
|
|
|
|
|
} |
1069
|
|
|
|
|
|
|
} |
1070
|
|
|
|
|
|
|
else { |
1071
|
3628
|
|
|
|
|
11581
|
return Esjis::uc_(); |
1072
|
|
|
|
|
|
|
} |
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
# |
1076
|
|
|
|
|
|
|
# ShiftJIS upper case without parameter |
1077
|
|
|
|
|
|
|
# |
1078
|
|
|
|
|
|
|
sub Esjis::uc_() { |
1079
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1080
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1081
|
|
|
|
|
|
|
} |
1082
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
# |
1084
|
|
|
|
|
|
|
# ShiftJIS fold case with parameter |
1085
|
|
|
|
|
|
|
# |
1086
|
|
|
|
|
|
|
sub Esjis::fc(@) { |
1087
|
0
|
50
|
|
3931
|
0
|
0
|
if (@_) { |
1088
|
3931
|
|
|
|
|
5470
|
my $s = shift @_; |
1089
|
3931
|
50
|
33
|
|
|
4389
|
if (@_ and wantarray) { |
1090
|
3931
|
0
|
|
|
|
6348
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1091
|
|
|
|
|
|
|
} |
1092
|
|
|
|
|
|
|
else { |
1093
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3931
|
|
|
|
|
9171
|
|
1094
|
|
|
|
|
|
|
} |
1095
|
|
|
|
|
|
|
} |
1096
|
|
|
|
|
|
|
else { |
1097
|
3931
|
|
|
|
|
13480
|
return Esjis::fc_(); |
1098
|
|
|
|
|
|
|
} |
1099
|
|
|
|
|
|
|
} |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
# |
1102
|
|
|
|
|
|
|
# ShiftJIS fold case without parameter |
1103
|
|
|
|
|
|
|
# |
1104
|
|
|
|
|
|
|
sub Esjis::fc_() { |
1105
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1106
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1107
|
|
|
|
|
|
|
} |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
# |
1110
|
|
|
|
|
|
|
# ShiftJIS regexp capture |
1111
|
|
|
|
|
|
|
# |
1112
|
|
|
|
|
|
|
{ |
1113
|
|
|
|
|
|
|
# 10.3. Creating Persistent Private Variables |
1114
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
1115
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
my $last_s_matched = 0; |
1118
|
|
|
|
|
|
|
|
1119
|
|
|
|
|
|
|
sub Esjis::capture { |
1120
|
0
|
0
|
0
|
0
|
1
|
0
|
if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) { |
1121
|
0
|
|
|
|
|
0
|
return $_[0] + 1; |
1122
|
|
|
|
|
|
|
} |
1123
|
0
|
|
|
|
|
0
|
return $_[0]; |
1124
|
|
|
|
|
|
|
} |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
# ShiftJIS mark last regexp matched |
1127
|
|
|
|
|
|
|
sub Esjis::matched() { |
1128
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 0; |
1129
|
|
|
|
|
|
|
} |
1130
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
# ShiftJIS mark last s/// matched |
1132
|
|
|
|
|
|
|
sub Esjis::s_matched() { |
1133
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 1; |
1134
|
|
|
|
|
|
|
} |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
# P.854 31.17. use re |
1137
|
|
|
|
|
|
|
# in Chapter 31. Pragmatic Modules |
1138
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
# P.1026 re |
1141
|
|
|
|
|
|
|
# in Chapter 29. Pragmatic Modules |
1142
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
$Esjis::matched = qr/(?{Esjis::matched})/; |
1145
|
|
|
|
|
|
|
} |
1146
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
# |
1148
|
|
|
|
|
|
|
# ShiftJIS regexp ignore case modifier |
1149
|
|
|
|
|
|
|
# |
1150
|
|
|
|
|
|
|
sub Esjis::ignorecase { |
1151
|
|
|
|
|
|
|
|
1152
|
0
|
|
|
0
|
0
|
0
|
my @string = @_; |
1153
|
0
|
|
|
|
|
0
|
my $metachar = qr/[\@\\|[\]{]/oxms; |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
# ignore case of $scalar or @array |
1156
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
# split regexp |
1159
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg; |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
# unescape character |
1162
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1163
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
# open character class [...] |
1166
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '[') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1167
|
0
|
|
|
|
|
0
|
my $left = $i; |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
# [] make die "unmatched [] in regexp ...\n" |
1170
|
|
|
|
|
|
|
|
1171
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1172
|
0
|
|
|
|
|
0
|
$i++; |
1173
|
|
|
|
|
|
|
} |
1174
|
|
|
|
|
|
|
|
1175
|
0
|
|
|
|
|
0
|
while (1) { |
1176
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1177
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1178
|
|
|
|
|
|
|
} |
1179
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1180
|
0
|
|
|
|
|
0
|
my $right = $i; |
1181
|
0
|
|
|
|
|
0
|
my @charlist = charlist_qr(@char[$left+1..$right-1], 'i'); |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
# escape character |
1184
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1185
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
} |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
# do not use quotemeta here |
1189
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1190
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1191
|
|
|
|
|
|
|
} |
1192
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1193
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1194
|
|
|
|
|
|
|
} |
1195
|
|
|
|
|
|
|
} |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
# [...] |
1198
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')'; |
1199
|
|
|
|
|
|
|
|
1200
|
0
|
|
|
|
|
0
|
$i = $left; |
1201
|
0
|
|
|
|
|
0
|
last; |
1202
|
|
|
|
|
|
|
} |
1203
|
|
|
|
|
|
|
} |
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
# open character class [^...] |
1207
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
1208
|
0
|
|
|
|
|
0
|
my $left = $i; |
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
# [^] make die "unmatched [] in regexp ...\n" |
1211
|
|
|
|
|
|
|
|
1212
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1213
|
0
|
|
|
|
|
0
|
$i++; |
1214
|
|
|
|
|
|
|
} |
1215
|
|
|
|
|
|
|
|
1216
|
0
|
|
|
|
|
0
|
while (1) { |
1217
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1218
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1219
|
|
|
|
|
|
|
} |
1220
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1221
|
0
|
|
|
|
|
0
|
my $right = $i; |
1222
|
0
|
|
|
|
|
0
|
my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i'); |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
# escape character |
1225
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1226
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
} |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
# do not use quotemeta here |
1230
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1231
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1232
|
|
|
|
|
|
|
} |
1233
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1234
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1235
|
|
|
|
|
|
|
} |
1236
|
|
|
|
|
|
|
} |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
# [^...] |
1239
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)"; |
1240
|
|
|
|
|
|
|
|
1241
|
0
|
|
|
|
|
0
|
$i = $left; |
1242
|
0
|
|
|
|
|
0
|
last; |
1243
|
|
|
|
|
|
|
} |
1244
|
|
|
|
|
|
|
} |
1245
|
|
|
|
|
|
|
} |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
# rewrite classic character class or escape character |
1248
|
|
|
|
|
|
|
elsif (my $char = classic_character_class($char[$i])) { |
1249
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
1250
|
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
# with /i modifier |
1253
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
1254
|
0
|
|
|
|
|
0
|
my $uc = Esjis::uc($char[$i]); |
1255
|
0
|
|
|
|
|
0
|
my $fc = Esjis::fc($char[$i]); |
1256
|
0
|
0
|
|
|
|
0
|
if ($uc ne $fc) { |
1257
|
0
|
0
|
|
|
|
0
|
if (CORE::length($fc) == 1) { |
1258
|
0
|
|
|
|
|
0
|
$char[$i] = '[' . $uc . $fc . ']'; |
1259
|
|
|
|
|
|
|
} |
1260
|
|
|
|
|
|
|
else { |
1261
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . $uc . '|' . $fc . ')'; |
1262
|
|
|
|
|
|
|
} |
1263
|
|
|
|
|
|
|
} |
1264
|
|
|
|
|
|
|
} |
1265
|
|
|
|
|
|
|
} |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
# characterize |
1268
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1269
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1270
|
|
|
|
|
|
|
|
1271
|
0
|
0
|
0
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
} |
1273
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
1275
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1276
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1277
|
|
|
|
|
|
|
} |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
# quote character before ? + * { |
1280
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
1281
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) { |
1282
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
1283
|
|
|
|
|
|
|
} |
1284
|
|
|
|
|
|
|
} |
1285
|
|
|
|
|
|
|
} |
1286
|
|
|
|
|
|
|
|
1287
|
0
|
|
|
|
|
0
|
$string = join '', @char; |
1288
|
|
|
|
|
|
|
} |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
# make regexp string |
1291
|
0
|
|
|
|
|
0
|
return @string; |
1292
|
|
|
|
|
|
|
} |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
# |
1295
|
|
|
|
|
|
|
# classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B ) |
1296
|
|
|
|
|
|
|
# |
1297
|
|
|
|
|
|
|
sub Esjis::classic_character_class { |
1298
|
0
|
|
|
5243
|
0
|
0
|
my($char) = @_; |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
return { |
1301
|
|
|
|
|
|
|
'\D' => '${Esjis::eD}', |
1302
|
|
|
|
|
|
|
'\S' => '${Esjis::eS}', |
1303
|
|
|
|
|
|
|
'\W' => '${Esjis::eW}', |
1304
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1305
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
# Before Perl 5.6, \s only matched the five whitespace characters |
1307
|
|
|
|
|
|
|
# tab, newline, form-feed, carriage return, and the space character |
1308
|
|
|
|
|
|
|
# itself, which, taken together, is the character class [\t\n\f\r ]. |
1309
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1311
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1312
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1313
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1314
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1315
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1316
|
|
|
|
|
|
|
'\s' => '\s', |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1319
|
|
|
|
|
|
|
'\C' => '[\x00-\xFF]', |
1320
|
|
|
|
|
|
|
'\X' => 'X', |
1321
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
# \h \v \H \V |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
# P.114 Character Class Shortcuts |
1325
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
1326
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
1327
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
# P.357 13.2.3 Whitespace |
1329
|
|
|
|
|
|
|
# in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes |
1330
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1331
|
|
|
|
|
|
|
# |
1332
|
|
|
|
|
|
|
# 0x00009 CHARACTER TABULATION h s |
1333
|
|
|
|
|
|
|
# 0x0000a LINE FEED (LF) vs |
1334
|
|
|
|
|
|
|
# 0x0000b LINE TABULATION v |
1335
|
|
|
|
|
|
|
# 0x0000c FORM FEED (FF) vs |
1336
|
|
|
|
|
|
|
# 0x0000d CARRIAGE RETURN (CR) vs |
1337
|
|
|
|
|
|
|
# 0x00020 SPACE h s |
1338
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
# P.196 Table 5-9. Alphanumeric regex metasymbols |
1340
|
|
|
|
|
|
|
# in Chapter 5. Pattern Matching |
1341
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1342
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
# (and so on) |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
'\H' => '${Esjis::eH}', |
1346
|
|
|
|
|
|
|
'\V' => '${Esjis::eV}', |
1347
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1348
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1349
|
|
|
|
|
|
|
'\R' => '${Esjis::eR}', |
1350
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
# \N |
1352
|
|
|
|
|
|
|
# |
1353
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
1354
|
|
|
|
|
|
|
# Character Classes and other Special Escapes |
1355
|
|
|
|
|
|
|
# Any character but \n (experimental). Not affected by /s modifier |
1356
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
'\N' => '${Esjis::eN}', |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
# \b \B |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
# P.180 Boundaries: The \b and \B Assertions |
1362
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1363
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
# P.219 Boundaries: The \b and \B Assertions |
1366
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1367
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
# \b really means (?:(?<=\w)(?!\w)|(?
|
1370
|
|
|
|
|
|
|
# or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z)) |
1371
|
|
|
|
|
|
|
'\b' => '${Esjis::eb}', |
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
# \B really means (?:(?<=\w)(?=\w)|(?
|
1374
|
|
|
|
|
|
|
# or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W)) |
1375
|
|
|
|
|
|
|
'\B' => '${Esjis::eB}', |
1376
|
|
|
|
|
|
|
|
1377
|
5243
|
|
100
|
|
|
7458
|
}->{$char} || ''; |
1378
|
|
|
|
|
|
|
} |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
# |
1381
|
|
|
|
|
|
|
# prepare ShiftJIS characters per length |
1382
|
|
|
|
|
|
|
# |
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
# 1 octet characters |
1385
|
|
|
|
|
|
|
my @chars1 = (); |
1386
|
|
|
|
|
|
|
sub chars1 { |
1387
|
5243
|
0
|
|
0
|
0
|
184349
|
if (@chars1) { |
1388
|
0
|
|
|
|
|
0
|
return @chars1; |
1389
|
|
|
|
|
|
|
} |
1390
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{1}) { |
1391
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{1} }; |
|
0
|
|
|
|
|
0
|
|
1392
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,1)) { |
1393
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1394
|
0
|
|
|
|
|
0
|
push @chars1, pack 'C', $oct0; |
1395
|
|
|
|
|
|
|
} |
1396
|
|
|
|
|
|
|
} |
1397
|
|
|
|
|
|
|
} |
1398
|
0
|
|
|
|
|
0
|
return @chars1; |
1399
|
|
|
|
|
|
|
} |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
# 2 octets characters |
1402
|
|
|
|
|
|
|
my @chars2 = (); |
1403
|
|
|
|
|
|
|
sub chars2 { |
1404
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars2) { |
1405
|
0
|
|
|
|
|
0
|
return @chars2; |
1406
|
|
|
|
|
|
|
} |
1407
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{2}) { |
1408
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{2} }; |
|
0
|
|
|
|
|
0
|
|
1409
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,2)) { |
1410
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1411
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1412
|
0
|
|
|
|
|
0
|
push @chars2, pack 'CC', $oct0,$oct1; |
1413
|
|
|
|
|
|
|
} |
1414
|
|
|
|
|
|
|
} |
1415
|
|
|
|
|
|
|
} |
1416
|
|
|
|
|
|
|
} |
1417
|
0
|
|
|
|
|
0
|
return @chars2; |
1418
|
|
|
|
|
|
|
} |
1419
|
|
|
|
|
|
|
|
1420
|
|
|
|
|
|
|
# 3 octets characters |
1421
|
|
|
|
|
|
|
my @chars3 = (); |
1422
|
|
|
|
|
|
|
sub chars3 { |
1423
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars3) { |
1424
|
0
|
|
|
|
|
0
|
return @chars3; |
1425
|
|
|
|
|
|
|
} |
1426
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{3}) { |
1427
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{3} }; |
|
0
|
|
|
|
|
0
|
|
1428
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,3)) { |
1429
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1430
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1431
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1432
|
0
|
|
|
|
|
0
|
push @chars3, pack 'CCC', $oct0,$oct1,$oct2; |
1433
|
|
|
|
|
|
|
} |
1434
|
|
|
|
|
|
|
} |
1435
|
|
|
|
|
|
|
} |
1436
|
|
|
|
|
|
|
} |
1437
|
|
|
|
|
|
|
} |
1438
|
0
|
|
|
|
|
0
|
return @chars3; |
1439
|
|
|
|
|
|
|
} |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
# 4 octets characters |
1442
|
|
|
|
|
|
|
my @chars4 = (); |
1443
|
|
|
|
|
|
|
sub chars4 { |
1444
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars4) { |
1445
|
0
|
|
|
|
|
0
|
return @chars4; |
1446
|
|
|
|
|
|
|
} |
1447
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{4}) { |
1448
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{4} }; |
|
0
|
|
|
|
|
0
|
|
1449
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,4)) { |
1450
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1451
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1452
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1453
|
0
|
|
|
|
|
0
|
for my $oct3 (@{$range[3]}) { |
|
0
|
|
|
|
|
0
|
|
1454
|
0
|
|
|
|
|
0
|
push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3; |
1455
|
|
|
|
|
|
|
} |
1456
|
|
|
|
|
|
|
} |
1457
|
|
|
|
|
|
|
} |
1458
|
|
|
|
|
|
|
} |
1459
|
|
|
|
|
|
|
} |
1460
|
|
|
|
|
|
|
} |
1461
|
0
|
|
|
|
|
0
|
return @chars4; |
1462
|
|
|
|
|
|
|
} |
1463
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
# |
1465
|
|
|
|
|
|
|
# ShiftJIS open character list for tr |
1466
|
|
|
|
|
|
|
# |
1467
|
|
|
|
|
|
|
sub _charlist_tr { |
1468
|
|
|
|
|
|
|
|
1469
|
0
|
|
|
0
|
|
0
|
local $_ = shift @_; |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
# unescape character |
1472
|
0
|
|
|
|
|
0
|
my @char = (); |
1473
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxmsgc) { |
1474
|
0
|
0
|
|
|
|
0
|
if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1475
|
0
|
|
|
|
|
0
|
push @char, '\-'; |
1476
|
|
|
|
|
|
|
} |
1477
|
|
|
|
|
|
|
elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) { |
1478
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(oct $1); |
1479
|
|
|
|
|
|
|
} |
1480
|
|
|
|
|
|
|
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) { |
1481
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(hex $1); |
1482
|
|
|
|
|
|
|
} |
1483
|
|
|
|
|
|
|
elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) { |
1484
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(CORE::ord($1) & 0x1F); |
1485
|
|
|
|
|
|
|
} |
1486
|
|
|
|
|
|
|
elsif (/\G (\\ [0nrtfbae]) /oxmsgc) { |
1487
|
|
|
|
|
|
|
push @char, { |
1488
|
|
|
|
|
|
|
'\0' => "\0", |
1489
|
|
|
|
|
|
|
'\n' => "\n", |
1490
|
|
|
|
|
|
|
'\r' => "\r", |
1491
|
|
|
|
|
|
|
'\t' => "\t", |
1492
|
|
|
|
|
|
|
'\f' => "\f", |
1493
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1494
|
|
|
|
|
|
|
'\a' => "\a", |
1495
|
|
|
|
|
|
|
'\e' => "\e", |
1496
|
0
|
|
|
|
|
0
|
}->{$1}; |
1497
|
|
|
|
|
|
|
} |
1498
|
|
|
|
|
|
|
elsif (/\G \\ ($q_char) /oxmsgc) { |
1499
|
0
|
|
|
|
|
0
|
push @char, $1; |
1500
|
|
|
|
|
|
|
} |
1501
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxmsgc) { |
1502
|
0
|
|
|
|
|
0
|
push @char, $1; |
1503
|
|
|
|
|
|
|
} |
1504
|
|
|
|
|
|
|
} |
1505
|
|
|
|
|
|
|
|
1506
|
|
|
|
|
|
|
# join separated multiple-octet |
1507
|
0
|
|
|
|
|
0
|
@char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg; |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
# unescape '-' |
1510
|
0
|
|
|
|
|
0
|
my @i = (); |
1511
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#char) { |
1512
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\-') { |
|
|
0
|
|
|
|
|
|
1513
|
0
|
|
|
|
|
0
|
$char[$i] = '-'; |
1514
|
|
|
|
|
|
|
} |
1515
|
|
|
|
|
|
|
elsif ($char[$i] eq '-') { |
1516
|
0
|
0
|
0
|
|
|
0
|
if ((0 < $i) and ($i < $#char)) { |
1517
|
0
|
|
|
|
|
0
|
push @i, $i; |
1518
|
|
|
|
|
|
|
} |
1519
|
|
|
|
|
|
|
} |
1520
|
|
|
|
|
|
|
} |
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
# open character list (reverse for splice) |
1523
|
0
|
|
|
|
|
0
|
for my $i (CORE::reverse @i) { |
1524
|
0
|
|
|
|
|
0
|
my @range = (); |
1525
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
# range error |
1527
|
0
|
0
|
0
|
|
|
0
|
if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) { |
1528
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1529
|
|
|
|
|
|
|
} |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
# range of multiple-octet code |
1532
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i-1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1533
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1534
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1(); |
|
0
|
|
|
|
|
0
|
|
1535
|
|
|
|
|
|
|
} |
1536
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 2) { |
1537
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1538
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars2(); |
|
0
|
|
|
|
|
0
|
|
1539
|
|
|
|
|
|
|
} |
1540
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1541
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1542
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1543
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1544
|
|
|
|
|
|
|
} |
1545
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1546
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1547
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1548
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1549
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1550
|
|
|
|
|
|
|
} |
1551
|
|
|
|
|
|
|
else { |
1552
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1553
|
|
|
|
|
|
|
} |
1554
|
|
|
|
|
|
|
} |
1555
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 2) { |
1556
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 2) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1557
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2(); |
|
0
|
|
|
|
|
0
|
|
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1560
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1561
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1562
|
|
|
|
|
|
|
} |
1563
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1564
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1565
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1566
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
else { |
1569
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1570
|
|
|
|
|
|
|
} |
1571
|
|
|
|
|
|
|
} |
1572
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 3) { |
1573
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 3) { |
|
|
0
|
|
|
|
|
|
1574
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ 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 $_} chars3(); |
|
0
|
|
|
|
|
0
|
|
1578
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1579
|
|
|
|
|
|
|
} |
1580
|
|
|
|
|
|
|
else { |
1581
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1582
|
|
|
|
|
|
|
} |
1583
|
|
|
|
|
|
|
} |
1584
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 4) { |
1585
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 4) { |
1586
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4(); |
|
0
|
|
|
|
|
0
|
|
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
else { |
1589
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1590
|
|
|
|
|
|
|
} |
1591
|
|
|
|
|
|
|
} |
1592
|
|
|
|
|
|
|
else { |
1593
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1594
|
|
|
|
|
|
|
} |
1595
|
|
|
|
|
|
|
|
1596
|
0
|
|
|
|
|
0
|
splice @char, $i-1, 3, @range; |
1597
|
|
|
|
|
|
|
} |
1598
|
|
|
|
|
|
|
|
1599
|
0
|
|
|
|
|
0
|
return @char; |
1600
|
|
|
|
|
|
|
} |
1601
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
# |
1603
|
|
|
|
|
|
|
# ShiftJIS open character class |
1604
|
|
|
|
|
|
|
# |
1605
|
|
|
|
|
|
|
sub _cc { |
1606
|
0
|
50
|
|
604
|
|
0
|
if (scalar(@_) == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1607
|
604
|
|
|
|
|
1182
|
die __FILE__, ": subroutine cc got no parameter.\n"; |
1608
|
|
|
|
|
|
|
} |
1609
|
|
|
|
|
|
|
elsif (scalar(@_) == 1) { |
1610
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1611
|
|
|
|
|
|
|
} |
1612
|
|
|
|
|
|
|
elsif (scalar(@_) == 2) { |
1613
|
302
|
50
|
|
|
|
988
|
if ($_[0] > $_[1]) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1614
|
302
|
|
|
|
|
671
|
die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n"; |
1615
|
|
|
|
|
|
|
} |
1616
|
|
|
|
|
|
|
elsif ($_[0] == $_[1]) { |
1617
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1618
|
|
|
|
|
|
|
} |
1619
|
|
|
|
|
|
|
elsif (($_[0]+1) == $_[1]) { |
1620
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]); |
1621
|
|
|
|
|
|
|
} |
1622
|
|
|
|
|
|
|
else { |
1623
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]); |
1624
|
|
|
|
|
|
|
} |
1625
|
|
|
|
|
|
|
} |
1626
|
|
|
|
|
|
|
else { |
1627
|
302
|
|
|
|
|
1386
|
die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n"; |
|
0
|
|
|
|
|
0
|
|
1628
|
|
|
|
|
|
|
} |
1629
|
|
|
|
|
|
|
} |
1630
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
# |
1632
|
|
|
|
|
|
|
# ShiftJIS octet range |
1633
|
|
|
|
|
|
|
# |
1634
|
|
|
|
|
|
|
sub _octets { |
1635
|
0
|
|
|
688
|
|
0
|
my $length = shift @_; |
1636
|
|
|
|
|
|
|
|
1637
|
688
|
100
|
|
|
|
1115
|
if ($length == 1) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1638
|
688
|
|
|
|
|
1392
|
my($a1) = unpack 'C', $_[0]; |
1639
|
426
|
|
|
|
|
1190
|
my($z1) = unpack 'C', $_[1]; |
1640
|
|
|
|
|
|
|
|
1641
|
426
|
50
|
|
|
|
777
|
if ($a1 > $z1) { |
1642
|
426
|
|
|
|
|
873
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1); |
1643
|
|
|
|
|
|
|
} |
1644
|
|
|
|
|
|
|
|
1645
|
0
|
50
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1646
|
426
|
|
|
|
|
1045
|
return sprintf('\x%02X',$a1); |
1647
|
|
|
|
|
|
|
} |
1648
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1649
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X\x%02X',$a1,$z1); |
1650
|
|
|
|
|
|
|
} |
1651
|
|
|
|
|
|
|
else { |
1652
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X-\x%02X',$a1,$z1); |
1653
|
|
|
|
|
|
|
} |
1654
|
|
|
|
|
|
|
} |
1655
|
|
|
|
|
|
|
elsif ($length == 2) { |
1656
|
426
|
|
|
|
|
2910
|
my($a1,$a2) = unpack 'CC', $_[0]; |
1657
|
262
|
|
|
|
|
598
|
my($z1,$z2) = unpack 'CC', $_[1]; |
1658
|
262
|
|
|
|
|
453
|
my($A1,$A2) = unpack 'CC', $_[2]; |
1659
|
262
|
|
|
|
|
417
|
my($Z1,$Z2) = unpack 'CC', $_[3]; |
1660
|
|
|
|
|
|
|
|
1661
|
262
|
100
|
|
|
|
413
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
return ( |
1663
|
|
|
|
|
|
|
# 11111111 222222222222 |
1664
|
|
|
|
|
|
|
# A A Z |
1665
|
262
|
|
|
|
|
449
|
_cc($a1) . _cc($a2,$z2), # a2-z2 |
1666
|
|
|
|
|
|
|
); |
1667
|
|
|
|
|
|
|
} |
1668
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1669
|
|
|
|
|
|
|
return ( |
1670
|
|
|
|
|
|
|
# 11111111111 222222222222 |
1671
|
|
|
|
|
|
|
# A Z A Z |
1672
|
222
|
|
|
|
|
359
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1673
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1674
|
|
|
|
|
|
|
); |
1675
|
|
|
|
|
|
|
} |
1676
|
|
|
|
|
|
|
else { |
1677
|
|
|
|
|
|
|
return ( |
1678
|
|
|
|
|
|
|
# 1111111111111111 222222222222 |
1679
|
|
|
|
|
|
|
# A Z A Z |
1680
|
40
|
|
|
|
|
73
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1681
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2), # - |
1682
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1683
|
|
|
|
|
|
|
); |
1684
|
|
|
|
|
|
|
} |
1685
|
|
|
|
|
|
|
} |
1686
|
|
|
|
|
|
|
elsif ($length == 3) { |
1687
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3) = unpack 'CCC', $_[0]; |
1688
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3) = unpack 'CCC', $_[1]; |
1689
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3) = unpack 'CCC', $_[2]; |
1690
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3) = unpack 'CCC', $_[3]; |
1691
|
|
|
|
|
|
|
|
1692
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1693
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1694
|
|
|
|
|
|
|
return ( |
1695
|
|
|
|
|
|
|
# 11111111 22222222 333333333333 |
1696
|
|
|
|
|
|
|
# A A A Z |
1697
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$z3), # a3-z3 |
1698
|
|
|
|
|
|
|
); |
1699
|
|
|
|
|
|
|
} |
1700
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1701
|
|
|
|
|
|
|
return ( |
1702
|
|
|
|
|
|
|
# 11111111 22222222222 333333333333 |
1703
|
|
|
|
|
|
|
# A A Z A Z |
1704
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1705
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1706
|
|
|
|
|
|
|
); |
1707
|
|
|
|
|
|
|
} |
1708
|
|
|
|
|
|
|
else { |
1709
|
|
|
|
|
|
|
return ( |
1710
|
|
|
|
|
|
|
# 11111111 2222222222222222 333333333333 |
1711
|
|
|
|
|
|
|
# A A Z A Z |
1712
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1713
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3), # - |
1714
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1715
|
|
|
|
|
|
|
); |
1716
|
|
|
|
|
|
|
} |
1717
|
|
|
|
|
|
|
} |
1718
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1719
|
|
|
|
|
|
|
return ( |
1720
|
|
|
|
|
|
|
# 11111111111 22222222222222 333333333333 |
1721
|
|
|
|
|
|
|
# A Z A Z A Z |
1722
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1723
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1724
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1725
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1726
|
|
|
|
|
|
|
); |
1727
|
|
|
|
|
|
|
} |
1728
|
|
|
|
|
|
|
else { |
1729
|
|
|
|
|
|
|
return ( |
1730
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 333333333333 |
1731
|
|
|
|
|
|
|
# A Z A Z A Z |
1732
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1733
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1734
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3), # - |
1735
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1736
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1737
|
|
|
|
|
|
|
); |
1738
|
|
|
|
|
|
|
} |
1739
|
|
|
|
|
|
|
} |
1740
|
|
|
|
|
|
|
elsif ($length == 4) { |
1741
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3,$a4) = unpack 'CCCC', $_[0]; |
1742
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3,$z4) = unpack 'CCCC', $_[1]; |
1743
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3,$A4) = unpack 'CCCC', $_[0]; |
1744
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3,$Z4) = unpack 'CCCC', $_[1]; |
1745
|
|
|
|
|
|
|
|
1746
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1747
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1748
|
0
|
0
|
|
|
|
0
|
if ($a3 == $z3) { |
|
|
0
|
|
|
|
|
|
1749
|
|
|
|
|
|
|
return ( |
1750
|
|
|
|
|
|
|
# 11111111 22222222 33333333 444444444444 |
1751
|
|
|
|
|
|
|
# A A A A Z |
1752
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$z4), # a4-z4 |
1753
|
|
|
|
|
|
|
); |
1754
|
|
|
|
|
|
|
} |
1755
|
|
|
|
|
|
|
elsif (($a3+1) == $z3) { |
1756
|
|
|
|
|
|
|
return ( |
1757
|
|
|
|
|
|
|
# 11111111 22222222 33333333333 444444444444 |
1758
|
|
|
|
|
|
|
# A A A Z A Z |
1759
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1760
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1761
|
|
|
|
|
|
|
); |
1762
|
|
|
|
|
|
|
} |
1763
|
|
|
|
|
|
|
else { |
1764
|
|
|
|
|
|
|
return ( |
1765
|
|
|
|
|
|
|
# 11111111 22222222 3333333333333333 444444444444 |
1766
|
|
|
|
|
|
|
# A A A Z A Z |
1767
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1768
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$z3-1) . _cc($A4,$Z4), # - |
1769
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1770
|
|
|
|
|
|
|
); |
1771
|
|
|
|
|
|
|
} |
1772
|
|
|
|
|
|
|
} |
1773
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1774
|
|
|
|
|
|
|
return ( |
1775
|
|
|
|
|
|
|
# 11111111 22222222222 33333333333333 444444444444 |
1776
|
|
|
|
|
|
|
# A A Z A Z A Z |
1777
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1778
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1779
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1780
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1781
|
|
|
|
|
|
|
); |
1782
|
|
|
|
|
|
|
} |
1783
|
|
|
|
|
|
|
else { |
1784
|
|
|
|
|
|
|
return ( |
1785
|
|
|
|
|
|
|
# 11111111 2222222222222222 33333333333333 444444444444 |
1786
|
|
|
|
|
|
|
# A A Z A Z A Z |
1787
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1788
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1789
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1790
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1791
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1792
|
|
|
|
|
|
|
); |
1793
|
|
|
|
|
|
|
} |
1794
|
|
|
|
|
|
|
} |
1795
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1796
|
|
|
|
|
|
|
return ( |
1797
|
|
|
|
|
|
|
# 11111111111 22222222222222 33333333333333 444444444444 |
1798
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1799
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1800
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1801
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1802
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1803
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1804
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1805
|
|
|
|
|
|
|
); |
1806
|
|
|
|
|
|
|
} |
1807
|
|
|
|
|
|
|
else { |
1808
|
|
|
|
|
|
|
return ( |
1809
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 33333333333333 444444444444 |
1810
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1811
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1812
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1813
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1814
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$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
|
|
|
|
|
|
|
} |
1821
|
|
|
|
|
|
|
else { |
1822
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _octets got invalid length ($length).\n"; |
1823
|
|
|
|
|
|
|
} |
1824
|
|
|
|
|
|
|
} |
1825
|
|
|
|
|
|
|
|
1826
|
|
|
|
|
|
|
# |
1827
|
|
|
|
|
|
|
# ShiftJIS range regexp |
1828
|
|
|
|
|
|
|
# |
1829
|
|
|
|
|
|
|
sub _range_regexp { |
1830
|
0
|
|
|
517
|
|
0
|
my($length,$first,$last) = @_; |
1831
|
|
|
|
|
|
|
|
1832
|
517
|
|
|
|
|
1150
|
my @range_regexp = (); |
1833
|
517
|
50
|
|
|
|
804
|
if (not exists $range_tr{$length}) { |
1834
|
517
|
|
|
|
|
1309
|
return @range_regexp; |
1835
|
|
|
|
|
|
|
} |
1836
|
|
|
|
|
|
|
|
1837
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{$length} }; |
|
517
|
|
|
|
|
737
|
|
1838
|
517
|
|
|
|
|
1313
|
while (my @range = splice(@ranges,0,$length)) { |
1839
|
517
|
|
|
|
|
1589
|
my $min = ''; |
1840
|
1682
|
|
|
|
|
2251
|
my $max = ''; |
1841
|
1682
|
|
|
|
|
1848
|
for (my $i=0; $i < $length; $i++) { |
1842
|
1682
|
|
|
|
|
2875
|
$min .= pack 'C', $range[$i][0]; |
1843
|
2206
|
|
|
|
|
4251
|
$max .= pack 'C', $range[$i][-1]; |
1844
|
|
|
|
|
|
|
} |
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
# min___max |
1847
|
|
|
|
|
|
|
# FIRST_____________LAST |
1848
|
|
|
|
|
|
|
# (nothing) |
1849
|
|
|
|
|
|
|
|
1850
|
2206
|
50
|
66
|
|
|
4495
|
if ($max lt $first) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
1851
|
|
|
|
|
|
|
} |
1852
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
# ********** |
1854
|
|
|
|
|
|
|
# min_________max |
1855
|
|
|
|
|
|
|
# FIRST_____________LAST |
1856
|
|
|
|
|
|
|
# ********** |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
elsif (($min le $first) and ($first le $max) and ($max le $last)) { |
1859
|
1682
|
|
|
|
|
13542
|
push @range_regexp, _octets($length,$first,$max,$min,$max); |
1860
|
|
|
|
|
|
|
} |
1861
|
|
|
|
|
|
|
|
1862
|
|
|
|
|
|
|
# ********************** |
1863
|
|
|
|
|
|
|
# min________________max |
1864
|
|
|
|
|
|
|
# FIRST_____________LAST |
1865
|
|
|
|
|
|
|
# ********************** |
1866
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
elsif (($min eq $first) and ($max eq $last)) { |
1868
|
20
|
|
|
|
|
52
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1869
|
|
|
|
|
|
|
} |
1870
|
|
|
|
|
|
|
|
1871
|
|
|
|
|
|
|
# ********* |
1872
|
|
|
|
|
|
|
# min___max |
1873
|
|
|
|
|
|
|
# FIRST_____________LAST |
1874
|
|
|
|
|
|
|
# ********* |
1875
|
|
|
|
|
|
|
|
1876
|
|
|
|
|
|
|
elsif (($first le $min) and ($max le $last)) { |
1877
|
0
|
|
|
|
|
0
|
push @range_regexp, _octets($length,$min,$max,$min,$max); |
1878
|
|
|
|
|
|
|
} |
1879
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
# ********************** |
1881
|
|
|
|
|
|
|
# min__________________________max |
1882
|
|
|
|
|
|
|
# FIRST_____________LAST |
1883
|
|
|
|
|
|
|
# ********************** |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
elsif (($min le $first) and ($last le $max)) { |
1886
|
40
|
|
|
|
|
74
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1887
|
|
|
|
|
|
|
} |
1888
|
|
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
# ********* |
1890
|
|
|
|
|
|
|
# min________max |
1891
|
|
|
|
|
|
|
# FIRST_____________LAST |
1892
|
|
|
|
|
|
|
# ********* |
1893
|
|
|
|
|
|
|
|
1894
|
|
|
|
|
|
|
elsif (($first le $min) and ($min le $last) and ($last le $max)) { |
1895
|
588
|
|
|
|
|
1396
|
push @range_regexp, _octets($length,$min,$last,$min,$max); |
1896
|
|
|
|
|
|
|
} |
1897
|
|
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
# min___max |
1899
|
|
|
|
|
|
|
# FIRST_____________LAST |
1900
|
|
|
|
|
|
|
# (nothing) |
1901
|
|
|
|
|
|
|
|
1902
|
|
|
|
|
|
|
elsif ($last lt $min) { |
1903
|
|
|
|
|
|
|
} |
1904
|
|
|
|
|
|
|
|
1905
|
|
|
|
|
|
|
else { |
1906
|
40
|
|
|
|
|
62
|
die __FILE__, ": subroutine _range_regexp panic.\n"; |
1907
|
|
|
|
|
|
|
} |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
|
1910
|
0
|
|
|
|
|
0
|
return @range_regexp; |
1911
|
|
|
|
|
|
|
} |
1912
|
|
|
|
|
|
|
|
1913
|
|
|
|
|
|
|
# |
1914
|
|
|
|
|
|
|
# ShiftJIS open character list for qr and not qr |
1915
|
|
|
|
|
|
|
# |
1916
|
|
|
|
|
|
|
sub _charlist { |
1917
|
|
|
|
|
|
|
|
1918
|
517
|
|
|
758
|
|
1264
|
my $modifier = pop @_; |
1919
|
758
|
|
|
|
|
1269
|
my @char = @_; |
1920
|
|
|
|
|
|
|
|
1921
|
758
|
100
|
|
|
|
1727
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
1922
|
|
|
|
|
|
|
|
1923
|
|
|
|
|
|
|
# unescape character |
1924
|
758
|
|
|
|
|
1806
|
for (my $i=0; $i <= $#char; $i++) { |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
# escape - to ... |
1927
|
758
|
100
|
100
|
|
|
2475
|
if ($char[$i] eq '-') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1928
|
2648
|
100
|
100
|
|
|
18678
|
if ((0 < $i) and ($i < $#char)) { |
1929
|
522
|
|
|
|
|
1942
|
$char[$i] = '...'; |
1930
|
|
|
|
|
|
|
} |
1931
|
|
|
|
|
|
|
} |
1932
|
|
|
|
|
|
|
|
1933
|
|
|
|
|
|
|
# octal escape sequence |
1934
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
1935
|
497
|
|
|
|
|
1076
|
$char[$i] = octchr($1); |
1936
|
|
|
|
|
|
|
} |
1937
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
# hexadecimal escape sequence |
1939
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
1940
|
0
|
|
|
|
|
0
|
$char[$i] = hexchr($1); |
1941
|
|
|
|
|
|
|
} |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
1944
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
1945
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
1946
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
1947
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
1948
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
1949
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1950
|
|
|
|
|
|
|
} |
1951
|
|
|
|
|
|
|
|
1952
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
1953
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
1954
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
1955
|
|
|
|
|
|
|
} |
1956
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) { |
1958
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr oct $1; |
1959
|
|
|
|
|
|
|
} |
1960
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) { |
1961
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr hex $1; |
1962
|
|
|
|
|
|
|
} |
1963
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) { |
1964
|
206
|
|
|
|
|
862
|
$char[$i] = CORE::chr(CORE::ord($1) & 0x1F); |
1965
|
|
|
|
|
|
|
} |
1966
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) { |
1967
|
|
|
|
|
|
|
$char[$i] = { |
1968
|
|
|
|
|
|
|
'\0' => "\0", |
1969
|
|
|
|
|
|
|
'\n' => "\n", |
1970
|
|
|
|
|
|
|
'\r' => "\r", |
1971
|
|
|
|
|
|
|
'\t' => "\t", |
1972
|
|
|
|
|
|
|
'\f' => "\f", |
1973
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1974
|
|
|
|
|
|
|
'\a' => "\a", |
1975
|
|
|
|
|
|
|
'\e' => "\e", |
1976
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1977
|
|
|
|
|
|
|
|
1978
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1979
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1980
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1981
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1982
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1983
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1984
|
|
|
|
|
|
|
'\s' => '\s', |
1985
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1987
|
|
|
|
|
|
|
'\D' => '${Esjis::eD}', |
1988
|
|
|
|
|
|
|
'\S' => '${Esjis::eS}', |
1989
|
|
|
|
|
|
|
'\W' => '${Esjis::eW}', |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
'\H' => '${Esjis::eH}', |
1992
|
|
|
|
|
|
|
'\V' => '${Esjis::eV}', |
1993
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1994
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1995
|
|
|
|
|
|
|
'\R' => '${Esjis::eR}', |
1996
|
|
|
|
|
|
|
|
1997
|
0
|
|
|
|
|
0
|
}->{$1}; |
1998
|
|
|
|
|
|
|
} |
1999
|
|
|
|
|
|
|
|
2000
|
|
|
|
|
|
|
# POSIX-style character classes |
2001
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) { |
2002
|
|
|
|
|
|
|
$char[$i] = { |
2003
|
|
|
|
|
|
|
|
2004
|
|
|
|
|
|
|
'[:lower:]' => '[\x41-\x5A\x61-\x7A]', |
2005
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A\x61-\x7A]', |
2006
|
|
|
|
|
|
|
'[:^lower:]' => '${Esjis::not_lower_i}', |
2007
|
|
|
|
|
|
|
'[:^upper:]' => '${Esjis::not_upper_i}', |
2008
|
|
|
|
|
|
|
|
2009
|
33
|
|
|
|
|
578
|
}->{$1}; |
2010
|
|
|
|
|
|
|
} |
2011
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) { |
2012
|
|
|
|
|
|
|
$char[$i] = { |
2013
|
|
|
|
|
|
|
|
2014
|
|
|
|
|
|
|
'[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]', |
2015
|
|
|
|
|
|
|
'[:alpha:]' => '[\x41-\x5A\x61-\x7A]', |
2016
|
|
|
|
|
|
|
'[:ascii:]' => '[\x00-\x7F]', |
2017
|
|
|
|
|
|
|
'[:blank:]' => '[\x09\x20]', |
2018
|
|
|
|
|
|
|
'[:cntrl:]' => '[\x00-\x1F\x7F]', |
2019
|
|
|
|
|
|
|
'[:digit:]' => '[\x30-\x39]', |
2020
|
|
|
|
|
|
|
'[:graph:]' => '[\x21-\x7F]', |
2021
|
|
|
|
|
|
|
'[:lower:]' => '[\x61-\x7A]', |
2022
|
|
|
|
|
|
|
'[:print:]' => '[\x20-\x7F]', |
2023
|
|
|
|
|
|
|
'[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]', |
2024
|
|
|
|
|
|
|
|
2025
|
|
|
|
|
|
|
# P.174 POSIX-Style Character Classes |
2026
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2027
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2028
|
|
|
|
|
|
|
|
2029
|
|
|
|
|
|
|
# P.311 11.2.4 Character Classes and other Special Escapes |
2030
|
|
|
|
|
|
|
# in Chapter 11: perlre: Perl regular expressions |
2031
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
2032
|
|
|
|
|
|
|
|
2033
|
|
|
|
|
|
|
# P.210 POSIX-Style Character Classes |
2034
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2035
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2036
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
'[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK") |
2038
|
|
|
|
|
|
|
|
2039
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A]', |
2040
|
|
|
|
|
|
|
'[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]', |
2041
|
|
|
|
|
|
|
'[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]', |
2042
|
|
|
|
|
|
|
'[:^alnum:]' => '${Esjis::not_alnum}', |
2043
|
|
|
|
|
|
|
'[:^alpha:]' => '${Esjis::not_alpha}', |
2044
|
|
|
|
|
|
|
'[:^ascii:]' => '${Esjis::not_ascii}', |
2045
|
|
|
|
|
|
|
'[:^blank:]' => '${Esjis::not_blank}', |
2046
|
|
|
|
|
|
|
'[:^cntrl:]' => '${Esjis::not_cntrl}', |
2047
|
|
|
|
|
|
|
'[:^digit:]' => '${Esjis::not_digit}', |
2048
|
|
|
|
|
|
|
'[:^graph:]' => '${Esjis::not_graph}', |
2049
|
|
|
|
|
|
|
'[:^lower:]' => '${Esjis::not_lower}', |
2050
|
|
|
|
|
|
|
'[:^print:]' => '${Esjis::not_print}', |
2051
|
|
|
|
|
|
|
'[:^punct:]' => '${Esjis::not_punct}', |
2052
|
|
|
|
|
|
|
'[:^space:]' => '${Esjis::not_space}', |
2053
|
|
|
|
|
|
|
'[:^upper:]' => '${Esjis::not_upper}', |
2054
|
|
|
|
|
|
|
'[:^word:]' => '${Esjis::not_word}', |
2055
|
|
|
|
|
|
|
'[:^xdigit:]' => '${Esjis::not_xdigit}', |
2056
|
|
|
|
|
|
|
|
2057
|
8
|
|
|
|
|
88
|
}->{$1}; |
2058
|
|
|
|
|
|
|
} |
2059
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) { |
2060
|
70
|
|
|
|
|
1385
|
$char[$i] = $1; |
2061
|
|
|
|
|
|
|
} |
2062
|
|
|
|
|
|
|
} |
2063
|
|
|
|
|
|
|
|
2064
|
|
|
|
|
|
|
# open character list |
2065
|
7
|
|
|
|
|
32
|
my @singleoctet = (); |
2066
|
758
|
|
|
|
|
1282
|
my @multipleoctet = (); |
2067
|
758
|
|
|
|
|
996
|
for (my $i=0; $i <= $#char; ) { |
2068
|
|
|
|
|
|
|
|
2069
|
|
|
|
|
|
|
# escaped - |
2070
|
758
|
100
|
100
|
|
|
1810
|
if (defined($char[$i+1]) and ($char[$i+1] eq '...')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2071
|
2151
|
|
|
|
|
9006
|
$i += 1; |
2072
|
497
|
|
|
|
|
685
|
next; |
2073
|
|
|
|
|
|
|
} |
2074
|
|
|
|
|
|
|
|
2075
|
|
|
|
|
|
|
# make range regexp |
2076
|
|
|
|
|
|
|
elsif ($char[$i] eq '...') { |
2077
|
|
|
|
|
|
|
|
2078
|
|
|
|
|
|
|
# range error |
2079
|
497
|
50
|
|
|
|
986
|
if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) { |
|
|
100
|
|
|
|
|
|
2080
|
497
|
|
|
|
|
1957
|
croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2081
|
|
|
|
|
|
|
} |
2082
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) { |
2083
|
0
|
50
|
|
|
|
0
|
if ($char[$i-1] gt $char[$i+1]) { |
2084
|
477
|
|
|
|
|
1169
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2085
|
|
|
|
|
|
|
} |
2086
|
|
|
|
|
|
|
} |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
# make range regexp per length |
2089
|
0
|
|
|
|
|
0
|
for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) { |
2090
|
497
|
|
|
|
|
1542
|
my @regexp = (); |
2091
|
|
|
|
|
|
|
|
2092
|
|
|
|
|
|
|
# is first and last |
2093
|
517
|
100
|
100
|
|
|
721
|
if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2094
|
517
|
|
|
|
|
1933
|
push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]); |
2095
|
|
|
|
|
|
|
} |
2096
|
|
|
|
|
|
|
|
2097
|
|
|
|
|
|
|
# is first |
2098
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i-1])) { |
2099
|
477
|
|
|
|
|
1378
|
push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length); |
2100
|
|
|
|
|
|
|
} |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
# is inside in first and last |
2103
|
|
|
|
|
|
|
elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) { |
2104
|
20
|
|
|
|
|
81
|
push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length); |
2105
|
|
|
|
|
|
|
} |
2106
|
|
|
|
|
|
|
|
2107
|
|
|
|
|
|
|
# is last |
2108
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i+1])) { |
2109
|
0
|
|
|
|
|
0
|
push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]); |
2110
|
|
|
|
|
|
|
} |
2111
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
else { |
2113
|
20
|
|
|
|
|
92
|
die __FILE__, ": subroutine make_regexp panic.\n"; |
2114
|
|
|
|
|
|
|
} |
2115
|
|
|
|
|
|
|
|
2116
|
0
|
100
|
|
|
|
0
|
if ($length == 1) { |
2117
|
517
|
|
|
|
|
1111
|
push @singleoctet, @regexp; |
2118
|
|
|
|
|
|
|
} |
2119
|
|
|
|
|
|
|
else { |
2120
|
386
|
|
|
|
|
955
|
push @multipleoctet, @regexp; |
2121
|
|
|
|
|
|
|
} |
2122
|
|
|
|
|
|
|
} |
2123
|
|
|
|
|
|
|
|
2124
|
131
|
|
|
|
|
304
|
$i += 2; |
2125
|
|
|
|
|
|
|
} |
2126
|
|
|
|
|
|
|
|
2127
|
|
|
|
|
|
|
# with /i modifier |
2128
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
2129
|
497
|
100
|
|
|
|
1069
|
if ($modifier =~ /i/oxms) { |
2130
|
764
|
|
|
|
|
1167
|
my $uc = Esjis::uc($char[$i]); |
2131
|
192
|
|
|
|
|
349
|
my $fc = Esjis::fc($char[$i]); |
2132
|
192
|
50
|
|
|
|
323
|
if ($uc ne $fc) { |
2133
|
192
|
50
|
|
|
|
333
|
if (CORE::length($fc) == 1) { |
2134
|
192
|
|
|
|
|
261
|
push @singleoctet, $uc, $fc; |
2135
|
|
|
|
|
|
|
} |
2136
|
|
|
|
|
|
|
else { |
2137
|
192
|
|
|
|
|
415
|
push @singleoctet, $uc; |
2138
|
0
|
|
|
|
|
0
|
push @multipleoctet, $fc; |
2139
|
|
|
|
|
|
|
} |
2140
|
|
|
|
|
|
|
} |
2141
|
|
|
|
|
|
|
else { |
2142
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2143
|
|
|
|
|
|
|
} |
2144
|
|
|
|
|
|
|
} |
2145
|
|
|
|
|
|
|
else { |
2146
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2147
|
|
|
|
|
|
|
} |
2148
|
572
|
|
|
|
|
937
|
$i += 1; |
2149
|
|
|
|
|
|
|
} |
2150
|
|
|
|
|
|
|
|
2151
|
|
|
|
|
|
|
# single character of single octet code |
2152
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) { |
2153
|
764
|
|
|
|
|
1261
|
push @singleoctet, "\t", "\x20"; |
2154
|
0
|
|
|
|
|
0
|
$i += 1; |
2155
|
|
|
|
|
|
|
} |
2156
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) { |
2157
|
0
|
|
|
|
|
0
|
push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D"; |
2158
|
0
|
|
|
|
|
0
|
$i += 1; |
2159
|
|
|
|
|
|
|
} |
2160
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) { |
2161
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2162
|
2
|
|
|
|
|
6
|
$i += 1; |
2163
|
|
|
|
|
|
|
} |
2164
|
|
|
|
|
|
|
|
2165
|
|
|
|
|
|
|
# single character of multiple-octet code |
2166
|
|
|
|
|
|
|
else { |
2167
|
2
|
|
|
|
|
11
|
push @multipleoctet, $char[$i]; |
2168
|
391
|
|
|
|
|
705
|
$i += 1; |
2169
|
|
|
|
|
|
|
} |
2170
|
|
|
|
|
|
|
} |
2171
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
# quote metachar |
2173
|
391
|
|
|
|
|
714
|
for (@singleoctet) { |
2174
|
758
|
50
|
|
|
|
1655
|
if ($_ eq '...') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2175
|
1384
|
|
|
|
|
6252
|
$_ = '-'; |
2176
|
|
|
|
|
|
|
} |
2177
|
|
|
|
|
|
|
elsif (/\A \n \z/oxms) { |
2178
|
0
|
|
|
|
|
0
|
$_ = '\n'; |
2179
|
|
|
|
|
|
|
} |
2180
|
|
|
|
|
|
|
elsif (/\A \r \z/oxms) { |
2181
|
8
|
|
|
|
|
31
|
$_ = '\r'; |
2182
|
|
|
|
|
|
|
} |
2183
|
|
|
|
|
|
|
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) { |
2184
|
8
|
|
|
|
|
29
|
$_ = sprintf('\x%02X', CORE::ord $1); |
2185
|
|
|
|
|
|
|
} |
2186
|
|
|
|
|
|
|
elsif (/\A [\x00-\xFF] \z/oxms) { |
2187
|
1
|
|
|
|
|
7
|
$_ = quotemeta $_; |
2188
|
|
|
|
|
|
|
} |
2189
|
|
|
|
|
|
|
} |
2190
|
939
|
|
|
|
|
1410
|
for (@multipleoctet) { |
2191
|
758
|
100
|
|
|
|
1393
|
if (/\A ([\x80-\xFF].*) ([\x00-\xFF]) \z/oxms) { |
2192
|
693
|
|
|
|
|
1775
|
$_ = $1 . quotemeta $2; |
2193
|
|
|
|
|
|
|
} |
2194
|
|
|
|
|
|
|
} |
2195
|
|
|
|
|
|
|
|
2196
|
|
|
|
|
|
|
# return character list |
2197
|
307
|
|
|
|
|
725
|
return \@singleoctet, \@multipleoctet; |
2198
|
|
|
|
|
|
|
} |
2199
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
# |
2201
|
|
|
|
|
|
|
# ShiftJIS octal escape sequence |
2202
|
|
|
|
|
|
|
# |
2203
|
|
|
|
|
|
|
sub octchr { |
2204
|
758
|
|
|
5
|
0
|
2803
|
my($octdigit) = @_; |
2205
|
|
|
|
|
|
|
|
2206
|
5
|
|
|
|
|
13
|
my @binary = (); |
2207
|
5
|
|
|
|
|
9
|
for my $octal (split(//,$octdigit)) { |
2208
|
|
|
|
|
|
|
push @binary, { |
2209
|
|
|
|
|
|
|
'0' => '000', |
2210
|
|
|
|
|
|
|
'1' => '001', |
2211
|
|
|
|
|
|
|
'2' => '010', |
2212
|
|
|
|
|
|
|
'3' => '011', |
2213
|
|
|
|
|
|
|
'4' => '100', |
2214
|
|
|
|
|
|
|
'5' => '101', |
2215
|
|
|
|
|
|
|
'6' => '110', |
2216
|
|
|
|
|
|
|
'7' => '111', |
2217
|
5
|
|
|
|
|
19
|
}->{$octal}; |
2218
|
|
|
|
|
|
|
} |
2219
|
50
|
|
|
|
|
173
|
my $binary = join '', @binary; |
2220
|
|
|
|
|
|
|
|
2221
|
|
|
|
|
|
|
my $octchr = { |
2222
|
|
|
|
|
|
|
# 1234567 |
2223
|
|
|
|
|
|
|
1 => pack('B*', "0000000$binary"), |
2224
|
|
|
|
|
|
|
2 => pack('B*', "000000$binary"), |
2225
|
|
|
|
|
|
|
3 => pack('B*', "00000$binary"), |
2226
|
|
|
|
|
|
|
4 => pack('B*', "0000$binary"), |
2227
|
|
|
|
|
|
|
5 => pack('B*', "000$binary"), |
2228
|
|
|
|
|
|
|
6 => pack('B*', "00$binary"), |
2229
|
|
|
|
|
|
|
7 => pack('B*', "0$binary"), |
2230
|
|
|
|
|
|
|
0 => pack('B*', "$binary"), |
2231
|
|
|
|
|
|
|
|
2232
|
5
|
|
|
|
|
12
|
}->{CORE::length($binary) % 8}; |
2233
|
|
|
|
|
|
|
|
2234
|
5
|
|
|
|
|
60
|
return $octchr; |
2235
|
|
|
|
|
|
|
} |
2236
|
|
|
|
|
|
|
|
2237
|
|
|
|
|
|
|
# |
2238
|
|
|
|
|
|
|
# ShiftJIS hexadecimal escape sequence |
2239
|
|
|
|
|
|
|
# |
2240
|
|
|
|
|
|
|
sub hexchr { |
2241
|
5
|
|
|
5
|
0
|
20
|
my($hexdigit) = @_; |
2242
|
|
|
|
|
|
|
|
2243
|
|
|
|
|
|
|
my $hexchr = { |
2244
|
|
|
|
|
|
|
1 => pack('H*', "0$hexdigit"), |
2245
|
|
|
|
|
|
|
0 => pack('H*', "$hexdigit"), |
2246
|
|
|
|
|
|
|
|
2247
|
5
|
|
|
|
|
16
|
}->{CORE::length($_[0]) % 2}; |
2248
|
|
|
|
|
|
|
|
2249
|
5
|
|
|
|
|
47
|
return $hexchr; |
2250
|
|
|
|
|
|
|
} |
2251
|
|
|
|
|
|
|
|
2252
|
|
|
|
|
|
|
# |
2253
|
|
|
|
|
|
|
# ShiftJIS open character list for qr |
2254
|
|
|
|
|
|
|
# |
2255
|
|
|
|
|
|
|
sub charlist_qr { |
2256
|
|
|
|
|
|
|
|
2257
|
5
|
|
|
519
|
0
|
21
|
my $modifier = pop @_; |
2258
|
519
|
|
|
|
|
1076
|
my @char = @_; |
2259
|
|
|
|
|
|
|
|
2260
|
519
|
|
|
|
|
1399
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2261
|
519
|
|
|
|
|
1792
|
my @singleoctet = @$singleoctet; |
2262
|
519
|
|
|
|
|
1265
|
my @multipleoctet = @$multipleoctet; |
2263
|
|
|
|
|
|
|
|
2264
|
|
|
|
|
|
|
# return character list |
2265
|
519
|
100
|
|
|
|
957
|
if (scalar(@singleoctet) >= 1) { |
2266
|
|
|
|
|
|
|
|
2267
|
|
|
|
|
|
|
# with /i modifier |
2268
|
519
|
100
|
|
|
|
1261
|
if ($modifier =~ m/i/oxms) { |
2269
|
384
|
|
|
|
|
924
|
my %singleoctet_ignorecase = (); |
2270
|
107
|
|
|
|
|
206
|
for (@singleoctet) { |
2271
|
107
|
|
66
|
|
|
168
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2272
|
277
|
|
|
|
|
912
|
for my $ord (hex($1) .. hex($2)) { |
2273
|
85
|
|
|
|
|
365
|
my $char = CORE::chr($ord); |
2274
|
1376
|
|
|
|
|
1838
|
my $uc = Esjis::uc($char); |
2275
|
1376
|
|
|
|
|
1752
|
my $fc = Esjis::fc($char); |
2276
|
1376
|
100
|
|
|
|
1920
|
if ($uc eq $fc) { |
2277
|
1376
|
|
|
|
|
2005
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2278
|
|
|
|
|
|
|
} |
2279
|
|
|
|
|
|
|
else { |
2280
|
787
|
50
|
|
|
|
1766
|
if (CORE::length($fc) == 1) { |
2281
|
589
|
|
|
|
|
726
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2282
|
589
|
|
|
|
|
1132
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2283
|
|
|
|
|
|
|
} |
2284
|
|
|
|
|
|
|
else { |
2285
|
589
|
|
|
|
|
1452
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2286
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2287
|
|
|
|
|
|
|
} |
2288
|
|
|
|
|
|
|
} |
2289
|
|
|
|
|
|
|
} |
2290
|
|
|
|
|
|
|
} |
2291
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2292
|
277
|
|
|
|
|
462
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2293
|
|
|
|
|
|
|
} |
2294
|
|
|
|
|
|
|
} |
2295
|
192
|
|
|
|
|
485
|
my $i = 0; |
2296
|
107
|
|
|
|
|
172
|
my @singleoctet_ignorecase = (); |
2297
|
107
|
|
|
|
|
139
|
for my $ord (0 .. 255) { |
2298
|
107
|
100
|
|
|
|
210
|
if (exists $singleoctet_ignorecase{$ord}) { |
2299
|
27392
|
|
|
|
|
31131
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1907
|
|
|
|
|
1709
|
|
2300
|
|
|
|
|
|
|
} |
2301
|
|
|
|
|
|
|
else { |
2302
|
1907
|
|
|
|
|
2853
|
$i++; |
2303
|
|
|
|
|
|
|
} |
2304
|
|
|
|
|
|
|
} |
2305
|
25485
|
|
|
|
|
24614
|
@singleoctet = (); |
2306
|
107
|
|
|
|
|
180
|
for my $range (@singleoctet_ignorecase) { |
2307
|
107
|
100
|
|
|
|
277
|
if (ref $range) { |
2308
|
11082
|
50
|
|
|
|
16790
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
221
|
|
2309
|
219
|
|
|
|
|
356
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
0
|
|
|
|
|
0
|
|
2310
|
|
|
|
|
|
|
} |
2311
|
0
|
|
|
|
|
0
|
elsif (scalar(@{$range}) == 2) { |
2312
|
219
|
|
|
|
|
389
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2313
|
|
|
|
|
|
|
} |
2314
|
|
|
|
|
|
|
else { |
2315
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
219
|
|
|
|
|
317
|
|
|
219
|
|
|
|
|
283
|
|
2316
|
|
|
|
|
|
|
} |
2317
|
|
|
|
|
|
|
} |
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
} |
2320
|
|
|
|
|
|
|
|
2321
|
219
|
|
|
|
|
1134
|
my $not_anchor = ''; |
2322
|
384
|
|
|
|
|
652
|
$not_anchor = '(?![\x81-\x9F\xE0-\xFC])'; |
2323
|
|
|
|
|
|
|
|
2324
|
384
|
|
|
|
|
677
|
push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' ); |
2325
|
|
|
|
|
|
|
} |
2326
|
384
|
100
|
|
|
|
1169
|
if (scalar(@multipleoctet) >= 2) { |
2327
|
519
|
|
|
|
|
1571
|
return '(?:' . join('|', @multipleoctet) . ')'; |
2328
|
|
|
|
|
|
|
} |
2329
|
|
|
|
|
|
|
else { |
2330
|
131
|
|
|
|
|
827
|
return $multipleoctet[0]; |
2331
|
|
|
|
|
|
|
} |
2332
|
|
|
|
|
|
|
} |
2333
|
|
|
|
|
|
|
|
2334
|
|
|
|
|
|
|
# |
2335
|
|
|
|
|
|
|
# ShiftJIS open character list for not qr |
2336
|
|
|
|
|
|
|
# |
2337
|
|
|
|
|
|
|
sub charlist_not_qr { |
2338
|
|
|
|
|
|
|
|
2339
|
388
|
|
|
239
|
0
|
1761
|
my $modifier = pop @_; |
2340
|
239
|
|
|
|
|
469
|
my @char = @_; |
2341
|
|
|
|
|
|
|
|
2342
|
239
|
|
|
|
|
565
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2343
|
239
|
|
|
|
|
639
|
my @singleoctet = @$singleoctet; |
2344
|
239
|
|
|
|
|
505
|
my @multipleoctet = @$multipleoctet; |
2345
|
|
|
|
|
|
|
|
2346
|
|
|
|
|
|
|
# with /i modifier |
2347
|
239
|
100
|
|
|
|
373
|
if ($modifier =~ m/i/oxms) { |
2348
|
239
|
|
|
|
|
597
|
my %singleoctet_ignorecase = (); |
2349
|
128
|
|
|
|
|
204
|
for (@singleoctet) { |
2350
|
128
|
|
66
|
|
|
176
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2351
|
277
|
|
|
|
|
936
|
for my $ord (hex($1) .. hex($2)) { |
2352
|
85
|
|
|
|
|
309
|
my $char = CORE::chr($ord); |
2353
|
1376
|
|
|
|
|
1810
|
my $uc = Esjis::uc($char); |
2354
|
1376
|
|
|
|
|
1624
|
my $fc = Esjis::fc($char); |
2355
|
1376
|
100
|
|
|
|
1861
|
if ($uc eq $fc) { |
2356
|
1376
|
|
|
|
|
2032
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2357
|
|
|
|
|
|
|
} |
2358
|
|
|
|
|
|
|
else { |
2359
|
787
|
50
|
|
|
|
1763
|
if (CORE::length($fc) == 1) { |
2360
|
589
|
|
|
|
|
707
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2361
|
589
|
|
|
|
|
1133
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2362
|
|
|
|
|
|
|
} |
2363
|
|
|
|
|
|
|
else { |
2364
|
589
|
|
|
|
|
1371
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2365
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2366
|
|
|
|
|
|
|
} |
2367
|
|
|
|
|
|
|
} |
2368
|
|
|
|
|
|
|
} |
2369
|
|
|
|
|
|
|
} |
2370
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2371
|
277
|
|
|
|
|
434
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2372
|
|
|
|
|
|
|
} |
2373
|
|
|
|
|
|
|
} |
2374
|
192
|
|
|
|
|
482
|
my $i = 0; |
2375
|
128
|
|
|
|
|
177
|
my @singleoctet_ignorecase = (); |
2376
|
128
|
|
|
|
|
179
|
for my $ord (0 .. 255) { |
2377
|
128
|
100
|
|
|
|
216
|
if (exists $singleoctet_ignorecase{$ord}) { |
2378
|
32768
|
|
|
|
|
37246
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1907
|
|
|
|
|
1653
|
|
2379
|
|
|
|
|
|
|
} |
2380
|
|
|
|
|
|
|
else { |
2381
|
1907
|
|
|
|
|
2904
|
$i++; |
2382
|
|
|
|
|
|
|
} |
2383
|
|
|
|
|
|
|
} |
2384
|
30861
|
|
|
|
|
30884
|
@singleoctet = (); |
2385
|
128
|
|
|
|
|
190
|
for my $range (@singleoctet_ignorecase) { |
2386
|
128
|
100
|
|
|
|
292
|
if (ref $range) { |
2387
|
11082
|
50
|
|
|
|
16960
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
223
|
|
2388
|
219
|
|
|
|
|
349
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
0
|
|
|
|
|
0
|
|
2389
|
|
|
|
|
|
|
} |
2390
|
0
|
|
|
|
|
0
|
elsif (scalar(@{$range}) == 2) { |
2391
|
219
|
|
|
|
|
308
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2392
|
|
|
|
|
|
|
} |
2393
|
|
|
|
|
|
|
else { |
2394
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
219
|
|
|
|
|
322
|
|
|
219
|
|
|
|
|
272
|
|
2395
|
|
|
|
|
|
|
} |
2396
|
|
|
|
|
|
|
} |
2397
|
|
|
|
|
|
|
} |
2398
|
|
|
|
|
|
|
} |
2399
|
|
|
|
|
|
|
|
2400
|
|
|
|
|
|
|
# return character list |
2401
|
219
|
100
|
|
|
|
1048
|
if (scalar(@multipleoctet) >= 1) { |
2402
|
239
|
100
|
|
|
|
551
|
if (scalar(@singleoctet) >= 1) { |
2403
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
# any character other than multiple-octet and single octet character class |
2405
|
114
|
|
|
|
|
201
|
return '(?!' . join('|', @multipleoctet) . ')(?:[^\x81-\x9F\xE0-\xFC' . join('', @singleoctet) . ']|[\x81-\x9F\xE0-\xFC][\x00-\xFF])'; |
2406
|
|
|
|
|
|
|
} |
2407
|
|
|
|
|
|
|
else { |
2408
|
|
|
|
|
|
|
|
2409
|
|
|
|
|
|
|
# any character other than multiple-octet character class |
2410
|
70
|
|
|
|
|
491
|
return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)"; |
2411
|
|
|
|
|
|
|
} |
2412
|
|
|
|
|
|
|
} |
2413
|
|
|
|
|
|
|
else { |
2414
|
44
|
50
|
|
|
|
298
|
if (scalar(@singleoctet) >= 1) { |
2415
|
|
|
|
|
|
|
|
2416
|
|
|
|
|
|
|
# any character other than single octet character class |
2417
|
125
|
|
|
|
|
277
|
return '(?:[^\x81-\x9F\xE0-\xFC' . join('', @singleoctet) . ']|[\x81-\x9F\xE0-\xFC][\x00-\xFF])'; |
2418
|
|
|
|
|
|
|
} |
2419
|
|
|
|
|
|
|
else { |
2420
|
|
|
|
|
|
|
|
2421
|
|
|
|
|
|
|
# any character |
2422
|
125
|
|
|
|
|
881
|
return "(?:$your_char)"; |
2423
|
|
|
|
|
|
|
} |
2424
|
|
|
|
|
|
|
} |
2425
|
|
|
|
|
|
|
} |
2426
|
|
|
|
|
|
|
|
2427
|
|
|
|
|
|
|
# |
2428
|
|
|
|
|
|
|
# open file in read mode |
2429
|
|
|
|
|
|
|
# |
2430
|
|
|
|
|
|
|
sub _open_r { |
2431
|
0
|
|
|
770
|
|
0
|
my(undef,$file) = @_; |
2432
|
390
|
|
|
390
|
|
7775
|
use Fcntl qw(O_RDONLY); |
|
390
|
|
|
|
|
889
|
|
|
390
|
|
|
|
|
65556
|
|
2433
|
770
|
|
|
|
|
2387
|
return CORE::sysopen($_[0], $file, &O_RDONLY); |
2434
|
|
|
|
|
|
|
} |
2435
|
|
|
|
|
|
|
|
2436
|
|
|
|
|
|
|
# |
2437
|
|
|
|
|
|
|
# open file in append mode |
2438
|
|
|
|
|
|
|
# |
2439
|
|
|
|
|
|
|
sub _open_a { |
2440
|
770
|
|
|
385
|
|
41130
|
my(undef,$file) = @_; |
2441
|
390
|
|
|
390
|
|
4320
|
use Fcntl qw(O_WRONLY O_APPEND O_CREAT); |
|
390
|
|
|
|
|
2603
|
|
|
390
|
|
|
|
|
6221038
|
|
2442
|
385
|
|
|
|
|
1242
|
return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT); |
2443
|
|
|
|
|
|
|
} |
2444
|
|
|
|
|
|
|
|
2445
|
|
|
|
|
|
|
# |
2446
|
|
|
|
|
|
|
# safe system |
2447
|
|
|
|
|
|
|
# |
2448
|
|
|
|
|
|
|
sub _systemx { |
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2451
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2452
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2453
|
|
|
|
|
|
|
# |
2454
|
|
|
|
|
|
|
# Be aware that in older releases of Perl, exec (and system) did not flush |
2455
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2456
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output in the case of exec, or |
2457
|
|
|
|
|
|
|
# misordererd output in the case of system. This situation was largely remedied |
2458
|
|
|
|
|
|
|
# in the 5.6 release of Perl. (So, 5.005 release not yet.) |
2459
|
|
|
|
|
|
|
|
2460
|
|
|
|
|
|
|
# P.855 exec |
2461
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2462
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2463
|
|
|
|
|
|
|
# |
2464
|
|
|
|
|
|
|
# In very old release of Perl (before v5.6), exec (and system) did not flush |
2465
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2466
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output with exec or misordered |
2467
|
|
|
|
|
|
|
# output with system. |
2468
|
|
|
|
|
|
|
|
2469
|
385
|
|
|
385
|
|
46480
|
$| = 1; |
2470
|
|
|
|
|
|
|
|
2471
|
|
|
|
|
|
|
# P.565 23.1.2. Cleaning Up Your Environment |
2472
|
|
|
|
|
|
|
# in Chapter 23: Security |
2473
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2474
|
|
|
|
|
|
|
|
2475
|
|
|
|
|
|
|
# P.656 Cleaning Up Your Environment |
2476
|
|
|
|
|
|
|
# in Chapter 20: Security |
2477
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2478
|
|
|
|
|
|
|
|
2479
|
|
|
|
|
|
|
# local $ENV{'PATH'} = '.'; |
2480
|
385
|
|
|
|
|
1508
|
local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer |
2481
|
|
|
|
|
|
|
|
2482
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2483
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2484
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2485
|
|
|
|
|
|
|
# |
2486
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as an |
2487
|
|
|
|
|
|
|
# indication that it should bypass shell processing. However, there is one |
2488
|
|
|
|
|
|
|
# place where you might still get tripped up. The exec call (and system, too) |
2489
|
|
|
|
|
|
|
# will not distinguish between a single scalar argument and an array containing |
2490
|
|
|
|
|
|
|
# only one element. |
2491
|
|
|
|
|
|
|
# |
2492
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2493
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2494
|
|
|
|
|
|
|
# or die "exec: $!"; # because @args == 1 |
2495
|
|
|
|
|
|
|
# |
2496
|
|
|
|
|
|
|
# To avoid this, you can use the PATHNAME syntax, explicitly duplicating the |
2497
|
|
|
|
|
|
|
# first argument as the pathname, which forces the rest of the arguments to be |
2498
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2499
|
|
|
|
|
|
|
# |
2500
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2501
|
|
|
|
|
|
|
# or die "can't exec @args: $!"; |
2502
|
|
|
|
|
|
|
|
2503
|
|
|
|
|
|
|
# P.855 exec |
2504
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2505
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2506
|
|
|
|
|
|
|
# |
2507
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as a |
2508
|
|
|
|
|
|
|
# directive to bypass shell processing. However, there is one place where |
2509
|
|
|
|
|
|
|
# you might still get tripped up. The exec call (and system, too) cannot |
2510
|
|
|
|
|
|
|
# distinguish between a single scalar argument and an array containing |
2511
|
|
|
|
|
|
|
# only one element. |
2512
|
|
|
|
|
|
|
# |
2513
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2514
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2515
|
|
|
|
|
|
|
# || die "exec: $!"; # because @args == 1 |
2516
|
|
|
|
|
|
|
# |
2517
|
|
|
|
|
|
|
# To avoid this, use the PATHNAME syntax, explicitly duplicating the first |
2518
|
|
|
|
|
|
|
# argument as the pathname, which forces the rest of the arguments to be |
2519
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2520
|
|
|
|
|
|
|
# |
2521
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2522
|
|
|
|
|
|
|
# || die "can't exec @args: $!"; |
2523
|
|
|
|
|
|
|
|
2524
|
385
|
|
|
|
|
3948
|
return CORE::system { $_[0] } @_; # safe even with one-argument list |
|
385
|
|
|
|
|
963
|
|
2525
|
|
|
|
|
|
|
} |
2526
|
|
|
|
|
|
|
|
2527
|
|
|
|
|
|
|
# |
2528
|
|
|
|
|
|
|
# ShiftJIS order to character (with parameter) |
2529
|
|
|
|
|
|
|
# |
2530
|
|
|
|
|
|
|
sub Esjis::chr(;$) { |
2531
|
|
|
|
|
|
|
|
2532
|
385
|
0
|
|
0
|
0
|
49324927
|
my $c = @_ ? $_[0] : $_; |
2533
|
|
|
|
|
|
|
|
2534
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2535
|
0
|
|
|
|
|
0
|
return "\x00"; |
2536
|
|
|
|
|
|
|
} |
2537
|
|
|
|
|
|
|
else { |
2538
|
0
|
|
|
|
|
0
|
my @chr = (); |
2539
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2540
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2541
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2542
|
|
|
|
|
|
|
} |
2543
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2544
|
|
|
|
|
|
|
} |
2545
|
|
|
|
|
|
|
} |
2546
|
|
|
|
|
|
|
|
2547
|
|
|
|
|
|
|
# |
2548
|
|
|
|
|
|
|
# ShiftJIS order to character (without parameter) |
2549
|
|
|
|
|
|
|
# |
2550
|
|
|
|
|
|
|
sub Esjis::chr_() { |
2551
|
|
|
|
|
|
|
|
2552
|
0
|
|
|
0
|
0
|
0
|
my $c = $_; |
2553
|
|
|
|
|
|
|
|
2554
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2555
|
0
|
|
|
|
|
0
|
return "\x00"; |
2556
|
|
|
|
|
|
|
} |
2557
|
|
|
|
|
|
|
else { |
2558
|
0
|
|
|
|
|
0
|
my @chr = (); |
2559
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2560
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2561
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2562
|
|
|
|
|
|
|
} |
2563
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2564
|
|
|
|
|
|
|
} |
2565
|
|
|
|
|
|
|
} |
2566
|
|
|
|
|
|
|
|
2567
|
|
|
|
|
|
|
# |
2568
|
|
|
|
|
|
|
# ShiftJIS stacked file test expr |
2569
|
|
|
|
|
|
|
# |
2570
|
|
|
|
|
|
|
sub Esjis::filetest { |
2571
|
|
|
|
|
|
|
|
2572
|
0
|
|
|
0
|
0
|
0
|
my $file = pop @_; |
2573
|
0
|
|
|
|
|
0
|
my $filetest = substr(pop @_, 1); |
2574
|
|
|
|
|
|
|
|
2575
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Esjis::$filetest(\$file)}) { |
2576
|
0
|
|
|
|
|
0
|
return ''; |
2577
|
|
|
|
|
|
|
} |
2578
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
2579
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
2580
|
0
|
|
|
|
|
0
|
return ''; |
2581
|
|
|
|
|
|
|
} |
2582
|
|
|
|
|
|
|
} |
2583
|
0
|
|
|
|
|
0
|
return 1; |
2584
|
|
|
|
|
|
|
} |
2585
|
|
|
|
|
|
|
|
2586
|
|
|
|
|
|
|
# |
2587
|
|
|
|
|
|
|
# ShiftJIS file test -r expr |
2588
|
|
|
|
|
|
|
# |
2589
|
|
|
|
|
|
|
sub Esjis::r(;*@) { |
2590
|
|
|
|
|
|
|
|
2591
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2592
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -r (Esjis::r)' if @_ and not wantarray; |
2593
|
|
|
|
|
|
|
|
2594
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2595
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2596
|
|
|
|
|
|
|
} |
2597
|
|
|
|
|
|
|
|
2598
|
|
|
|
|
|
|
# P.908 32.39. Symbol |
2599
|
|
|
|
|
|
|
# in Chapter 32: Standard Modules |
2600
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2601
|
|
|
|
|
|
|
|
2602
|
|
|
|
|
|
|
# P.326 Prototypes |
2603
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
2604
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2605
|
|
|
|
|
|
|
|
2606
|
|
|
|
|
|
|
# (and so on) |
2607
|
|
|
|
|
|
|
|
2608
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2609
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r $fh,@_) : -r $fh; |
2610
|
|
|
|
|
|
|
} |
2611
|
|
|
|
|
|
|
elsif (-e $_) { |
2612
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2613
|
|
|
|
|
|
|
} |
2614
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2615
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2616
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2617
|
|
|
|
|
|
|
} |
2618
|
|
|
|
|
|
|
else { |
2619
|
|
|
|
|
|
|
|
2620
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::*() |
2621
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
2622
|
|
|
|
|
|
|
# (and so on) |
2623
|
|
|
|
|
|
|
|
2624
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2625
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2626
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
2627
|
0
|
|
|
|
|
0
|
close $fh; |
2628
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($r,@_) : $r; |
2629
|
|
|
|
|
|
|
} |
2630
|
|
|
|
|
|
|
} |
2631
|
|
|
|
|
|
|
} |
2632
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2633
|
|
|
|
|
|
|
} |
2634
|
|
|
|
|
|
|
|
2635
|
|
|
|
|
|
|
# |
2636
|
|
|
|
|
|
|
# ShiftJIS file test -w expr |
2637
|
|
|
|
|
|
|
# |
2638
|
|
|
|
|
|
|
sub Esjis::w(;*@) { |
2639
|
|
|
|
|
|
|
|
2640
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2641
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -w (Esjis::w)' if @_ and not wantarray; |
2642
|
|
|
|
|
|
|
|
2643
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2644
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2645
|
|
|
|
|
|
|
} |
2646
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2647
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w $fh,@_) : -w $fh; |
2648
|
|
|
|
|
|
|
} |
2649
|
|
|
|
|
|
|
elsif (-e $_) { |
2650
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2651
|
|
|
|
|
|
|
} |
2652
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2653
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2654
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2655
|
|
|
|
|
|
|
} |
2656
|
|
|
|
|
|
|
else { |
2657
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2658
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2659
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
2660
|
0
|
|
|
|
|
0
|
close $fh; |
2661
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($w,@_) : $w; |
2662
|
|
|
|
|
|
|
} |
2663
|
|
|
|
|
|
|
} |
2664
|
|
|
|
|
|
|
} |
2665
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2666
|
|
|
|
|
|
|
} |
2667
|
|
|
|
|
|
|
|
2668
|
|
|
|
|
|
|
# |
2669
|
|
|
|
|
|
|
# ShiftJIS file test -x expr |
2670
|
|
|
|
|
|
|
# |
2671
|
|
|
|
|
|
|
sub Esjis::x(;*@) { |
2672
|
|
|
|
|
|
|
|
2673
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2674
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -x (Esjis::x)' if @_ and not wantarray; |
2675
|
|
|
|
|
|
|
|
2676
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2677
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2678
|
|
|
|
|
|
|
} |
2679
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2680
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x $fh,@_) : -x $fh; |
2681
|
|
|
|
|
|
|
} |
2682
|
|
|
|
|
|
|
elsif (-e $_) { |
2683
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2684
|
|
|
|
|
|
|
} |
2685
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2686
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2687
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2688
|
|
|
|
|
|
|
} |
2689
|
|
|
|
|
|
|
else { |
2690
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2691
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2692
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
2693
|
0
|
|
|
|
|
0
|
close $fh; |
2694
|
|
|
|
|
|
|
} |
2695
|
|
|
|
|
|
|
|
2696
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2697
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2698
|
|
|
|
|
|
|
} |
2699
|
|
|
|
|
|
|
} |
2700
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2701
|
|
|
|
|
|
|
} |
2702
|
|
|
|
|
|
|
|
2703
|
|
|
|
|
|
|
# |
2704
|
|
|
|
|
|
|
# ShiftJIS file test -o expr |
2705
|
|
|
|
|
|
|
# |
2706
|
|
|
|
|
|
|
sub Esjis::o(;*@) { |
2707
|
|
|
|
|
|
|
|
2708
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2709
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -o (Esjis::o)' if @_ and not wantarray; |
2710
|
|
|
|
|
|
|
|
2711
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2712
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2713
|
|
|
|
|
|
|
} |
2714
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2715
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o $fh,@_) : -o $fh; |
2716
|
|
|
|
|
|
|
} |
2717
|
|
|
|
|
|
|
elsif (-e $_) { |
2718
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2719
|
|
|
|
|
|
|
} |
2720
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2721
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2722
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2723
|
|
|
|
|
|
|
} |
2724
|
|
|
|
|
|
|
else { |
2725
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2726
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2727
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
2728
|
0
|
|
|
|
|
0
|
close $fh; |
2729
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($o,@_) : $o; |
2730
|
|
|
|
|
|
|
} |
2731
|
|
|
|
|
|
|
} |
2732
|
|
|
|
|
|
|
} |
2733
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2734
|
|
|
|
|
|
|
} |
2735
|
|
|
|
|
|
|
|
2736
|
|
|
|
|
|
|
# |
2737
|
|
|
|
|
|
|
# ShiftJIS file test -R expr |
2738
|
|
|
|
|
|
|
# |
2739
|
|
|
|
|
|
|
sub Esjis::R(;*@) { |
2740
|
|
|
|
|
|
|
|
2741
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2742
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -R (Esjis::R)' if @_ and not wantarray; |
2743
|
|
|
|
|
|
|
|
2744
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2745
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2746
|
|
|
|
|
|
|
} |
2747
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2748
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R $fh,@_) : -R $fh; |
2749
|
|
|
|
|
|
|
} |
2750
|
|
|
|
|
|
|
elsif (-e $_) { |
2751
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2752
|
|
|
|
|
|
|
} |
2753
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2754
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2755
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2756
|
|
|
|
|
|
|
} |
2757
|
|
|
|
|
|
|
else { |
2758
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2759
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2760
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
2761
|
0
|
|
|
|
|
0
|
close $fh; |
2762
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($R,@_) : $R; |
2763
|
|
|
|
|
|
|
} |
2764
|
|
|
|
|
|
|
} |
2765
|
|
|
|
|
|
|
} |
2766
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2767
|
|
|
|
|
|
|
} |
2768
|
|
|
|
|
|
|
|
2769
|
|
|
|
|
|
|
# |
2770
|
|
|
|
|
|
|
# ShiftJIS file test -W expr |
2771
|
|
|
|
|
|
|
# |
2772
|
|
|
|
|
|
|
sub Esjis::W(;*@) { |
2773
|
|
|
|
|
|
|
|
2774
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2775
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -W (Esjis::W)' if @_ and not wantarray; |
2776
|
|
|
|
|
|
|
|
2777
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2778
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2779
|
|
|
|
|
|
|
} |
2780
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2781
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W $fh,@_) : -W $fh; |
2782
|
|
|
|
|
|
|
} |
2783
|
|
|
|
|
|
|
elsif (-e $_) { |
2784
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2785
|
|
|
|
|
|
|
} |
2786
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2787
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2788
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2789
|
|
|
|
|
|
|
} |
2790
|
|
|
|
|
|
|
else { |
2791
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2792
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2793
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
2794
|
0
|
|
|
|
|
0
|
close $fh; |
2795
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($W,@_) : $W; |
2796
|
|
|
|
|
|
|
} |
2797
|
|
|
|
|
|
|
} |
2798
|
|
|
|
|
|
|
} |
2799
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2800
|
|
|
|
|
|
|
} |
2801
|
|
|
|
|
|
|
|
2802
|
|
|
|
|
|
|
# |
2803
|
|
|
|
|
|
|
# ShiftJIS file test -X expr |
2804
|
|
|
|
|
|
|
# |
2805
|
|
|
|
|
|
|
sub Esjis::X(;*@) { |
2806
|
|
|
|
|
|
|
|
2807
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
2808
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -X (Esjis::X)' if @_ and not wantarray; |
2809
|
|
|
|
|
|
|
|
2810
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2811
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2812
|
|
|
|
|
|
|
} |
2813
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2814
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X $fh,@_) : -X $fh; |
2815
|
|
|
|
|
|
|
} |
2816
|
|
|
|
|
|
|
elsif (-e $_) { |
2817
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2818
|
|
|
|
|
|
|
} |
2819
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2820
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2821
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2822
|
|
|
|
|
|
|
} |
2823
|
|
|
|
|
|
|
else { |
2824
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2825
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2826
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
2827
|
0
|
|
|
|
|
0
|
close $fh; |
2828
|
|
|
|
|
|
|
} |
2829
|
|
|
|
|
|
|
|
2830
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2831
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2832
|
|
|
|
|
|
|
} |
2833
|
|
|
|
|
|
|
} |
2834
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2835
|
|
|
|
|
|
|
} |
2836
|
|
|
|
|
|
|
|
2837
|
|
|
|
|
|
|
# |
2838
|
|
|
|
|
|
|
# ShiftJIS file test -O expr |
2839
|
|
|
|
|
|
|
# |
2840
|
|
|
|
|
|
|
sub Esjis::O(;*@) { |
2841
|
|
|
|
|
|
|
|
2842
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2843
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -O (Esjis::O)' if @_ and not wantarray; |
2844
|
|
|
|
|
|
|
|
2845
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2846
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2847
|
|
|
|
|
|
|
} |
2848
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2849
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O $fh,@_) : -O $fh; |
2850
|
|
|
|
|
|
|
} |
2851
|
|
|
|
|
|
|
elsif (-e $_) { |
2852
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2853
|
|
|
|
|
|
|
} |
2854
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2855
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2856
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2857
|
|
|
|
|
|
|
} |
2858
|
|
|
|
|
|
|
else { |
2859
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2860
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2861
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
2862
|
0
|
|
|
|
|
0
|
close $fh; |
2863
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($O,@_) : $O; |
2864
|
|
|
|
|
|
|
} |
2865
|
|
|
|
|
|
|
} |
2866
|
|
|
|
|
|
|
} |
2867
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2868
|
|
|
|
|
|
|
} |
2869
|
|
|
|
|
|
|
|
2870
|
|
|
|
|
|
|
# |
2871
|
|
|
|
|
|
|
# ShiftJIS file test -e expr |
2872
|
|
|
|
|
|
|
# |
2873
|
|
|
|
|
|
|
sub Esjis::e(;*@) { |
2874
|
|
|
|
|
|
|
|
2875
|
0
|
50
|
|
770
|
0
|
0
|
local $_ = shift if @_; |
2876
|
770
|
50
|
33
|
|
|
2984
|
croak 'Too many arguments for -e (Esjis::e)' if @_ and not wantarray; |
2877
|
|
|
|
|
|
|
|
2878
|
770
|
|
|
|
|
3260
|
local $^W = 0; |
2879
|
|
|
|
|
|
|
|
2880
|
770
|
|
|
|
|
2588
|
my $fh = qualify_to_ref $_; |
2881
|
770
|
50
|
|
|
|
2332
|
if ($_ eq '_') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2882
|
770
|
0
|
|
|
|
4852
|
return wantarray ? (-e _,@_) : -e _; |
2883
|
|
|
|
|
|
|
} |
2884
|
|
|
|
|
|
|
|
2885
|
|
|
|
|
|
|
# return false if directory handle |
2886
|
|
|
|
|
|
|
elsif (defined Esjis::telldir($fh)) { |
2887
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2888
|
|
|
|
|
|
|
} |
2889
|
|
|
|
|
|
|
|
2890
|
|
|
|
|
|
|
# return true if file handle |
2891
|
|
|
|
|
|
|
elsif (defined fileno $fh) { |
2892
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2893
|
|
|
|
|
|
|
} |
2894
|
|
|
|
|
|
|
|
2895
|
|
|
|
|
|
|
elsif (-e $_) { |
2896
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2897
|
|
|
|
|
|
|
} |
2898
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2899
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2900
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2901
|
|
|
|
|
|
|
} |
2902
|
|
|
|
|
|
|
else { |
2903
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2904
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2905
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
2906
|
0
|
|
|
|
|
0
|
close $fh; |
2907
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($e,@_) : $e; |
2908
|
|
|
|
|
|
|
} |
2909
|
|
|
|
|
|
|
} |
2910
|
|
|
|
|
|
|
} |
2911
|
0
|
50
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2912
|
|
|
|
|
|
|
} |
2913
|
|
|
|
|
|
|
|
2914
|
|
|
|
|
|
|
# |
2915
|
|
|
|
|
|
|
# ShiftJIS file test -z expr |
2916
|
|
|
|
|
|
|
# |
2917
|
|
|
|
|
|
|
sub Esjis::z(;*@) { |
2918
|
|
|
|
|
|
|
|
2919
|
770
|
0
|
|
0
|
0
|
4792
|
local $_ = shift if @_; |
2920
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -z (Esjis::z)' if @_ and not wantarray; |
2921
|
|
|
|
|
|
|
|
2922
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2923
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2924
|
|
|
|
|
|
|
} |
2925
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2926
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z $fh,@_) : -z $fh; |
2927
|
|
|
|
|
|
|
} |
2928
|
|
|
|
|
|
|
elsif (-e $_) { |
2929
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2930
|
|
|
|
|
|
|
} |
2931
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2932
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2933
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2934
|
|
|
|
|
|
|
} |
2935
|
|
|
|
|
|
|
else { |
2936
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2937
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2938
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
2939
|
0
|
|
|
|
|
0
|
close $fh; |
2940
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($z,@_) : $z; |
2941
|
|
|
|
|
|
|
} |
2942
|
|
|
|
|
|
|
} |
2943
|
|
|
|
|
|
|
} |
2944
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2945
|
|
|
|
|
|
|
} |
2946
|
|
|
|
|
|
|
|
2947
|
|
|
|
|
|
|
# |
2948
|
|
|
|
|
|
|
# ShiftJIS file test -s expr |
2949
|
|
|
|
|
|
|
# |
2950
|
|
|
|
|
|
|
sub Esjis::s(;*@) { |
2951
|
|
|
|
|
|
|
|
2952
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2953
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -s (Esjis::s)' if @_ and not wantarray; |
2954
|
|
|
|
|
|
|
|
2955
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2956
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2957
|
|
|
|
|
|
|
} |
2958
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2959
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s $fh,@_) : -s $fh; |
2960
|
|
|
|
|
|
|
} |
2961
|
|
|
|
|
|
|
elsif (-e $_) { |
2962
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2963
|
|
|
|
|
|
|
} |
2964
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2965
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2966
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2967
|
|
|
|
|
|
|
} |
2968
|
|
|
|
|
|
|
else { |
2969
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2970
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2971
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
2972
|
0
|
|
|
|
|
0
|
close $fh; |
2973
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($s,@_) : $s; |
2974
|
|
|
|
|
|
|
} |
2975
|
|
|
|
|
|
|
} |
2976
|
|
|
|
|
|
|
} |
2977
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2978
|
|
|
|
|
|
|
} |
2979
|
|
|
|
|
|
|
|
2980
|
|
|
|
|
|
|
# |
2981
|
|
|
|
|
|
|
# ShiftJIS file test -f expr |
2982
|
|
|
|
|
|
|
# |
2983
|
|
|
|
|
|
|
sub Esjis::f(;*@) { |
2984
|
|
|
|
|
|
|
|
2985
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2986
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -f (Esjis::f)' if @_ and not wantarray; |
2987
|
|
|
|
|
|
|
|
2988
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2989
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
2990
|
|
|
|
|
|
|
} |
2991
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2992
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f $fh,@_) : -f $fh; |
2993
|
|
|
|
|
|
|
} |
2994
|
|
|
|
|
|
|
elsif (-e $_) { |
2995
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
2996
|
|
|
|
|
|
|
} |
2997
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2998
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2999
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3000
|
|
|
|
|
|
|
} |
3001
|
|
|
|
|
|
|
else { |
3002
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3003
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3004
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3005
|
0
|
|
|
|
|
0
|
close $fh; |
3006
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($f,@_) : $f; |
3007
|
|
|
|
|
|
|
} |
3008
|
|
|
|
|
|
|
} |
3009
|
|
|
|
|
|
|
} |
3010
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3011
|
|
|
|
|
|
|
} |
3012
|
|
|
|
|
|
|
|
3013
|
|
|
|
|
|
|
# |
3014
|
|
|
|
|
|
|
# ShiftJIS file test -d expr |
3015
|
|
|
|
|
|
|
# |
3016
|
|
|
|
|
|
|
sub Esjis::d(;*@) { |
3017
|
|
|
|
|
|
|
|
3018
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3019
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -d (Esjis::d)' if @_ and not wantarray; |
3020
|
|
|
|
|
|
|
|
3021
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3022
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3023
|
|
|
|
|
|
|
} |
3024
|
|
|
|
|
|
|
|
3025
|
|
|
|
|
|
|
# return false if file handle or directory handle |
3026
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3027
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3028
|
|
|
|
|
|
|
} |
3029
|
|
|
|
|
|
|
elsif (-e $_) { |
3030
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3031
|
|
|
|
|
|
|
} |
3032
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3033
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d "$_/.",@_) : -d "$_/."; |
3034
|
|
|
|
|
|
|
} |
3035
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3036
|
|
|
|
|
|
|
} |
3037
|
|
|
|
|
|
|
|
3038
|
|
|
|
|
|
|
# |
3039
|
|
|
|
|
|
|
# ShiftJIS file test -l expr |
3040
|
|
|
|
|
|
|
# |
3041
|
|
|
|
|
|
|
sub Esjis::l(;*@) { |
3042
|
|
|
|
|
|
|
|
3043
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3044
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -l (Esjis::l)' if @_ and not wantarray; |
3045
|
|
|
|
|
|
|
|
3046
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3047
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3048
|
|
|
|
|
|
|
} |
3049
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3050
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l $fh,@_) : -l $fh; |
3051
|
|
|
|
|
|
|
} |
3052
|
|
|
|
|
|
|
elsif (-e $_) { |
3053
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3054
|
|
|
|
|
|
|
} |
3055
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3056
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3057
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3058
|
|
|
|
|
|
|
} |
3059
|
|
|
|
|
|
|
else { |
3060
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3061
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3062
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3063
|
0
|
|
|
|
|
0
|
close $fh; |
3064
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($l,@_) : $l; |
3065
|
|
|
|
|
|
|
} |
3066
|
|
|
|
|
|
|
} |
3067
|
|
|
|
|
|
|
} |
3068
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3069
|
|
|
|
|
|
|
} |
3070
|
|
|
|
|
|
|
|
3071
|
|
|
|
|
|
|
# |
3072
|
|
|
|
|
|
|
# ShiftJIS file test -p expr |
3073
|
|
|
|
|
|
|
# |
3074
|
|
|
|
|
|
|
sub Esjis::p(;*@) { |
3075
|
|
|
|
|
|
|
|
3076
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3077
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -p (Esjis::p)' if @_ and not wantarray; |
3078
|
|
|
|
|
|
|
|
3079
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3080
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3081
|
|
|
|
|
|
|
} |
3082
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3083
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p $fh,@_) : -p $fh; |
3084
|
|
|
|
|
|
|
} |
3085
|
|
|
|
|
|
|
elsif (-e $_) { |
3086
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3087
|
|
|
|
|
|
|
} |
3088
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3089
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3090
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3091
|
|
|
|
|
|
|
} |
3092
|
|
|
|
|
|
|
else { |
3093
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3094
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3095
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3096
|
0
|
|
|
|
|
0
|
close $fh; |
3097
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($p,@_) : $p; |
3098
|
|
|
|
|
|
|
} |
3099
|
|
|
|
|
|
|
} |
3100
|
|
|
|
|
|
|
} |
3101
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3102
|
|
|
|
|
|
|
} |
3103
|
|
|
|
|
|
|
|
3104
|
|
|
|
|
|
|
# |
3105
|
|
|
|
|
|
|
# ShiftJIS file test -S expr |
3106
|
|
|
|
|
|
|
# |
3107
|
|
|
|
|
|
|
sub Esjis::S(;*@) { |
3108
|
|
|
|
|
|
|
|
3109
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3110
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -S (Esjis::S)' if @_ and not wantarray; |
3111
|
|
|
|
|
|
|
|
3112
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3113
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3114
|
|
|
|
|
|
|
} |
3115
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3116
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S $fh,@_) : -S $fh; |
3117
|
|
|
|
|
|
|
} |
3118
|
|
|
|
|
|
|
elsif (-e $_) { |
3119
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3120
|
|
|
|
|
|
|
} |
3121
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3122
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3123
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3124
|
|
|
|
|
|
|
} |
3125
|
|
|
|
|
|
|
else { |
3126
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3127
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3128
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3129
|
0
|
|
|
|
|
0
|
close $fh; |
3130
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($S,@_) : $S; |
3131
|
|
|
|
|
|
|
} |
3132
|
|
|
|
|
|
|
} |
3133
|
|
|
|
|
|
|
} |
3134
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3135
|
|
|
|
|
|
|
} |
3136
|
|
|
|
|
|
|
|
3137
|
|
|
|
|
|
|
# |
3138
|
|
|
|
|
|
|
# ShiftJIS file test -b expr |
3139
|
|
|
|
|
|
|
# |
3140
|
|
|
|
|
|
|
sub Esjis::b(;*@) { |
3141
|
|
|
|
|
|
|
|
3142
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3143
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -b (Esjis::b)' if @_ and not wantarray; |
3144
|
|
|
|
|
|
|
|
3145
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3146
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3147
|
|
|
|
|
|
|
} |
3148
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3149
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b $fh,@_) : -b $fh; |
3150
|
|
|
|
|
|
|
} |
3151
|
|
|
|
|
|
|
elsif (-e $_) { |
3152
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3153
|
|
|
|
|
|
|
} |
3154
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3155
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3156
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3157
|
|
|
|
|
|
|
} |
3158
|
|
|
|
|
|
|
else { |
3159
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3160
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3161
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
3162
|
0
|
|
|
|
|
0
|
close $fh; |
3163
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($b,@_) : $b; |
3164
|
|
|
|
|
|
|
} |
3165
|
|
|
|
|
|
|
} |
3166
|
|
|
|
|
|
|
} |
3167
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3168
|
|
|
|
|
|
|
} |
3169
|
|
|
|
|
|
|
|
3170
|
|
|
|
|
|
|
# |
3171
|
|
|
|
|
|
|
# ShiftJIS file test -c expr |
3172
|
|
|
|
|
|
|
# |
3173
|
|
|
|
|
|
|
sub Esjis::c(;*@) { |
3174
|
|
|
|
|
|
|
|
3175
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3176
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -c (Esjis::c)' if @_ and not wantarray; |
3177
|
|
|
|
|
|
|
|
3178
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3179
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3180
|
|
|
|
|
|
|
} |
3181
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3182
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c $fh,@_) : -c $fh; |
3183
|
|
|
|
|
|
|
} |
3184
|
|
|
|
|
|
|
elsif (-e $_) { |
3185
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3186
|
|
|
|
|
|
|
} |
3187
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3188
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3189
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3190
|
|
|
|
|
|
|
} |
3191
|
|
|
|
|
|
|
else { |
3192
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3193
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3194
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
3195
|
0
|
|
|
|
|
0
|
close $fh; |
3196
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($c,@_) : $c; |
3197
|
|
|
|
|
|
|
} |
3198
|
|
|
|
|
|
|
} |
3199
|
|
|
|
|
|
|
} |
3200
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3201
|
|
|
|
|
|
|
} |
3202
|
|
|
|
|
|
|
|
3203
|
|
|
|
|
|
|
# |
3204
|
|
|
|
|
|
|
# ShiftJIS file test -u expr |
3205
|
|
|
|
|
|
|
# |
3206
|
|
|
|
|
|
|
sub Esjis::u(;*@) { |
3207
|
|
|
|
|
|
|
|
3208
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3209
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -u (Esjis::u)' if @_ and not wantarray; |
3210
|
|
|
|
|
|
|
|
3211
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3212
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3213
|
|
|
|
|
|
|
} |
3214
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3215
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u $fh,@_) : -u $fh; |
3216
|
|
|
|
|
|
|
} |
3217
|
|
|
|
|
|
|
elsif (-e $_) { |
3218
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3219
|
|
|
|
|
|
|
} |
3220
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3221
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3222
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3223
|
|
|
|
|
|
|
} |
3224
|
|
|
|
|
|
|
else { |
3225
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3226
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3227
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
3228
|
0
|
|
|
|
|
0
|
close $fh; |
3229
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($u,@_) : $u; |
3230
|
|
|
|
|
|
|
} |
3231
|
|
|
|
|
|
|
} |
3232
|
|
|
|
|
|
|
} |
3233
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3234
|
|
|
|
|
|
|
} |
3235
|
|
|
|
|
|
|
|
3236
|
|
|
|
|
|
|
# |
3237
|
|
|
|
|
|
|
# ShiftJIS file test -g expr |
3238
|
|
|
|
|
|
|
# |
3239
|
|
|
|
|
|
|
sub Esjis::g(;*@) { |
3240
|
|
|
|
|
|
|
|
3241
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3242
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -g (Esjis::g)' if @_ and not wantarray; |
3243
|
|
|
|
|
|
|
|
3244
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3245
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3246
|
|
|
|
|
|
|
} |
3247
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3248
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g $fh,@_) : -g $fh; |
3249
|
|
|
|
|
|
|
} |
3250
|
|
|
|
|
|
|
elsif (-e $_) { |
3251
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3252
|
|
|
|
|
|
|
} |
3253
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3254
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3255
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3256
|
|
|
|
|
|
|
} |
3257
|
|
|
|
|
|
|
else { |
3258
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3259
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3260
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
3261
|
0
|
|
|
|
|
0
|
close $fh; |
3262
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($g,@_) : $g; |
3263
|
|
|
|
|
|
|
} |
3264
|
|
|
|
|
|
|
} |
3265
|
|
|
|
|
|
|
} |
3266
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3267
|
|
|
|
|
|
|
} |
3268
|
|
|
|
|
|
|
|
3269
|
|
|
|
|
|
|
# |
3270
|
|
|
|
|
|
|
# ShiftJIS file test -k expr |
3271
|
|
|
|
|
|
|
# |
3272
|
|
|
|
|
|
|
sub Esjis::k(;*@) { |
3273
|
|
|
|
|
|
|
|
3274
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3275
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -k (Esjis::k)' if @_ and not wantarray; |
3276
|
|
|
|
|
|
|
|
3277
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3278
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3279
|
|
|
|
|
|
|
} |
3280
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3281
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3282
|
|
|
|
|
|
|
} |
3283
|
|
|
|
|
|
|
elsif ($] =~ /^5\.008/oxms) { |
3284
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3285
|
|
|
|
|
|
|
} |
3286
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
3287
|
|
|
|
|
|
|
} |
3288
|
|
|
|
|
|
|
|
3289
|
|
|
|
|
|
|
# |
3290
|
|
|
|
|
|
|
# ShiftJIS file test -T expr |
3291
|
|
|
|
|
|
|
# |
3292
|
|
|
|
|
|
|
sub Esjis::T(;*@) { |
3293
|
|
|
|
|
|
|
|
3294
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3295
|
|
|
|
|
|
|
|
3296
|
|
|
|
|
|
|
# Use of croak without parentheses makes die on Strawberry Perl 5.008 and 5.010, like: |
3297
|
|
|
|
|
|
|
# croak 'Too many arguments for -T (Esjis::T)'; |
3298
|
|
|
|
|
|
|
# Must be used by parentheses like: |
3299
|
|
|
|
|
|
|
# croak('Too many arguments for -T (Esjis::T)'); |
3300
|
|
|
|
|
|
|
|
3301
|
0
|
0
|
0
|
|
|
0
|
if (@_ and not wantarray) { |
3302
|
0
|
|
|
|
|
0
|
croak('Too many arguments for -T (Esjis::T)'); |
3303
|
|
|
|
|
|
|
} |
3304
|
|
|
|
|
|
|
|
3305
|
0
|
|
|
|
|
0
|
my $T = 1; |
3306
|
|
|
|
|
|
|
|
3307
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3308
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3309
|
|
|
|
|
|
|
|
3310
|
0
|
0
|
|
|
|
0
|
if (defined Esjis::telldir($fh)) { |
3311
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3312
|
|
|
|
|
|
|
} |
3313
|
|
|
|
|
|
|
|
3314
|
|
|
|
|
|
|
# P.813 29.2.176. tell |
3315
|
|
|
|
|
|
|
# in Chapter 29: Functions |
3316
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
3317
|
|
|
|
|
|
|
|
3318
|
|
|
|
|
|
|
# P.970 tell |
3319
|
|
|
|
|
|
|
# in Chapter 27: Functions |
3320
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3321
|
|
|
|
|
|
|
|
3322
|
|
|
|
|
|
|
# (and so on) |
3323
|
|
|
|
|
|
|
|
3324
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3325
|
|
|
|
|
|
|
|
3326
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3327
|
|
|
|
|
|
|
|
3328
|
|
|
|
|
|
|
# P.163 Binary file check in Little Perl Parlor 16 |
3329
|
|
|
|
|
|
|
# of Book No. T1008901080816 ZASSHI 08901-8 UNIX MAGAZINE 1993 Aug VOL8#8 |
3330
|
|
|
|
|
|
|
# (and so on) |
3331
|
|
|
|
|
|
|
|
3332
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3333
|
0
|
|
|
|
|
0
|
$T = ''; |
3334
|
|
|
|
|
|
|
} |
3335
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3336
|
0
|
|
|
|
|
0
|
$T = ''; |
3337
|
|
|
|
|
|
|
} |
3338
|
|
|
|
|
|
|
} |
3339
|
|
|
|
|
|
|
|
3340
|
|
|
|
|
|
|
# 0 byte or eof |
3341
|
|
|
|
|
|
|
else { |
3342
|
0
|
|
|
|
|
0
|
$T = 1; |
3343
|
|
|
|
|
|
|
} |
3344
|
|
|
|
|
|
|
|
3345
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3346
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3347
|
|
|
|
|
|
|
} |
3348
|
|
|
|
|
|
|
else { |
3349
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3350
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3351
|
|
|
|
|
|
|
} |
3352
|
|
|
|
|
|
|
|
3353
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3354
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3355
|
|
|
|
|
|
|
} |
3356
|
|
|
|
|
|
|
else { |
3357
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3358
|
|
|
|
|
|
|
} |
3359
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3360
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3361
|
0
|
|
|
|
|
0
|
$T = ''; |
3362
|
|
|
|
|
|
|
} |
3363
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3364
|
0
|
|
|
|
|
0
|
$T = ''; |
3365
|
|
|
|
|
|
|
} |
3366
|
|
|
|
|
|
|
} |
3367
|
|
|
|
|
|
|
|
3368
|
|
|
|
|
|
|
# 0 byte or eof |
3369
|
|
|
|
|
|
|
else { |
3370
|
0
|
|
|
|
|
0
|
$T = 1; |
3371
|
|
|
|
|
|
|
} |
3372
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3373
|
0
|
|
|
|
|
0
|
close $fh; |
3374
|
|
|
|
|
|
|
} |
3375
|
|
|
|
|
|
|
|
3376
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($T,@_) : $T; |
3377
|
|
|
|
|
|
|
} |
3378
|
|
|
|
|
|
|
|
3379
|
|
|
|
|
|
|
# |
3380
|
|
|
|
|
|
|
# ShiftJIS file test -B expr |
3381
|
|
|
|
|
|
|
# |
3382
|
|
|
|
|
|
|
sub Esjis::B(;*@) { |
3383
|
|
|
|
|
|
|
|
3384
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3385
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -B (Esjis::B)' if @_ and not wantarray; |
3386
|
0
|
|
|
|
|
0
|
my $B = ''; |
3387
|
|
|
|
|
|
|
|
3388
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3389
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3390
|
|
|
|
|
|
|
|
3391
|
0
|
0
|
|
|
|
0
|
if (defined Esjis::telldir($fh)) { |
3392
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3393
|
|
|
|
|
|
|
} |
3394
|
|
|
|
|
|
|
|
3395
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3396
|
|
|
|
|
|
|
|
3397
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3398
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3399
|
0
|
|
|
|
|
0
|
$B = 1; |
3400
|
|
|
|
|
|
|
} |
3401
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3402
|
0
|
|
|
|
|
0
|
$B = 1; |
3403
|
|
|
|
|
|
|
} |
3404
|
|
|
|
|
|
|
} |
3405
|
|
|
|
|
|
|
|
3406
|
|
|
|
|
|
|
# 0 byte or eof |
3407
|
|
|
|
|
|
|
else { |
3408
|
0
|
|
|
|
|
0
|
$B = 1; |
3409
|
|
|
|
|
|
|
} |
3410
|
|
|
|
|
|
|
|
3411
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3412
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3413
|
|
|
|
|
|
|
} |
3414
|
|
|
|
|
|
|
else { |
3415
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3416
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3417
|
|
|
|
|
|
|
} |
3418
|
|
|
|
|
|
|
|
3419
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3420
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3421
|
|
|
|
|
|
|
} |
3422
|
|
|
|
|
|
|
else { |
3423
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3424
|
|
|
|
|
|
|
} |
3425
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3426
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3427
|
0
|
|
|
|
|
0
|
$B = 1; |
3428
|
|
|
|
|
|
|
} |
3429
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3430
|
0
|
|
|
|
|
0
|
$B = 1; |
3431
|
|
|
|
|
|
|
} |
3432
|
|
|
|
|
|
|
} |
3433
|
|
|
|
|
|
|
|
3434
|
|
|
|
|
|
|
# 0 byte or eof |
3435
|
|
|
|
|
|
|
else { |
3436
|
0
|
|
|
|
|
0
|
$B = 1; |
3437
|
|
|
|
|
|
|
} |
3438
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3439
|
0
|
|
|
|
|
0
|
close $fh; |
3440
|
|
|
|
|
|
|
} |
3441
|
|
|
|
|
|
|
|
3442
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($B,@_) : $B; |
3443
|
|
|
|
|
|
|
} |
3444
|
|
|
|
|
|
|
|
3445
|
|
|
|
|
|
|
# |
3446
|
|
|
|
|
|
|
# ShiftJIS file test -M expr |
3447
|
|
|
|
|
|
|
# |
3448
|
|
|
|
|
|
|
sub Esjis::M(;*@) { |
3449
|
|
|
|
|
|
|
|
3450
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3451
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -M (Esjis::M)' if @_ and not wantarray; |
3452
|
|
|
|
|
|
|
|
3453
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3454
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3455
|
|
|
|
|
|
|
} |
3456
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3457
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M $fh,@_) : -M $fh; |
3458
|
|
|
|
|
|
|
} |
3459
|
|
|
|
|
|
|
elsif (-e $_) { |
3460
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3461
|
|
|
|
|
|
|
} |
3462
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3463
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3464
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3465
|
|
|
|
|
|
|
} |
3466
|
|
|
|
|
|
|
else { |
3467
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3468
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3469
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3470
|
0
|
|
|
|
|
0
|
close $fh; |
3471
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
3472
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($M,@_) : $M; |
3473
|
|
|
|
|
|
|
} |
3474
|
|
|
|
|
|
|
} |
3475
|
|
|
|
|
|
|
} |
3476
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3477
|
|
|
|
|
|
|
} |
3478
|
|
|
|
|
|
|
|
3479
|
|
|
|
|
|
|
# |
3480
|
|
|
|
|
|
|
# ShiftJIS file test -A expr |
3481
|
|
|
|
|
|
|
# |
3482
|
|
|
|
|
|
|
sub Esjis::A(;*@) { |
3483
|
|
|
|
|
|
|
|
3484
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3485
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -A (Esjis::A)' if @_ and not wantarray; |
3486
|
|
|
|
|
|
|
|
3487
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3488
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3489
|
|
|
|
|
|
|
} |
3490
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3491
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A $fh,@_) : -A $fh; |
3492
|
|
|
|
|
|
|
} |
3493
|
|
|
|
|
|
|
elsif (-e $_) { |
3494
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3495
|
|
|
|
|
|
|
} |
3496
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3497
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3498
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3499
|
|
|
|
|
|
|
} |
3500
|
|
|
|
|
|
|
else { |
3501
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3502
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3503
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3504
|
0
|
|
|
|
|
0
|
close $fh; |
3505
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
3506
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($A,@_) : $A; |
3507
|
|
|
|
|
|
|
} |
3508
|
|
|
|
|
|
|
} |
3509
|
|
|
|
|
|
|
} |
3510
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3511
|
|
|
|
|
|
|
} |
3512
|
|
|
|
|
|
|
|
3513
|
|
|
|
|
|
|
# |
3514
|
|
|
|
|
|
|
# ShiftJIS file test -C expr |
3515
|
|
|
|
|
|
|
# |
3516
|
|
|
|
|
|
|
sub Esjis::C(;*@) { |
3517
|
|
|
|
|
|
|
|
3518
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3519
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -C (Esjis::C)' if @_ and not wantarray; |
3520
|
|
|
|
|
|
|
|
3521
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3522
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3523
|
|
|
|
|
|
|
} |
3524
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3525
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C $fh,@_) : -C $fh; |
3526
|
|
|
|
|
|
|
} |
3527
|
|
|
|
|
|
|
elsif (-e $_) { |
3528
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3529
|
|
|
|
|
|
|
} |
3530
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3531
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3532
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3533
|
|
|
|
|
|
|
} |
3534
|
|
|
|
|
|
|
else { |
3535
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3536
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3537
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3538
|
0
|
|
|
|
|
0
|
close $fh; |
3539
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
3540
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($C,@_) : $C; |
3541
|
|
|
|
|
|
|
} |
3542
|
|
|
|
|
|
|
} |
3543
|
|
|
|
|
|
|
} |
3544
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3545
|
|
|
|
|
|
|
} |
3546
|
|
|
|
|
|
|
|
3547
|
|
|
|
|
|
|
# |
3548
|
|
|
|
|
|
|
# ShiftJIS stacked file test $_ |
3549
|
|
|
|
|
|
|
# |
3550
|
|
|
|
|
|
|
sub Esjis::filetest_ { |
3551
|
|
|
|
|
|
|
|
3552
|
0
|
|
|
0
|
0
|
0
|
my $filetest = substr(pop @_, 1); |
3553
|
|
|
|
|
|
|
|
3554
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Esjis::${filetest}_}) { |
3555
|
0
|
|
|
|
|
0
|
return ''; |
3556
|
|
|
|
|
|
|
} |
3557
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
3558
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
3559
|
0
|
|
|
|
|
0
|
return ''; |
3560
|
|
|
|
|
|
|
} |
3561
|
|
|
|
|
|
|
} |
3562
|
0
|
|
|
|
|
0
|
return 1; |
3563
|
|
|
|
|
|
|
} |
3564
|
|
|
|
|
|
|
|
3565
|
|
|
|
|
|
|
# |
3566
|
|
|
|
|
|
|
# ShiftJIS file test -r $_ |
3567
|
|
|
|
|
|
|
# |
3568
|
|
|
|
|
|
|
sub Esjis::r_() { |
3569
|
|
|
|
|
|
|
|
3570
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3571
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3572
|
|
|
|
|
|
|
} |
3573
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3574
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3575
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3576
|
|
|
|
|
|
|
} |
3577
|
|
|
|
|
|
|
else { |
3578
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3579
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3580
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
3581
|
0
|
|
|
|
|
0
|
close $fh; |
3582
|
0
|
0
|
|
|
|
0
|
return $r ? 1 : ''; |
3583
|
|
|
|
|
|
|
} |
3584
|
|
|
|
|
|
|
} |
3585
|
|
|
|
|
|
|
} |
3586
|
|
|
|
|
|
|
|
3587
|
|
|
|
|
|
|
# 10.10. Returning Failure |
3588
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
3589
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
3590
|
|
|
|
|
|
|
# (and so on) |
3591
|
|
|
|
|
|
|
|
3592
|
|
|
|
|
|
|
# 2010-01-26 The difference of "return;" and "return undef;" |
3593
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20100126/1264474754 |
3594
|
|
|
|
|
|
|
# |
3595
|
|
|
|
|
|
|
# "Perl Best Practices" recommends to use "return;"*1 to return nothing, but |
3596
|
|
|
|
|
|
|
# it might be wrong in some cases. If you use this idiom for those functions |
3597
|
|
|
|
|
|
|
# which are expected to return a scalar value, e.g. searching functions, the |
3598
|
|
|
|
|
|
|
# user of those functions will be surprised at what they return in list |
3599
|
|
|
|
|
|
|
# context, an empty list - note that many functions and all the methods |
3600
|
|
|
|
|
|
|
# evaluate their arguments in list context. You'd better to use "return undef;" |
3601
|
|
|
|
|
|
|
# for such scalar functions. |
3602
|
|
|
|
|
|
|
# |
3603
|
|
|
|
|
|
|
# sub search_something { |
3604
|
|
|
|
|
|
|
# my($arg) = @_; |
3605
|
|
|
|
|
|
|
# # search_something... |
3606
|
|
|
|
|
|
|
# if(defined $found){ |
3607
|
|
|
|
|
|
|
# return $found; |
3608
|
|
|
|
|
|
|
# } |
3609
|
|
|
|
|
|
|
# return; # XXX: you'd better to "return undef;" |
3610
|
|
|
|
|
|
|
# } |
3611
|
|
|
|
|
|
|
# |
3612
|
|
|
|
|
|
|
# # ... |
3613
|
|
|
|
|
|
|
# |
3614
|
|
|
|
|
|
|
# # you'll get what you want, but ... |
3615
|
|
|
|
|
|
|
# my $something = search_something($source); |
3616
|
|
|
|
|
|
|
# |
3617
|
|
|
|
|
|
|
# # you won't get what you want here. |
3618
|
|
|
|
|
|
|
# # @_ for doit() is (-foo => $opt), not (undef, -foo => $opt). |
3619
|
|
|
|
|
|
|
# $obj->doit(search_something($source), -option=> $optval); |
3620
|
|
|
|
|
|
|
# |
3621
|
|
|
|
|
|
|
# # you have to use the "scalar" operator in such a case. |
3622
|
|
|
|
|
|
|
# $obj->doit(scalar search_something($source), ...); |
3623
|
|
|
|
|
|
|
# |
3624
|
|
|
|
|
|
|
# *1: it returns an empty list in list context, or returns undef in scalar |
3625
|
|
|
|
|
|
|
# context |
3626
|
|
|
|
|
|
|
# |
3627
|
|
|
|
|
|
|
# (and so on) |
3628
|
|
|
|
|
|
|
|
3629
|
0
|
|
|
|
|
0
|
return undef; |
3630
|
|
|
|
|
|
|
} |
3631
|
|
|
|
|
|
|
|
3632
|
|
|
|
|
|
|
# |
3633
|
|
|
|
|
|
|
# ShiftJIS file test -w $_ |
3634
|
|
|
|
|
|
|
# |
3635
|
|
|
|
|
|
|
sub Esjis::w_() { |
3636
|
|
|
|
|
|
|
|
3637
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3638
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3639
|
|
|
|
|
|
|
} |
3640
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3641
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3642
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3643
|
|
|
|
|
|
|
} |
3644
|
|
|
|
|
|
|
else { |
3645
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3646
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3647
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
3648
|
0
|
|
|
|
|
0
|
close $fh; |
3649
|
0
|
0
|
|
|
|
0
|
return $w ? 1 : ''; |
3650
|
|
|
|
|
|
|
} |
3651
|
|
|
|
|
|
|
} |
3652
|
|
|
|
|
|
|
} |
3653
|
0
|
|
|
|
|
0
|
return undef; |
3654
|
|
|
|
|
|
|
} |
3655
|
|
|
|
|
|
|
|
3656
|
|
|
|
|
|
|
# |
3657
|
|
|
|
|
|
|
# ShiftJIS file test -x $_ |
3658
|
|
|
|
|
|
|
# |
3659
|
|
|
|
|
|
|
sub Esjis::x_() { |
3660
|
|
|
|
|
|
|
|
3661
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3662
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3663
|
|
|
|
|
|
|
} |
3664
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3665
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3666
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3667
|
|
|
|
|
|
|
} |
3668
|
|
|
|
|
|
|
else { |
3669
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3670
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3671
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
3672
|
0
|
|
|
|
|
0
|
close $fh; |
3673
|
|
|
|
|
|
|
} |
3674
|
|
|
|
|
|
|
|
3675
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3676
|
0
|
|
|
|
|
0
|
return ''; |
3677
|
|
|
|
|
|
|
} |
3678
|
|
|
|
|
|
|
} |
3679
|
0
|
|
|
|
|
0
|
return undef; |
3680
|
|
|
|
|
|
|
} |
3681
|
|
|
|
|
|
|
|
3682
|
|
|
|
|
|
|
# |
3683
|
|
|
|
|
|
|
# ShiftJIS file test -o $_ |
3684
|
|
|
|
|
|
|
# |
3685
|
|
|
|
|
|
|
sub Esjis::o_() { |
3686
|
|
|
|
|
|
|
|
3687
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3688
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3689
|
|
|
|
|
|
|
} |
3690
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3691
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3692
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3693
|
|
|
|
|
|
|
} |
3694
|
|
|
|
|
|
|
else { |
3695
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3696
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3697
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
3698
|
0
|
|
|
|
|
0
|
close $fh; |
3699
|
0
|
0
|
|
|
|
0
|
return $o ? 1 : ''; |
3700
|
|
|
|
|
|
|
} |
3701
|
|
|
|
|
|
|
} |
3702
|
|
|
|
|
|
|
} |
3703
|
0
|
|
|
|
|
0
|
return undef; |
3704
|
|
|
|
|
|
|
} |
3705
|
|
|
|
|
|
|
|
3706
|
|
|
|
|
|
|
# |
3707
|
|
|
|
|
|
|
# ShiftJIS file test -R $_ |
3708
|
|
|
|
|
|
|
# |
3709
|
|
|
|
|
|
|
sub Esjis::R_() { |
3710
|
|
|
|
|
|
|
|
3711
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3712
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3713
|
|
|
|
|
|
|
} |
3714
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3715
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3716
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3717
|
|
|
|
|
|
|
} |
3718
|
|
|
|
|
|
|
else { |
3719
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3720
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3721
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
3722
|
0
|
|
|
|
|
0
|
close $fh; |
3723
|
0
|
0
|
|
|
|
0
|
return $R ? 1 : ''; |
3724
|
|
|
|
|
|
|
} |
3725
|
|
|
|
|
|
|
} |
3726
|
|
|
|
|
|
|
} |
3727
|
0
|
|
|
|
|
0
|
return undef; |
3728
|
|
|
|
|
|
|
} |
3729
|
|
|
|
|
|
|
|
3730
|
|
|
|
|
|
|
# |
3731
|
|
|
|
|
|
|
# ShiftJIS file test -W $_ |
3732
|
|
|
|
|
|
|
# |
3733
|
|
|
|
|
|
|
sub Esjis::W_() { |
3734
|
|
|
|
|
|
|
|
3735
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3736
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3737
|
|
|
|
|
|
|
} |
3738
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3739
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3740
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3741
|
|
|
|
|
|
|
} |
3742
|
|
|
|
|
|
|
else { |
3743
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3744
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3745
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
3746
|
0
|
|
|
|
|
0
|
close $fh; |
3747
|
0
|
0
|
|
|
|
0
|
return $W ? 1 : ''; |
3748
|
|
|
|
|
|
|
} |
3749
|
|
|
|
|
|
|
} |
3750
|
|
|
|
|
|
|
} |
3751
|
0
|
|
|
|
|
0
|
return undef; |
3752
|
|
|
|
|
|
|
} |
3753
|
|
|
|
|
|
|
|
3754
|
|
|
|
|
|
|
# |
3755
|
|
|
|
|
|
|
# ShiftJIS file test -X $_ |
3756
|
|
|
|
|
|
|
# |
3757
|
|
|
|
|
|
|
sub Esjis::X_() { |
3758
|
|
|
|
|
|
|
|
3759
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3760
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3761
|
|
|
|
|
|
|
} |
3762
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3763
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3764
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3765
|
|
|
|
|
|
|
} |
3766
|
|
|
|
|
|
|
else { |
3767
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3768
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3769
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
3770
|
0
|
|
|
|
|
0
|
close $fh; |
3771
|
|
|
|
|
|
|
} |
3772
|
|
|
|
|
|
|
|
3773
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3774
|
0
|
|
|
|
|
0
|
return ''; |
3775
|
|
|
|
|
|
|
} |
3776
|
|
|
|
|
|
|
} |
3777
|
0
|
|
|
|
|
0
|
return undef; |
3778
|
|
|
|
|
|
|
} |
3779
|
|
|
|
|
|
|
|
3780
|
|
|
|
|
|
|
# |
3781
|
|
|
|
|
|
|
# ShiftJIS file test -O $_ |
3782
|
|
|
|
|
|
|
# |
3783
|
|
|
|
|
|
|
sub Esjis::O_() { |
3784
|
|
|
|
|
|
|
|
3785
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3786
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3787
|
|
|
|
|
|
|
} |
3788
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3789
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3790
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3791
|
|
|
|
|
|
|
} |
3792
|
|
|
|
|
|
|
else { |
3793
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3794
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3795
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
3796
|
0
|
|
|
|
|
0
|
close $fh; |
3797
|
0
|
0
|
|
|
|
0
|
return $O ? 1 : ''; |
3798
|
|
|
|
|
|
|
} |
3799
|
|
|
|
|
|
|
} |
3800
|
|
|
|
|
|
|
} |
3801
|
0
|
|
|
|
|
0
|
return undef; |
3802
|
|
|
|
|
|
|
} |
3803
|
|
|
|
|
|
|
|
3804
|
|
|
|
|
|
|
# |
3805
|
|
|
|
|
|
|
# ShiftJIS file test -e $_ |
3806
|
|
|
|
|
|
|
# |
3807
|
|
|
|
|
|
|
sub Esjis::e_() { |
3808
|
|
|
|
|
|
|
|
3809
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3810
|
0
|
|
|
|
|
0
|
return 1; |
3811
|
|
|
|
|
|
|
} |
3812
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3813
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3814
|
0
|
|
|
|
|
0
|
return 1; |
3815
|
|
|
|
|
|
|
} |
3816
|
|
|
|
|
|
|
else { |
3817
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3818
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3819
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
3820
|
0
|
|
|
|
|
0
|
close $fh; |
3821
|
0
|
0
|
|
|
|
0
|
return $e ? 1 : ''; |
3822
|
|
|
|
|
|
|
} |
3823
|
|
|
|
|
|
|
} |
3824
|
|
|
|
|
|
|
} |
3825
|
0
|
|
|
|
|
0
|
return undef; |
3826
|
|
|
|
|
|
|
} |
3827
|
|
|
|
|
|
|
|
3828
|
|
|
|
|
|
|
# |
3829
|
|
|
|
|
|
|
# ShiftJIS file test -z $_ |
3830
|
|
|
|
|
|
|
# |
3831
|
|
|
|
|
|
|
sub Esjis::z_() { |
3832
|
|
|
|
|
|
|
|
3833
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3834
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3835
|
|
|
|
|
|
|
} |
3836
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3837
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3838
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3839
|
|
|
|
|
|
|
} |
3840
|
|
|
|
|
|
|
else { |
3841
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3842
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3843
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
3844
|
0
|
|
|
|
|
0
|
close $fh; |
3845
|
0
|
0
|
|
|
|
0
|
return $z ? 1 : ''; |
3846
|
|
|
|
|
|
|
} |
3847
|
|
|
|
|
|
|
} |
3848
|
|
|
|
|
|
|
} |
3849
|
0
|
|
|
|
|
0
|
return undef; |
3850
|
|
|
|
|
|
|
} |
3851
|
|
|
|
|
|
|
|
3852
|
|
|
|
|
|
|
# |
3853
|
|
|
|
|
|
|
# ShiftJIS file test -s $_ |
3854
|
|
|
|
|
|
|
# |
3855
|
|
|
|
|
|
|
sub Esjis::s_() { |
3856
|
|
|
|
|
|
|
|
3857
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3858
|
0
|
|
|
|
|
0
|
return -s _; |
3859
|
|
|
|
|
|
|
} |
3860
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3861
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3862
|
0
|
|
|
|
|
0
|
return -s _; |
3863
|
|
|
|
|
|
|
} |
3864
|
|
|
|
|
|
|
else { |
3865
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3866
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3867
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
3868
|
0
|
|
|
|
|
0
|
close $fh; |
3869
|
0
|
|
|
|
|
0
|
return $s; |
3870
|
|
|
|
|
|
|
} |
3871
|
|
|
|
|
|
|
} |
3872
|
|
|
|
|
|
|
} |
3873
|
0
|
|
|
|
|
0
|
return undef; |
3874
|
|
|
|
|
|
|
} |
3875
|
|
|
|
|
|
|
|
3876
|
|
|
|
|
|
|
# |
3877
|
|
|
|
|
|
|
# ShiftJIS file test -f $_ |
3878
|
|
|
|
|
|
|
# |
3879
|
|
|
|
|
|
|
sub Esjis::f_() { |
3880
|
|
|
|
|
|
|
|
3881
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3882
|
0
|
0
|
|
|
|
0
|
return -f _ ? 1 : ''; |
3883
|
|
|
|
|
|
|
} |
3884
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3885
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3886
|
0
|
|
|
|
|
0
|
return ''; |
3887
|
|
|
|
|
|
|
} |
3888
|
|
|
|
|
|
|
else { |
3889
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3890
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3891
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3892
|
0
|
|
|
|
|
0
|
close $fh; |
3893
|
0
|
0
|
|
|
|
0
|
return $f ? 1 : ''; |
3894
|
|
|
|
|
|
|
} |
3895
|
|
|
|
|
|
|
} |
3896
|
|
|
|
|
|
|
} |
3897
|
0
|
|
|
|
|
0
|
return undef; |
3898
|
|
|
|
|
|
|
} |
3899
|
|
|
|
|
|
|
|
3900
|
|
|
|
|
|
|
# |
3901
|
|
|
|
|
|
|
# ShiftJIS file test -d $_ |
3902
|
|
|
|
|
|
|
# |
3903
|
|
|
|
|
|
|
sub Esjis::d_() { |
3904
|
|
|
|
|
|
|
|
3905
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3906
|
0
|
0
|
|
|
|
0
|
return -d _ ? 1 : ''; |
3907
|
|
|
|
|
|
|
} |
3908
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3909
|
0
|
0
|
|
|
|
0
|
return -d "$_/." ? 1 : ''; |
3910
|
|
|
|
|
|
|
} |
3911
|
0
|
|
|
|
|
0
|
return undef; |
3912
|
|
|
|
|
|
|
} |
3913
|
|
|
|
|
|
|
|
3914
|
|
|
|
|
|
|
# |
3915
|
|
|
|
|
|
|
# ShiftJIS file test -l $_ |
3916
|
|
|
|
|
|
|
# |
3917
|
|
|
|
|
|
|
sub Esjis::l_() { |
3918
|
|
|
|
|
|
|
|
3919
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3920
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3921
|
|
|
|
|
|
|
} |
3922
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3923
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3924
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3925
|
|
|
|
|
|
|
} |
3926
|
|
|
|
|
|
|
else { |
3927
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3928
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3929
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3930
|
0
|
|
|
|
|
0
|
close $fh; |
3931
|
0
|
0
|
|
|
|
0
|
return $l ? 1 : ''; |
3932
|
|
|
|
|
|
|
} |
3933
|
|
|
|
|
|
|
} |
3934
|
|
|
|
|
|
|
} |
3935
|
0
|
|
|
|
|
0
|
return undef; |
3936
|
|
|
|
|
|
|
} |
3937
|
|
|
|
|
|
|
|
3938
|
|
|
|
|
|
|
# |
3939
|
|
|
|
|
|
|
# ShiftJIS file test -p $_ |
3940
|
|
|
|
|
|
|
# |
3941
|
|
|
|
|
|
|
sub Esjis::p_() { |
3942
|
|
|
|
|
|
|
|
3943
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3944
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3945
|
|
|
|
|
|
|
} |
3946
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3947
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3948
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3949
|
|
|
|
|
|
|
} |
3950
|
|
|
|
|
|
|
else { |
3951
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3952
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3953
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3954
|
0
|
|
|
|
|
0
|
close $fh; |
3955
|
0
|
0
|
|
|
|
0
|
return $p ? 1 : ''; |
3956
|
|
|
|
|
|
|
} |
3957
|
|
|
|
|
|
|
} |
3958
|
|
|
|
|
|
|
} |
3959
|
0
|
|
|
|
|
0
|
return undef; |
3960
|
|
|
|
|
|
|
} |
3961
|
|
|
|
|
|
|
|
3962
|
|
|
|
|
|
|
# |
3963
|
|
|
|
|
|
|
# ShiftJIS file test -S $_ |
3964
|
|
|
|
|
|
|
# |
3965
|
|
|
|
|
|
|
sub Esjis::S_() { |
3966
|
|
|
|
|
|
|
|
3967
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3968
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3969
|
|
|
|
|
|
|
} |
3970
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3971
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3972
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3973
|
|
|
|
|
|
|
} |
3974
|
|
|
|
|
|
|
else { |
3975
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3976
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3977
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3978
|
0
|
|
|
|
|
0
|
close $fh; |
3979
|
0
|
0
|
|
|
|
0
|
return $S ? 1 : ''; |
3980
|
|
|
|
|
|
|
} |
3981
|
|
|
|
|
|
|
} |
3982
|
|
|
|
|
|
|
} |
3983
|
0
|
|
|
|
|
0
|
return undef; |
3984
|
|
|
|
|
|
|
} |
3985
|
|
|
|
|
|
|
|
3986
|
|
|
|
|
|
|
# |
3987
|
|
|
|
|
|
|
# ShiftJIS file test -b $_ |
3988
|
|
|
|
|
|
|
# |
3989
|
|
|
|
|
|
|
sub Esjis::b_() { |
3990
|
|
|
|
|
|
|
|
3991
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3992
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
3993
|
|
|
|
|
|
|
} |
3994
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3995
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3996
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
3997
|
|
|
|
|
|
|
} |
3998
|
|
|
|
|
|
|
else { |
3999
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4000
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4001
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
4002
|
0
|
|
|
|
|
0
|
close $fh; |
4003
|
0
|
0
|
|
|
|
0
|
return $b ? 1 : ''; |
4004
|
|
|
|
|
|
|
} |
4005
|
|
|
|
|
|
|
} |
4006
|
|
|
|
|
|
|
} |
4007
|
0
|
|
|
|
|
0
|
return undef; |
4008
|
|
|
|
|
|
|
} |
4009
|
|
|
|
|
|
|
|
4010
|
|
|
|
|
|
|
# |
4011
|
|
|
|
|
|
|
# ShiftJIS file test -c $_ |
4012
|
|
|
|
|
|
|
# |
4013
|
|
|
|
|
|
|
sub Esjis::c_() { |
4014
|
|
|
|
|
|
|
|
4015
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4016
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4017
|
|
|
|
|
|
|
} |
4018
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4019
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4020
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4021
|
|
|
|
|
|
|
} |
4022
|
|
|
|
|
|
|
else { |
4023
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4024
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4025
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
4026
|
0
|
|
|
|
|
0
|
close $fh; |
4027
|
0
|
0
|
|
|
|
0
|
return $c ? 1 : ''; |
4028
|
|
|
|
|
|
|
} |
4029
|
|
|
|
|
|
|
} |
4030
|
|
|
|
|
|
|
} |
4031
|
0
|
|
|
|
|
0
|
return undef; |
4032
|
|
|
|
|
|
|
} |
4033
|
|
|
|
|
|
|
|
4034
|
|
|
|
|
|
|
# |
4035
|
|
|
|
|
|
|
# ShiftJIS file test -u $_ |
4036
|
|
|
|
|
|
|
# |
4037
|
|
|
|
|
|
|
sub Esjis::u_() { |
4038
|
|
|
|
|
|
|
|
4039
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4040
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4041
|
|
|
|
|
|
|
} |
4042
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4043
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4044
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4045
|
|
|
|
|
|
|
} |
4046
|
|
|
|
|
|
|
else { |
4047
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4048
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4049
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
4050
|
0
|
|
|
|
|
0
|
close $fh; |
4051
|
0
|
0
|
|
|
|
0
|
return $u ? 1 : ''; |
4052
|
|
|
|
|
|
|
} |
4053
|
|
|
|
|
|
|
} |
4054
|
|
|
|
|
|
|
} |
4055
|
0
|
|
|
|
|
0
|
return undef; |
4056
|
|
|
|
|
|
|
} |
4057
|
|
|
|
|
|
|
|
4058
|
|
|
|
|
|
|
# |
4059
|
|
|
|
|
|
|
# ShiftJIS file test -g $_ |
4060
|
|
|
|
|
|
|
# |
4061
|
|
|
|
|
|
|
sub Esjis::g_() { |
4062
|
|
|
|
|
|
|
|
4063
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4064
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4065
|
|
|
|
|
|
|
} |
4066
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4067
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4068
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4069
|
|
|
|
|
|
|
} |
4070
|
|
|
|
|
|
|
else { |
4071
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4072
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4073
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
4074
|
0
|
|
|
|
|
0
|
close $fh; |
4075
|
0
|
0
|
|
|
|
0
|
return $g ? 1 : ''; |
4076
|
|
|
|
|
|
|
} |
4077
|
|
|
|
|
|
|
} |
4078
|
|
|
|
|
|
|
} |
4079
|
0
|
|
|
|
|
0
|
return undef; |
4080
|
|
|
|
|
|
|
} |
4081
|
|
|
|
|
|
|
|
4082
|
|
|
|
|
|
|
# |
4083
|
|
|
|
|
|
|
# ShiftJIS file test -k $_ |
4084
|
|
|
|
|
|
|
# |
4085
|
|
|
|
|
|
|
sub Esjis::k_() { |
4086
|
|
|
|
|
|
|
|
4087
|
0
|
0
|
|
0
|
0
|
0
|
if ($] =~ /^5\.008/oxms) { |
4088
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
4089
|
|
|
|
|
|
|
} |
4090
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
4091
|
|
|
|
|
|
|
} |
4092
|
|
|
|
|
|
|
|
4093
|
|
|
|
|
|
|
# |
4094
|
|
|
|
|
|
|
# ShiftJIS file test -T $_ |
4095
|
|
|
|
|
|
|
# |
4096
|
|
|
|
|
|
|
sub Esjis::T_() { |
4097
|
|
|
|
|
|
|
|
4098
|
0
|
|
|
0
|
0
|
0
|
my $T = 1; |
4099
|
|
|
|
|
|
|
|
4100
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4101
|
0
|
|
|
|
|
0
|
return undef; |
4102
|
|
|
|
|
|
|
} |
4103
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4104
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4105
|
|
|
|
|
|
|
} |
4106
|
|
|
|
|
|
|
else { |
4107
|
0
|
|
|
|
|
0
|
return undef; |
4108
|
|
|
|
|
|
|
} |
4109
|
|
|
|
|
|
|
|
4110
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4111
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4112
|
0
|
|
|
|
|
0
|
$T = ''; |
4113
|
|
|
|
|
|
|
} |
4114
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4115
|
0
|
|
|
|
|
0
|
$T = ''; |
4116
|
|
|
|
|
|
|
} |
4117
|
|
|
|
|
|
|
} |
4118
|
|
|
|
|
|
|
|
4119
|
|
|
|
|
|
|
# 0 byte or eof |
4120
|
|
|
|
|
|
|
else { |
4121
|
0
|
|
|
|
|
0
|
$T = 1; |
4122
|
|
|
|
|
|
|
} |
4123
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
4124
|
0
|
|
|
|
|
0
|
close $fh; |
4125
|
|
|
|
|
|
|
|
4126
|
0
|
|
|
|
|
0
|
return $T; |
4127
|
|
|
|
|
|
|
} |
4128
|
|
|
|
|
|
|
|
4129
|
|
|
|
|
|
|
# |
4130
|
|
|
|
|
|
|
# ShiftJIS file test -B $_ |
4131
|
|
|
|
|
|
|
# |
4132
|
|
|
|
|
|
|
sub Esjis::B_() { |
4133
|
|
|
|
|
|
|
|
4134
|
0
|
|
|
0
|
0
|
0
|
my $B = ''; |
4135
|
|
|
|
|
|
|
|
4136
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4137
|
0
|
|
|
|
|
0
|
return undef; |
4138
|
|
|
|
|
|
|
} |
4139
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4140
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4141
|
|
|
|
|
|
|
} |
4142
|
|
|
|
|
|
|
else { |
4143
|
0
|
|
|
|
|
0
|
return undef; |
4144
|
|
|
|
|
|
|
} |
4145
|
|
|
|
|
|
|
|
4146
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4147
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4148
|
0
|
|
|
|
|
0
|
$B = 1; |
4149
|
|
|
|
|
|
|
} |
4150
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4151
|
0
|
|
|
|
|
0
|
$B = 1; |
4152
|
|
|
|
|
|
|
} |
4153
|
|
|
|
|
|
|
} |
4154
|
|
|
|
|
|
|
|
4155
|
|
|
|
|
|
|
# 0 byte or eof |
4156
|
|
|
|
|
|
|
else { |
4157
|
0
|
|
|
|
|
0
|
$B = 1; |
4158
|
|
|
|
|
|
|
} |
4159
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
4160
|
0
|
|
|
|
|
0
|
close $fh; |
4161
|
|
|
|
|
|
|
|
4162
|
0
|
|
|
|
|
0
|
return $B; |
4163
|
|
|
|
|
|
|
} |
4164
|
|
|
|
|
|
|
|
4165
|
|
|
|
|
|
|
# |
4166
|
|
|
|
|
|
|
# ShiftJIS file test -M $_ |
4167
|
|
|
|
|
|
|
# |
4168
|
|
|
|
|
|
|
sub Esjis::M_() { |
4169
|
|
|
|
|
|
|
|
4170
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4171
|
0
|
|
|
|
|
0
|
return -M _; |
4172
|
|
|
|
|
|
|
} |
4173
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4174
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4175
|
0
|
|
|
|
|
0
|
return -M _; |
4176
|
|
|
|
|
|
|
} |
4177
|
|
|
|
|
|
|
else { |
4178
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4179
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4180
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4181
|
0
|
|
|
|
|
0
|
close $fh; |
4182
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
4183
|
0
|
|
|
|
|
0
|
return $M; |
4184
|
|
|
|
|
|
|
} |
4185
|
|
|
|
|
|
|
} |
4186
|
|
|
|
|
|
|
} |
4187
|
0
|
|
|
|
|
0
|
return undef; |
4188
|
|
|
|
|
|
|
} |
4189
|
|
|
|
|
|
|
|
4190
|
|
|
|
|
|
|
# |
4191
|
|
|
|
|
|
|
# ShiftJIS file test -A $_ |
4192
|
|
|
|
|
|
|
# |
4193
|
|
|
|
|
|
|
sub Esjis::A_() { |
4194
|
|
|
|
|
|
|
|
4195
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4196
|
0
|
|
|
|
|
0
|
return -A _; |
4197
|
|
|
|
|
|
|
} |
4198
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4199
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4200
|
0
|
|
|
|
|
0
|
return -A _; |
4201
|
|
|
|
|
|
|
} |
4202
|
|
|
|
|
|
|
else { |
4203
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4204
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4205
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4206
|
0
|
|
|
|
|
0
|
close $fh; |
4207
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
4208
|
0
|
|
|
|
|
0
|
return $A; |
4209
|
|
|
|
|
|
|
} |
4210
|
|
|
|
|
|
|
} |
4211
|
|
|
|
|
|
|
} |
4212
|
0
|
|
|
|
|
0
|
return undef; |
4213
|
|
|
|
|
|
|
} |
4214
|
|
|
|
|
|
|
|
4215
|
|
|
|
|
|
|
# |
4216
|
|
|
|
|
|
|
# ShiftJIS file test -C $_ |
4217
|
|
|
|
|
|
|
# |
4218
|
|
|
|
|
|
|
sub Esjis::C_() { |
4219
|
|
|
|
|
|
|
|
4220
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4221
|
0
|
|
|
|
|
0
|
return -C _; |
4222
|
|
|
|
|
|
|
} |
4223
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4224
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4225
|
0
|
|
|
|
|
0
|
return -C _; |
4226
|
|
|
|
|
|
|
} |
4227
|
|
|
|
|
|
|
else { |
4228
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4229
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4230
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4231
|
0
|
|
|
|
|
0
|
close $fh; |
4232
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
4233
|
0
|
|
|
|
|
0
|
return $C; |
4234
|
|
|
|
|
|
|
} |
4235
|
|
|
|
|
|
|
} |
4236
|
|
|
|
|
|
|
} |
4237
|
0
|
|
|
|
|
0
|
return undef; |
4238
|
|
|
|
|
|
|
} |
4239
|
|
|
|
|
|
|
|
4240
|
|
|
|
|
|
|
# |
4241
|
|
|
|
|
|
|
# ShiftJIS path globbing (with parameter) |
4242
|
|
|
|
|
|
|
# |
4243
|
|
|
|
|
|
|
sub Esjis::glob($) { |
4244
|
|
|
|
|
|
|
|
4245
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4246
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(@_); |
4247
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4248
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4249
|
|
|
|
|
|
|
} |
4250
|
0
|
|
|
|
|
0
|
return @glob; |
4251
|
|
|
|
|
|
|
} |
4252
|
|
|
|
|
|
|
else { |
4253
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(@_); |
4254
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4255
|
0
|
|
|
|
|
0
|
return $glob; |
4256
|
|
|
|
|
|
|
} |
4257
|
|
|
|
|
|
|
} |
4258
|
|
|
|
|
|
|
|
4259
|
|
|
|
|
|
|
# |
4260
|
|
|
|
|
|
|
# ShiftJIS path globbing (without parameter) |
4261
|
|
|
|
|
|
|
# |
4262
|
|
|
|
|
|
|
sub Esjis::glob_() { |
4263
|
|
|
|
|
|
|
|
4264
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4265
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(); |
4266
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4267
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4268
|
|
|
|
|
|
|
} |
4269
|
0
|
|
|
|
|
0
|
return @glob; |
4270
|
|
|
|
|
|
|
} |
4271
|
|
|
|
|
|
|
else { |
4272
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(); |
4273
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4274
|
0
|
|
|
|
|
0
|
return $glob; |
4275
|
|
|
|
|
|
|
} |
4276
|
|
|
|
|
|
|
} |
4277
|
|
|
|
|
|
|
|
4278
|
|
|
|
|
|
|
# |
4279
|
|
|
|
|
|
|
# ShiftJIS path globbing via File::DosGlob 1.10 |
4280
|
|
|
|
|
|
|
# |
4281
|
|
|
|
|
|
|
# Often I confuse "_dosglob" and "_doglob". |
4282
|
|
|
|
|
|
|
# So, I renamed "_dosglob" to "_DOS_like_glob". |
4283
|
|
|
|
|
|
|
# |
4284
|
|
|
|
|
|
|
my %iter; |
4285
|
|
|
|
|
|
|
my %entries; |
4286
|
|
|
|
|
|
|
sub _DOS_like_glob { |
4287
|
|
|
|
|
|
|
|
4288
|
|
|
|
|
|
|
# context (keyed by second cxix argument provided by core) |
4289
|
0
|
|
|
0
|
|
0
|
my($expr,$cxix) = @_; |
4290
|
|
|
|
|
|
|
|
4291
|
|
|
|
|
|
|
# glob without args defaults to $_ |
4292
|
0
|
0
|
|
|
|
0
|
$expr = $_ if not defined $expr; |
4293
|
|
|
|
|
|
|
|
4294
|
|
|
|
|
|
|
# represents the current user's home directory |
4295
|
|
|
|
|
|
|
# |
4296
|
|
|
|
|
|
|
# 7.3. Expanding Tildes in Filenames |
4297
|
|
|
|
|
|
|
# in Chapter 7. File Access |
4298
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4299
|
|
|
|
|
|
|
# |
4300
|
|
|
|
|
|
|
# and File::HomeDir, File::HomeDir::Windows module |
4301
|
|
|
|
|
|
|
|
4302
|
|
|
|
|
|
|
# DOS-like system |
4303
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
|
|
0
|
|
|
|
|
|
4304
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ (?= [^/\\] ) } |
|
0
|
|
|
|
|
0
|
|
4305
|
|
|
|
|
|
|
{ my_home_MSWin32() }oxmse; |
4306
|
|
|
|
|
|
|
} |
4307
|
|
|
|
|
|
|
|
4308
|
|
|
|
|
|
|
# Mac OS system |
4309
|
0
|
0
|
|
|
|
0
|
elsif ($^O eq 'MacOS') { |
4310
|
0
|
|
|
|
|
0
|
if ($expr =~ / \A ~ /oxms) { |
|
0
|
|
|
|
|
0
|
|
4311
|
|
|
|
|
|
|
$expr =~ s{ \A ~ (?= [^/:] ) } |
4312
|
|
|
|
|
|
|
{ my_home_MacOS() }oxmse; |
4313
|
|
|
|
|
|
|
} |
4314
|
|
|
|
|
|
|
} |
4315
|
|
|
|
|
|
|
|
4316
|
0
|
0
|
0
|
|
|
0
|
# UNIX-like system |
|
0
|
|
|
|
|
0
|
|
4317
|
|
|
|
|
|
|
else { |
4318
|
|
|
|
|
|
|
$expr =~ s{ \A ~ ( (?:[^\x81-\x9F\xE0-\xFC/]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])* ) } |
4319
|
|
|
|
|
|
|
{ $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse; |
4320
|
0
|
0
|
|
|
|
0
|
} |
4321
|
0
|
0
|
|
|
|
0
|
|
4322
|
|
|
|
|
|
|
# assume global context if not provided one |
4323
|
|
|
|
|
|
|
$cxix = '_G_' if not defined $cxix; |
4324
|
0
|
0
|
|
|
|
0
|
$iter{$cxix} = 0 if not exists $iter{$cxix}; |
4325
|
0
|
0
|
|
|
|
0
|
|
4326
|
|
|
|
|
|
|
# if we're just beginning, do it all first |
4327
|
|
|
|
|
|
|
if ($iter{$cxix} == 0) { |
4328
|
0
|
|
|
|
|
0
|
if ($^O eq 'MacOS') { |
4329
|
|
|
|
|
|
|
|
4330
|
|
|
|
|
|
|
# first, take care of updirs and trailing colons |
4331
|
0
|
|
|
|
|
0
|
my @expr = _canonpath_MacOS(_parse_line($expr)); |
4332
|
|
|
|
|
|
|
|
4333
|
0
|
0
|
|
|
|
0
|
# expand volume names |
|
0
|
|
|
|
|
0
|
|
4334
|
|
|
|
|
|
|
@expr = _expand_volume_MacOS(@expr); |
4335
|
|
|
|
|
|
|
|
4336
|
0
|
|
|
|
|
0
|
$entries{$cxix} = (@expr) ? [ map { _unescape_MacOS($_) } _do_glob_MacOS(1,@expr) ] : [()]; |
4337
|
|
|
|
|
|
|
} |
4338
|
|
|
|
|
|
|
else { |
4339
|
|
|
|
|
|
|
$entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ]; |
4340
|
|
|
|
|
|
|
} |
4341
|
0
|
0
|
|
|
|
0
|
} |
4342
|
0
|
|
|
|
|
0
|
|
4343
|
0
|
|
|
|
|
0
|
# chuck it all out, quick or slow |
|
0
|
|
|
|
|
0
|
|
4344
|
|
|
|
|
|
|
if (wantarray) { |
4345
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4346
|
0
|
0
|
|
|
|
0
|
return @{delete $entries{$cxix}}; |
|
0
|
|
|
|
|
0
|
|
4347
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4348
|
|
|
|
|
|
|
else { |
4349
|
|
|
|
|
|
|
if ($iter{$cxix} = scalar @{$entries{$cxix}}) { |
4350
|
|
|
|
|
|
|
return shift @{$entries{$cxix}}; |
4351
|
0
|
|
|
|
|
0
|
} |
4352
|
0
|
|
|
|
|
0
|
else { |
4353
|
0
|
|
|
|
|
0
|
# return undef for EOL |
4354
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4355
|
|
|
|
|
|
|
delete $entries{$cxix}; |
4356
|
|
|
|
|
|
|
return undef; |
4357
|
|
|
|
|
|
|
} |
4358
|
|
|
|
|
|
|
} |
4359
|
|
|
|
|
|
|
} |
4360
|
|
|
|
|
|
|
|
4361
|
|
|
|
|
|
|
# |
4362
|
|
|
|
|
|
|
# ShiftJIS path globbing subroutine |
4363
|
0
|
|
|
0
|
|
0
|
# |
4364
|
0
|
|
|
|
|
0
|
sub _do_glob { |
4365
|
0
|
|
|
|
|
0
|
|
4366
|
|
|
|
|
|
|
my($cond,@expr) = @_; |
4367
|
|
|
|
|
|
|
my @glob = (); |
4368
|
0
|
|
|
|
|
0
|
my $fix_drive_relative_paths = 0; |
4369
|
0
|
0
|
|
|
|
0
|
|
4370
|
0
|
0
|
|
|
|
0
|
OUTER: |
4371
|
|
|
|
|
|
|
for my $expr (@expr) { |
4372
|
0
|
|
|
|
|
0
|
next OUTER if not defined $expr; |
4373
|
0
|
|
|
|
|
0
|
next OUTER if $expr eq ''; |
4374
|
0
|
|
|
|
|
0
|
|
4375
|
0
|
|
|
|
|
0
|
my @matched = (); |
4376
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4377
|
|
|
|
|
|
|
my $head = '.'; |
4378
|
|
|
|
|
|
|
my $pathsep = '/'; |
4379
|
0
|
0
|
|
|
|
0
|
my $tail; |
4380
|
0
|
|
|
|
|
0
|
|
4381
|
0
|
0
|
|
|
|
0
|
# if argument is within quotes strip em and do no globbing |
4382
|
0
|
0
|
|
|
|
0
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4383
|
0
|
|
|
|
|
0
|
$expr = $1; |
4384
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4385
|
|
|
|
|
|
|
if (Esjis::d $expr) { |
4386
|
|
|
|
|
|
|
push @glob, $expr; |
4387
|
0
|
0
|
|
|
|
0
|
} |
4388
|
0
|
|
|
|
|
0
|
} |
4389
|
|
|
|
|
|
|
else { |
4390
|
|
|
|
|
|
|
if (Esjis::e $expr) { |
4391
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
4392
|
|
|
|
|
|
|
} |
4393
|
|
|
|
|
|
|
} |
4394
|
|
|
|
|
|
|
next OUTER; |
4395
|
|
|
|
|
|
|
} |
4396
|
0
|
0
|
|
|
|
0
|
|
4397
|
0
|
0
|
|
|
|
0
|
# wildcards with a drive prefix such as h:*.pm must be changed |
4398
|
0
|
|
|
|
|
0
|
# to h:./*.pm to expand correctly |
4399
|
|
|
|
|
|
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4400
|
|
|
|
|
|
|
if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^\x81-\x9F\xE0-\xFC/\\]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]) #$1./$2#oxms) { |
4401
|
|
|
|
|
|
|
$fix_drive_relative_paths = 1; |
4402
|
0
|
0
|
|
|
|
0
|
} |
4403
|
0
|
0
|
|
|
|
0
|
} |
4404
|
0
|
|
|
|
|
0
|
|
4405
|
0
|
|
|
|
|
0
|
if (($head, $tail) = _parse_path($expr,$pathsep)) { |
4406
|
|
|
|
|
|
|
if ($tail eq '') { |
4407
|
0
|
0
|
|
|
|
0
|
push @glob, $expr; |
4408
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4409
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4410
|
0
|
|
|
|
|
0
|
if ($head =~ / \A (?:$q_char)*? [*?] /oxms) { |
4411
|
|
|
|
|
|
|
if (@globdir = _do_glob('d', $head)) { |
4412
|
|
|
|
|
|
|
push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir); |
4413
|
0
|
0
|
0
|
|
|
0
|
next OUTER; |
4414
|
0
|
|
|
|
|
0
|
} |
4415
|
|
|
|
|
|
|
} |
4416
|
0
|
|
|
|
|
0
|
if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) { |
4417
|
|
|
|
|
|
|
$head .= $pathsep; |
4418
|
|
|
|
|
|
|
} |
4419
|
|
|
|
|
|
|
$expr = $tail; |
4420
|
0
|
0
|
|
|
|
0
|
} |
4421
|
0
|
0
|
|
|
|
0
|
|
4422
|
0
|
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4423
|
|
|
|
|
|
|
if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) { |
4424
|
0
|
0
|
0
|
|
|
0
|
if ($head eq '.') { |
4425
|
0
|
|
|
|
|
0
|
$head = ''; |
4426
|
|
|
|
|
|
|
} |
4427
|
0
|
|
|
|
|
0
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4428
|
0
|
0
|
|
|
|
0
|
$head .= $pathsep; |
4429
|
0
|
0
|
|
|
|
0
|
} |
4430
|
0
|
|
|
|
|
0
|
$head .= $expr; |
4431
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4432
|
|
|
|
|
|
|
if (Esjis::d $head) { |
4433
|
|
|
|
|
|
|
push @glob, $head; |
4434
|
0
|
0
|
|
|
|
0
|
} |
4435
|
0
|
|
|
|
|
0
|
} |
4436
|
|
|
|
|
|
|
else { |
4437
|
|
|
|
|
|
|
if (Esjis::e $head) { |
4438
|
0
|
|
|
|
|
0
|
push @glob, $head; |
4439
|
|
|
|
|
|
|
} |
4440
|
0
|
0
|
|
|
|
0
|
} |
4441
|
0
|
|
|
|
|
0
|
next OUTER; |
4442
|
0
|
|
|
|
|
0
|
} |
4443
|
|
|
|
|
|
|
Esjis::opendir(*DIR, $head) or next OUTER; |
4444
|
0
|
0
|
|
|
|
0
|
my @leaf = readdir DIR; |
4445
|
0
|
|
|
|
|
0
|
closedir DIR; |
4446
|
|
|
|
|
|
|
|
4447
|
0
|
0
|
0
|
|
|
0
|
if ($head eq '.') { |
4448
|
0
|
|
|
|
|
0
|
$head = ''; |
4449
|
|
|
|
|
|
|
} |
4450
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4451
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4452
|
0
|
|
|
|
|
0
|
} |
4453
|
0
|
|
|
|
|
0
|
|
4454
|
|
|
|
|
|
|
my $pattern = ''; |
4455
|
|
|
|
|
|
|
while ($expr =~ / \G ($q_char) /oxgc) { |
4456
|
|
|
|
|
|
|
my $char = $1; |
4457
|
|
|
|
|
|
|
|
4458
|
|
|
|
|
|
|
# 6.9. Matching Shell Globs as Regular Expressions |
4459
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
4460
|
0
|
0
|
|
|
|
0
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4461
|
0
|
|
|
|
|
0
|
# (and so on) |
4462
|
|
|
|
|
|
|
|
4463
|
|
|
|
|
|
|
if ($char eq '*') { |
4464
|
0
|
|
|
|
|
0
|
$pattern .= "(?:$your_char)*", |
4465
|
|
|
|
|
|
|
} |
4466
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4467
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)?", # DOS style |
4468
|
0
|
|
|
|
|
0
|
# $pattern .= "(?:$your_char)", # UNIX style |
4469
|
|
|
|
|
|
|
} |
4470
|
|
|
|
|
|
|
elsif ((my $fc = Esjis::fc($char)) ne $char) { |
4471
|
0
|
|
|
|
|
0
|
$pattern .= $fc; |
4472
|
|
|
|
|
|
|
} |
4473
|
|
|
|
|
|
|
else { |
4474
|
0
|
|
|
0
|
|
0
|
$pattern .= quotemeta $char; |
|
0
|
|
|
|
|
0
|
|
4475
|
|
|
|
|
|
|
} |
4476
|
|
|
|
|
|
|
} |
4477
|
|
|
|
|
|
|
my $matchsub = sub { Esjis::fc($_[0]) =~ /\A $pattern \z/xms }; |
4478
|
|
|
|
|
|
|
|
4479
|
|
|
|
|
|
|
# if ($@) { |
4480
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4481
|
|
|
|
|
|
|
# next OUTER; |
4482
|
0
|
|
|
|
|
0
|
# } |
4483
|
0
|
0
|
0
|
|
|
0
|
|
4484
|
0
|
|
|
|
|
0
|
INNER: |
4485
|
|
|
|
|
|
|
for my $leaf (@leaf) { |
4486
|
0
|
0
|
0
|
|
|
0
|
if ($leaf eq '.' or $leaf eq '..') { |
4487
|
0
|
|
|
|
|
0
|
next INNER; |
4488
|
|
|
|
|
|
|
} |
4489
|
|
|
|
|
|
|
if ($cond eq 'd' and not Esjis::d "$head$leaf") { |
4490
|
0
|
0
|
|
|
|
0
|
next INNER; |
4491
|
0
|
|
|
|
|
0
|
} |
4492
|
0
|
|
|
|
|
0
|
|
4493
|
|
|
|
|
|
|
if (&$matchsub($leaf)) { |
4494
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4495
|
|
|
|
|
|
|
next INNER; |
4496
|
|
|
|
|
|
|
} |
4497
|
|
|
|
|
|
|
|
4498
|
0
|
0
|
0
|
|
|
0
|
# [DOS compatibility special case] |
|
|
|
0
|
|
|
|
|
4499
|
|
|
|
|
|
|
# Failed, add a trailing dot and try again, but only... |
4500
|
|
|
|
|
|
|
|
4501
|
|
|
|
|
|
|
if (Esjis::index($leaf,'.') == -1 and # if name does not have a dot in it *and* |
4502
|
0
|
0
|
|
|
|
0
|
CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and* |
4503
|
0
|
|
|
|
|
0
|
Esjis::index($pattern,'\\.') != -1 # pattern has a dot. |
4504
|
0
|
|
|
|
|
0
|
) { |
4505
|
|
|
|
|
|
|
if (&$matchsub("$leaf.")) { |
4506
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4507
|
|
|
|
|
|
|
next INNER; |
4508
|
0
|
0
|
|
|
|
0
|
} |
4509
|
0
|
|
|
|
|
0
|
} |
4510
|
|
|
|
|
|
|
} |
4511
|
|
|
|
|
|
|
if (@matched) { |
4512
|
0
|
0
|
|
|
|
0
|
push @glob, @matched; |
4513
|
0
|
|
|
|
|
0
|
} |
4514
|
0
|
|
|
|
|
0
|
} |
4515
|
|
|
|
|
|
|
if ($fix_drive_relative_paths) { |
4516
|
|
|
|
|
|
|
for my $glob (@glob) { |
4517
|
0
|
|
|
|
|
0
|
$glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms; |
4518
|
|
|
|
|
|
|
} |
4519
|
|
|
|
|
|
|
} |
4520
|
|
|
|
|
|
|
return @glob; |
4521
|
|
|
|
|
|
|
} |
4522
|
|
|
|
|
|
|
|
4523
|
|
|
|
|
|
|
# |
4524
|
|
|
|
|
|
|
# ShiftJIS parse line |
4525
|
0
|
|
|
0
|
|
0
|
# |
4526
|
|
|
|
|
|
|
sub _parse_line { |
4527
|
0
|
|
|
|
|
0
|
|
4528
|
0
|
|
|
|
|
0
|
my($line) = @_; |
4529
|
0
|
|
|
|
|
0
|
|
4530
|
|
|
|
|
|
|
$line .= ' '; |
4531
|
|
|
|
|
|
|
my @piece = (); |
4532
|
|
|
|
|
|
|
while ($line =~ / |
4533
|
|
|
|
|
|
|
" ( (?>(?: [^\x81-\x9F\xE0-\xFC"] |[\x81-\x9F\xE0-\xFC][\x00-\xFF] )* ) ) " (?>\s+) | |
4534
|
0
|
0
|
|
|
|
0
|
( (?>(?: [^\x81-\x9F\xE0-\xFC"\s]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] )* ) ) (?>\s+) |
4535
|
|
|
|
|
|
|
/oxmsg |
4536
|
0
|
|
|
|
|
0
|
) { |
4537
|
|
|
|
|
|
|
push @piece, defined($1) ? $1 : $2; |
4538
|
|
|
|
|
|
|
} |
4539
|
|
|
|
|
|
|
return @piece; |
4540
|
|
|
|
|
|
|
} |
4541
|
|
|
|
|
|
|
|
4542
|
|
|
|
|
|
|
# |
4543
|
|
|
|
|
|
|
# ShiftJIS parse path |
4544
|
0
|
|
|
0
|
|
0
|
# |
4545
|
|
|
|
|
|
|
sub _parse_path { |
4546
|
0
|
|
|
|
|
0
|
|
4547
|
0
|
|
|
|
|
0
|
my($path,$pathsep) = @_; |
4548
|
0
|
|
|
|
|
0
|
|
4549
|
|
|
|
|
|
|
$path .= '/'; |
4550
|
|
|
|
|
|
|
my @subpath = (); |
4551
|
|
|
|
|
|
|
while ($path =~ / |
4552
|
0
|
|
|
|
|
0
|
((?: [^\x81-\x9F\xE0-\xFC\/\\]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] )+?) [\/\\] |
4553
|
|
|
|
|
|
|
/oxmsg |
4554
|
|
|
|
|
|
|
) { |
4555
|
0
|
|
|
|
|
0
|
push @subpath, $1; |
4556
|
0
|
|
|
|
|
0
|
} |
4557
|
0
|
|
|
|
|
0
|
|
4558
|
|
|
|
|
|
|
my $tail = pop @subpath; |
4559
|
|
|
|
|
|
|
my $head = join $pathsep, @subpath; |
4560
|
|
|
|
|
|
|
return $head, $tail; |
4561
|
|
|
|
|
|
|
} |
4562
|
|
|
|
|
|
|
|
4563
|
|
|
|
|
|
|
# |
4564
|
|
|
|
|
|
|
# ShiftJIS path globbing on Mac OS |
4565
|
0
|
|
|
0
|
|
0
|
# |
4566
|
0
|
|
|
|
|
0
|
sub _do_glob_MacOS { |
4567
|
|
|
|
|
|
|
|
4568
|
|
|
|
|
|
|
my($cond,@expr) = @_; |
4569
|
0
|
|
|
|
|
0
|
my @glob = (); |
4570
|
0
|
0
|
|
|
|
0
|
|
4571
|
0
|
0
|
|
|
|
0
|
OUTER_MACOS: |
4572
|
|
|
|
|
|
|
for my $expr (@expr) { |
4573
|
0
|
|
|
|
|
0
|
next OUTER_MACOS if not defined $expr; |
4574
|
0
|
|
|
|
|
0
|
next OUTER_MACOS if $expr eq ''; |
4575
|
0
|
|
|
|
|
0
|
|
4576
|
0
|
|
|
|
|
0
|
my @matched = (); |
4577
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4578
|
0
|
|
|
|
|
0
|
my $head = ':'; |
4579
|
|
|
|
|
|
|
my $unesc_head = $head; |
4580
|
|
|
|
|
|
|
my $pathsep = ':'; |
4581
|
0
|
0
|
|
|
|
0
|
my $tail; |
4582
|
0
|
|
|
|
|
0
|
|
4583
|
|
|
|
|
|
|
# if $expr is within quotes strip em and do no globbing |
4584
|
|
|
|
|
|
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4585
|
0
|
|
|
|
|
0
|
$expr = $1; |
4586
|
|
|
|
|
|
|
|
4587
|
0
|
0
|
|
|
|
0
|
# $expr may contain escaped metachars '\*', '\?', and '\' |
4588
|
0
|
0
|
|
|
|
0
|
$expr = _unescape_MacOS($expr); |
4589
|
0
|
|
|
|
|
0
|
|
4590
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4591
|
|
|
|
|
|
|
if (Esjis::d $expr) { |
4592
|
|
|
|
|
|
|
push @glob, $expr; |
4593
|
0
|
0
|
|
|
|
0
|
} |
4594
|
0
|
|
|
|
|
0
|
} |
4595
|
|
|
|
|
|
|
else { |
4596
|
|
|
|
|
|
|
if (Esjis::e $expr) { |
4597
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
4598
|
|
|
|
|
|
|
} |
4599
|
|
|
|
|
|
|
} |
4600
|
|
|
|
|
|
|
next OUTER_MACOS; |
4601
|
0
|
0
|
|
|
|
0
|
} |
4602
|
0
|
0
|
|
|
|
0
|
|
4603
|
0
|
|
|
|
|
0
|
# note: $1 is not greedy |
4604
|
0
|
|
|
|
|
0
|
if (($head,$pathsep,$tail) = $expr =~ /\A ((?:$q_char)*?) (:+) ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?) \z/oxms) { |
4605
|
|
|
|
|
|
|
if ($tail eq '') { |
4606
|
0
|
0
|
|
|
|
0
|
push @glob, $expr; |
4607
|
0
|
0
|
|
|
|
0
|
next OUTER_MACOS; |
4608
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4609
|
0
|
|
|
|
|
0
|
if (_hasmeta_MacOS($head)) { |
4610
|
|
|
|
|
|
|
if (@globdir = _do_glob_MacOS('d', $head)) { |
4611
|
|
|
|
|
|
|
push @glob, _do_glob_MacOS($cond, map {"$_$pathsep$tail"} @globdir); |
4612
|
0
|
|
|
|
|
0
|
next OUTER_MACOS; |
4613
|
|
|
|
|
|
|
} |
4614
|
|
|
|
|
|
|
} |
4615
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4616
|
|
|
|
|
|
|
|
4617
|
0
|
|
|
|
|
0
|
# unescape $head for file operations |
4618
|
|
|
|
|
|
|
$unesc_head = _unescape_MacOS($head); |
4619
|
|
|
|
|
|
|
|
4620
|
|
|
|
|
|
|
$expr = $tail; |
4621
|
0
|
0
|
|
|
|
0
|
} |
4622
|
0
|
0
|
|
|
|
0
|
|
4623
|
0
|
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4624
|
|
|
|
|
|
|
if (not _hasmeta_MacOS($expr)) { |
4625
|
0
|
|
|
|
|
0
|
if ($head eq ':') { |
4626
|
|
|
|
|
|
|
$unesc_head = $head = ''; |
4627
|
|
|
|
|
|
|
} |
4628
|
0
|
|
|
|
|
0
|
$head .= $expr; |
4629
|
|
|
|
|
|
|
|
4630
|
0
|
0
|
|
|
|
0
|
# unescape $head and $expr for file operations |
4631
|
0
|
0
|
|
|
|
0
|
$unesc_head .= _unescape_MacOS($expr); |
4632
|
0
|
|
|
|
|
0
|
|
4633
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4634
|
|
|
|
|
|
|
if (Esjis::d $unesc_head) { |
4635
|
|
|
|
|
|
|
push @glob, $head; |
4636
|
0
|
0
|
|
|
|
0
|
} |
4637
|
0
|
|
|
|
|
0
|
} |
4638
|
|
|
|
|
|
|
else { |
4639
|
|
|
|
|
|
|
if (Esjis::e $unesc_head) { |
4640
|
0
|
|
|
|
|
0
|
push @glob, $head; |
4641
|
|
|
|
|
|
|
} |
4642
|
0
|
0
|
|
|
|
0
|
} |
4643
|
0
|
|
|
|
|
0
|
next OUTER_MACOS; |
4644
|
0
|
|
|
|
|
0
|
} |
4645
|
|
|
|
|
|
|
Esjis::opendir(*DIR, $head) or next OUTER_MACOS; |
4646
|
0
|
|
|
|
|
0
|
my @leaf = readdir DIR; |
4647
|
0
|
|
|
0
|
|
0
|
closedir DIR; |
|
0
|
|
|
|
|
0
|
|
4648
|
|
|
|
|
|
|
|
4649
|
|
|
|
|
|
|
my $pattern = _quotemeta_MacOS($expr); |
4650
|
|
|
|
|
|
|
my $matchsub = sub { Esjis::fc($_[0]) =~ /\A $pattern \z/xms }; |
4651
|
|
|
|
|
|
|
|
4652
|
|
|
|
|
|
|
# if ($@) { |
4653
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4654
|
|
|
|
|
|
|
# next OUTER_MACOS; |
4655
|
0
|
|
|
|
|
0
|
# } |
4656
|
0
|
0
|
0
|
|
|
0
|
|
4657
|
0
|
|
|
|
|
0
|
INNER_MACOS: |
4658
|
|
|
|
|
|
|
for my $leaf (@leaf) { |
4659
|
0
|
0
|
0
|
|
|
0
|
if ($leaf eq '.' or $leaf eq '..') { |
4660
|
0
|
|
|
|
|
0
|
next INNER_MACOS; |
4661
|
|
|
|
|
|
|
} |
4662
|
|
|
|
|
|
|
if ($cond eq 'd' and not Esjis::d qq{$unesc_head$leaf}) { |
4663
|
0
|
0
|
|
|
|
0
|
next INNER_MACOS; |
4664
|
0
|
0
|
0
|
|
|
0
|
} |
4665
|
|
|
|
|
|
|
|
4666
|
|
|
|
|
|
|
if (&$matchsub($leaf)) { |
4667
|
0
|
|
|
|
|
0
|
if (($unesc_head eq ':') and (Esjis::f qq{$unesc_head$leaf})) { |
4668
|
|
|
|
|
|
|
} |
4669
|
|
|
|
|
|
|
else { |
4670
|
|
|
|
|
|
|
$leaf = $unesc_head . $leaf; |
4671
|
|
|
|
|
|
|
} |
4672
|
|
|
|
|
|
|
|
4673
|
0
|
|
|
|
|
0
|
# On Mac OS, the two glob metachars '*' and '?' and the escape |
4674
|
0
|
|
|
|
|
0
|
# char '\' are valid characters for file and directory names. |
4675
|
|
|
|
|
|
|
# We have to escape and treat them specially. |
4676
|
|
|
|
|
|
|
push @matched, _escape_MacOS($leaf); |
4677
|
0
|
0
|
|
|
|
0
|
next INNER_MACOS; |
4678
|
0
|
|
|
|
|
0
|
} |
4679
|
|
|
|
|
|
|
} |
4680
|
|
|
|
|
|
|
if (@matched) { |
4681
|
0
|
|
|
|
|
0
|
push @glob, @matched; |
4682
|
|
|
|
|
|
|
} |
4683
|
|
|
|
|
|
|
} |
4684
|
|
|
|
|
|
|
return @glob; |
4685
|
|
|
|
|
|
|
} |
4686
|
|
|
|
|
|
|
|
4687
|
|
|
|
|
|
|
# |
4688
|
|
|
|
|
|
|
# _expand_volume_MacOS() will only be used on Mac OS (OS9 or older): |
4689
|
|
|
|
|
|
|
# Takes an array of original patterns as argument and returns an array of |
4690
|
|
|
|
|
|
|
# possibly modified patterns. Each original pattern is processed like |
4691
|
|
|
|
|
|
|
# that: |
4692
|
|
|
|
|
|
|
# + If there's a volume name in the pattern, we push a separate pattern |
4693
|
|
|
|
|
|
|
# for each mounted volume that matches (with '*', '?', and '\' escaped). |
4694
|
|
|
|
|
|
|
# + If there's no volume name in the original pattern, it is pushed |
4695
|
|
|
|
|
|
|
# unchanged. |
4696
|
|
|
|
|
|
|
# Note that the returned array of patterns may be empty. |
4697
|
0
|
|
|
0
|
|
0
|
# |
4698
|
0
|
0
|
|
|
|
0
|
sub _expand_volume_MacOS { |
4699
|
|
|
|
|
|
|
|
4700
|
0
|
|
|
|
|
0
|
CORE::eval q{ CORE::require MacPerl; }; |
4701
|
0
|
|
|
|
|
0
|
croak "Can't require MacPerl;" if $@; |
4702
|
0
|
|
|
|
|
0
|
|
4703
|
|
|
|
|
|
|
my @volume_glob = @_; |
4704
|
|
|
|
|
|
|
my @expand_volume = (); |
4705
|
0
|
0
|
|
|
|
0
|
for my $volume_glob (@volume_glob) { |
4706
|
0
|
|
|
|
|
0
|
|
4707
|
0
|
|
|
|
|
0
|
# volume name in pattern |
4708
|
|
|
|
|
|
|
if ($volume_glob =~ /\A ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+:) (.*) \z/oxms) { |
4709
|
0
|
|
|
|
|
0
|
my $pattern = _quotemeta_MacOS($1); |
|
0
|
|
|
|
|
0
|
|
4710
|
0
|
0
|
|
|
|
0
|
my $tail = $2; |
4711
|
|
|
|
|
|
|
|
4712
|
|
|
|
|
|
|
for my $volume (map { MacPerl::MakePath($_) } MacPerl::Volumes()) { |
4713
|
|
|
|
|
|
|
if ($volume =~ /\A $pattern \z/xmsi) { |
4714
|
|
|
|
|
|
|
|
4715
|
0
|
|
|
|
|
0
|
# On Mac OS, the two glob metachars '*' and '?' and the |
4716
|
|
|
|
|
|
|
# escape char '\' are valid characters for volume names. |
4717
|
|
|
|
|
|
|
# We have to escape and treat them specially. |
4718
|
|
|
|
|
|
|
push @expand_volume, _escape_MacOS($volume) . $tail; |
4719
|
|
|
|
|
|
|
} |
4720
|
|
|
|
|
|
|
} |
4721
|
|
|
|
|
|
|
} |
4722
|
0
|
|
|
|
|
0
|
|
4723
|
|
|
|
|
|
|
# no volume name in pattern |
4724
|
|
|
|
|
|
|
else { |
4725
|
0
|
|
|
|
|
0
|
push @expand_volume, $volume_glob; |
4726
|
|
|
|
|
|
|
} |
4727
|
|
|
|
|
|
|
} |
4728
|
|
|
|
|
|
|
return @expand_volume; |
4729
|
|
|
|
|
|
|
} |
4730
|
|
|
|
|
|
|
|
4731
|
|
|
|
|
|
|
# |
4732
|
|
|
|
|
|
|
# _canonpath_MacOS() will only be used on Mac OS (OS9 or older): |
4733
|
|
|
|
|
|
|
# Resolves any updirs in the pattern. Removes a single trailing colon |
4734
|
0
|
|
|
0
|
|
0
|
# from the pattern, unless it's a volume name pattern like "*HD:" |
4735
|
|
|
|
|
|
|
# |
4736
|
0
|
|
|
|
|
0
|
sub _canonpath_MacOS { |
4737
|
|
|
|
|
|
|
my(@expr) = @_; |
4738
|
|
|
|
|
|
|
|
4739
|
0
|
|
|
|
|
0
|
for my $expr (@expr) { |
4740
|
|
|
|
|
|
|
|
4741
|
|
|
|
|
|
|
# resolve any updirs, e.g. "*HD:t?p::a*" -> "*HD:a*" |
4742
|
0
|
|
|
|
|
0
|
1 while ($expr =~ s/\A ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?) : (?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+ :: ((?:$q_char)*?) \z/$1:$2/oxms); |
4743
|
|
|
|
|
|
|
|
4744
|
0
|
|
|
|
|
0
|
# remove a single trailing colon, e.g. ":*:" -> ":*" |
4745
|
|
|
|
|
|
|
$expr =~ s/ : ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+) : \z/:$1/oxms; |
4746
|
|
|
|
|
|
|
} |
4747
|
|
|
|
|
|
|
return @expr; |
4748
|
|
|
|
|
|
|
} |
4749
|
|
|
|
|
|
|
|
4750
|
|
|
|
|
|
|
# |
4751
|
|
|
|
|
|
|
# _escape_MacOS() will only be used on Mac OS (OS9 or older): |
4752
|
0
|
|
|
0
|
|
0
|
# Escape metachars '*', '?', and '\' of arguments. |
4753
|
|
|
|
|
|
|
# |
4754
|
|
|
|
|
|
|
sub _escape_MacOS { |
4755
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4756
|
0
|
|
|
|
|
0
|
|
4757
|
0
|
|
|
|
|
0
|
# escape regex metachars but not '\' and glob chars '*', '?' |
4758
|
0
|
0
|
|
|
|
0
|
my $escape = ''; |
4759
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G ($q_char) /oxmsgc) { |
4760
|
|
|
|
|
|
|
my $char = $1; |
4761
|
|
|
|
|
|
|
if ($char =~ /\A [*?\\] \z/oxms) { |
4762
|
0
|
|
|
|
|
0
|
$escape .= '\\' . $char; |
4763
|
|
|
|
|
|
|
} |
4764
|
|
|
|
|
|
|
else { |
4765
|
0
|
|
|
|
|
0
|
$escape .= $char; |
4766
|
|
|
|
|
|
|
} |
4767
|
|
|
|
|
|
|
} |
4768
|
|
|
|
|
|
|
return $escape; |
4769
|
|
|
|
|
|
|
} |
4770
|
|
|
|
|
|
|
|
4771
|
|
|
|
|
|
|
# |
4772
|
|
|
|
|
|
|
# _unescape_MacOS() will only be used on Mac OS (OS9 or older): |
4773
|
|
|
|
|
|
|
# Unescapes a list of arguments which may contain escaped |
4774
|
0
|
|
|
0
|
|
0
|
# metachars '*', '?', and '\'. |
4775
|
|
|
|
|
|
|
# |
4776
|
0
|
|
|
|
|
0
|
sub _unescape_MacOS { |
4777
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4778
|
0
|
|
|
|
|
0
|
|
4779
|
0
|
0
|
|
|
|
0
|
my $unescape = ''; |
4780
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxmsgc) { |
4781
|
|
|
|
|
|
|
my $char = $1; |
4782
|
|
|
|
|
|
|
if ($char =~ /\A \\([*?\\]) \z/oxms) { |
4783
|
0
|
|
|
|
|
0
|
$unescape .= $1; |
4784
|
|
|
|
|
|
|
} |
4785
|
|
|
|
|
|
|
else { |
4786
|
0
|
|
|
|
|
0
|
$unescape .= $char; |
4787
|
|
|
|
|
|
|
} |
4788
|
|
|
|
|
|
|
} |
4789
|
|
|
|
|
|
|
return $unescape; |
4790
|
|
|
|
|
|
|
} |
4791
|
|
|
|
|
|
|
|
4792
|
|
|
|
|
|
|
# |
4793
|
0
|
|
|
0
|
|
0
|
# _hasmeta_MacOS() will only be used on Mac OS (OS9 or older): |
4794
|
|
|
|
|
|
|
# |
4795
|
|
|
|
|
|
|
sub _hasmeta_MacOS { |
4796
|
|
|
|
|
|
|
my($expr) = @_; |
4797
|
|
|
|
|
|
|
|
4798
|
0
|
|
|
|
|
0
|
# if a '*' or '?' is preceded by an odd count of '\', temporary delete |
4799
|
0
|
|
|
|
|
0
|
# it (and its preceding backslashes), i.e. don't treat '\*' and '\?' as |
4800
|
0
|
0
|
|
|
|
0
|
# wildcards |
|
|
0
|
|
|
|
|
|
4801
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxgc) { |
4802
|
|
|
|
|
|
|
my $char = $1; |
4803
|
|
|
|
|
|
|
if ($char eq '*') { |
4804
|
0
|
|
|
|
|
0
|
return 1; |
4805
|
|
|
|
|
|
|
} |
4806
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4807
|
0
|
|
|
|
|
0
|
return 1; |
4808
|
|
|
|
|
|
|
} |
4809
|
|
|
|
|
|
|
} |
4810
|
|
|
|
|
|
|
return 0; |
4811
|
|
|
|
|
|
|
} |
4812
|
|
|
|
|
|
|
|
4813
|
|
|
|
|
|
|
# |
4814
|
0
|
|
|
0
|
|
0
|
# _quotemeta_MacOS() will only be used on Mac OS (OS9 or older): |
4815
|
|
|
|
|
|
|
# |
4816
|
|
|
|
|
|
|
sub _quotemeta_MacOS { |
4817
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4818
|
0
|
|
|
|
|
0
|
|
4819
|
0
|
|
|
|
|
0
|
# escape regex metachars but not '\' and glob chars '*', '?' |
4820
|
0
|
0
|
|
|
|
0
|
my $quotemeta = ''; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4821
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxgc) { |
4822
|
|
|
|
|
|
|
my $char = $1; |
4823
|
|
|
|
|
|
|
if ($char =~ /\A \\[*?\\] \z/oxms) { |
4824
|
0
|
|
|
|
|
0
|
$quotemeta .= $char; |
4825
|
|
|
|
|
|
|
} |
4826
|
|
|
|
|
|
|
elsif ($char eq '*') { |
4827
|
0
|
|
|
|
|
0
|
$quotemeta .= "(?:$your_char)*", |
4828
|
|
|
|
|
|
|
} |
4829
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4830
|
|
|
|
|
|
|
$quotemeta .= "(?:$your_char)?", # DOS style |
4831
|
0
|
|
|
|
|
0
|
# $quotemeta .= "(?:$your_char)", # UNIX style |
4832
|
|
|
|
|
|
|
} |
4833
|
|
|
|
|
|
|
elsif ((my $fc = Esjis::fc($char)) ne $char) { |
4834
|
0
|
|
|
|
|
0
|
$quotemeta .= $fc; |
4835
|
|
|
|
|
|
|
} |
4836
|
|
|
|
|
|
|
else { |
4837
|
0
|
|
|
|
|
0
|
$quotemeta .= quotemeta $char; |
4838
|
|
|
|
|
|
|
} |
4839
|
|
|
|
|
|
|
} |
4840
|
|
|
|
|
|
|
return $quotemeta; |
4841
|
|
|
|
|
|
|
} |
4842
|
|
|
|
|
|
|
|
4843
|
|
|
|
|
|
|
# |
4844
|
|
|
|
|
|
|
# via File::HomeDir::Windows 1.00 |
4845
|
|
|
|
|
|
|
# |
4846
|
|
|
|
|
|
|
sub my_home_MSWin32 { |
4847
|
|
|
|
|
|
|
|
4848
|
0
|
0
|
0
|
0
|
0
|
0
|
# A lot of unix people and unix-derived tools rely on |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
4849
|
0
|
|
|
|
|
0
|
# the ability to overload HOME. We will support it too |
4850
|
|
|
|
|
|
|
# so that they can replace raw HOME calls with File::HomeDir. |
4851
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { |
4852
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4853
|
|
|
|
|
|
|
} |
4854
|
0
|
|
|
|
|
0
|
|
4855
|
|
|
|
|
|
|
# Do we have a user profile? |
4856
|
|
|
|
|
|
|
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { |
4857
|
|
|
|
|
|
|
return $ENV{'USERPROFILE'}; |
4858
|
|
|
|
|
|
|
} |
4859
|
0
|
|
|
|
|
0
|
|
4860
|
|
|
|
|
|
|
# Some Windows use something like $ENV{'HOME'} |
4861
|
|
|
|
|
|
|
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { |
4862
|
0
|
|
|
|
|
0
|
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'}; |
4863
|
|
|
|
|
|
|
} |
4864
|
|
|
|
|
|
|
|
4865
|
|
|
|
|
|
|
return undef; |
4866
|
|
|
|
|
|
|
} |
4867
|
|
|
|
|
|
|
|
4868
|
|
|
|
|
|
|
# |
4869
|
|
|
|
|
|
|
# via File::HomeDir::MacOS9 1.00 |
4870
|
|
|
|
|
|
|
# |
4871
|
0
|
0
|
|
0
|
0
|
0
|
sub my_home_MacOS { |
4872
|
0
|
|
|
|
|
0
|
|
4873
|
|
|
|
|
|
|
# Try for $ENV{'HOME'} if we have it |
4874
|
|
|
|
|
|
|
if (defined $ENV{'HOME'}) { |
4875
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4876
|
|
|
|
|
|
|
} |
4877
|
|
|
|
|
|
|
|
4878
|
|
|
|
|
|
|
### DESPERATION SETS IN |
4879
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4880
|
0
|
|
|
|
|
0
|
# We could use the desktop |
4881
|
|
|
|
|
|
|
SCOPE: { |
4882
|
0
|
|
|
|
|
0
|
local $@; |
4883
|
0
|
|
|
|
|
0
|
CORE::eval { |
4884
|
0
|
|
|
|
|
0
|
# Find the desktop via Mac::Files |
4885
|
|
|
|
|
|
|
local $SIG{'__DIE__'} = ''; |
4886
|
|
|
|
|
|
|
CORE::require Mac::Files; |
4887
|
|
|
|
|
|
|
my $home = Mac::Files::FindFolder( |
4888
|
0
|
0
|
0
|
|
|
0
|
Mac::Files::kOnSystemDisk(), |
4889
|
|
|
|
|
|
|
Mac::Files::kDesktopFolderType(), |
4890
|
|
|
|
|
|
|
); |
4891
|
|
|
|
|
|
|
return $home if $home and Esjis::d($home); |
4892
|
|
|
|
|
|
|
}; |
4893
|
|
|
|
|
|
|
} |
4894
|
|
|
|
|
|
|
|
4895
|
0
|
|
|
|
|
0
|
# Desperation on any platform |
|
0
|
|
|
|
|
0
|
|
4896
|
0
|
|
|
|
|
0
|
SCOPE: { |
4897
|
0
|
0
|
0
|
|
|
0
|
# On some platforms getpwuid dies if called at all |
4898
|
|
|
|
|
|
|
local $SIG{'__DIE__'} = ''; |
4899
|
|
|
|
|
|
|
my $home = CORE::eval q{ (getpwuid($<))[7] }; |
4900
|
0
|
|
|
|
|
0
|
return $home if $home and Esjis::d($home); |
4901
|
|
|
|
|
|
|
} |
4902
|
|
|
|
|
|
|
|
4903
|
|
|
|
|
|
|
croak "Could not locate current user's home directory"; |
4904
|
|
|
|
|
|
|
} |
4905
|
|
|
|
|
|
|
|
4906
|
|
|
|
|
|
|
# |
4907
|
0
|
|
|
0
|
0
|
0
|
# via File::HomeDir::Unix 1.00 |
4908
|
|
|
|
|
|
|
# |
4909
|
0
|
0
|
0
|
|
|
0
|
sub my_home { |
|
|
0
|
0
|
|
|
|
|
4910
|
0
|
|
|
|
|
0
|
my $home; |
4911
|
|
|
|
|
|
|
|
4912
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { |
4913
|
|
|
|
|
|
|
$home = $ENV{'HOME'}; |
4914
|
|
|
|
|
|
|
} |
4915
|
|
|
|
|
|
|
|
4916
|
0
|
|
|
|
|
0
|
# This is from the original code, but I'm guessing |
4917
|
|
|
|
|
|
|
# it means "login directory" and exists on some Unixes. |
4918
|
|
|
|
|
|
|
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { |
4919
|
|
|
|
|
|
|
$home = $ENV{'LOGDIR'}; |
4920
|
|
|
|
|
|
|
} |
4921
|
|
|
|
|
|
|
|
4922
|
|
|
|
|
|
|
### More-desperate methods |
4923
|
0
|
|
|
|
|
0
|
|
4924
|
|
|
|
|
|
|
# Light desperation on any (Unixish) platform |
4925
|
|
|
|
|
|
|
else { |
4926
|
|
|
|
|
|
|
$home = CORE::eval q{ (getpwuid($<))[7] }; |
4927
|
|
|
|
|
|
|
} |
4928
|
0
|
0
|
0
|
|
|
0
|
|
4929
|
0
|
|
|
|
|
0
|
# On Unix in general, a non-existant home means "no home" |
4930
|
|
|
|
|
|
|
# For example, "nobody"-like users might use /nonexistant |
4931
|
0
|
|
|
|
|
0
|
if (defined $home and ! Esjis::d($home)) { |
4932
|
|
|
|
|
|
|
$home = undef; |
4933
|
|
|
|
|
|
|
} |
4934
|
|
|
|
|
|
|
return $home; |
4935
|
|
|
|
|
|
|
} |
4936
|
|
|
|
|
|
|
|
4937
|
|
|
|
|
|
|
# |
4938
|
|
|
|
|
|
|
# ShiftJIS file lstat (with parameter) |
4939
|
0
|
0
|
|
0
|
0
|
0
|
# |
4940
|
|
|
|
|
|
|
sub Esjis::lstat(*) { |
4941
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4942
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
4943
|
|
|
|
|
|
|
|
4944
|
|
|
|
|
|
|
if (-e $_) { |
4945
|
|
|
|
|
|
|
return CORE::lstat _; |
4946
|
|
|
|
|
|
|
} |
4947
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4948
|
|
|
|
|
|
|
|
4949
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::lstat() |
4950
|
0
|
|
|
|
|
0
|
# on Windows opens the file for the path which has 5c at end. |
4951
|
0
|
0
|
|
|
|
0
|
# (and so on) |
4952
|
0
|
0
|
|
|
|
0
|
|
4953
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4954
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4955
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4956
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4957
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4958
|
0
|
|
|
|
|
0
|
return @stat; |
4959
|
0
|
|
|
|
|
0
|
} |
4960
|
0
|
|
|
|
|
0
|
else { |
4961
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4962
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4963
|
|
|
|
|
|
|
return $stat; |
4964
|
0
|
0
|
|
|
|
0
|
} |
4965
|
|
|
|
|
|
|
} |
4966
|
|
|
|
|
|
|
} |
4967
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4968
|
|
|
|
|
|
|
} |
4969
|
|
|
|
|
|
|
|
4970
|
|
|
|
|
|
|
# |
4971
|
|
|
|
|
|
|
# ShiftJIS file lstat (without parameter) |
4972
|
0
|
0
|
|
0
|
0
|
0
|
# |
|
|
0
|
|
|
|
|
|
4973
|
0
|
|
|
|
|
0
|
sub Esjis::lstat_() { |
4974
|
|
|
|
|
|
|
|
4975
|
|
|
|
|
|
|
if (-e $_) { |
4976
|
0
|
|
|
|
|
0
|
return CORE::lstat _; |
4977
|
0
|
0
|
|
|
|
0
|
} |
4978
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4979
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4980
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4981
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4982
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4983
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4984
|
0
|
|
|
|
|
0
|
return @stat; |
4985
|
0
|
|
|
|
|
0
|
} |
4986
|
0
|
|
|
|
|
0
|
else { |
4987
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4988
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
4989
|
|
|
|
|
|
|
return $stat; |
4990
|
0
|
0
|
|
|
|
0
|
} |
4991
|
|
|
|
|
|
|
} |
4992
|
|
|
|
|
|
|
} |
4993
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4994
|
|
|
|
|
|
|
} |
4995
|
|
|
|
|
|
|
|
4996
|
|
|
|
|
|
|
# |
4997
|
|
|
|
|
|
|
# ShiftJIS path opendir |
4998
|
0
|
|
|
0
|
0
|
0
|
# |
4999
|
0
|
0
|
|
|
|
0
|
sub Esjis::opendir(*$) { |
|
|
0
|
|
|
|
|
|
5000
|
0
|
|
|
|
|
0
|
|
5001
|
|
|
|
|
|
|
my $dh = qualify_to_ref $_[0]; |
5002
|
|
|
|
|
|
|
if (CORE::opendir $dh, $_[1]) { |
5003
|
0
|
0
|
|
|
|
0
|
return 1; |
5004
|
0
|
|
|
|
|
0
|
} |
5005
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_[1])) { |
5006
|
|
|
|
|
|
|
if (CORE::opendir $dh, "$_[1]/.") { |
5007
|
0
|
|
|
|
|
0
|
return 1; |
5008
|
|
|
|
|
|
|
} |
5009
|
|
|
|
|
|
|
} |
5010
|
|
|
|
|
|
|
return undef; |
5011
|
|
|
|
|
|
|
} |
5012
|
|
|
|
|
|
|
|
5013
|
|
|
|
|
|
|
# |
5014
|
|
|
|
|
|
|
# ShiftJIS file stat (with parameter) |
5015
|
0
|
50
|
|
385
|
0
|
0
|
# |
5016
|
|
|
|
|
|
|
sub Esjis::stat(*) { |
5017
|
385
|
|
|
|
|
2483
|
|
5018
|
385
|
50
|
|
|
|
2493
|
local $_ = shift if @_; |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5019
|
385
|
|
|
|
|
14191
|
|
5020
|
|
|
|
|
|
|
my $fh = qualify_to_ref $_; |
5021
|
|
|
|
|
|
|
if (defined fileno $fh) { |
5022
|
0
|
|
|
|
|
0
|
return CORE::stat $fh; |
5023
|
|
|
|
|
|
|
} |
5024
|
|
|
|
|
|
|
elsif (-e $_) { |
5025
|
|
|
|
|
|
|
return CORE::stat _; |
5026
|
|
|
|
|
|
|
} |
5027
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
5028
|
|
|
|
|
|
|
|
5029
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::stat() |
5030
|
385
|
|
|
|
|
3081
|
# on Windows opens the file for the path which has 5c at end. |
5031
|
0
|
0
|
|
|
|
0
|
# (and so on) |
5032
|
0
|
0
|
|
|
|
0
|
|
5033
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
5034
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
5035
|
0
|
|
|
|
|
0
|
if (wantarray) { |
5036
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5037
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
5038
|
0
|
|
|
|
|
0
|
return @stat; |
5039
|
0
|
|
|
|
|
0
|
} |
5040
|
0
|
|
|
|
|
0
|
else { |
5041
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5042
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
5043
|
|
|
|
|
|
|
return $stat; |
5044
|
0
|
0
|
|
|
|
0
|
} |
5045
|
|
|
|
|
|
|
} |
5046
|
|
|
|
|
|
|
} |
5047
|
|
|
|
|
|
|
return wantarray ? () : undef; |
5048
|
|
|
|
|
|
|
} |
5049
|
|
|
|
|
|
|
|
5050
|
|
|
|
|
|
|
# |
5051
|
|
|
|
|
|
|
# ShiftJIS file stat (without parameter) |
5052
|
0
|
|
|
0
|
0
|
0
|
# |
5053
|
0
|
0
|
|
|
|
0
|
sub Esjis::stat_() { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5054
|
0
|
|
|
|
|
0
|
|
5055
|
|
|
|
|
|
|
my $fh = qualify_to_ref $_; |
5056
|
|
|
|
|
|
|
if (defined fileno $fh) { |
5057
|
0
|
|
|
|
|
0
|
return CORE::stat $fh; |
5058
|
|
|
|
|
|
|
} |
5059
|
|
|
|
|
|
|
elsif (-e $_) { |
5060
|
0
|
|
|
|
|
0
|
return CORE::stat _; |
5061
|
0
|
0
|
|
|
|
0
|
} |
5062
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
5063
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
5064
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
5065
|
0
|
|
|
|
|
0
|
if (wantarray) { |
5066
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5067
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
5068
|
0
|
|
|
|
|
0
|
return @stat; |
5069
|
0
|
|
|
|
|
0
|
} |
5070
|
0
|
|
|
|
|
0
|
else { |
5071
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5072
|
|
|
|
|
|
|
close MUST_BE_BAREWORD_AT_HERE; |
5073
|
|
|
|
|
|
|
return $stat; |
5074
|
0
|
0
|
|
|
|
0
|
} |
5075
|
|
|
|
|
|
|
} |
5076
|
|
|
|
|
|
|
} |
5077
|
|
|
|
|
|
|
return wantarray ? () : undef; |
5078
|
|
|
|
|
|
|
} |
5079
|
|
|
|
|
|
|
|
5080
|
|
|
|
|
|
|
# |
5081
|
|
|
|
|
|
|
# ShiftJIS path unlink |
5082
|
0
|
0
|
|
0
|
0
|
0
|
# |
5083
|
|
|
|
|
|
|
sub Esjis::unlink(@) { |
5084
|
0
|
|
|
|
|
0
|
|
5085
|
0
|
|
|
|
|
0
|
local @_ = ($_) unless @_; |
5086
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5087
|
0
|
|
|
|
|
0
|
my $unlink = 0; |
5088
|
|
|
|
|
|
|
for (@_) { |
5089
|
|
|
|
|
|
|
if (CORE::unlink) { |
5090
|
|
|
|
|
|
|
$unlink++; |
5091
|
|
|
|
|
|
|
} |
5092
|
0
|
|
|
|
|
0
|
elsif (Esjis::d($_)) { |
5093
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5094
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
5095
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
5096
|
|
|
|
|
|
|
my $file = join '', map {{'/' => '\\'}->{$_} || $_} @char; |
5097
|
0
|
|
|
|
|
0
|
if ($file =~ / \A (?:$q_char)*? [ ] /oxms) { |
5098
|
0
|
0
|
|
|
|
0
|
$file = qq{"$file"}; |
5099
|
0
|
|
|
|
|
0
|
} |
5100
|
|
|
|
|
|
|
my $fh = gensym(); |
5101
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
5102
|
0
|
0
|
0
|
|
|
0
|
close $fh; |
|
|
0
|
|
|
|
|
|
5103
|
0
|
|
|
|
|
0
|
|
5104
|
|
|
|
|
|
|
# cmd.exe on Windows NT, Windows 2000, Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
5105
|
|
|
|
|
|
|
if ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
5106
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
5107
|
|
|
|
|
|
|
} |
5108
|
0
|
|
|
|
|
0
|
|
5109
|
|
|
|
|
|
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
5110
|
|
|
|
|
|
|
elsif (qx{ver} =~ /\b(?:Windows 2000)\b/oms) { |
5111
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
5112
|
|
|
|
|
|
|
} |
5113
|
|
|
|
|
|
|
|
5114
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
5115
|
0
|
|
|
|
|
0
|
# command.com can not "2>NUL" |
5116
|
|
|
|
|
|
|
else { |
5117
|
|
|
|
|
|
|
CORE::system 'ATTRIB', '-R', $file; # clears Read-only file attribute |
5118
|
0
|
0
|
|
|
|
0
|
CORE::system 'DEL', $file; |
5119
|
0
|
|
|
|
|
0
|
} |
5120
|
|
|
|
|
|
|
|
5121
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
5122
|
0
|
|
|
|
|
0
|
close $fh; |
5123
|
|
|
|
|
|
|
} |
5124
|
|
|
|
|
|
|
else { |
5125
|
|
|
|
|
|
|
$unlink++; |
5126
|
|
|
|
|
|
|
} |
5127
|
0
|
|
|
|
|
0
|
} |
5128
|
|
|
|
|
|
|
} |
5129
|
|
|
|
|
|
|
} |
5130
|
|
|
|
|
|
|
return $unlink; |
5131
|
|
|
|
|
|
|
} |
5132
|
|
|
|
|
|
|
|
5133
|
|
|
|
|
|
|
# |
5134
|
|
|
|
|
|
|
# ShiftJIS chdir |
5135
|
0
|
0
|
|
0
|
0
|
0
|
# |
5136
|
0
|
|
|
|
|
0
|
sub Esjis::chdir(;$) { |
5137
|
|
|
|
|
|
|
|
5138
|
|
|
|
|
|
|
if (@_ == 0) { |
5139
|
0
|
|
|
|
|
0
|
return CORE::chdir; |
5140
|
|
|
|
|
|
|
} |
5141
|
0
|
0
|
|
|
|
0
|
|
5142
|
0
|
0
|
|
|
|
0
|
my($dir) = @_; |
5143
|
0
|
|
|
|
|
0
|
|
5144
|
|
|
|
|
|
|
if (_MSWin32_5Cended_path($dir)) { |
5145
|
|
|
|
|
|
|
if (not Esjis::d $dir) { |
5146
|
0
|
0
|
0
|
|
|
0
|
return 0; |
|
|
0
|
|
|
|
|
|
5147
|
0
|
|
|
|
|
0
|
} |
5148
|
|
|
|
|
|
|
|
5149
|
|
|
|
|
|
|
if ($] =~ /^5\.005/oxms) { |
5150
|
0
|
|
|
|
|
0
|
return CORE::chdir $dir; |
5151
|
0
|
|
|
|
|
0
|
} |
5152
|
|
|
|
|
|
|
elsif (($] =~ /^(?:5\.006|5\.008000)/oxms) and ($^O eq 'MSWin32')) { |
5153
|
|
|
|
|
|
|
local $@; |
5154
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
5155
|
|
|
|
|
|
|
CORE::require 'jacode.pl'; |
5156
|
|
|
|
|
|
|
|
5157
|
|
|
|
|
|
|
# P.676 ${^WIDE_SYSTEM_CALLS} |
5158
|
|
|
|
|
|
|
# in Chapter 28: Special Names |
5159
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5160
|
|
|
|
|
|
|
|
5161
|
|
|
|
|
|
|
# P.790 ${^WIDE_SYSTEM_CALLS} |
5162
|
|
|
|
|
|
|
# in Chapter 25: Special Names |
5163
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5164
|
|
|
|
|
|
|
|
5165
|
0
|
0
|
|
|
|
0
|
local ${^WIDE_SYSTEM_CALLS} = 1; |
5166
|
0
|
|
|
|
|
0
|
return CORE::chdir jcode::utf8($dir,'sjis'); |
5167
|
|
|
|
|
|
|
}; |
5168
|
|
|
|
|
|
|
if (not $@) { |
5169
|
|
|
|
|
|
|
return $chdir; |
5170
|
|
|
|
|
|
|
} |
5171
|
|
|
|
|
|
|
} |
5172
|
|
|
|
|
|
|
|
5173
|
|
|
|
|
|
|
# old idea (Win32 module required) |
5174
|
|
|
|
|
|
|
elsif (0) { |
5175
|
|
|
|
|
|
|
local $@; |
5176
|
|
|
|
|
|
|
my $shortdir = ''; |
5177
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
5178
|
|
|
|
|
|
|
use Win32; |
5179
|
|
|
|
|
|
|
$shortdir = Win32::GetShortPathName($dir); |
5180
|
|
|
|
|
|
|
if ($shortdir ne $dir) { |
5181
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
5182
|
|
|
|
|
|
|
} |
5183
|
|
|
|
|
|
|
else { |
5184
|
|
|
|
|
|
|
return 0; |
5185
|
|
|
|
|
|
|
} |
5186
|
|
|
|
|
|
|
}; |
5187
|
|
|
|
|
|
|
if ($@) { |
5188
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
5189
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
5190
|
|
|
|
|
|
|
pop @char; |
5191
|
|
|
|
|
|
|
} |
5192
|
|
|
|
|
|
|
$dir = join '', @char; |
5193
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path), Win32.pm module may help you"; |
5194
|
|
|
|
|
|
|
} |
5195
|
|
|
|
|
|
|
elsif ($shortdir eq $dir) { |
5196
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
5197
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
5198
|
|
|
|
|
|
|
pop @char; |
5199
|
|
|
|
|
|
|
} |
5200
|
|
|
|
|
|
|
$dir = join '', @char; |
5201
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path)"; |
5202
|
|
|
|
|
|
|
} |
5203
|
|
|
|
|
|
|
return $chdir; |
5204
|
0
|
|
|
|
|
0
|
} |
5205
|
|
|
|
|
|
|
|
5206
|
|
|
|
|
|
|
# rejected idea ... |
5207
|
|
|
|
|
|
|
elsif (0) { |
5208
|
|
|
|
|
|
|
|
5209
|
|
|
|
|
|
|
# MSDN SetCurrentDirectory function |
5210
|
|
|
|
|
|
|
# http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365530(v=vs.85).aspx |
5211
|
|
|
|
|
|
|
# |
5212
|
|
|
|
|
|
|
# Data Execution Prevention (DEP) |
5213
|
|
|
|
|
|
|
# http://vlaurie.com/computers2/Articles/dep.htm |
5214
|
|
|
|
|
|
|
# |
5215
|
|
|
|
|
|
|
# Learning x86 assembler with Perl -- Shibuya.pm#11 |
5216
|
|
|
|
|
|
|
# http://developer.cybozu.co.jp/takesako/2009/06/perl-x86-shibuy.html |
5217
|
|
|
|
|
|
|
# |
5218
|
|
|
|
|
|
|
# Introduction to Win32::API programming in Perl |
5219
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559 |
5220
|
|
|
|
|
|
|
# |
5221
|
|
|
|
|
|
|
# DynaLoader - Dynamically load C libraries into Perl code |
5222
|
|
|
|
|
|
|
# http://perldoc.perl.org/DynaLoader.html |
5223
|
|
|
|
|
|
|
# |
5224
|
|
|
|
|
|
|
# Basic knowledge of DynaLoader |
5225
|
|
|
|
|
|
|
# http://blog.64p.org/entry/20090313/1236934042 |
5226
|
|
|
|
|
|
|
|
5227
|
|
|
|
|
|
|
if (($] =~ /^5\.006/oxms) and |
5228
|
|
|
|
|
|
|
($^O eq 'MSWin32') and |
5229
|
|
|
|
|
|
|
($ENV{'PROCESSOR_ARCHITECTURE'} eq 'x86') and |
5230
|
|
|
|
|
|
|
CORE::eval(q{CORE::require 'Dyna'.'Loader'}) |
5231
|
|
|
|
|
|
|
) { |
5232
|
|
|
|
|
|
|
my $x86 = join('', |
5233
|
|
|
|
|
|
|
|
5234
|
|
|
|
|
|
|
# PUSH Iv |
5235
|
|
|
|
|
|
|
"\x68", pack('P', "$dir\\\0"), |
5236
|
|
|
|
|
|
|
|
5237
|
|
|
|
|
|
|
# MOV eAX, Iv |
5238
|
|
|
|
|
|
|
"\xb8", pack('L', |
5239
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_find_symbol'}{'CODE'}->( |
5240
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_load_file'}{'CODE'}->("$ENV{'SystemRoot'}\\system32\\kernel32.dll"), |
5241
|
|
|
|
|
|
|
'SetCurrentDirectoryA' |
5242
|
|
|
|
|
|
|
) |
5243
|
|
|
|
|
|
|
), |
5244
|
|
|
|
|
|
|
|
5245
|
|
|
|
|
|
|
# CALL eAX |
5246
|
|
|
|
|
|
|
"\xff\xd0", |
5247
|
|
|
|
|
|
|
|
5248
|
|
|
|
|
|
|
# RETN |
5249
|
|
|
|
|
|
|
"\xc3", |
5250
|
|
|
|
|
|
|
); |
5251
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_install_xsub'}{'CODE'}->('_SetCurrentDirectoryA', unpack('L', pack 'P', $x86)); |
5252
|
|
|
|
|
|
|
_SetCurrentDirectoryA(); |
5253
|
|
|
|
|
|
|
chomp(my $chdir = qx{chdir}); |
5254
|
|
|
|
|
|
|
if (Esjis::fc($chdir) eq Esjis::fc($dir)) { |
5255
|
|
|
|
|
|
|
return 1; |
5256
|
|
|
|
|
|
|
} |
5257
|
|
|
|
|
|
|
else { |
5258
|
|
|
|
|
|
|
return 0; |
5259
|
|
|
|
|
|
|
} |
5260
|
|
|
|
|
|
|
} |
5261
|
|
|
|
|
|
|
} |
5262
|
|
|
|
|
|
|
|
5263
|
|
|
|
|
|
|
# COMMAND.COM's unhelpful tips: |
5264
|
|
|
|
|
|
|
# Displays a list of files and subdirectories in a directory. |
5265
|
|
|
|
|
|
|
# http://www.lagmonster.org/docs/DOS7/z-dir.html |
5266
|
|
|
|
|
|
|
# |
5267
|
|
|
|
|
|
|
# Syntax: |
5268
|
|
|
|
|
|
|
# |
5269
|
|
|
|
|
|
|
# DIR [drive:] [path] [filename] [/Switches] |
5270
|
|
|
|
|
|
|
# |
5271
|
|
|
|
|
|
|
# /Z Long file names are not displayed in the file listing |
5272
|
|
|
|
|
|
|
# |
5273
|
|
|
|
|
|
|
# Limitations |
5274
|
|
|
|
|
|
|
# The undocumented /Z switch (no long names) would appear to |
5275
|
|
|
|
|
|
|
# have been not fully developed and has a couple of problems: |
5276
|
|
|
|
|
|
|
# |
5277
|
|
|
|
|
|
|
# 1. It will only work if: |
5278
|
|
|
|
|
|
|
# There is no path specified (ie. for the current directory in |
5279
|
|
|
|
|
|
|
# the current drive) |
5280
|
|
|
|
|
|
|
# The path is specified as the root directory of any drive |
5281
|
|
|
|
|
|
|
# (eg. C:\, D:\, etc.) |
5282
|
|
|
|
|
|
|
# The path is specified as the current directory of any drive |
5283
|
|
|
|
|
|
|
# by using the drive letter only (eg. C:, D:, etc.) |
5284
|
|
|
|
|
|
|
# The path is specified as the parent directory using the .. |
5285
|
|
|
|
|
|
|
# notation (eg. DIR .. /Z) |
5286
|
|
|
|
|
|
|
# Any other syntax results in a "File Not Found" error message. |
5287
|
|
|
|
|
|
|
# |
5288
|
|
|
|
|
|
|
# 2. The /Z switch is compatable with the /S switch to show |
5289
|
|
|
|
|
|
|
# subdirectories (as long as the above rules are followed) and |
5290
|
|
|
|
|
|
|
# all the files are shown with short names only. The |
5291
|
|
|
|
|
|
|
# subdirectories are also shown with short names only. However, |
5292
|
|
|
|
|
|
|
# the header for each subdirectory after the first level gives |
5293
|
|
|
|
|
|
|
# the subdirectory's long name. |
5294
|
|
|
|
|
|
|
# |
5295
|
|
|
|
|
|
|
# 3. The /Z switch is also compatable with the /B switch to give |
5296
|
|
|
|
|
|
|
# a simple list of files with short names only. When used with |
5297
|
|
|
|
|
|
|
# the /S switch as well, all files are listed with their full |
5298
|
|
|
|
|
|
|
# paths. The file names themselves are all in short form, and |
5299
|
|
|
|
|
|
|
# the path of those files in the current directory are in short |
5300
|
0
|
|
|
|
|
0
|
# form, but the paths of any files in subdirectories are in |
5301
|
0
|
|
|
|
|
0
|
# long filename form. |
5302
|
0
|
|
|
|
|
0
|
|
5303
|
0
|
|
|
|
|
0
|
my $shortdir = ''; |
5304
|
0
|
|
|
|
|
0
|
my $i = 0; |
5305
|
0
|
0
|
0
|
|
|
0
|
my @subdir = (); |
5306
|
0
|
|
|
|
|
0
|
while ($dir =~ / \G ($q_char) /oxgc) { |
5307
|
0
|
|
|
|
|
0
|
my $char = $1; |
5308
|
0
|
|
|
|
|
0
|
if (($char eq '\\') or ($char eq '/')) { |
5309
|
|
|
|
|
|
|
$i++; |
5310
|
|
|
|
|
|
|
$subdir[$i] = $char; |
5311
|
0
|
|
|
|
|
0
|
$i++; |
5312
|
|
|
|
|
|
|
} |
5313
|
|
|
|
|
|
|
else { |
5314
|
0
|
0
|
0
|
|
|
0
|
$subdir[$i] .= $char; |
5315
|
0
|
|
|
|
|
0
|
} |
5316
|
|
|
|
|
|
|
} |
5317
|
|
|
|
|
|
|
if (($subdir[-1] eq '\\') or ($subdir[-1] eq '/')) { |
5318
|
|
|
|
|
|
|
pop @subdir; |
5319
|
|
|
|
|
|
|
} |
5320
|
|
|
|
|
|
|
|
5321
|
|
|
|
|
|
|
# P.504 PERL5SHELL (Microsoft ports only) |
5322
|
|
|
|
|
|
|
# in Chapter 19: The Command-Line Interface |
5323
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5324
|
|
|
|
|
|
|
|
5325
|
|
|
|
|
|
|
# P.597 PERL5SHELL (Microsoft ports only) |
5326
|
|
|
|
|
|
|
# in Chapter 17: The Command-Line Interface |
5327
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5328
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
5329
|
0
|
|
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
5330
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000 |
|
0
|
|
|
|
|
0
|
|
5331
|
0
|
0
|
|
|
|
0
|
if (qx{ver} =~ /\b(?:Windows NT|Windows 2000)\b/oms) { |
5332
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5333
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5334
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5335
|
0
|
|
|
|
|
0
|
|
5336
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5337
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 39, 8+1+3; |
5338
|
|
|
|
|
|
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5339
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5340
|
|
|
|
|
|
|
last; |
5341
|
|
|
|
|
|
|
} |
5342
|
|
|
|
|
|
|
} |
5343
|
|
|
|
|
|
|
} |
5344
|
|
|
|
|
|
|
|
5345
|
|
|
|
|
|
|
# an idea (not so portable, only Windows 2000 or later) |
5346
|
|
|
|
|
|
|
elsif (0) { |
5347
|
|
|
|
|
|
|
chomp($shortdir = qx{for %I in ("$dir") do \@echo %~sI 2>NUL}); |
5348
|
|
|
|
|
|
|
} |
5349
|
0
|
|
|
|
|
0
|
|
5350
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
|
0
|
|
|
|
|
0
|
|
5351
|
0
|
0
|
|
|
|
0
|
elsif ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
5352
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5353
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5354
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5355
|
0
|
|
|
|
|
0
|
|
5356
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5357
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 36, 8+1+3; |
5358
|
|
|
|
|
|
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5359
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5360
|
|
|
|
|
|
|
last; |
5361
|
|
|
|
|
|
|
} |
5362
|
|
|
|
|
|
|
} |
5363
|
|
|
|
|
|
|
} |
5364
|
0
|
|
|
|
|
0
|
|
5365
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
|
0
|
|
|
|
|
0
|
|
5366
|
0
|
0
|
|
|
|
0
|
else { |
5367
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad "$dir*"}); |
5368
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5369
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5370
|
0
|
|
|
|
|
0
|
|
5371
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----v |
5372
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 0, 8+1+3; |
5373
|
0
|
|
|
|
|
0
|
CORE::substr($shortleafdir,8,1) = '.'; |
5374
|
|
|
|
|
|
|
$shortleafdir =~ s/ \. [ ]+ \z//oxms; |
5375
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5376
|
|
|
|
|
|
|
last; |
5377
|
|
|
|
|
|
|
} |
5378
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5379
|
0
|
|
|
|
|
0
|
} |
5380
|
|
|
|
|
|
|
|
5381
|
|
|
|
|
|
|
if ($shortdir eq '') { |
5382
|
0
|
|
|
|
|
0
|
return 0; |
5383
|
|
|
|
|
|
|
} |
5384
|
0
|
|
|
|
|
0
|
elsif (Esjis::fc($shortdir) eq Esjis::fc($dir)) { |
5385
|
|
|
|
|
|
|
return 0; |
5386
|
|
|
|
|
|
|
} |
5387
|
0
|
|
|
|
|
0
|
return CORE::chdir $shortdir; |
5388
|
|
|
|
|
|
|
} |
5389
|
|
|
|
|
|
|
else { |
5390
|
|
|
|
|
|
|
return CORE::chdir $dir; |
5391
|
|
|
|
|
|
|
} |
5392
|
|
|
|
|
|
|
} |
5393
|
|
|
|
|
|
|
|
5394
|
|
|
|
|
|
|
# |
5395
|
|
|
|
|
|
|
# ShiftJIS chr(0x5C) ended path on MSWin32 |
5396
|
0
|
50
|
33
|
770
|
|
0
|
# |
5397
|
770
|
50
|
|
|
|
5117
|
sub _MSWin32_5Cended_path { |
5398
|
770
|
|
|
|
|
4477
|
|
5399
|
0
|
0
|
|
|
|
0
|
if ((@_ >= 1) and ($_[0] ne '')) { |
5400
|
0
|
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
5401
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5402
|
|
|
|
|
|
|
if ($char[-1] =~ / \x5C \z/oxms) { |
5403
|
|
|
|
|
|
|
return 1; |
5404
|
0
|
|
|
|
|
0
|
} |
5405
|
|
|
|
|
|
|
} |
5406
|
|
|
|
|
|
|
} |
5407
|
|
|
|
|
|
|
return undef; |
5408
|
|
|
|
|
|
|
} |
5409
|
|
|
|
|
|
|
|
5410
|
|
|
|
|
|
|
# |
5411
|
|
|
|
|
|
|
# do ShiftJIS file |
5412
|
770
|
|
|
0
|
0
|
2119
|
# |
5413
|
|
|
|
|
|
|
sub Esjis::do($) { |
5414
|
0
|
|
|
|
|
0
|
|
5415
|
|
|
|
|
|
|
my($filename) = @_; |
5416
|
|
|
|
|
|
|
|
5417
|
|
|
|
|
|
|
my $realfilename; |
5418
|
0
|
|
|
|
|
0
|
my $result; |
|
0
|
|
|
|
|
0
|
|
5419
|
0
|
0
|
|
|
|
0
|
ITER_DO: |
5420
|
0
|
|
|
|
|
0
|
{ |
5421
|
|
|
|
|
|
|
for my $prefix (@INC) { |
5422
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5423
|
0
|
|
|
|
|
0
|
$realfilename = "$prefix$filename"; |
5424
|
|
|
|
|
|
|
} |
5425
|
|
|
|
|
|
|
else { |
5426
|
0
|
0
|
|
|
|
0
|
$realfilename = "$prefix/$filename"; |
5427
|
|
|
|
|
|
|
} |
5428
|
0
|
|
|
|
|
0
|
|
5429
|
|
|
|
|
|
|
if (Esjis::f($realfilename)) { |
5430
|
0
|
0
|
|
|
|
0
|
|
5431
|
0
|
|
|
|
|
0
|
my $script = ''; |
5432
|
0
|
|
|
|
|
0
|
|
5433
|
0
|
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
5434
|
0
|
0
|
0
|
|
|
0
|
my $e_mtime = (Esjis::stat("$realfilename.e"))[9]; |
5435
|
0
|
|
|
|
|
0
|
my $mtime = (Esjis::stat($realfilename))[9]; |
5436
|
|
|
|
|
|
|
my $module_mtime = (Esjis::stat(__FILE__))[9]; |
5437
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5438
|
|
|
|
|
|
|
Esjis::unlink "$realfilename.e"; |
5439
|
0
|
0
|
|
|
|
0
|
} |
5440
|
0
|
|
|
|
|
0
|
} |
5441
|
0
|
0
|
|
|
|
0
|
|
5442
|
0
|
0
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
|
|
0
|
|
|
|
|
|
5443
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5444
|
|
|
|
|
|
|
if (_open_r($fh, "$realfilename.e")) { |
5445
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5446
|
|
|
|
|
|
|
CORE::eval q{ |
5447
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5448
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5449
|
|
|
|
|
|
|
}; |
5450
|
|
|
|
|
|
|
} |
5451
|
|
|
|
|
|
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5452
|
|
|
|
|
|
|
|
5453
|
|
|
|
|
|
|
# P.419 File Locking |
5454
|
|
|
|
|
|
|
# in Chapter 16: Interprocess Communication |
5455
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5456
|
|
|
|
|
|
|
|
5457
|
|
|
|
|
|
|
# P.524 File Locking |
5458
|
|
|
|
|
|
|
# in Chapter 15: Interprocess Communication |
5459
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5460
|
0
|
|
|
|
|
0
|
|
5461
|
0
|
0
|
|
|
|
0
|
# (and so on) |
5462
|
0
|
|
|
|
|
0
|
|
5463
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5464
|
|
|
|
|
|
|
if ($@) { |
5465
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5466
|
0
|
|
|
|
|
0
|
} |
5467
|
|
|
|
|
|
|
} |
5468
|
0
|
|
|
|
|
0
|
else { |
5469
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5470
|
0
|
0
|
|
|
|
0
|
} |
5471
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5472
|
|
|
|
|
|
|
$script = <$fh>; |
5473
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5474
|
|
|
|
|
|
|
CORE::eval q{ |
5475
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5476
|
0
|
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5477
|
|
|
|
|
|
|
}; |
5478
|
|
|
|
|
|
|
} |
5479
|
|
|
|
|
|
|
close $fh; |
5480
|
0
|
|
|
|
|
0
|
} |
5481
|
0
|
0
|
|
|
|
0
|
} |
5482
|
0
|
0
|
|
|
|
0
|
else { |
|
|
0
|
|
|
|
|
|
5483
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5484
|
|
|
|
|
|
|
if (_open_r($fh, $realfilename)) { |
5485
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5486
|
|
|
|
|
|
|
CORE::eval q{ |
5487
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5488
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5489
|
0
|
|
|
|
|
0
|
}; |
5490
|
0
|
0
|
|
|
|
0
|
} |
5491
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5492
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5493
|
|
|
|
|
|
|
if ($@) { |
5494
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5495
|
0
|
|
|
|
|
0
|
} |
5496
|
|
|
|
|
|
|
} |
5497
|
0
|
|
|
|
|
0
|
else { |
5498
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5499
|
0
|
0
|
|
|
|
0
|
} |
5500
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5501
|
|
|
|
|
|
|
$script = <$fh>; |
5502
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5503
|
|
|
|
|
|
|
CORE::eval q{ |
5504
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5505
|
0
|
|
|
|
|
0
|
Mac::Files::FSpRstFLock($realfilename); |
5506
|
|
|
|
|
|
|
}; |
5507
|
|
|
|
|
|
|
} |
5508
|
0
|
0
|
|
|
|
0
|
close $fh; |
5509
|
0
|
|
|
|
|
0
|
} |
5510
|
0
|
|
|
|
|
0
|
|
5511
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
5512
|
0
|
0
|
|
|
|
0
|
CORE::require Sjis; |
5513
|
0
|
0
|
|
|
|
0
|
$script = Sjis::escape_script($script); |
|
|
0
|
|
|
|
|
|
5514
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5515
|
|
|
|
|
|
|
open($fh, ">$realfilename.e") or die __FILE__, ": Can't write open file: $realfilename.e\n"; |
5516
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5517
|
|
|
|
|
|
|
CORE::eval q{ |
5518
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5519
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5520
|
0
|
|
|
|
|
0
|
}; |
5521
|
0
|
0
|
|
|
|
0
|
} |
5522
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5523
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5524
|
|
|
|
|
|
|
if ($@) { |
5525
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5526
|
0
|
|
|
|
|
0
|
} |
5527
|
|
|
|
|
|
|
} |
5528
|
0
|
|
|
|
|
0
|
else { |
5529
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5530
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5531
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
5532
|
0
|
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5533
|
|
|
|
|
|
|
print {$fh} $script; |
5534
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5535
|
|
|
|
|
|
|
CORE::eval q{ |
5536
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5537
|
0
|
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5538
|
|
|
|
|
|
|
}; |
5539
|
|
|
|
|
|
|
} |
5540
|
|
|
|
|
|
|
close $fh; |
5541
|
|
|
|
|
|
|
} |
5542
|
390
|
|
|
390
|
|
13442
|
} |
|
390
|
|
|
|
|
2807
|
|
|
390
|
|
|
|
|
366124
|
|
|
0
|
|
|
|
|
0
|
|
5543
|
0
|
|
|
|
|
0
|
|
5544
|
|
|
|
|
|
|
{ |
5545
|
0
|
|
|
|
|
0
|
no strict; |
5546
|
|
|
|
|
|
|
$result = scalar CORE::eval $script; |
5547
|
|
|
|
|
|
|
} |
5548
|
|
|
|
|
|
|
last ITER_DO; |
5549
|
|
|
|
|
|
|
} |
5550
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5551
|
0
|
|
|
|
|
0
|
} |
5552
|
0
|
|
|
|
|
0
|
|
5553
|
|
|
|
|
|
|
if ($@) { |
5554
|
|
|
|
|
|
|
$INC{$filename} = undef; |
5555
|
0
|
|
|
|
|
0
|
return undef; |
5556
|
|
|
|
|
|
|
} |
5557
|
|
|
|
|
|
|
elsif (not $result) { |
5558
|
0
|
|
|
|
|
0
|
return undef; |
5559
|
0
|
|
|
|
|
0
|
} |
5560
|
|
|
|
|
|
|
else { |
5561
|
|
|
|
|
|
|
$INC{$filename} = $realfilename; |
5562
|
|
|
|
|
|
|
return $result; |
5563
|
|
|
|
|
|
|
} |
5564
|
|
|
|
|
|
|
} |
5565
|
|
|
|
|
|
|
|
5566
|
|
|
|
|
|
|
# |
5567
|
|
|
|
|
|
|
# require ShiftJIS file |
5568
|
|
|
|
|
|
|
# |
5569
|
|
|
|
|
|
|
|
5570
|
|
|
|
|
|
|
# require |
5571
|
|
|
|
|
|
|
# in Chapter 3: Functions |
5572
|
|
|
|
|
|
|
# of ISBN 1-56592-149-6 Programming Perl, Second Edition. |
5573
|
|
|
|
|
|
|
# |
5574
|
|
|
|
|
|
|
# sub require { |
5575
|
|
|
|
|
|
|
# my($filename) = @_; |
5576
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5577
|
|
|
|
|
|
|
# my($realfilename, $result); |
5578
|
|
|
|
|
|
|
# ITER: { |
5579
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5580
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5581
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5582
|
|
|
|
|
|
|
# $result = CORE::eval `cat $realfilename`; |
5583
|
|
|
|
|
|
|
# last ITER; |
5584
|
|
|
|
|
|
|
# } |
5585
|
|
|
|
|
|
|
# } |
5586
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5587
|
|
|
|
|
|
|
# } |
5588
|
|
|
|
|
|
|
# die $@ if $@; |
5589
|
|
|
|
|
|
|
# die "$filename did not return true value" unless $result; |
5590
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5591
|
|
|
|
|
|
|
# return $result; |
5592
|
|
|
|
|
|
|
# } |
5593
|
|
|
|
|
|
|
|
5594
|
|
|
|
|
|
|
# require |
5595
|
|
|
|
|
|
|
# in Chapter 9: perlfunc: Perl builtin functions |
5596
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5597
|
|
|
|
|
|
|
# |
5598
|
|
|
|
|
|
|
# sub require { |
5599
|
|
|
|
|
|
|
# my($filename) = @_; |
5600
|
|
|
|
|
|
|
# if (exists $INC{$filename}) { |
5601
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5602
|
|
|
|
|
|
|
# die "Compilation failed in require"; |
5603
|
|
|
|
|
|
|
# } |
5604
|
|
|
|
|
|
|
# my($realfilename, $result); |
5605
|
|
|
|
|
|
|
# ITER: { |
5606
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5607
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5608
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5609
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5610
|
|
|
|
|
|
|
# $result = do $realfilename; |
5611
|
|
|
|
|
|
|
# last ITER; |
5612
|
|
|
|
|
|
|
# } |
5613
|
|
|
|
|
|
|
# } |
5614
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5615
|
|
|
|
|
|
|
# } |
5616
|
|
|
|
|
|
|
# if ($@) { |
5617
|
|
|
|
|
|
|
# $INC{$filename} = undef; |
5618
|
|
|
|
|
|
|
# die $@; |
5619
|
|
|
|
|
|
|
# } |
5620
|
|
|
|
|
|
|
# elsif (!$result) { |
5621
|
|
|
|
|
|
|
# delete $INC{$filename}; |
5622
|
|
|
|
|
|
|
# die "$filename did not return true value"; |
5623
|
|
|
|
|
|
|
# } |
5624
|
|
|
|
|
|
|
# else { |
5625
|
|
|
|
|
|
|
# return $result; |
5626
|
|
|
|
|
|
|
# } |
5627
|
|
|
|
|
|
|
# } |
5628
|
0
|
0
|
|
0
|
0
|
0
|
|
5629
|
|
|
|
|
|
|
sub Esjis::require(;$) { |
5630
|
0
|
0
|
|
|
|
0
|
|
5631
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5632
|
0
|
|
|
|
|
0
|
|
5633
|
|
|
|
|
|
|
if (exists $INC{$_}) { |
5634
|
|
|
|
|
|
|
return 1 if $INC{$_}; |
5635
|
|
|
|
|
|
|
croak "Compilation failed in require: $_"; |
5636
|
|
|
|
|
|
|
} |
5637
|
|
|
|
|
|
|
|
5638
|
|
|
|
|
|
|
# jcode.pl |
5639
|
|
|
|
|
|
|
# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/ |
5640
|
|
|
|
|
|
|
|
5641
|
0
|
0
|
|
|
|
0
|
# jacode.pl |
5642
|
0
|
|
|
|
|
0
|
# http://search.cpan.org/dist/jacode/ |
5643
|
|
|
|
|
|
|
|
5644
|
|
|
|
|
|
|
if (/ \b (?: jcode\.pl | jacode(?>[0-9]*)\.pl ) \z /oxms) { |
5645
|
0
|
|
|
|
|
0
|
return CORE::require($_); |
5646
|
|
|
|
|
|
|
} |
5647
|
|
|
|
|
|
|
|
5648
|
|
|
|
|
|
|
my $realfilename; |
5649
|
0
|
|
|
|
|
0
|
my $result; |
|
0
|
|
|
|
|
0
|
|
5650
|
0
|
0
|
|
|
|
0
|
ITER_REQUIRE: |
5651
|
0
|
|
|
|
|
0
|
{ |
5652
|
|
|
|
|
|
|
for my $prefix (@INC) { |
5653
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5654
|
0
|
|
|
|
|
0
|
$realfilename = "$prefix$_"; |
5655
|
|
|
|
|
|
|
} |
5656
|
|
|
|
|
|
|
else { |
5657
|
0
|
0
|
|
|
|
0
|
$realfilename = "$prefix/$_"; |
5658
|
0
|
|
|
|
|
0
|
} |
5659
|
|
|
|
|
|
|
|
5660
|
0
|
|
|
|
|
0
|
if (Esjis::f($realfilename)) { |
5661
|
|
|
|
|
|
|
$INC{$_} = $realfilename; |
5662
|
0
|
0
|
|
|
|
0
|
|
5663
|
0
|
|
|
|
|
0
|
my $script = ''; |
5664
|
0
|
|
|
|
|
0
|
|
5665
|
0
|
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
5666
|
0
|
0
|
0
|
|
|
0
|
my $e_mtime = (Esjis::stat("$realfilename.e"))[9]; |
5667
|
0
|
|
|
|
|
0
|
my $mtime = (Esjis::stat($realfilename))[9]; |
5668
|
|
|
|
|
|
|
my $module_mtime = (Esjis::stat(__FILE__))[9]; |
5669
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5670
|
|
|
|
|
|
|
Esjis::unlink "$realfilename.e"; |
5671
|
0
|
0
|
|
|
|
0
|
} |
5672
|
0
|
|
|
|
|
0
|
} |
5673
|
0
|
0
|
|
|
|
0
|
|
5674
|
0
|
0
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
|
|
0
|
|
|
|
|
|
5675
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5676
|
|
|
|
|
|
|
_open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e"; |
5677
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5678
|
|
|
|
|
|
|
CORE::eval q{ |
5679
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5680
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5681
|
0
|
|
|
|
|
0
|
}; |
5682
|
0
|
0
|
|
|
|
0
|
} |
5683
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5684
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5685
|
|
|
|
|
|
|
if ($@) { |
5686
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5687
|
0
|
|
|
|
|
0
|
} |
5688
|
|
|
|
|
|
|
} |
5689
|
0
|
|
|
|
|
0
|
else { |
5690
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5691
|
0
|
0
|
|
|
|
0
|
} |
5692
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5693
|
|
|
|
|
|
|
$script = <$fh>; |
5694
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5695
|
|
|
|
|
|
|
CORE::eval q{ |
5696
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5697
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5698
|
|
|
|
|
|
|
}; |
5699
|
|
|
|
|
|
|
} |
5700
|
0
|
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename"; |
5701
|
0
|
0
|
|
|
|
0
|
} |
5702
|
0
|
0
|
|
|
|
0
|
else { |
|
|
0
|
|
|
|
|
|
5703
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5704
|
|
|
|
|
|
|
_open_r($fh, $realfilename) or croak "Can't open file: $realfilename"; |
5705
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5706
|
|
|
|
|
|
|
CORE::eval q{ |
5707
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5708
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5709
|
0
|
|
|
|
|
0
|
}; |
5710
|
0
|
0
|
|
|
|
0
|
} |
5711
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5712
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5713
|
|
|
|
|
|
|
if ($@) { |
5714
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5715
|
0
|
|
|
|
|
0
|
} |
5716
|
|
|
|
|
|
|
} |
5717
|
0
|
|
|
|
|
0
|
else { |
5718
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5719
|
0
|
0
|
|
|
|
0
|
} |
5720
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5721
|
|
|
|
|
|
|
$script = <$fh>; |
5722
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5723
|
|
|
|
|
|
|
CORE::eval q{ |
5724
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5725
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock($realfilename); |
5726
|
|
|
|
|
|
|
}; |
5727
|
0
|
0
|
|
|
|
0
|
} |
5728
|
0
|
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename"; |
5729
|
0
|
|
|
|
|
0
|
|
5730
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
5731
|
0
|
0
|
|
|
|
0
|
CORE::require Sjis; |
5732
|
0
|
0
|
|
|
|
0
|
$script = Sjis::escape_script($script); |
|
|
0
|
|
|
|
|
|
5733
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5734
|
|
|
|
|
|
|
open($fh, ">$realfilename.e") or croak "Can't write open file: $realfilename.e"; |
5735
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5736
|
|
|
|
|
|
|
CORE::eval q{ |
5737
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5738
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5739
|
0
|
|
|
|
|
0
|
}; |
5740
|
0
|
0
|
|
|
|
0
|
} |
5741
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5742
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5743
|
|
|
|
|
|
|
if ($@) { |
5744
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5745
|
0
|
|
|
|
|
0
|
} |
5746
|
|
|
|
|
|
|
} |
5747
|
0
|
|
|
|
|
0
|
else { |
5748
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5749
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5750
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
5751
|
0
|
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5752
|
|
|
|
|
|
|
print {$fh} $script; |
5753
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5754
|
|
|
|
|
|
|
CORE::eval q{ |
5755
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5756
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5757
|
|
|
|
|
|
|
}; |
5758
|
|
|
|
|
|
|
} |
5759
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename"; |
5760
|
|
|
|
|
|
|
} |
5761
|
390
|
|
|
390
|
|
2952
|
} |
|
390
|
|
|
|
|
2238
|
|
|
390
|
|
|
|
|
392135
|
|
|
0
|
|
|
|
|
0
|
|
5762
|
0
|
|
|
|
|
0
|
|
5763
|
|
|
|
|
|
|
{ |
5764
|
0
|
|
|
|
|
0
|
no strict; |
5765
|
|
|
|
|
|
|
$result = scalar CORE::eval $script; |
5766
|
|
|
|
|
|
|
} |
5767
|
0
|
|
|
|
|
0
|
last ITER_REQUIRE; |
5768
|
|
|
|
|
|
|
} |
5769
|
|
|
|
|
|
|
} |
5770
|
0
|
0
|
|
|
|
0
|
croak "Can't find $_ in \@INC"; |
|
|
0
|
|
|
|
|
|
5771
|
0
|
|
|
|
|
0
|
} |
5772
|
0
|
|
|
|
|
0
|
|
5773
|
|
|
|
|
|
|
if ($@) { |
5774
|
|
|
|
|
|
|
$INC{$_} = undef; |
5775
|
0
|
|
|
|
|
0
|
croak $@; |
5776
|
0
|
|
|
|
|
0
|
} |
5777
|
|
|
|
|
|
|
elsif (not $result) { |
5778
|
|
|
|
|
|
|
delete $INC{$_}; |
5779
|
0
|
|
|
|
|
0
|
croak "$_ did not return true value"; |
5780
|
|
|
|
|
|
|
} |
5781
|
|
|
|
|
|
|
else { |
5782
|
|
|
|
|
|
|
return $result; |
5783
|
|
|
|
|
|
|
} |
5784
|
|
|
|
|
|
|
} |
5785
|
|
|
|
|
|
|
|
5786
|
|
|
|
|
|
|
# |
5787
|
|
|
|
|
|
|
# ShiftJIS telldir avoid warning |
5788
|
0
|
|
|
770
|
0
|
0
|
# |
5789
|
|
|
|
|
|
|
sub Esjis::telldir(*) { |
5790
|
770
|
|
|
|
|
2294
|
|
5791
|
|
|
|
|
|
|
local $^W = 0; |
5792
|
|
|
|
|
|
|
|
5793
|
|
|
|
|
|
|
return CORE::telldir $_[0]; |
5794
|
|
|
|
|
|
|
} |
5795
|
|
|
|
|
|
|
|
5796
|
|
|
|
|
|
|
# |
5797
|
770
|
0
|
|
0
|
0
|
46721
|
# ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched |
5798
|
0
|
0
|
0
|
|
|
0
|
# |
5799
|
0
|
|
|
|
|
0
|
sub Esjis::PREMATCH { |
5800
|
|
|
|
|
|
|
if (defined($&)) { |
5801
|
|
|
|
|
|
|
if (defined($1) and (CORE::substr($&,-CORE::length($1),CORE::length($1)) eq $1)) { |
5802
|
0
|
|
|
|
|
0
|
return CORE::substr($&,0,CORE::length($&)-CORE::length($1)); |
5803
|
|
|
|
|
|
|
} |
5804
|
|
|
|
|
|
|
else { |
5805
|
|
|
|
|
|
|
croak 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp'; |
5806
|
0
|
|
|
|
|
0
|
} |
5807
|
|
|
|
|
|
|
} |
5808
|
0
|
|
|
|
|
0
|
else { |
5809
|
|
|
|
|
|
|
return ''; |
5810
|
|
|
|
|
|
|
} |
5811
|
|
|
|
|
|
|
return $`; |
5812
|
|
|
|
|
|
|
} |
5813
|
|
|
|
|
|
|
|
5814
|
|
|
|
|
|
|
# |
5815
|
0
|
0
|
|
0
|
0
|
0
|
# ${^MATCH}, $MATCH, $& the string that matched |
5816
|
0
|
0
|
|
|
|
0
|
# |
5817
|
0
|
|
|
|
|
0
|
sub Esjis::MATCH { |
5818
|
|
|
|
|
|
|
if (defined($&)) { |
5819
|
|
|
|
|
|
|
if (defined($1)) { |
5820
|
0
|
|
|
|
|
0
|
return $1; |
5821
|
|
|
|
|
|
|
} |
5822
|
|
|
|
|
|
|
else { |
5823
|
|
|
|
|
|
|
croak 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp'; |
5824
|
0
|
|
|
|
|
0
|
} |
5825
|
|
|
|
|
|
|
} |
5826
|
0
|
|
|
|
|
0
|
else { |
5827
|
|
|
|
|
|
|
return ''; |
5828
|
|
|
|
|
|
|
} |
5829
|
|
|
|
|
|
|
return $&; |
5830
|
|
|
|
|
|
|
} |
5831
|
|
|
|
|
|
|
|
5832
|
|
|
|
|
|
|
# |
5833
|
0
|
|
|
0
|
0
|
0
|
# ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched |
5834
|
|
|
|
|
|
|
# |
5835
|
|
|
|
|
|
|
sub Esjis::POSTMATCH { |
5836
|
|
|
|
|
|
|
return $'; |
5837
|
|
|
|
|
|
|
} |
5838
|
|
|
|
|
|
|
|
5839
|
|
|
|
|
|
|
# |
5840
|
|
|
|
|
|
|
# ShiftJIS character to order (with parameter) |
5841
|
0
|
0
|
|
0
|
1
|
0
|
# |
5842
|
|
|
|
|
|
|
sub Sjis::ord(;$) { |
5843
|
0
|
0
|
|
|
|
0
|
|
5844
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5845
|
0
|
|
|
|
|
0
|
|
5846
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5847
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5848
|
|
|
|
|
|
|
my $ord = 0; |
5849
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
5850
|
|
|
|
|
|
|
$ord = $ord * 0x100 + $o; |
5851
|
|
|
|
|
|
|
} |
5852
|
0
|
|
|
|
|
0
|
return $ord; |
5853
|
|
|
|
|
|
|
} |
5854
|
|
|
|
|
|
|
else { |
5855
|
|
|
|
|
|
|
return CORE::ord $_; |
5856
|
|
|
|
|
|
|
} |
5857
|
|
|
|
|
|
|
} |
5858
|
|
|
|
|
|
|
|
5859
|
|
|
|
|
|
|
# |
5860
|
|
|
|
|
|
|
# ShiftJIS character to order (without parameter) |
5861
|
0
|
0
|
|
0
|
0
|
0
|
# |
5862
|
0
|
|
|
|
|
0
|
sub Sjis::ord_() { |
5863
|
0
|
|
|
|
|
0
|
|
5864
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5865
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5866
|
|
|
|
|
|
|
my $ord = 0; |
5867
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
5868
|
|
|
|
|
|
|
$ord = $ord * 0x100 + $o; |
5869
|
|
|
|
|
|
|
} |
5870
|
0
|
|
|
|
|
0
|
return $ord; |
5871
|
|
|
|
|
|
|
} |
5872
|
|
|
|
|
|
|
else { |
5873
|
|
|
|
|
|
|
return CORE::ord $_; |
5874
|
|
|
|
|
|
|
} |
5875
|
|
|
|
|
|
|
} |
5876
|
|
|
|
|
|
|
|
5877
|
|
|
|
|
|
|
# |
5878
|
|
|
|
|
|
|
# ShiftJIS reverse |
5879
|
0
|
0
|
|
0
|
0
|
0
|
# |
5880
|
0
|
|
|
|
|
0
|
sub Sjis::reverse(@) { |
5881
|
|
|
|
|
|
|
|
5882
|
|
|
|
|
|
|
if (wantarray) { |
5883
|
|
|
|
|
|
|
return CORE::reverse @_; |
5884
|
|
|
|
|
|
|
} |
5885
|
|
|
|
|
|
|
else { |
5886
|
|
|
|
|
|
|
|
5887
|
|
|
|
|
|
|
# One of us once cornered Larry in an elevator and asked him what |
5888
|
|
|
|
|
|
|
# problem he was solving with this, but he looked as far off into |
5889
|
0
|
|
|
|
|
0
|
# the distance as he could in an elevator and said, "It seemed like |
5890
|
|
|
|
|
|
|
# a good idea at the time." |
5891
|
|
|
|
|
|
|
|
5892
|
|
|
|
|
|
|
return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg); |
5893
|
|
|
|
|
|
|
} |
5894
|
|
|
|
|
|
|
} |
5895
|
|
|
|
|
|
|
|
5896
|
|
|
|
|
|
|
# |
5897
|
|
|
|
|
|
|
# ShiftJIS getc (with parameter, without parameter) |
5898
|
0
|
|
|
0
|
0
|
0
|
# |
5899
|
0
|
0
|
|
|
|
0
|
sub Sjis::getc(;*@) { |
5900
|
0
|
0
|
0
|
|
|
0
|
|
5901
|
|
|
|
|
|
|
my($package) = caller; |
5902
|
0
|
|
|
|
|
0
|
my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN; |
|
0
|
|
|
|
|
0
|
|
5903
|
0
|
|
|
|
|
0
|
croak 'Too many arguments for Sjis::getc' if @_ and not wantarray; |
5904
|
0
|
|
|
|
|
0
|
|
5905
|
0
|
|
|
|
|
0
|
my @length = sort { $a <=> $b } keys %range_tr; |
5906
|
0
|
0
|
|
|
|
0
|
my $getc = ''; |
5907
|
0
|
0
|
|
|
|
0
|
for my $length ($length[0] .. $length[-1]) { |
5908
|
0
|
0
|
|
|
|
0
|
$getc .= CORE::getc($fh); |
5909
|
|
|
|
|
|
|
if (exists $range_tr{CORE::length($getc)}) { |
5910
|
|
|
|
|
|
|
if ($getc =~ /\A ${Esjis::dot_s} \z/oxms) { |
5911
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5912
|
0
|
0
|
|
|
|
0
|
} |
5913
|
|
|
|
|
|
|
} |
5914
|
|
|
|
|
|
|
} |
5915
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5916
|
|
|
|
|
|
|
} |
5917
|
|
|
|
|
|
|
|
5918
|
|
|
|
|
|
|
# |
5919
|
|
|
|
|
|
|
# ShiftJIS length by character |
5920
|
0
|
0
|
|
0
|
1
|
0
|
# |
5921
|
|
|
|
|
|
|
sub Sjis::length(;$) { |
5922
|
0
|
|
|
|
|
0
|
|
5923
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5924
|
|
|
|
|
|
|
|
5925
|
|
|
|
|
|
|
local @_ = /\G ($q_char) /oxmsg; |
5926
|
|
|
|
|
|
|
return scalar @_; |
5927
|
|
|
|
|
|
|
} |
5928
|
|
|
|
|
|
|
|
5929
|
|
|
|
|
|
|
# |
5930
|
|
|
|
|
|
|
# ShiftJIS substr by character |
5931
|
|
|
|
|
|
|
# |
5932
|
|
|
|
|
|
|
BEGIN { |
5933
|
|
|
|
|
|
|
|
5934
|
|
|
|
|
|
|
# P.232 The lvalue Attribute |
5935
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
5936
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5937
|
|
|
|
|
|
|
|
5938
|
|
|
|
|
|
|
# P.336 The lvalue Attribute |
5939
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
5940
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5941
|
|
|
|
|
|
|
|
5942
|
|
|
|
|
|
|
# P.144 8.4 Lvalue subroutines |
5943
|
390
|
50
|
0
|
390
|
1
|
235771
|
# in Chapter 8: perlsub: Perl subroutines |
|
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
|
|
5944
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5945
|
|
|
|
|
|
|
|
5946
|
|
|
|
|
|
|
CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : ''); |
5947
|
|
|
|
|
|
|
# vv----------------------******* |
5948
|
|
|
|
|
|
|
sub Sjis::substr($$;$$) %s { |
5949
|
|
|
|
|
|
|
|
5950
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5951
|
|
|
|
|
|
|
|
5952
|
|
|
|
|
|
|
# If the substring is beyond either end of the string, substr() returns the undefined |
5953
|
|
|
|
|
|
|
# value and produces a warning. When used as an lvalue, specifying a substring that |
5954
|
|
|
|
|
|
|
# is entirely outside the string raises an exception. |
5955
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/substr.html |
5956
|
|
|
|
|
|
|
|
5957
|
|
|
|
|
|
|
# A return with no argument returns the scalar value undef in scalar context, |
5958
|
|
|
|
|
|
|
# an empty list () in list context, and (naturally) nothing at all in void |
5959
|
|
|
|
|
|
|
# context. |
5960
|
|
|
|
|
|
|
|
5961
|
|
|
|
|
|
|
my $offset = $_[1]; |
5962
|
|
|
|
|
|
|
if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) { |
5963
|
|
|
|
|
|
|
return; |
5964
|
|
|
|
|
|
|
} |
5965
|
|
|
|
|
|
|
|
5966
|
|
|
|
|
|
|
# substr($string,$offset,$length,$replacement) |
5967
|
|
|
|
|
|
|
if (@_ == 4) { |
5968
|
|
|
|
|
|
|
my(undef,undef,$length,$replacement) = @_; |
5969
|
|
|
|
|
|
|
my $substr = join '', splice(@char, $offset, $length, $replacement); |
5970
|
|
|
|
|
|
|
$_[0] = join '', @char; |
5971
|
|
|
|
|
|
|
|
5972
|
|
|
|
|
|
|
# return $substr; this doesn't work, don't say "return" |
5973
|
|
|
|
|
|
|
$substr; |
5974
|
|
|
|
|
|
|
} |
5975
|
|
|
|
|
|
|
|
5976
|
|
|
|
|
|
|
# substr($string,$offset,$length) |
5977
|
|
|
|
|
|
|
elsif (@_ == 3) { |
5978
|
|
|
|
|
|
|
my(undef,undef,$length) = @_; |
5979
|
|
|
|
|
|
|
my $octet_offset = 0; |
5980
|
|
|
|
|
|
|
my $octet_length = 0; |
5981
|
|
|
|
|
|
|
if ($offset == 0) { |
5982
|
|
|
|
|
|
|
$octet_offset = 0; |
5983
|
|
|
|
|
|
|
} |
5984
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5985
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5986
|
|
|
|
|
|
|
} |
5987
|
|
|
|
|
|
|
else { |
5988
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5989
|
|
|
|
|
|
|
} |
5990
|
|
|
|
|
|
|
if ($length == 0) { |
5991
|
|
|
|
|
|
|
$octet_length = 0; |
5992
|
|
|
|
|
|
|
} |
5993
|
|
|
|
|
|
|
elsif ($length > 0) { |
5994
|
|
|
|
|
|
|
$octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]); |
5995
|
|
|
|
|
|
|
} |
5996
|
|
|
|
|
|
|
else { |
5997
|
|
|
|
|
|
|
$octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]); |
5998
|
|
|
|
|
|
|
} |
5999
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset, $octet_length); |
6000
|
|
|
|
|
|
|
} |
6001
|
|
|
|
|
|
|
|
6002
|
|
|
|
|
|
|
# substr($string,$offset) |
6003
|
|
|
|
|
|
|
else { |
6004
|
|
|
|
|
|
|
my $octet_offset = 0; |
6005
|
|
|
|
|
|
|
if ($offset == 0) { |
6006
|
|
|
|
|
|
|
$octet_offset = 0; |
6007
|
|
|
|
|
|
|
} |
6008
|
|
|
|
|
|
|
elsif ($offset > 0) { |
6009
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
6010
|
|
|
|
|
|
|
} |
6011
|
|
|
|
|
|
|
else { |
6012
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
6013
|
|
|
|
|
|
|
} |
6014
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset); |
6015
|
|
|
|
|
|
|
} |
6016
|
|
|
|
|
|
|
} |
6017
|
|
|
|
|
|
|
END |
6018
|
|
|
|
|
|
|
} |
6019
|
|
|
|
|
|
|
|
6020
|
|
|
|
|
|
|
# |
6021
|
|
|
|
|
|
|
# ShiftJIS index by character |
6022
|
0
|
|
|
0
|
1
|
0
|
# |
6023
|
0
|
0
|
|
|
|
0
|
sub Sjis::index($$;$) { |
6024
|
0
|
|
|
|
|
0
|
|
6025
|
|
|
|
|
|
|
my $index; |
6026
|
|
|
|
|
|
|
if (@_ == 3) { |
6027
|
0
|
|
|
|
|
0
|
$index = Esjis::index($_[0], $_[1], CORE::length(Sjis::substr($_[0], 0, $_[2]))); |
6028
|
|
|
|
|
|
|
} |
6029
|
|
|
|
|
|
|
else { |
6030
|
0
|
0
|
|
|
|
0
|
$index = Esjis::index($_[0], $_[1]); |
6031
|
0
|
|
|
|
|
0
|
} |
6032
|
|
|
|
|
|
|
|
6033
|
|
|
|
|
|
|
if ($index == -1) { |
6034
|
0
|
|
|
|
|
0
|
return -1; |
6035
|
|
|
|
|
|
|
} |
6036
|
|
|
|
|
|
|
else { |
6037
|
|
|
|
|
|
|
return Sjis::length(CORE::substr $_[0], 0, $index); |
6038
|
|
|
|
|
|
|
} |
6039
|
|
|
|
|
|
|
} |
6040
|
|
|
|
|
|
|
|
6041
|
|
|
|
|
|
|
# |
6042
|
|
|
|
|
|
|
# ShiftJIS rindex by character |
6043
|
0
|
|
|
0
|
1
|
0
|
# |
6044
|
0
|
0
|
|
|
|
0
|
sub Sjis::rindex($$;$) { |
6045
|
0
|
|
|
|
|
0
|
|
6046
|
|
|
|
|
|
|
my $rindex; |
6047
|
|
|
|
|
|
|
if (@_ == 3) { |
6048
|
0
|
|
|
|
|
0
|
$rindex = Esjis::rindex($_[0], $_[1], CORE::length(Sjis::substr($_[0], 0, $_[2]))); |
6049
|
|
|
|
|
|
|
} |
6050
|
|
|
|
|
|
|
else { |
6051
|
0
|
0
|
|
|
|
0
|
$rindex = Esjis::rindex($_[0], $_[1]); |
6052
|
0
|
|
|
|
|
0
|
} |
6053
|
|
|
|
|
|
|
|
6054
|
|
|
|
|
|
|
if ($rindex == -1) { |
6055
|
0
|
|
|
|
|
0
|
return -1; |
6056
|
|
|
|
|
|
|
} |
6057
|
|
|
|
|
|
|
else { |
6058
|
|
|
|
|
|
|
return Sjis::length(CORE::substr $_[0], 0, $rindex); |
6059
|
|
|
|
|
|
|
} |
6060
|
|
|
|
|
|
|
} |
6061
|
390
|
|
|
390
|
|
6199
|
|
|
390
|
|
|
|
|
2422
|
|
|
390
|
|
|
|
|
42027
|
|
6062
|
|
|
|
|
|
|
# when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??' |
6063
|
|
|
|
|
|
|
# when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else) |
6064
|
|
|
|
|
|
|
use vars qw($slash); $slash = 'm//'; |
6065
|
|
|
|
|
|
|
|
6066
|
|
|
|
|
|
|
# ord() to ord() or Sjis::ord() |
6067
|
|
|
|
|
|
|
my $function_ord = 'ord'; |
6068
|
|
|
|
|
|
|
|
6069
|
|
|
|
|
|
|
# ord to ord or Sjis::ord_ |
6070
|
|
|
|
|
|
|
my $function_ord_ = 'ord'; |
6071
|
|
|
|
|
|
|
|
6072
|
|
|
|
|
|
|
# reverse to reverse or Sjis::reverse |
6073
|
|
|
|
|
|
|
my $function_reverse = 'reverse'; |
6074
|
|
|
|
|
|
|
|
6075
|
|
|
|
|
|
|
# getc to getc or Sjis::getc |
6076
|
|
|
|
|
|
|
my $function_getc = 'getc'; |
6077
|
|
|
|
|
|
|
|
6078
|
|
|
|
|
|
|
# P.1023 Appendix W.9 Multibyte Anchoring |
6079
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
6080
|
|
|
|
|
|
|
|
6081
|
390
|
|
|
390
|
|
2778
|
my $anchor = ''; |
|
390
|
|
|
0
|
|
843
|
|
|
390
|
|
|
|
|
22707527
|
|
6082
|
|
|
|
|
|
|
$anchor = q{${Esjis::anchor}}; |
6083
|
|
|
|
|
|
|
|
6084
|
|
|
|
|
|
|
use vars qw($nest); |
6085
|
|
|
|
|
|
|
|
6086
|
|
|
|
|
|
|
# regexp of nested parens in qqXX |
6087
|
|
|
|
|
|
|
|
6088
|
|
|
|
|
|
|
# P.340 Matching Nested Constructs with Embedded Code |
6089
|
|
|
|
|
|
|
# in Chapter 7: Perl |
6090
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6091
|
|
|
|
|
|
|
|
6092
|
|
|
|
|
|
|
my $qq_paren = qr{(?{local $nest=0}) (?>(?: |
6093
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\()] | |
6094
|
|
|
|
|
|
|
\( (?{$nest++}) | |
6095
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6096
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6097
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6098
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6099
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6100
|
|
|
|
|
|
|
[\x00-\xFF] |
6101
|
|
|
|
|
|
|
}xms; |
6102
|
|
|
|
|
|
|
|
6103
|
|
|
|
|
|
|
my $qq_brace = qr{(?{local $nest=0}) (?>(?: |
6104
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\{}] | |
6105
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
6106
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6107
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6108
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6109
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6110
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6111
|
|
|
|
|
|
|
[\x00-\xFF] |
6112
|
|
|
|
|
|
|
}xms; |
6113
|
|
|
|
|
|
|
|
6114
|
|
|
|
|
|
|
my $qq_bracket = qr{(?{local $nest=0}) (?>(?: |
6115
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\]] | |
6116
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
6117
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6118
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6119
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6120
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6121
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6122
|
|
|
|
|
|
|
[\x00-\xFF] |
6123
|
|
|
|
|
|
|
}xms; |
6124
|
|
|
|
|
|
|
|
6125
|
|
|
|
|
|
|
my $qq_angle = qr{(?{local $nest=0}) (?>(?: |
6126
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\<>] | |
6127
|
|
|
|
|
|
|
\< (?{$nest++}) | |
6128
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6129
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6130
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6131
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6132
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6133
|
|
|
|
|
|
|
[\x00-\xFF] |
6134
|
|
|
|
|
|
|
}xms; |
6135
|
|
|
|
|
|
|
|
6136
|
|
|
|
|
|
|
my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} | |
6137
|
|
|
|
|
|
|
(?: ::)? (?: |
6138
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
6139
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
6140
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
6141
|
|
|
|
|
|
|
)) |
6142
|
|
|
|
|
|
|
}xms; |
6143
|
|
|
|
|
|
|
|
6144
|
|
|
|
|
|
|
my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} | |
6145
|
|
|
|
|
|
|
(?: ::)? (?: |
6146
|
|
|
|
|
|
|
(?>[0-9]+) | |
6147
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFCa-zA-Z_0-9\[\]] | |
6148
|
|
|
|
|
|
|
^[A-Z] | |
6149
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
6150
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
6151
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
6152
|
|
|
|
|
|
|
)) |
6153
|
|
|
|
|
|
|
}xms; |
6154
|
|
|
|
|
|
|
|
6155
|
|
|
|
|
|
|
my $qq_substr = qr{(?> Char::substr | Sjis::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \) |
6156
|
|
|
|
|
|
|
}xms; |
6157
|
|
|
|
|
|
|
|
6158
|
|
|
|
|
|
|
# regexp of nested parens in qXX |
6159
|
|
|
|
|
|
|
my $q_paren = qr{(?{local $nest=0}) (?>(?: |
6160
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC()] | |
6161
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6162
|
|
|
|
|
|
|
\( (?{$nest++}) | |
6163
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6164
|
|
|
|
|
|
|
[\x00-\xFF] |
6165
|
|
|
|
|
|
|
}xms; |
6166
|
|
|
|
|
|
|
|
6167
|
|
|
|
|
|
|
my $q_brace = qr{(?{local $nest=0}) (?>(?: |
6168
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\{\}] | |
6169
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6170
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
6171
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6172
|
|
|
|
|
|
|
[\x00-\xFF] |
6173
|
|
|
|
|
|
|
}xms; |
6174
|
|
|
|
|
|
|
|
6175
|
|
|
|
|
|
|
my $q_bracket = qr{(?{local $nest=0}) (?>(?: |
6176
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\[\]] | |
6177
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6178
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
6179
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6180
|
|
|
|
|
|
|
[\x00-\xFF] |
6181
|
|
|
|
|
|
|
}xms; |
6182
|
|
|
|
|
|
|
|
6183
|
|
|
|
|
|
|
my $q_angle = qr{(?{local $nest=0}) (?>(?: |
6184
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC<>] | |
6185
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6186
|
|
|
|
|
|
|
\< (?{$nest++}) | |
6187
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6188
|
|
|
|
|
|
|
[\x00-\xFF] |
6189
|
|
|
|
|
|
|
}xms; |
6190
|
|
|
|
|
|
|
|
6191
|
|
|
|
|
|
|
my $matched = ''; |
6192
|
|
|
|
|
|
|
my $s_matched = ''; |
6193
|
|
|
|
|
|
|
$matched = q{$Esjis::matched}; |
6194
|
|
|
|
|
|
|
$s_matched = q{ Esjis::s_matched();}; |
6195
|
|
|
|
|
|
|
|
6196
|
|
|
|
|
|
|
my $tr_variable = ''; # variable of tr/// |
6197
|
|
|
|
|
|
|
my $sub_variable = ''; # variable of s/// |
6198
|
|
|
|
|
|
|
my $bind_operator = ''; # =~ or !~ |
6199
|
|
|
|
|
|
|
|
6200
|
|
|
|
|
|
|
my @heredoc = (); # here document |
6201
|
|
|
|
|
|
|
my @heredoc_delimiter = (); |
6202
|
|
|
|
|
|
|
my $here_script = ''; # here script |
6203
|
|
|
|
|
|
|
|
6204
|
|
|
|
|
|
|
# |
6205
|
0
|
50
|
|
385
|
0
|
0
|
# escape ShiftJIS script |
6206
|
|
|
|
|
|
|
# |
6207
|
|
|
|
|
|
|
sub Sjis::escape(;$) { |
6208
|
|
|
|
|
|
|
local($_) = $_[0] if @_; |
6209
|
|
|
|
|
|
|
|
6210
|
|
|
|
|
|
|
# P.359 The Study Function |
6211
|
385
|
|
|
|
|
1420
|
# in Chapter 7: Perl |
6212
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6213
|
|
|
|
|
|
|
|
6214
|
|
|
|
|
|
|
study $_; # Yes, I studied study yesterday. |
6215
|
|
|
|
|
|
|
|
6216
|
|
|
|
|
|
|
# while all script |
6217
|
|
|
|
|
|
|
|
6218
|
|
|
|
|
|
|
# 6.14. Matching from Where the Last Pattern Left Off |
6219
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
6220
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
6221
|
|
|
|
|
|
|
# (and so on) |
6222
|
|
|
|
|
|
|
|
6223
|
|
|
|
|
|
|
# one member of Tag-team |
6224
|
|
|
|
|
|
|
# |
6225
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
6226
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
6227
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
6228
|
|
|
|
|
|
|
# P.255 Use leading anchors |
6229
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front expressions |
6230
|
|
|
|
|
|
|
# in Chapter 6: Crafting an Efficient Expression |
6231
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
6232
|
385
|
|
|
|
|
848
|
# in Chapter 7: Perl |
6233
|
385
|
|
|
|
|
737
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6234
|
385
|
|
|
|
|
1816
|
|
6235
|
|
|
|
|
|
|
my $e_script = ''; |
6236
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { # member |
6237
|
187362
|
|
|
|
|
305552
|
$e_script .= Sjis::escape_token(); |
6238
|
|
|
|
|
|
|
} |
6239
|
|
|
|
|
|
|
|
6240
|
|
|
|
|
|
|
return $e_script; |
6241
|
|
|
|
|
|
|
} |
6242
|
|
|
|
|
|
|
|
6243
|
|
|
|
|
|
|
# |
6244
|
|
|
|
|
|
|
# escape ShiftJIS token of script |
6245
|
|
|
|
|
|
|
# |
6246
|
|
|
|
|
|
|
sub Sjis::escape_token { |
6247
|
385
|
|
|
187362
|
0
|
6567
|
|
6248
|
|
|
|
|
|
|
# \n output here document |
6249
|
|
|
|
|
|
|
|
6250
|
|
|
|
|
|
|
my $ignore_modules = join('|', qw( |
6251
|
|
|
|
|
|
|
utf8 |
6252
|
|
|
|
|
|
|
bytes |
6253
|
|
|
|
|
|
|
charnames |
6254
|
|
|
|
|
|
|
I18N::Japanese |
6255
|
|
|
|
|
|
|
I18N::Collate |
6256
|
|
|
|
|
|
|
I18N::JExt |
6257
|
|
|
|
|
|
|
File::DosGlob |
6258
|
|
|
|
|
|
|
Wild |
6259
|
|
|
|
|
|
|
Wildcard |
6260
|
|
|
|
|
|
|
Japanese |
6261
|
|
|
|
|
|
|
)); |
6262
|
|
|
|
|
|
|
|
6263
|
|
|
|
|
|
|
# another member of Tag-team |
6264
|
|
|
|
|
|
|
# |
6265
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
6266
|
187362
|
100
|
100
|
|
|
230848
|
# in Chapter 7: Perl |
|
|
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
|
|
|
|
|
|
6267
|
187362
|
|
|
|
|
15097938
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6268
|
31549
|
100
|
|
|
|
40757
|
|
6269
|
31549
|
|
|
|
|
56992
|
if (/\G ( \n ) /oxgc) { # another member (and so on) |
6270
|
|
|
|
|
|
|
my $heredoc = ''; |
6271
|
197
|
|
|
|
|
308
|
if (scalar(@heredoc_delimiter) >= 1) { |
6272
|
197
|
|
|
|
|
452
|
$slash = 'm//'; |
6273
|
|
|
|
|
|
|
|
6274
|
|
|
|
|
|
|
$heredoc = join '', @heredoc; |
6275
|
197
|
|
|
|
|
387
|
@heredoc = (); |
6276
|
197
|
|
|
|
|
453
|
|
6277
|
|
|
|
|
|
|
# skip here document |
6278
|
205
|
|
|
|
|
1397
|
for my $heredoc_delimiter (@heredoc_delimiter) { |
6279
|
|
|
|
|
|
|
/\G .*? \n $heredoc_delimiter \n/xmsgc; |
6280
|
197
|
|
|
|
|
394
|
} |
6281
|
|
|
|
|
|
|
@heredoc_delimiter = (); |
6282
|
197
|
|
|
|
|
371
|
|
6283
|
|
|
|
|
|
|
$here_script = ''; |
6284
|
|
|
|
|
|
|
} |
6285
|
|
|
|
|
|
|
return "\n" . $heredoc; |
6286
|
31549
|
|
|
|
|
96404
|
} |
6287
|
|
|
|
|
|
|
|
6288
|
|
|
|
|
|
|
# ignore space, comment |
6289
|
|
|
|
|
|
|
elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; } |
6290
|
|
|
|
|
|
|
|
6291
|
|
|
|
|
|
|
# if (, elsif (, unless (, while (, until (, given (, and when ( |
6292
|
|
|
|
|
|
|
|
6293
|
|
|
|
|
|
|
# given, when |
6294
|
|
|
|
|
|
|
|
6295
|
|
|
|
|
|
|
# P.225 The given Statement |
6296
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
6297
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6298
|
|
|
|
|
|
|
|
6299
|
|
|
|
|
|
|
# P.133 The given Statement |
6300
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
6301
|
42807
|
|
|
|
|
136677
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6302
|
3797
|
|
|
|
|
6032
|
|
6303
|
|
|
|
|
|
|
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) { |
6304
|
|
|
|
|
|
|
$slash = 'm//'; |
6305
|
|
|
|
|
|
|
return $1; |
6306
|
|
|
|
|
|
|
} |
6307
|
|
|
|
|
|
|
|
6308
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ tr///; |
6309
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ s///; |
6310
|
|
|
|
|
|
|
|
6311
|
|
|
|
|
|
|
# state |
6312
|
|
|
|
|
|
|
|
6313
|
|
|
|
|
|
|
# P.68 Persistent, Private Variables |
6314
|
|
|
|
|
|
|
# in Chapter 4: Subroutines |
6315
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6316
|
|
|
|
|
|
|
|
6317
|
|
|
|
|
|
|
# P.160 Persistent Lexically Scoped Variables: state |
6318
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
6319
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6320
|
|
|
|
|
|
|
|
6321
|
3797
|
|
|
|
|
12208
|
# (and so on) |
6322
|
|
|
|
|
|
|
|
6323
|
170
|
50
|
|
|
|
505
|
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) { |
|
|
50
|
|
|
|
|
|
6324
|
170
|
|
|
|
|
6541
|
my $e_string = e_string($1); |
6325
|
0
|
|
|
|
|
0
|
|
6326
|
0
|
|
|
|
|
0
|
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6327
|
0
|
|
|
|
|
0
|
$tr_variable = $e_string . e_string($1); |
6328
|
|
|
|
|
|
|
$bind_operator = $2; |
6329
|
|
|
|
|
|
|
$slash = 'm//'; |
6330
|
0
|
|
|
|
|
0
|
return ''; |
6331
|
0
|
|
|
|
|
0
|
} |
6332
|
0
|
|
|
|
|
0
|
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6333
|
0
|
|
|
|
|
0
|
$sub_variable = $e_string . e_string($1); |
6334
|
|
|
|
|
|
|
$bind_operator = $2; |
6335
|
|
|
|
|
|
|
$slash = 'm//'; |
6336
|
0
|
|
|
|
|
0
|
return ''; |
6337
|
170
|
|
|
|
|
381
|
} |
6338
|
|
|
|
|
|
|
else { |
6339
|
|
|
|
|
|
|
$slash = 'div'; |
6340
|
|
|
|
|
|
|
return $e_string; |
6341
|
|
|
|
|
|
|
} |
6342
|
|
|
|
|
|
|
} |
6343
|
170
|
|
|
|
|
673
|
|
6344
|
4
|
|
|
|
|
10
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
6345
|
|
|
|
|
|
|
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
6346
|
|
|
|
|
|
|
$slash = 'div'; |
6347
|
|
|
|
|
|
|
return q{Esjis::PREMATCH()}; |
6348
|
|
|
|
|
|
|
} |
6349
|
4
|
|
|
|
|
18
|
|
6350
|
28
|
|
|
|
|
59
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
6351
|
|
|
|
|
|
|
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
6352
|
|
|
|
|
|
|
$slash = 'div'; |
6353
|
|
|
|
|
|
|
return q{Esjis::MATCH()}; |
6354
|
|
|
|
|
|
|
} |
6355
|
28
|
|
|
|
|
91
|
|
6356
|
1
|
|
|
|
|
3
|
# $', ${'} --> $', ${'} |
6357
|
|
|
|
|
|
|
elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) { |
6358
|
|
|
|
|
|
|
$slash = 'div'; |
6359
|
|
|
|
|
|
|
return $1; |
6360
|
|
|
|
|
|
|
} |
6361
|
1
|
|
|
|
|
3
|
|
6362
|
3
|
|
|
|
|
6
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
6363
|
|
|
|
|
|
|
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
6364
|
|
|
|
|
|
|
$slash = 'div'; |
6365
|
|
|
|
|
|
|
return q{Esjis::POSTMATCH()}; |
6366
|
|
|
|
|
|
|
} |
6367
|
|
|
|
|
|
|
|
6368
|
|
|
|
|
|
|
# scalar variable $scalar =~ tr///; |
6369
|
|
|
|
|
|
|
# scalar variable $scalar =~ s///; |
6370
|
3
|
|
|
|
|
10
|
# substr() =~ tr///; |
6371
|
|
|
|
|
|
|
# substr() =~ s///; |
6372
|
2883
|
100
|
|
|
|
6880
|
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) { |
|
|
100
|
|
|
|
|
|
6373
|
2883
|
|
|
|
|
12110
|
my $scalar = e_string($1); |
6374
|
9
|
|
|
|
|
15
|
|
6375
|
9
|
|
|
|
|
16
|
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6376
|
9
|
|
|
|
|
11
|
$tr_variable = $scalar; |
6377
|
|
|
|
|
|
|
$bind_operator = $1; |
6378
|
|
|
|
|
|
|
$slash = 'm//'; |
6379
|
9
|
|
|
|
|
25
|
return ''; |
6380
|
254
|
|
|
|
|
439
|
} |
6381
|
254
|
|
|
|
|
513
|
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6382
|
254
|
|
|
|
|
437
|
$sub_variable = $scalar; |
6383
|
|
|
|
|
|
|
$bind_operator = $1; |
6384
|
|
|
|
|
|
|
$slash = 'm//'; |
6385
|
254
|
|
|
|
|
762
|
return ''; |
6386
|
2620
|
|
|
|
|
4056
|
} |
6387
|
|
|
|
|
|
|
else { |
6388
|
|
|
|
|
|
|
$slash = 'div'; |
6389
|
|
|
|
|
|
|
return $scalar; |
6390
|
|
|
|
|
|
|
} |
6391
|
|
|
|
|
|
|
} |
6392
|
2620
|
|
|
|
|
8497
|
|
6393
|
|
|
|
|
|
|
# end of statement |
6394
|
|
|
|
|
|
|
elsif (/\G ( [,;] ) /oxgc) { |
6395
|
12269
|
|
|
|
|
20441
|
$slash = 'm//'; |
6396
|
|
|
|
|
|
|
|
6397
|
|
|
|
|
|
|
# clear tr/// variable |
6398
|
12269
|
|
|
|
|
15010
|
$tr_variable = ''; |
6399
|
|
|
|
|
|
|
|
6400
|
12269
|
|
|
|
|
20623
|
# clear s/// variable |
6401
|
|
|
|
|
|
|
$sub_variable = ''; |
6402
|
12269
|
|
|
|
|
14067
|
|
6403
|
|
|
|
|
|
|
$bind_operator = ''; |
6404
|
|
|
|
|
|
|
|
6405
|
|
|
|
|
|
|
return $1; |
6406
|
|
|
|
|
|
|
} |
6407
|
12269
|
|
|
|
|
44322
|
|
6408
|
|
|
|
|
|
|
# bareword |
6409
|
|
|
|
|
|
|
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
6410
|
|
|
|
|
|
|
return $1; |
6411
|
|
|
|
|
|
|
} |
6412
|
0
|
|
|
|
|
0
|
|
6413
|
2
|
|
|
|
|
32
|
# $0 --> $0 |
6414
|
|
|
|
|
|
|
elsif (/\G ( \$ 0 ) /oxmsgc) { |
6415
|
|
|
|
|
|
|
$slash = 'div'; |
6416
|
2
|
|
|
|
|
14
|
return $1; |
6417
|
0
|
|
|
|
|
0
|
} |
6418
|
|
|
|
|
|
|
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
6419
|
|
|
|
|
|
|
$slash = 'div'; |
6420
|
|
|
|
|
|
|
return $1; |
6421
|
|
|
|
|
|
|
} |
6422
|
0
|
|
|
|
|
0
|
|
6423
|
1
|
|
|
|
|
3
|
# $$ --> $$ |
6424
|
|
|
|
|
|
|
elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
6425
|
|
|
|
|
|
|
$slash = 'div'; |
6426
|
|
|
|
|
|
|
return $1; |
6427
|
|
|
|
|
|
|
} |
6428
|
|
|
|
|
|
|
|
6429
|
1
|
|
|
|
|
3
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6430
|
219
|
|
|
|
|
364
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6431
|
|
|
|
|
|
|
elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
6432
|
|
|
|
|
|
|
$slash = 'div'; |
6433
|
219
|
|
|
|
|
570
|
return e_capture($1); |
6434
|
0
|
|
|
|
|
0
|
} |
6435
|
|
|
|
|
|
|
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
6436
|
|
|
|
|
|
|
$slash = 'div'; |
6437
|
|
|
|
|
|
|
return e_capture($1); |
6438
|
|
|
|
|
|
|
} |
6439
|
0
|
|
|
|
|
0
|
|
6440
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6441
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
6442
|
|
|
|
|
|
|
$slash = 'div'; |
6443
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6444
|
|
|
|
|
|
|
} |
6445
|
0
|
|
|
|
|
0
|
|
6446
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
6447
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
6448
|
|
|
|
|
|
|
$slash = 'div'; |
6449
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6450
|
|
|
|
|
|
|
} |
6451
|
0
|
|
|
|
|
0
|
|
6452
|
0
|
|
|
|
|
0
|
# $$foo |
6453
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
6454
|
|
|
|
|
|
|
$slash = 'div'; |
6455
|
|
|
|
|
|
|
return e_capture($1); |
6456
|
|
|
|
|
|
|
} |
6457
|
0
|
|
|
|
|
0
|
|
6458
|
0
|
|
|
|
|
0
|
# ${ foo } |
6459
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) { |
6460
|
|
|
|
|
|
|
$slash = 'div'; |
6461
|
|
|
|
|
|
|
return '${' . $1 . '}'; |
6462
|
|
|
|
|
|
|
} |
6463
|
0
|
|
|
|
|
0
|
|
6464
|
0
|
|
|
|
|
0
|
# ${ ... } |
6465
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
6466
|
|
|
|
|
|
|
$slash = 'div'; |
6467
|
|
|
|
|
|
|
return e_capture($1); |
6468
|
|
|
|
|
|
|
} |
6469
|
|
|
|
|
|
|
|
6470
|
0
|
|
|
|
|
0
|
# variable or function |
6471
|
605
|
|
|
|
|
1151
|
# $ @ % & * $ # |
6472
|
|
|
|
|
|
|
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) { |
6473
|
|
|
|
|
|
|
$slash = 'div'; |
6474
|
|
|
|
|
|
|
return $1; |
6475
|
|
|
|
|
|
|
} |
6476
|
605
|
|
|
|
|
2283
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
6477
|
103
|
|
|
|
|
229
|
# $ @ # \ ' " / ? ( ) [ ] < > |
6478
|
|
|
|
|
|
|
elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
6479
|
|
|
|
|
|
|
$slash = 'div'; |
6480
|
|
|
|
|
|
|
return $1; |
6481
|
|
|
|
|
|
|
} |
6482
|
103
|
|
|
|
|
400
|
|
6483
|
|
|
|
|
|
|
# while () |
6484
|
|
|
|
|
|
|
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) { |
6485
|
|
|
|
|
|
|
return $1; |
6486
|
|
|
|
|
|
|
} |
6487
|
|
|
|
|
|
|
|
6488
|
|
|
|
|
|
|
# while () --- glob |
6489
|
|
|
|
|
|
|
|
6490
|
0
|
|
|
|
|
0
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6491
|
|
|
|
|
|
|
|
6492
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^\x81-\x9F\xE0-\xFC>\0\a\e\f\n\r\t]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+?) > (?>\s*) \) \b /oxgc) { |
6493
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob("' . $1 . '"))'; |
6494
|
|
|
|
|
|
|
} |
6495
|
0
|
|
|
|
|
0
|
|
6496
|
|
|
|
|
|
|
# while (glob) |
6497
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) { |
6498
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob_)'; |
6499
|
|
|
|
|
|
|
} |
6500
|
0
|
|
|
|
|
0
|
|
6501
|
|
|
|
|
|
|
# while (glob(WILDCARD)) |
6502
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) { |
6503
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob'; |
6504
|
0
|
|
|
|
|
0
|
} |
|
484
|
|
|
|
|
1143
|
|
6505
|
|
|
|
|
|
|
|
6506
|
|
|
|
|
|
|
# doit if, doit unless, doit while, doit until, doit for, doit when |
6507
|
484
|
|
|
|
|
2376
|
elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; } |
|
19
|
|
|
|
|
48
|
|
6508
|
19
|
|
|
|
|
83
|
|
|
0
|
|
|
|
|
0
|
|
6509
|
0
|
|
|
|
|
0
|
# subroutines of package Esjis |
|
13
|
|
|
|
|
25
|
|
6510
|
13
|
|
|
|
|
42
|
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
6511
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
114
|
|
|
|
|
199
|
|
6512
|
114
|
|
|
|
|
408
|
elsif (/\G \b Sjis::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
2
|
|
|
|
|
4
|
|
6513
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; } |
|
2
|
|
|
|
|
5
|
|
6514
|
2
|
|
|
|
|
6
|
elsif (/\G \b Sjis::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Sjis::escape'; } |
|
2
|
|
|
|
|
3
|
|
6515
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; } |
|
0
|
|
|
|
|
0
|
|
6516
|
0
|
|
|
|
|
0
|
elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::chop'; } |
|
2
|
|
|
|
|
3
|
|
6517
|
2
|
|
|
|
|
11
|
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; } |
|
2
|
|
|
|
|
3
|
|
6518
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; } |
|
2
|
|
|
|
|
4
|
|
6519
|
2
|
|
|
|
|
5
|
elsif (/\G \b Sjis::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Sjis::index'; } |
|
0
|
|
|
|
|
0
|
|
6520
|
0
|
|
|
|
|
0
|
elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::index'; } |
|
2
|
|
|
|
|
3
|
|
6521
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; } |
|
2
|
|
|
|
|
5
|
|
6522
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; } |
|
1
|
|
|
|
|
2
|
|
6523
|
1
|
|
|
|
|
4
|
elsif (/\G \b Sjis::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Sjis::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6524
|
0
|
|
|
|
|
0
|
elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6525
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lc'; } |
|
0
|
|
|
|
|
0
|
|
6526
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lcfirst'; } |
|
3
|
|
|
|
|
7
|
|
6527
|
|
|
|
|
|
|
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::uc'; } |
6528
|
|
|
|
|
|
|
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::ucfirst'; } |
6529
|
|
|
|
|
|
|
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::fc'; } |
6530
|
|
|
|
|
|
|
|
6531
|
|
|
|
|
|
|
# stacked file test operators |
6532
|
|
|
|
|
|
|
|
6533
|
|
|
|
|
|
|
# P.179 File Test Operators |
6534
|
|
|
|
|
|
|
# in Chapter 12: File Tests |
6535
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6536
|
|
|
|
|
|
|
|
6537
|
|
|
|
|
|
|
# P.106 Named Unary and File Test Operators |
6538
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
6539
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6540
|
|
|
|
|
|
|
|
6541
|
3
|
|
|
|
|
14
|
# (and so on) |
|
0
|
|
|
|
|
0
|
|
6542
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6543
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6544
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6545
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6546
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6547
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
3
|
|
6548
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6549
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6550
|
1
|
|
|
|
|
6
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
5
|
|
|
|
|
11
|
|
6551
|
5
|
|
|
|
|
22
|
|
|
0
|
|
|
|
|
0
|
|
6552
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6553
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6554
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6555
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6556
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
3
|
|
6557
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6558
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6559
|
1
|
|
|
|
|
7
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6560
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6561
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6562
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6563
|
|
|
|
|
|
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
6564
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $slash = 'm//'; return "Esjis::filetest qw($1),"; } |
|
0
|
|
|
|
|
0
|
|
6565
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6566
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6567
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6568
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6569
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6570
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
5
|
|
6571
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
6572
|
2
|
|
|
|
|
10
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
103
|
|
|
|
|
230
|
|
6573
|
103
|
|
|
|
|
310
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6574
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6575
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6576
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6577
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6578
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
4
|
|
6579
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6580
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6581
|
2
|
|
|
|
|
21
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
6
|
|
|
|
|
13
|
|
6582
|
6
|
|
|
|
|
32
|
|
|
0
|
|
|
|
|
0
|
|
6583
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6584
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Esjis::$1($2)"; } |
|
50
|
|
|
|
|
94
|
|
6585
|
50
|
|
|
|
|
264
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Esjis::$1($2)"; } |
|
2
|
|
|
|
|
5
|
|
6586
|
2
|
|
|
|
|
11
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return "Esjis::$1"; } |
|
1
|
|
|
|
|
4
|
|
6587
|
1
|
|
|
|
|
4
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Esjis::$1(::"."$2)"; } |
|
3
|
|
|
|
|
8
|
|
6588
|
|
|
|
|
|
|
elsif (/\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-t $2"; } |
6589
|
|
|
|
|
|
|
elsif (/\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lstat'; } |
6590
|
3
|
|
|
|
|
12
|
elsif (/\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::stat'; } |
|
0
|
|
|
|
|
0
|
|
6591
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6592
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
6593
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6594
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6595
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6596
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6597
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
6598
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6599
|
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
|
|
6600
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6601
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6602
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6603
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6604
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6605
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6606
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6607
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6608
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6609
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6610
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
6611
|
|
|
|
|
|
|
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; } |
6612
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; } |
|
2
|
|
|
|
|
6
|
|
6613
|
2
|
|
|
|
|
6
|
elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; } |
|
2
|
|
|
|
|
5
|
|
6614
|
2
|
|
|
|
|
7
|
|
|
36
|
|
|
|
|
71
|
|
6615
|
36
|
|
|
|
|
144
|
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; } |
|
2
|
|
|
|
|
5
|
|
6616
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
7
|
|
6617
|
2
|
|
|
|
|
9
|
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::chr'; } |
|
8
|
|
|
|
|
27
|
|
6618
|
8
|
|
|
|
|
34
|
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; } |
|
0
|
|
|
|
|
0
|
|
6619
|
0
|
|
|
|
|
0
|
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; } |
|
0
|
|
|
|
|
0
|
|
6620
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::glob'; } |
|
0
|
|
|
|
|
0
|
|
6621
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lc_'; } |
|
0
|
|
|
|
|
0
|
|
6622
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lcfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6623
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::uc_'; } |
|
0
|
|
|
|
|
0
|
|
6624
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::ucfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6625
|
|
|
|
|
|
|
elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::fc_'; } |
6626
|
0
|
|
|
|
|
0
|
elsif (/\G \b lstat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lstat_'; } |
|
0
|
|
|
|
|
0
|
|
6627
|
|
|
|
|
|
|
elsif (/\G \b stat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::stat_'; } |
6628
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6629
|
|
|
|
|
|
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Esjis::filetest_(qw($1))"; } |
6630
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) |
|
0
|
|
|
|
|
0
|
|
6631
|
|
|
|
|
|
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Esjis::${1}_"; } |
6632
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6633
|
0
|
|
|
|
|
0
|
elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; } |
|
0
|
|
|
|
|
0
|
|
6634
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6635
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; } |
|
0
|
|
|
|
|
0
|
|
6636
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
6
|
|
6637
|
2
|
|
|
|
|
9
|
elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::chr_'; } |
|
0
|
|
|
|
|
0
|
|
6638
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; } |
|
4
|
|
|
|
|
9
|
|
6639
|
4
|
|
|
|
|
17
|
elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; } |
|
8
|
|
|
|
|
27
|
|
6640
|
8
|
|
|
|
|
40
|
elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::glob_'; } |
|
2
|
|
|
|
|
7
|
|
6641
|
2
|
|
|
|
|
11
|
elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; } |
|
0
|
|
|
|
|
0
|
|
6642
|
0
|
|
|
|
|
0
|
elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; } |
|
87
|
|
|
|
|
235
|
|
6643
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Esjis::opendir$1*"; } |
6644
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Esjis::opendir$1*"; } |
6645
|
|
|
|
|
|
|
elsif (/\G \b unlink \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::unlink'; } |
6646
|
87
|
|
|
|
|
378
|
|
6647
|
|
|
|
|
|
|
# chdir |
6648
|
3
|
|
|
|
|
8
|
elsif (/\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
6649
|
|
|
|
|
|
|
$slash = 'm//'; |
6650
|
3
|
|
|
|
|
4
|
|
6651
|
3
|
|
|
|
|
12
|
my $e = 'Esjis::chdir'; |
6652
|
|
|
|
|
|
|
|
6653
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6654
|
|
|
|
|
|
|
$e .= $1; |
6655
|
3
|
50
|
|
|
|
13
|
} |
|
3
|
100
|
|
|
|
251
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6656
|
|
|
|
|
|
|
|
6657
|
|
|
|
|
|
|
# end of chdir |
6658
|
0
|
|
|
|
|
0
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return $e; } |
6659
|
|
|
|
|
|
|
|
6660
|
|
|
|
|
|
|
# chdir scalar value |
6661
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return $e . e_string($1); } |
6662
|
1
|
0
|
|
|
|
3
|
|
|
0
|
|
|
|
|
0
|
|
6663
|
|
|
|
|
|
|
# chdir qq// |
6664
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qq) \b /oxgc) { |
6665
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6666
|
0
|
|
|
|
|
0
|
else { |
6667
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6668
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6669
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq ( ) --> qr ( ) |
6670
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq { } --> qr { } |
6671
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq [ ] --> qr [ ] |
6672
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq < > --> qr < > |
6673
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq','{','}',$2); } # qq | | --> qr { } |
6674
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq * * --> qr * * |
6675
|
|
|
|
|
|
|
} |
6676
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6677
|
|
|
|
|
|
|
} |
6678
|
|
|
|
|
|
|
} |
6679
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6680
|
|
|
|
|
|
|
# chdir q// |
6681
|
0
|
|
|
|
|
0
|
elsif (/\G \b (q) \b /oxgc) { |
6682
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6683
|
0
|
|
|
|
|
0
|
else { |
6684
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6685
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6686
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q ( ) --> qr ( ) |
6687
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q { } --> qr { } |
6688
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q [ ] --> qr [ ] |
6689
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q < > --> qr < > |
6690
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q','{','}',$2); } # q | | --> qr { } |
6691
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q * * --> qr * * |
6692
|
|
|
|
|
|
|
} |
6693
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6694
|
|
|
|
|
|
|
} |
6695
|
|
|
|
|
|
|
} |
6696
|
0
|
|
|
|
|
0
|
|
6697
|
2
|
|
|
|
|
5
|
# chdir '' |
6698
|
2
|
50
|
|
|
|
8
|
elsif (/\G (\') /oxgc) { |
|
13
|
50
|
|
|
|
58
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6699
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6700
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6701
|
2
|
|
|
|
|
6
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6702
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
6703
|
11
|
|
|
|
|
23
|
elsif (/\G \' /oxgc) { return $e . e_chdir_q('',"'","'",$q_string); } |
6704
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6705
|
|
|
|
|
|
|
} |
6706
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6707
|
|
|
|
|
|
|
} |
6708
|
0
|
|
|
|
|
0
|
|
6709
|
0
|
|
|
|
|
0
|
# chdir "" |
6710
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6711
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6712
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6713
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6714
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
6715
|
0
|
|
|
|
|
0
|
elsif (/\G \" /oxgc) { return $e . e_chdir('','"','"',$qq_string); } |
6716
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6717
|
|
|
|
|
|
|
} |
6718
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6719
|
|
|
|
|
|
|
} |
6720
|
|
|
|
|
|
|
} |
6721
|
0
|
|
|
|
|
0
|
|
6722
|
|
|
|
|
|
|
# split |
6723
|
404
|
|
|
|
|
1087
|
elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
6724
|
404
|
|
|
|
|
877
|
$slash = 'm//'; |
6725
|
404
|
|
|
|
|
1723
|
|
6726
|
|
|
|
|
|
|
my $e = ''; |
6727
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6728
|
|
|
|
|
|
|
$e .= $1; |
6729
|
401
|
100
|
|
|
|
1868
|
} |
|
404
|
100
|
|
|
|
20510
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6730
|
|
|
|
|
|
|
|
6731
|
|
|
|
|
|
|
# end of split |
6732
|
3
|
|
|
|
|
19
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Esjis::split' . $e; } |
6733
|
|
|
|
|
|
|
|
6734
|
|
|
|
|
|
|
# split scalar value |
6735
|
1
|
|
|
|
|
5
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Esjis::split' . $e . e_string($1); } |
6736
|
0
|
|
|
|
|
0
|
|
6737
|
0
|
|
|
|
|
0
|
# split literal space |
6738
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Esjis::split' . $e . qq {qq$1 $2}; } |
6739
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6740
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6741
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6742
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6743
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6744
|
0
|
|
|
|
|
0
|
elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Esjis::split' . $e . qq {q$1 $2}; } |
6745
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6746
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6747
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6748
|
13
|
|
|
|
|
112
|
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6749
|
|
|
|
|
|
|
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6750
|
|
|
|
|
|
|
elsif (/\G ' [ ] ' /oxgc) { return 'Esjis::split' . $e . qq {' '}; } |
6751
|
|
|
|
|
|
|
elsif (/\G " [ ] " /oxgc) { return 'Esjis::split' . $e . qq {" "}; } |
6752
|
2
|
0
|
|
|
|
13
|
|
|
0
|
|
|
|
|
0
|
|
6753
|
|
|
|
|
|
|
# split qq// |
6754
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qq) \b /oxgc) { |
6755
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6756
|
0
|
|
|
|
|
0
|
else { |
6757
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6758
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6759
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( ) |
6760
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { } |
6761
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ] |
6762
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < > |
6763
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { } |
6764
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * * |
6765
|
|
|
|
|
|
|
} |
6766
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6767
|
|
|
|
|
|
|
} |
6768
|
|
|
|
|
|
|
} |
6769
|
0
|
50
|
|
|
|
0
|
|
|
124
|
|
|
|
|
957
|
|
6770
|
|
|
|
|
|
|
# split qr// |
6771
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qr) \b /oxgc) { |
6772
|
124
|
50
|
|
|
|
346
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# # |
|
124
|
50
|
|
|
|
6720
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6773
|
0
|
|
|
|
|
0
|
else { |
6774
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6775
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6776
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( ) |
6777
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { } |
6778
|
56
|
|
|
|
|
229
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ] |
6779
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < > |
6780
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' ' |
6781
|
68
|
|
|
|
|
342
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { } |
6782
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * * |
6783
|
|
|
|
|
|
|
} |
6784
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6785
|
|
|
|
|
|
|
} |
6786
|
|
|
|
|
|
|
} |
6787
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6788
|
|
|
|
|
|
|
# split q// |
6789
|
0
|
|
|
|
|
0
|
elsif (/\G \b (q) \b /oxgc) { |
6790
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6791
|
0
|
|
|
|
|
0
|
else { |
6792
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6793
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6794
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( ) |
6795
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { } |
6796
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ] |
6797
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < > |
6798
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { } |
6799
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * * |
6800
|
|
|
|
|
|
|
} |
6801
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6802
|
|
|
|
|
|
|
} |
6803
|
|
|
|
|
|
|
} |
6804
|
0
|
50
|
|
|
|
0
|
|
|
136
|
|
|
|
|
1206
|
|
6805
|
|
|
|
|
|
|
# split m// |
6806
|
0
|
|
|
|
|
0
|
elsif (/\G \b (m) \b /oxgc) { |
6807
|
136
|
50
|
|
|
|
391
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # # |
|
136
|
50
|
|
|
|
7549
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6808
|
0
|
|
|
|
|
0
|
else { |
6809
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6810
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6811
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( ) |
6812
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { } |
6813
|
56
|
|
|
|
|
266
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ] |
6814
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < > |
6815
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' ' |
6816
|
80
|
|
|
|
|
422
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { } |
6817
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * * |
6818
|
|
|
|
|
|
|
} |
6819
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6820
|
|
|
|
|
|
|
} |
6821
|
|
|
|
|
|
|
} |
6822
|
0
|
|
|
|
|
0
|
|
6823
|
0
|
|
|
|
|
0
|
# split '' |
6824
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6825
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6826
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6827
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6828
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
6829
|
0
|
|
|
|
|
0
|
elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' ' |
6830
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6831
|
|
|
|
|
|
|
} |
6832
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6833
|
|
|
|
|
|
|
} |
6834
|
0
|
|
|
|
|
0
|
|
6835
|
0
|
|
|
|
|
0
|
# split "" |
6836
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6837
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6838
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6839
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6840
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
6841
|
0
|
|
|
|
|
0
|
elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " " |
6842
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6843
|
|
|
|
|
|
|
} |
6844
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6845
|
|
|
|
|
|
|
} |
6846
|
0
|
|
|
|
|
0
|
|
6847
|
125
|
|
|
|
|
338
|
# split // |
6848
|
125
|
50
|
|
|
|
393
|
elsif (/\G (\/) /oxgc) { |
|
558
|
50
|
|
|
|
3100
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6849
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
6850
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6851
|
125
|
|
|
|
|
611
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
6852
|
|
|
|
|
|
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
6853
|
433
|
|
|
|
|
1206
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / / |
6854
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
6855
|
|
|
|
|
|
|
} |
6856
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6857
|
|
|
|
|
|
|
} |
6858
|
|
|
|
|
|
|
} |
6859
|
|
|
|
|
|
|
|
6860
|
|
|
|
|
|
|
# tr/// or y/// |
6861
|
|
|
|
|
|
|
|
6862
|
|
|
|
|
|
|
# about [cdsrbB]* (/B modifier) |
6863
|
|
|
|
|
|
|
# |
6864
|
|
|
|
|
|
|
# P.559 appendix C |
6865
|
|
|
|
|
|
|
# of ISBN 4-89052-384-7 Programming perl |
6866
|
0
|
|
|
|
|
0
|
# (Japanese title is: Perl puroguramingu) |
6867
|
|
|
|
|
|
|
|
6868
|
|
|
|
|
|
|
elsif (/\G \b ( tr | y ) \b /oxgc) { |
6869
|
11
|
50
|
|
|
|
30
|
my $ope = $1; |
6870
|
11
|
|
|
|
|
155
|
|
6871
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
6872
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # # |
6873
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6874
|
0
|
|
|
|
|
0
|
return e_tr(@tr,'',$4,$6); |
6875
|
11
|
|
|
|
|
19
|
} |
6876
|
11
|
50
|
|
|
|
31
|
else { |
|
11
|
50
|
|
|
|
755
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6877
|
|
|
|
|
|
|
my $e = ''; |
6878
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6879
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6880
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6881
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6882
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6883
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6884
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( ) |
6885
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { } |
6886
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ] |
6887
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < > |
6888
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * * |
6889
|
|
|
|
|
|
|
} |
6890
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6891
|
0
|
|
|
|
|
0
|
} |
6892
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6893
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6894
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6895
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6896
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( ) |
6897
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { } |
6898
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ] |
6899
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < > |
6900
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * * |
6901
|
|
|
|
|
|
|
} |
6902
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6903
|
0
|
|
|
|
|
0
|
} |
6904
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6905
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6906
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6907
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6908
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( ) |
6909
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { } |
6910
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ] |
6911
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < > |
6912
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * * |
6913
|
|
|
|
|
|
|
} |
6914
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6915
|
0
|
|
|
|
|
0
|
} |
6916
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6917
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6918
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6919
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6920
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( ) |
6921
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { } |
6922
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ] |
6923
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < > |
6924
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * * |
6925
|
|
|
|
|
|
|
} |
6926
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6927
|
0
|
|
|
|
|
0
|
} |
6928
|
11
|
|
|
|
|
41
|
# $1 $2 $3 $4 $5 $6 |
6929
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * * |
6930
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6931
|
11
|
|
|
|
|
34
|
return e_tr(@tr,'',$4,$6); |
6932
|
|
|
|
|
|
|
} |
6933
|
|
|
|
|
|
|
} |
6934
|
|
|
|
|
|
|
die __FILE__, ": Transliteration pattern not terminated\n"; |
6935
|
|
|
|
|
|
|
} |
6936
|
|
|
|
|
|
|
} |
6937
|
0
|
|
|
|
|
0
|
|
6938
|
|
|
|
|
|
|
# qq// |
6939
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6940
|
5900
|
100
|
|
|
|
17177
|
my $ope = $1; |
6941
|
5900
|
|
|
|
|
12598
|
|
6942
|
40
|
|
|
|
|
71
|
# if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# # |
6943
|
40
|
100
|
|
|
|
97
|
if (/\G (\#) /oxgc) { # qq# # |
|
1948
|
50
|
|
|
|
5321
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6944
|
80
|
|
|
|
|
140
|
my $qq_string = ''; |
6945
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6946
|
40
|
|
|
|
|
114
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6947
|
|
|
|
|
|
|
elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; } |
6948
|
1828
|
|
|
|
|
3357
|
elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); } |
6949
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6950
|
|
|
|
|
|
|
} |
6951
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6952
|
0
|
|
|
|
|
0
|
} |
6953
|
5860
|
|
|
|
|
8301
|
|
6954
|
5860
|
50
|
|
|
|
15015
|
else { |
|
5860
|
50
|
|
|
|
24042
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6955
|
|
|
|
|
|
|
my $e = ''; |
6956
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6957
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6958
|
0
|
|
|
|
|
0
|
|
6959
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( ) |
6960
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { # qq ( ) |
6961
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6962
|
0
|
|
|
|
|
0
|
local $nest = 1; |
6963
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
6964
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6965
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6966
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; } |
6967
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
6968
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); } |
6969
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
6970
|
0
|
|
|
|
|
0
|
} |
6971
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6972
|
|
|
|
|
|
|
} |
6973
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6974
|
|
|
|
|
|
|
} |
6975
|
0
|
|
|
|
|
0
|
|
6976
|
5778
|
|
|
|
|
8555
|
# elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { } |
6977
|
5778
|
|
|
|
|
8898
|
elsif (/\G (\{) /oxgc) { # qq { } |
6978
|
5778
|
100
|
|
|
|
12576
|
my $qq_string = ''; |
|
246074
|
50
|
|
|
|
808349
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6979
|
720
|
|
|
|
|
1431
|
local $nest = 1; |
6980
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
1384
|
|
|
|
|
2129
|
|
6981
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6982
|
1384
|
100
|
|
|
|
2647
|
elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; } |
|
7162
|
|
|
|
|
12054
|
|
6983
|
5778
|
|
|
|
|
13985
|
elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; } |
6984
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
6985
|
1384
|
|
|
|
|
2994
|
if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); } |
6986
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
6987
|
236808
|
|
|
|
|
477301
|
} |
6988
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6989
|
|
|
|
|
|
|
} |
6990
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6991
|
|
|
|
|
|
|
} |
6992
|
0
|
|
|
|
|
0
|
|
6993
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ] |
6994
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # qq [ ] |
6995
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6996
|
0
|
|
|
|
|
0
|
local $nest = 1; |
6997
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
6998
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6999
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7000
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; } |
7001
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
7002
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); } |
7003
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
7004
|
0
|
|
|
|
|
0
|
} |
7005
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7006
|
|
|
|
|
|
|
} |
7007
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7008
|
|
|
|
|
|
|
} |
7009
|
0
|
|
|
|
|
0
|
|
7010
|
62
|
|
|
|
|
113
|
# elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < > |
7011
|
62
|
|
|
|
|
113
|
elsif (/\G (\<) /oxgc) { # qq < > |
7012
|
62
|
100
|
|
|
|
191
|
my $qq_string = ''; |
|
2040
|
50
|
|
|
|
7217
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7013
|
22
|
|
|
|
|
63
|
local $nest = 1; |
7014
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
2
|
|
|
|
|
4
|
|
7015
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7016
|
2
|
100
|
|
|
|
4
|
elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; } |
|
64
|
|
|
|
|
135
|
|
7017
|
62
|
|
|
|
|
166
|
elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; } |
7018
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
7019
|
2
|
|
|
|
|
4
|
if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); } |
7020
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
7021
|
1952
|
|
|
|
|
3862
|
} |
7022
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7023
|
|
|
|
|
|
|
} |
7024
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7025
|
|
|
|
|
|
|
} |
7026
|
0
|
|
|
|
|
0
|
|
7027
|
20
|
|
|
|
|
32
|
# elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * * |
7028
|
20
|
|
|
|
|
21
|
elsif (/\G (\S) /oxgc) { # qq * * |
7029
|
20
|
50
|
|
|
|
39
|
my $delimiter = $1; |
|
840
|
50
|
|
|
|
2270
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7030
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
7031
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7032
|
20
|
|
|
|
|
49
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7033
|
|
|
|
|
|
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; } |
7034
|
820
|
|
|
|
|
1494
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); } |
7035
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7036
|
|
|
|
|
|
|
} |
7037
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7038
|
|
|
|
|
|
|
} |
7039
|
|
|
|
|
|
|
} |
7040
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7041
|
|
|
|
|
|
|
} |
7042
|
|
|
|
|
|
|
} |
7043
|
0
|
|
|
|
|
0
|
|
7044
|
184
|
50
|
|
|
|
525
|
# qr// |
7045
|
184
|
|
|
|
|
808
|
elsif (/\G \b (qr) \b /oxgc) { |
7046
|
|
|
|
|
|
|
my $ope = $1; |
7047
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # # |
7048
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
7049
|
184
|
|
|
|
|
267
|
} |
7050
|
184
|
50
|
|
|
|
498
|
else { |
|
184
|
50
|
|
|
|
4656
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7051
|
0
|
|
|
|
|
0
|
my $e = ''; |
7052
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7053
|
1
|
|
|
|
|
7
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7054
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( ) |
7055
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { } |
7056
|
76
|
|
|
|
|
257
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ] |
7057
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < > |
7058
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' ' |
7059
|
107
|
|
|
|
|
345
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { } |
7060
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * * |
7061
|
|
|
|
|
|
|
} |
7062
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7063
|
|
|
|
|
|
|
} |
7064
|
|
|
|
|
|
|
} |
7065
|
0
|
|
|
|
|
0
|
|
7066
|
34
|
50
|
|
|
|
116
|
# qw// |
7067
|
34
|
|
|
|
|
125
|
elsif (/\G \b (qw) \b /oxgc) { |
7068
|
|
|
|
|
|
|
my $ope = $1; |
7069
|
|
|
|
|
|
|
if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# # |
7070
|
0
|
|
|
|
|
0
|
return e_qw($ope,$1,$3,$2); |
7071
|
34
|
|
|
|
|
70
|
} |
7072
|
34
|
50
|
|
|
|
134
|
else { |
|
34
|
50
|
|
|
|
237
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7073
|
|
|
|
|
|
|
my $e = ''; |
7074
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7075
|
34
|
|
|
|
|
132
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7076
|
|
|
|
|
|
|
|
7077
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
7078
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
7079
|
|
|
|
|
|
|
|
7080
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
7081
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
7082
|
|
|
|
|
|
|
|
7083
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
7084
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
7085
|
|
|
|
|
|
|
|
7086
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
7087
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
7088
|
|
|
|
|
|
|
|
7089
|
0
|
|
|
|
|
0
|
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
7090
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
7091
|
|
|
|
|
|
|
} |
7092
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7093
|
|
|
|
|
|
|
} |
7094
|
|
|
|
|
|
|
} |
7095
|
0
|
|
|
|
|
0
|
|
7096
|
3
|
50
|
|
|
|
11
|
# qx// |
7097
|
3
|
|
|
|
|
71
|
elsif (/\G \b (qx) \b /oxgc) { |
7098
|
|
|
|
|
|
|
my $ope = $1; |
7099
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
7100
|
0
|
|
|
|
|
0
|
return e_qq($ope,$1,$3,$2); |
7101
|
3
|
|
|
|
|
30
|
} |
7102
|
3
|
50
|
|
|
|
12
|
else { |
|
3
|
50
|
|
|
|
408
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7103
|
0
|
|
|
|
|
0
|
my $e = ''; |
7104
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7105
|
2
|
|
|
|
|
8
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7106
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( ) |
7107
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { } |
7108
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ] |
7109
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < > |
7110
|
1
|
|
|
|
|
5
|
elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' ' |
7111
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * * |
7112
|
|
|
|
|
|
|
} |
7113
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7114
|
|
|
|
|
|
|
} |
7115
|
|
|
|
|
|
|
} |
7116
|
0
|
|
|
|
|
0
|
|
7117
|
|
|
|
|
|
|
# q// |
7118
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
7119
|
|
|
|
|
|
|
my $ope = $1; |
7120
|
|
|
|
|
|
|
|
7121
|
|
|
|
|
|
|
# if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# # |
7122
|
|
|
|
|
|
|
|
7123
|
607
|
50
|
|
|
|
2043
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7124
|
607
|
|
|
|
|
1991
|
# (and so on) |
7125
|
0
|
|
|
|
|
0
|
|
7126
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) /oxgc) { # q# # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7127
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
7128
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7129
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7130
|
|
|
|
|
|
|
elsif (/\G (\\\#) /oxgc) { $q_string .= $1; } |
7131
|
0
|
|
|
|
|
0
|
elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); } |
7132
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7133
|
|
|
|
|
|
|
} |
7134
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7135
|
0
|
|
|
|
|
0
|
} |
7136
|
607
|
|
|
|
|
1200
|
|
7137
|
607
|
50
|
|
|
|
2138
|
else { |
|
607
|
100
|
|
|
|
3861
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7138
|
|
|
|
|
|
|
my $e = ''; |
7139
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
7140
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7141
|
0
|
|
|
|
|
0
|
|
7142
|
1
|
|
|
|
|
2
|
# elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( ) |
7143
|
1
|
|
|
|
|
2
|
elsif (/\G (\() /oxgc) { # q ( ) |
7144
|
1
|
50
|
|
|
|
4
|
my $q_string = ''; |
|
7
|
50
|
|
|
|
52
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7145
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7146
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7147
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7148
|
|
|
|
|
|
|
elsif (/\G (\\\)) /oxgc) { $q_string .= $1; } |
7149
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\\\() /oxgc) { $q_string .= $1; } |
|
1
|
|
|
|
|
3
|
|
7150
|
1
|
|
|
|
|
2
|
elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; } |
7151
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
7152
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); } |
7153
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7154
|
6
|
|
|
|
|
13
|
} |
7155
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7156
|
|
|
|
|
|
|
} |
7157
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7158
|
|
|
|
|
|
|
} |
7159
|
0
|
|
|
|
|
0
|
|
7160
|
600
|
|
|
|
|
1317
|
# elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { } |
7161
|
600
|
|
|
|
|
1212
|
elsif (/\G (\{) /oxgc) { # q { } |
7162
|
600
|
50
|
|
|
|
1855
|
my $q_string = ''; |
|
8204
|
50
|
|
|
|
41153
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7163
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7164
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7165
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
114
|
|
|
|
|
226
|
|
7166
|
|
|
|
|
|
|
elsif (/\G (\\\}) /oxgc) { $q_string .= $1; } |
7167
|
114
|
100
|
|
|
|
232
|
elsif (/\G (\\\{) /oxgc) { $q_string .= $1; } |
|
714
|
|
|
|
|
2079
|
|
7168
|
600
|
|
|
|
|
2415
|
elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; } |
7169
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
7170
|
114
|
|
|
|
|
270
|
if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); } |
7171
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7172
|
7376
|
|
|
|
|
17984
|
} |
7173
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7174
|
|
|
|
|
|
|
} |
7175
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7176
|
|
|
|
|
|
|
} |
7177
|
0
|
|
|
|
|
0
|
|
7178
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ] |
7179
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # q [ ] |
7180
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7181
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7182
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7183
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7184
|
|
|
|
|
|
|
elsif (/\G (\\\]) /oxgc) { $q_string .= $1; } |
7185
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\[) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7186
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; } |
7187
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
7188
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); } |
7189
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7190
|
0
|
|
|
|
|
0
|
} |
7191
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7192
|
|
|
|
|
|
|
} |
7193
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7194
|
|
|
|
|
|
|
} |
7195
|
0
|
|
|
|
|
0
|
|
7196
|
5
|
|
|
|
|
12
|
# elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < > |
7197
|
5
|
|
|
|
|
10
|
elsif (/\G (\<) /oxgc) { # q < > |
7198
|
5
|
50
|
|
|
|
18
|
my $q_string = ''; |
|
82
|
50
|
|
|
|
411
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7199
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7200
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7201
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7202
|
|
|
|
|
|
|
elsif (/\G (\\\>) /oxgc) { $q_string .= $1; } |
7203
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\\\<) /oxgc) { $q_string .= $1; } |
|
5
|
|
|
|
|
22
|
|
7204
|
5
|
|
|
|
|
35
|
elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; } |
7205
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
7206
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); } |
7207
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7208
|
77
|
|
|
|
|
156
|
} |
7209
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7210
|
|
|
|
|
|
|
} |
7211
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7212
|
|
|
|
|
|
|
} |
7213
|
0
|
|
|
|
|
0
|
|
7214
|
1
|
|
|
|
|
3
|
# elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * * |
7215
|
1
|
|
|
|
|
2
|
elsif (/\G (\S) /oxgc) { # q * * |
7216
|
1
|
50
|
|
|
|
3
|
my $delimiter = $1; |
|
14
|
50
|
|
|
|
77
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7217
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
7218
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7219
|
1
|
|
|
|
|
2
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7220
|
|
|
|
|
|
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; } |
7221
|
13
|
|
|
|
|
27
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); } |
7222
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7223
|
|
|
|
|
|
|
} |
7224
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7225
|
|
|
|
|
|
|
} |
7226
|
|
|
|
|
|
|
} |
7227
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7228
|
|
|
|
|
|
|
} |
7229
|
|
|
|
|
|
|
} |
7230
|
0
|
|
|
|
|
0
|
|
7231
|
491
|
50
|
|
|
|
1421
|
# m// |
7232
|
491
|
|
|
|
|
2818
|
elsif (/\G \b (m) \b /oxgc) { |
7233
|
|
|
|
|
|
|
my $ope = $1; |
7234
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# # |
7235
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
7236
|
491
|
|
|
|
|
795
|
} |
7237
|
491
|
50
|
|
|
|
1336
|
else { |
|
491
|
50
|
|
|
|
20938
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7238
|
0
|
|
|
|
|
0
|
my $e = ''; |
7239
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7240
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7241
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( ) |
7242
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { } |
7243
|
92
|
|
|
|
|
269
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ] |
7244
|
87
|
|
|
|
|
345
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < > |
7245
|
0
|
|
|
|
|
0
|
elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ? |
7246
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' ' |
7247
|
312
|
|
|
|
|
1133
|
elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { } |
7248
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * * |
7249
|
|
|
|
|
|
|
} |
7250
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7251
|
|
|
|
|
|
|
} |
7252
|
|
|
|
|
|
|
} |
7253
|
|
|
|
|
|
|
|
7254
|
|
|
|
|
|
|
# s/// |
7255
|
|
|
|
|
|
|
|
7256
|
|
|
|
|
|
|
# about [cegimosxpradlunbB]* (/cg modifier) |
7257
|
|
|
|
|
|
|
# |
7258
|
|
|
|
|
|
|
# P.67 Pattern-Matching Operators |
7259
|
0
|
|
|
|
|
0
|
# of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition. |
7260
|
|
|
|
|
|
|
|
7261
|
|
|
|
|
|
|
elsif (/\G \b (s) \b /oxgc) { |
7262
|
291
|
100
|
|
|
|
885
|
my $ope = $1; |
7263
|
291
|
|
|
|
|
4797
|
|
7264
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7265
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # # |
7266
|
1
|
|
|
|
|
6
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7267
|
290
|
|
|
|
|
592
|
} |
7268
|
290
|
50
|
|
|
|
897
|
else { |
|
290
|
50
|
|
|
|
30416
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7269
|
|
|
|
|
|
|
my $e = ''; |
7270
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7271
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7272
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7273
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7274
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7275
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7276
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7277
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7278
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7279
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7280
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7281
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7282
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7283
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7284
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7285
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7286
|
|
|
|
|
|
|
} |
7287
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7288
|
0
|
|
|
|
|
0
|
} |
7289
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7290
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7291
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7292
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7293
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7294
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7295
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7296
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7297
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7298
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7299
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7300
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7301
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7302
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7303
|
|
|
|
|
|
|
} |
7304
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7305
|
0
|
|
|
|
|
0
|
} |
7306
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7307
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7308
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7309
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7310
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7311
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7312
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7313
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7314
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7315
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7316
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7317
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7318
|
|
|
|
|
|
|
} |
7319
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7320
|
0
|
|
|
|
|
0
|
} |
7321
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7322
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7323
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7324
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7325
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7326
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7327
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7328
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7329
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7330
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7331
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7332
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7333
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7334
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7335
|
|
|
|
|
|
|
} |
7336
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7337
|
0
|
|
|
|
|
0
|
} |
7338
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7339
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { |
7340
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7341
|
96
|
|
|
|
|
310
|
} |
7342
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7343
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7344
|
|
|
|
|
|
|
return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { } |
7345
|
2
|
|
|
|
|
36
|
} |
7346
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7347
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7348
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7349
|
0
|
|
|
|
|
0
|
} |
7350
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7351
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7352
|
192
|
|
|
|
|
811
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7353
|
|
|
|
|
|
|
} |
7354
|
|
|
|
|
|
|
} |
7355
|
|
|
|
|
|
|
die __FILE__, ": Substitution pattern not terminated\n"; |
7356
|
|
|
|
|
|
|
} |
7357
|
0
|
|
|
|
|
0
|
} |
7358
|
1
|
|
|
|
|
6
|
|
7359
|
0
|
|
|
|
|
0
|
# do |
7360
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s*) \{ ) /oxmsgc) { return 'do'; } |
7361
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?: q | qq | qx ) \b) /oxmsgc) { return 'Esjis::do'; } |
7362
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s+) (?>\w+)) /oxmsgc) { return 'do'; } |
7363
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s*) \$ (?> \w+ (?: ::\w+)* ) \( ) /oxmsgc) { return 'do'; } |
7364
|
2
|
|
|
|
|
11
|
elsif (/\G \b do \b /oxmsgc) { return 'Esjis::do'; } |
7365
|
0
|
|
|
|
|
0
|
|
7366
|
0
|
|
|
|
|
0
|
# require ignore module |
7367
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; } |
7368
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# require$1\n$2"; } |
7369
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; } |
7370
|
0
|
|
|
|
|
0
|
|
7371
|
0
|
|
|
|
|
0
|
# require version number |
7372
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7373
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7374
|
0
|
|
|
|
|
0
|
elsif (/\G \b require (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7375
|
|
|
|
|
|
|
|
7376
|
|
|
|
|
|
|
# require bare package name |
7377
|
18
|
|
|
|
|
141
|
elsif (/\G \b require (?>\s+) ((?>[A-Za-z_]\w* (?: :: [A-Za-z_]\w*)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7378
|
0
|
|
|
|
|
0
|
|
7379
|
|
|
|
|
|
|
# require else |
7380
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s*) ; /oxmsgc) { return 'Esjis::require;'; } |
7381
|
1
|
|
|
|
|
5
|
elsif (/\G \b require \b /oxmsgc) { return 'Esjis::require'; } |
7382
|
70
|
|
|
|
|
633
|
|
7383
|
0
|
|
|
|
|
0
|
# use strict; --> use strict; no strict qw(refs); |
7384
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; } |
7385
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; } |
7386
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; } |
7387
|
0
|
50
|
33
|
|
|
0
|
|
|
|
|
33
|
|
|
|
|
7388
|
3
|
|
|
|
|
58
|
# use 5.12.0; --> use 5.12.0; no strict qw(refs); |
7389
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7390
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) { |
7391
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
7392
|
|
|
|
|
|
|
} |
7393
|
|
|
|
|
|
|
else { |
7394
|
|
|
|
|
|
|
return "use $1;"; |
7395
|
3
|
0
|
0
|
|
|
19
|
} |
|
|
|
0
|
|
|
|
|
7396
|
0
|
|
|
|
|
0
|
} |
7397
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7398
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) { |
7399
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
7400
|
|
|
|
|
|
|
} |
7401
|
|
|
|
|
|
|
else { |
7402
|
|
|
|
|
|
|
return "use $1;"; |
7403
|
|
|
|
|
|
|
} |
7404
|
0
|
|
|
|
|
0
|
} |
7405
|
2
|
|
|
|
|
15
|
|
7406
|
0
|
|
|
|
|
0
|
# ignore use module |
7407
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; } |
7408
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# use$1\n$2"; } |
7409
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; } |
7410
|
0
|
|
|
|
|
0
|
|
7411
|
0
|
|
|
|
|
0
|
# ignore no module |
7412
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; } |
7413
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# no$1\n$2"; } |
7414
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; } |
7415
|
0
|
|
|
|
|
0
|
|
7416
|
0
|
|
|
|
|
0
|
# use without import |
7417
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7418
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7419
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7420
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7421
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7422
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7423
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7424
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7425
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7426
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7427
|
|
|
|
|
|
|
|
7428
|
|
|
|
|
|
|
# use with import no parameter |
7429
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_use_noparam($1); } |
7430
|
0
|
|
|
|
|
0
|
|
7431
|
0
|
|
|
|
|
0
|
# use with import parameters |
7432
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7433
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\x9F\xE0-\xFC']* \') (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7434
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\x9F\xE0-\xFC"]* \") (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7435
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7436
|
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); } |
7437
|
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); } |
7438
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x81-\x9F\xE0-\xFC>]* \>) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7439
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7440
|
0
|
|
|
|
|
0
|
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); } |
7441
|
0
|
|
|
|
|
0
|
|
7442
|
0
|
|
|
|
|
0
|
# no without unimport |
7443
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7444
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7445
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7446
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7447
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7448
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7449
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7450
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7451
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7452
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7453
|
|
|
|
|
|
|
|
7454
|
|
|
|
|
|
|
# no with unimport no parameter |
7455
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_no_noparam($1); } |
7456
|
0
|
|
|
|
|
0
|
|
7457
|
0
|
|
|
|
|
0
|
# no with unimport parameters |
7458
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7459
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\x9F\xE0-\xFC']* \') (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7460
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\x9F\xE0-\xFC"]* \") (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7461
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7462
|
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); } |
7463
|
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); } |
7464
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x81-\x9F\xE0-\xFC>]* \>) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7465
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7466
|
0
|
|
|
|
|
0
|
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); } |
7467
|
|
|
|
|
|
|
|
7468
|
|
|
|
|
|
|
# use else |
7469
|
0
|
|
|
|
|
0
|
elsif (/\G \b use \b /oxmsgc) { return "use"; } |
7470
|
|
|
|
|
|
|
|
7471
|
|
|
|
|
|
|
# use else |
7472
|
|
|
|
|
|
|
elsif (/\G \b no \b /oxmsgc) { return "no"; } |
7473
|
2
|
|
|
|
|
10
|
|
7474
|
3199
|
|
|
|
|
7774
|
# '' |
7475
|
3199
|
100
|
|
|
|
9139
|
elsif (/\G (?
|
|
15823
|
100
|
|
|
|
56833
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7476
|
8
|
|
|
|
|
21
|
my $q_string = ''; |
7477
|
48
|
|
|
|
|
110
|
while (not /\G \z/oxgc) { |
7478
|
3199
|
|
|
|
|
8466
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7479
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
7480
|
12568
|
|
|
|
|
29226
|
elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); } |
7481
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7482
|
|
|
|
|
|
|
} |
7483
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7484
|
|
|
|
|
|
|
} |
7485
|
0
|
|
|
|
|
0
|
|
7486
|
3440
|
|
|
|
|
8636
|
# "" |
7487
|
3440
|
100
|
|
|
|
9513
|
elsif (/\G (\") /oxgc) { |
|
72112
|
100
|
|
|
|
219495
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7488
|
109
|
|
|
|
|
239
|
my $qq_string = ''; |
7489
|
14
|
|
|
|
|
35
|
while (not /\G \z/oxgc) { |
7490
|
3440
|
|
|
|
|
9001
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7491
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
7492
|
68549
|
|
|
|
|
135322
|
elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); } |
7493
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
7494
|
|
|
|
|
|
|
} |
7495
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7496
|
|
|
|
|
|
|
} |
7497
|
0
|
|
|
|
|
0
|
|
7498
|
37
|
|
|
|
|
113
|
# `` |
7499
|
37
|
50
|
|
|
|
150
|
elsif (/\G (\`) /oxgc) { |
|
313
|
50
|
|
|
|
1800
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7500
|
0
|
|
|
|
|
0
|
my $qx_string = ''; |
7501
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7502
|
37
|
|
|
|
|
133
|
if (/\G (\\\\) /oxgc) { $qx_string .= $1; } |
7503
|
|
|
|
|
|
|
elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; } |
7504
|
276
|
|
|
|
|
689
|
elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); } |
7505
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; } |
7506
|
|
|
|
|
|
|
} |
7507
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7508
|
|
|
|
|
|
|
} |
7509
|
0
|
|
|
|
|
0
|
|
7510
|
1231
|
|
|
|
|
3191
|
# // --- not divide operator (num / num), not defined-or |
7511
|
1231
|
100
|
|
|
|
3600
|
elsif (($slash eq 'm//') and /\G (\/) /oxgc) { |
|
12525
|
50
|
|
|
|
43531
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7512
|
11
|
|
|
|
|
40
|
my $regexp = ''; |
7513
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7514
|
1231
|
|
|
|
|
3583
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7515
|
|
|
|
|
|
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } |
7516
|
11283
|
|
|
|
|
22564
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); } |
7517
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7518
|
|
|
|
|
|
|
} |
7519
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7520
|
|
|
|
|
|
|
} |
7521
|
0
|
|
|
|
|
0
|
|
7522
|
92
|
|
|
|
|
212
|
# ?? --- not conditional operator (condition ? then : else) |
7523
|
92
|
50
|
|
|
|
238
|
elsif (($slash eq 'm//') and /\G (\?) /oxgc) { |
|
266
|
50
|
|
|
|
1268
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7524
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
7525
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7526
|
92
|
|
|
|
|
242
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7527
|
|
|
|
|
|
|
elsif (/\G (\\\?) /oxgc) { $regexp .= $1; } |
7528
|
174
|
|
|
|
|
471
|
elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); } |
7529
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7530
|
|
|
|
|
|
|
} |
7531
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7532
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
7533
|
|
|
|
|
|
|
|
7534
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
7535
|
0
|
|
|
|
|
0
|
elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
7536
|
|
|
|
|
|
|
|
7537
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
7538
|
|
|
|
|
|
|
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; } |
7539
|
0
|
|
|
|
|
0
|
|
7540
|
6
|
|
|
|
|
15
|
# <<~'HEREDOC' |
7541
|
6
|
|
|
|
|
14
|
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
7542
|
|
|
|
|
|
|
$slash = 'm//'; |
7543
|
|
|
|
|
|
|
my $here_quote = $1; |
7544
|
6
|
50
|
|
|
|
10
|
my $delimiter = $2; |
7545
|
6
|
|
|
|
|
14
|
|
7546
|
6
|
|
|
|
|
31
|
# get here document |
7547
|
|
|
|
|
|
|
if ($here_script eq '') { |
7548
|
6
|
50
|
|
|
|
36
|
$here_script = CORE::substr $_, pos $_; |
7549
|
6
|
|
|
|
|
64
|
$here_script =~ s/.*?\n//oxm; |
7550
|
6
|
|
|
|
|
16
|
} |
7551
|
6
|
|
|
|
|
11
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7552
|
6
|
|
|
|
|
87
|
my $heredoc = $1; |
7553
|
6
|
|
|
|
|
23
|
my $indent = $2; |
7554
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7555
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7556
|
6
|
|
|
|
|
15
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7557
|
|
|
|
|
|
|
} |
7558
|
0
|
|
|
|
|
0
|
else { |
7559
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7560
|
|
|
|
|
|
|
} |
7561
|
|
|
|
|
|
|
return qq{<<'$delimiter'}; |
7562
|
|
|
|
|
|
|
} |
7563
|
|
|
|
|
|
|
|
7564
|
|
|
|
|
|
|
# <<~\HEREDOC |
7565
|
|
|
|
|
|
|
|
7566
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7567
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7568
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7569
|
|
|
|
|
|
|
|
7570
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7571
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7572
|
6
|
|
|
|
|
26
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7573
|
3
|
|
|
|
|
7
|
|
7574
|
3
|
|
|
|
|
9
|
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
7575
|
|
|
|
|
|
|
$slash = 'm//'; |
7576
|
|
|
|
|
|
|
my $here_quote = $1; |
7577
|
3
|
50
|
|
|
|
7
|
my $delimiter = $2; |
7578
|
3
|
|
|
|
|
9
|
|
7579
|
3
|
|
|
|
|
15
|
# get here document |
7580
|
|
|
|
|
|
|
if ($here_script eq '') { |
7581
|
3
|
50
|
|
|
|
18
|
$here_script = CORE::substr $_, pos $_; |
7582
|
3
|
|
|
|
|
44
|
$here_script =~ s/.*?\n//oxm; |
7583
|
3
|
|
|
|
|
9
|
} |
7584
|
3
|
|
|
|
|
4
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7585
|
3
|
|
|
|
|
40
|
my $heredoc = $1; |
7586
|
3
|
|
|
|
|
15
|
my $indent = $2; |
7587
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7588
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7589
|
3
|
|
|
|
|
8
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7590
|
|
|
|
|
|
|
} |
7591
|
0
|
|
|
|
|
0
|
else { |
7592
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7593
|
|
|
|
|
|
|
} |
7594
|
|
|
|
|
|
|
return qq{<<\\$delimiter}; |
7595
|
|
|
|
|
|
|
} |
7596
|
3
|
|
|
|
|
13
|
|
7597
|
6
|
|
|
|
|
17
|
# <<~"HEREDOC" |
7598
|
6
|
|
|
|
|
17
|
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
7599
|
|
|
|
|
|
|
$slash = 'm//'; |
7600
|
|
|
|
|
|
|
my $here_quote = $1; |
7601
|
6
|
50
|
|
|
|
12
|
my $delimiter = $2; |
7602
|
6
|
|
|
|
|
17
|
|
7603
|
6
|
|
|
|
|
28
|
# get here document |
7604
|
|
|
|
|
|
|
if ($here_script eq '') { |
7605
|
6
|
50
|
|
|
|
42
|
$here_script = CORE::substr $_, pos $_; |
7606
|
6
|
|
|
|
|
80
|
$here_script =~ s/.*?\n//oxm; |
7607
|
6
|
|
|
|
|
17
|
} |
7608
|
6
|
|
|
|
|
12
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7609
|
6
|
|
|
|
|
60
|
my $heredoc = $1; |
7610
|
6
|
|
|
|
|
21
|
my $indent = $2; |
7611
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7612
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7613
|
6
|
|
|
|
|
20
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7614
|
|
|
|
|
|
|
} |
7615
|
0
|
|
|
|
|
0
|
else { |
7616
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7617
|
|
|
|
|
|
|
} |
7618
|
|
|
|
|
|
|
return qq{<<"$delimiter"}; |
7619
|
|
|
|
|
|
|
} |
7620
|
6
|
|
|
|
|
28
|
|
7621
|
3
|
|
|
|
|
9
|
# <<~HEREDOC |
7622
|
3
|
|
|
|
|
10
|
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
7623
|
|
|
|
|
|
|
$slash = 'm//'; |
7624
|
|
|
|
|
|
|
my $here_quote = $1; |
7625
|
3
|
50
|
|
|
|
8
|
my $delimiter = $2; |
7626
|
3
|
|
|
|
|
8
|
|
7627
|
3
|
|
|
|
|
32
|
# get here document |
7628
|
|
|
|
|
|
|
if ($here_script eq '') { |
7629
|
3
|
50
|
|
|
|
22
|
$here_script = CORE::substr $_, pos $_; |
7630
|
3
|
|
|
|
|
48
|
$here_script =~ s/.*?\n//oxm; |
7631
|
3
|
|
|
|
|
11
|
} |
7632
|
3
|
|
|
|
|
8
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7633
|
3
|
|
|
|
|
49
|
my $heredoc = $1; |
7634
|
3
|
|
|
|
|
14
|
my $indent = $2; |
7635
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7636
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7637
|
3
|
|
|
|
|
11
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7638
|
|
|
|
|
|
|
} |
7639
|
0
|
|
|
|
|
0
|
else { |
7640
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7641
|
|
|
|
|
|
|
} |
7642
|
|
|
|
|
|
|
return qq{<<$delimiter}; |
7643
|
|
|
|
|
|
|
} |
7644
|
3
|
|
|
|
|
19
|
|
7645
|
6
|
|
|
|
|
33
|
# <<~`HEREDOC` |
7646
|
6
|
|
|
|
|
14
|
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
7647
|
|
|
|
|
|
|
$slash = 'm//'; |
7648
|
|
|
|
|
|
|
my $here_quote = $1; |
7649
|
6
|
50
|
|
|
|
17
|
my $delimiter = $2; |
7650
|
6
|
|
|
|
|
18
|
|
7651
|
6
|
|
|
|
|
56
|
# get here document |
7652
|
|
|
|
|
|
|
if ($here_script eq '') { |
7653
|
6
|
50
|
|
|
|
47
|
$here_script = CORE::substr $_, pos $_; |
7654
|
6
|
|
|
|
|
74
|
$here_script =~ s/.*?\n//oxm; |
7655
|
6
|
|
|
|
|
15
|
} |
7656
|
6
|
|
|
|
|
9
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7657
|
6
|
|
|
|
|
75
|
my $heredoc = $1; |
7658
|
6
|
|
|
|
|
28
|
my $indent = $2; |
7659
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7660
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7661
|
6
|
|
|
|
|
17
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7662
|
|
|
|
|
|
|
} |
7663
|
0
|
|
|
|
|
0
|
else { |
7664
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7665
|
|
|
|
|
|
|
} |
7666
|
|
|
|
|
|
|
return qq{<<`$delimiter`}; |
7667
|
|
|
|
|
|
|
} |
7668
|
6
|
|
|
|
|
26
|
|
7669
|
86
|
|
|
|
|
218
|
# <<'HEREDOC' |
7670
|
86
|
|
|
|
|
211
|
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
7671
|
|
|
|
|
|
|
$slash = 'm//'; |
7672
|
|
|
|
|
|
|
my $here_quote = $1; |
7673
|
86
|
100
|
|
|
|
165
|
my $delimiter = $2; |
7674
|
86
|
|
|
|
|
209
|
|
7675
|
83
|
|
|
|
|
537
|
# get here document |
7676
|
|
|
|
|
|
|
if ($here_script eq '') { |
7677
|
83
|
50
|
|
|
|
543
|
$here_script = CORE::substr $_, pos $_; |
7678
|
86
|
|
|
|
|
762
|
$here_script =~ s/.*?\n//oxm; |
7679
|
86
|
|
|
|
|
336
|
} |
7680
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7681
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7682
|
86
|
|
|
|
|
160
|
push @heredoc_delimiter, $delimiter; |
7683
|
|
|
|
|
|
|
} |
7684
|
0
|
|
|
|
|
0
|
else { |
7685
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7686
|
|
|
|
|
|
|
} |
7687
|
|
|
|
|
|
|
return $here_quote; |
7688
|
|
|
|
|
|
|
} |
7689
|
|
|
|
|
|
|
|
7690
|
|
|
|
|
|
|
# <<\HEREDOC |
7691
|
|
|
|
|
|
|
|
7692
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7693
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7694
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7695
|
|
|
|
|
|
|
|
7696
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7697
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7698
|
86
|
|
|
|
|
359
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7699
|
2
|
|
|
|
|
5
|
|
7700
|
2
|
|
|
|
|
5
|
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
7701
|
|
|
|
|
|
|
$slash = 'm//'; |
7702
|
|
|
|
|
|
|
my $here_quote = $1; |
7703
|
2
|
100
|
|
|
|
9
|
my $delimiter = $2; |
7704
|
2
|
|
|
|
|
4
|
|
7705
|
1
|
|
|
|
|
5
|
# get here document |
7706
|
|
|
|
|
|
|
if ($here_script eq '') { |
7707
|
1
|
50
|
|
|
|
6
|
$here_script = CORE::substr $_, pos $_; |
7708
|
2
|
|
|
|
|
26
|
$here_script =~ s/.*?\n//oxm; |
7709
|
2
|
|
|
|
|
8
|
} |
7710
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7711
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7712
|
2
|
|
|
|
|
5
|
push @heredoc_delimiter, $delimiter; |
7713
|
|
|
|
|
|
|
} |
7714
|
0
|
|
|
|
|
0
|
else { |
7715
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7716
|
|
|
|
|
|
|
} |
7717
|
|
|
|
|
|
|
return $here_quote; |
7718
|
|
|
|
|
|
|
} |
7719
|
2
|
|
|
|
|
7
|
|
7720
|
39
|
|
|
|
|
124
|
# <<"HEREDOC" |
7721
|
39
|
|
|
|
|
107
|
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
7722
|
|
|
|
|
|
|
$slash = 'm//'; |
7723
|
|
|
|
|
|
|
my $here_quote = $1; |
7724
|
39
|
100
|
|
|
|
85
|
my $delimiter = $2; |
7725
|
39
|
|
|
|
|
115
|
|
7726
|
38
|
|
|
|
|
277
|
# get here document |
7727
|
|
|
|
|
|
|
if ($here_script eq '') { |
7728
|
38
|
50
|
|
|
|
249
|
$here_script = CORE::substr $_, pos $_; |
7729
|
39
|
|
|
|
|
597
|
$here_script =~ s/.*?\n//oxm; |
7730
|
39
|
|
|
|
|
156
|
} |
7731
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7732
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7733
|
39
|
|
|
|
|
116
|
push @heredoc_delimiter, $delimiter; |
7734
|
|
|
|
|
|
|
} |
7735
|
0
|
|
|
|
|
0
|
else { |
7736
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7737
|
|
|
|
|
|
|
} |
7738
|
|
|
|
|
|
|
return $here_quote; |
7739
|
|
|
|
|
|
|
} |
7740
|
39
|
|
|
|
|
221
|
|
7741
|
54
|
|
|
|
|
158
|
# <
|
7742
|
54
|
|
|
|
|
137
|
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
7743
|
|
|
|
|
|
|
$slash = 'm//'; |
7744
|
|
|
|
|
|
|
my $here_quote = $1; |
7745
|
54
|
100
|
|
|
|
114
|
my $delimiter = $2; |
7746
|
54
|
|
|
|
|
177
|
|
7747
|
51
|
|
|
|
|
335
|
# get here document |
7748
|
|
|
|
|
|
|
if ($here_script eq '') { |
7749
|
51
|
50
|
|
|
|
415
|
$here_script = CORE::substr $_, pos $_; |
7750
|
54
|
|
|
|
|
874
|
$here_script =~ s/.*?\n//oxm; |
7751
|
54
|
|
|
|
|
213
|
} |
7752
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7753
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7754
|
54
|
|
|
|
|
149
|
push @heredoc_delimiter, $delimiter; |
7755
|
|
|
|
|
|
|
} |
7756
|
0
|
|
|
|
|
0
|
else { |
7757
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7758
|
|
|
|
|
|
|
} |
7759
|
|
|
|
|
|
|
return $here_quote; |
7760
|
|
|
|
|
|
|
} |
7761
|
54
|
|
|
|
|
269
|
|
7762
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
7763
|
0
|
|
|
|
|
0
|
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
7764
|
|
|
|
|
|
|
$slash = 'm//'; |
7765
|
|
|
|
|
|
|
my $here_quote = $1; |
7766
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
7767
|
0
|
|
|
|
|
0
|
|
7768
|
0
|
|
|
|
|
0
|
# get here document |
7769
|
|
|
|
|
|
|
if ($here_script eq '') { |
7770
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
7771
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
7772
|
0
|
|
|
|
|
0
|
} |
7773
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7774
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7775
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
7776
|
|
|
|
|
|
|
} |
7777
|
0
|
|
|
|
|
0
|
else { |
7778
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7779
|
|
|
|
|
|
|
} |
7780
|
|
|
|
|
|
|
return $here_quote; |
7781
|
|
|
|
|
|
|
} |
7782
|
0
|
|
|
|
|
0
|
|
7783
|
|
|
|
|
|
|
# <<= <=> <= < operator |
7784
|
|
|
|
|
|
|
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { |
7785
|
|
|
|
|
|
|
return $1; |
7786
|
|
|
|
|
|
|
} |
7787
|
13
|
|
|
|
|
93
|
|
7788
|
|
|
|
|
|
|
# |
7789
|
|
|
|
|
|
|
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { |
7790
|
|
|
|
|
|
|
return $1; |
7791
|
|
|
|
|
|
|
} |
7792
|
|
|
|
|
|
|
|
7793
|
|
|
|
|
|
|
# --- glob |
7794
|
|
|
|
|
|
|
|
7795
|
0
|
|
|
|
|
0
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7796
|
|
|
|
|
|
|
|
7797
|
|
|
|
|
|
|
elsif (/\G < ((?:[^\x81-\x9F\xE0-\xFC>\0\a\e\f\n\r\t]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+?) > /oxgc) { |
7798
|
|
|
|
|
|
|
return 'Esjis::glob("' . $1 . '")'; |
7799
|
0
|
|
|
|
|
0
|
} |
7800
|
|
|
|
|
|
|
|
7801
|
|
|
|
|
|
|
# __DATA__ |
7802
|
0
|
|
|
|
|
0
|
elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; } |
7803
|
|
|
|
|
|
|
|
7804
|
|
|
|
|
|
|
# __END__ |
7805
|
|
|
|
|
|
|
elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; } |
7806
|
|
|
|
|
|
|
|
7807
|
|
|
|
|
|
|
# \cD Control-D |
7808
|
|
|
|
|
|
|
|
7809
|
|
|
|
|
|
|
# P.68 2.6.8. Other Literal Tokens |
7810
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7811
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7812
|
|
|
|
|
|
|
|
7813
|
|
|
|
|
|
|
# P.76 Other Literal Tokens |
7814
|
385
|
|
|
|
|
3169
|
# in Chapter 2: Bits and Pieces |
7815
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7816
|
|
|
|
|
|
|
|
7817
|
0
|
|
|
|
|
0
|
elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; } |
7818
|
|
|
|
|
|
|
|
7819
|
|
|
|
|
|
|
# \cZ Control-Z |
7820
|
|
|
|
|
|
|
elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; } |
7821
|
|
|
|
|
|
|
|
7822
|
|
|
|
|
|
|
# any operator before div |
7823
|
|
|
|
|
|
|
elsif (/\G ( |
7824
|
0
|
|
|
|
|
0
|
-- | \+\+ | |
|
14213
|
|
|
|
|
33472
|
|
7825
|
|
|
|
|
|
|
[\)\}\]] |
7826
|
|
|
|
|
|
|
|
7827
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; return $1; } |
7828
|
|
|
|
|
|
|
|
7829
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
7830
|
14213
|
|
|
|
|
71974
|
elsif (/\G ( |
|
7
|
|
|
|
|
16
|
|
7831
|
|
|
|
|
|
|
\.\.\. |
7832
|
|
|
|
|
|
|
|
7833
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; } |
7834
|
|
|
|
|
|
|
|
7835
|
|
|
|
|
|
|
# any operator before m// |
7836
|
|
|
|
|
|
|
|
7837
|
|
|
|
|
|
|
# //, //= (defined-or) |
7838
|
|
|
|
|
|
|
|
7839
|
|
|
|
|
|
|
# P.164 Logical Operators |
7840
|
|
|
|
|
|
|
# in Chapter 10: More Control Structures |
7841
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7842
|
|
|
|
|
|
|
|
7843
|
|
|
|
|
|
|
# P.119 C-Style Logical (Short-Circuit) Operators |
7844
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7845
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7846
|
|
|
|
|
|
|
|
7847
|
|
|
|
|
|
|
# (and so on) |
7848
|
|
|
|
|
|
|
|
7849
|
|
|
|
|
|
|
# ~~ |
7850
|
|
|
|
|
|
|
|
7851
|
|
|
|
|
|
|
# P.221 The Smart Match Operator |
7852
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
7853
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7854
|
|
|
|
|
|
|
|
7855
|
|
|
|
|
|
|
# P.112 Smartmatch Operator |
7856
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7857
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7858
|
|
|
|
|
|
|
|
7859
|
|
|
|
|
|
|
# (and so on) |
7860
|
|
|
|
|
|
|
|
7861
|
|
|
|
|
|
|
elsif (/\G ((?> |
7862
|
|
|
|
|
|
|
|
7863
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
7864
|
|
|
|
|
|
|
%= | % | |
7865
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
7866
|
|
|
|
|
|
|
-= | -> | - | |
7867
|
|
|
|
|
|
|
:(?>\s*)= | |
7868
|
|
|
|
|
|
|
: | |
7869
|
|
|
|
|
|
|
<<>> | |
7870
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
7871
|
|
|
|
|
|
|
== | => | =~ | = | |
7872
|
|
|
|
|
|
|
>>= | >> | >= | > | |
7873
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
7874
|
|
|
|
|
|
|
\+= | \+ | |
7875
|
|
|
|
|
|
|
\.\. | \.= | \. | |
7876
|
|
|
|
|
|
|
\/\/= | \/\/ | |
7877
|
|
|
|
|
|
|
\/= | \/ | |
7878
|
|
|
|
|
|
|
\? | |
7879
|
|
|
|
|
|
|
\\ | |
7880
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
7881
|
|
|
|
|
|
|
\b x= | |
7882
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
7883
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
7884
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
7885
|
|
|
|
|
|
|
\b(?: print )\b | |
7886
|
7
|
|
|
|
|
35
|
|
|
23904
|
|
|
|
|
53731
|
|
7887
|
|
|
|
|
|
|
[,;\(\{\[] |
7888
|
|
|
|
|
|
|
|
7889
|
23904
|
|
|
|
|
119740
|
)) /oxgc) { $slash = 'm//'; return $1; } |
|
37187
|
|
|
|
|
85197
|
|
7890
|
|
|
|
|
|
|
|
7891
|
|
|
|
|
|
|
# other any character |
7892
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; } |
7893
|
37187
|
|
|
|
|
204949
|
|
7894
|
|
|
|
|
|
|
# system error |
7895
|
|
|
|
|
|
|
else { |
7896
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
7897
|
|
|
|
|
|
|
} |
7898
|
|
|
|
|
|
|
} |
7899
|
0
|
|
|
3102
|
0
|
0
|
|
7900
|
3102
|
|
|
|
|
7886
|
# escape ShiftJIS string |
7901
|
|
|
|
|
|
|
sub e_string { |
7902
|
3102
|
|
|
|
|
4702
|
my($string) = @_; |
7903
|
|
|
|
|
|
|
my $e_string = ''; |
7904
|
|
|
|
|
|
|
|
7905
|
|
|
|
|
|
|
local $slash = 'm//'; |
7906
|
|
|
|
|
|
|
|
7907
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
7908
|
3102
|
|
|
|
|
5168
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
7909
|
|
|
|
|
|
|
# (and so on) |
7910
|
|
|
|
|
|
|
|
7911
|
3102
|
100
|
66
|
|
|
29499
|
my @char = $string =~ / \G (?>[^\x81-\x9F\xE0-\xFC\\]|\\$q_char|$q_char) /oxmsg; |
7912
|
3102
|
50
|
|
|
|
15265
|
|
7913
|
3023
|
|
|
|
|
8180
|
# without { ... } |
7914
|
|
|
|
|
|
|
if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) { |
7915
|
|
|
|
|
|
|
if ($string !~ /<
|
7916
|
|
|
|
|
|
|
return $string; |
7917
|
|
|
|
|
|
|
} |
7918
|
3023
|
|
|
|
|
8007
|
} |
7919
|
79
|
50
|
|
|
|
232
|
|
|
|
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
|
|
|
|
|
|
7920
|
|
|
|
|
|
|
E_STRING_LOOP: |
7921
|
|
|
|
|
|
|
while ($string !~ /\G \z/oxgc) { |
7922
|
|
|
|
|
|
|
if (0) { |
7923
|
606
|
|
|
|
|
83421
|
} |
7924
|
0
|
|
|
|
|
0
|
|
7925
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Esjis::PREMATCH()]} |
7926
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
7927
|
|
|
|
|
|
|
$e_string .= q{Esjis::PREMATCH()}; |
7928
|
|
|
|
|
|
|
$slash = 'div'; |
7929
|
|
|
|
|
|
|
} |
7930
|
0
|
|
|
|
|
0
|
|
7931
|
0
|
|
|
|
|
0
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Esjis::MATCH()]} |
7932
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
7933
|
|
|
|
|
|
|
$e_string .= q{Esjis::MATCH()}; |
7934
|
|
|
|
|
|
|
$slash = 'div'; |
7935
|
|
|
|
|
|
|
} |
7936
|
0
|
|
|
|
|
0
|
|
7937
|
0
|
|
|
|
|
0
|
# $', ${'} --> $', ${'} |
7938
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) { |
7939
|
|
|
|
|
|
|
$e_string .= $1; |
7940
|
|
|
|
|
|
|
$slash = 'div'; |
7941
|
|
|
|
|
|
|
} |
7942
|
0
|
|
|
|
|
0
|
|
7943
|
0
|
|
|
|
|
0
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Esjis::POSTMATCH()]} |
7944
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
7945
|
|
|
|
|
|
|
$e_string .= q{Esjis::POSTMATCH()}; |
7946
|
|
|
|
|
|
|
$slash = 'div'; |
7947
|
|
|
|
|
|
|
} |
7948
|
0
|
|
|
|
|
0
|
|
7949
|
0
|
|
|
|
|
0
|
# bareword |
7950
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
7951
|
|
|
|
|
|
|
$e_string .= $1; |
7952
|
|
|
|
|
|
|
$slash = 'div'; |
7953
|
|
|
|
|
|
|
} |
7954
|
0
|
|
|
|
|
0
|
|
7955
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
7956
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) { |
7957
|
|
|
|
|
|
|
$e_string .= $1; |
7958
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
7959
|
0
|
|
|
|
|
0
|
} |
7960
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
7961
|
|
|
|
|
|
|
$e_string .= $1; |
7962
|
|
|
|
|
|
|
$slash = 'div'; |
7963
|
|
|
|
|
|
|
} |
7964
|
0
|
|
|
|
|
0
|
|
7965
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
7966
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
7967
|
|
|
|
|
|
|
$e_string .= $1; |
7968
|
|
|
|
|
|
|
$slash = 'div'; |
7969
|
|
|
|
|
|
|
} |
7970
|
|
|
|
|
|
|
|
7971
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
7972
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
7973
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
7974
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7975
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
7976
|
0
|
|
|
|
|
0
|
} |
7977
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
7978
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7979
|
|
|
|
|
|
|
$slash = 'div'; |
7980
|
|
|
|
|
|
|
} |
7981
|
0
|
|
|
|
|
0
|
|
7982
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
7983
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
7984
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7985
|
|
|
|
|
|
|
$slash = 'div'; |
7986
|
|
|
|
|
|
|
} |
7987
|
0
|
|
|
|
|
0
|
|
7988
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
7989
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
7990
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7991
|
|
|
|
|
|
|
$slash = 'div'; |
7992
|
|
|
|
|
|
|
} |
7993
|
0
|
|
|
|
|
0
|
|
7994
|
0
|
|
|
|
|
0
|
# $$foo |
7995
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
7996
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7997
|
|
|
|
|
|
|
$slash = 'div'; |
7998
|
|
|
|
|
|
|
} |
7999
|
0
|
|
|
|
|
0
|
|
8000
|
0
|
|
|
|
|
0
|
# ${ foo } |
8001
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) { |
8002
|
|
|
|
|
|
|
$e_string .= '${' . $1 . '}'; |
8003
|
|
|
|
|
|
|
$slash = 'div'; |
8004
|
|
|
|
|
|
|
} |
8005
|
0
|
|
|
|
|
0
|
|
8006
|
3
|
|
|
|
|
11
|
# ${ ... } |
8007
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
8008
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
8009
|
|
|
|
|
|
|
$slash = 'div'; |
8010
|
|
|
|
|
|
|
} |
8011
|
|
|
|
|
|
|
|
8012
|
3
|
|
|
|
|
15
|
# variable or function |
8013
|
0
|
|
|
|
|
0
|
# $ @ % & * $ # |
8014
|
|
|
|
|
|
|
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) { |
8015
|
|
|
|
|
|
|
$e_string .= $1; |
8016
|
|
|
|
|
|
|
$slash = 'div'; |
8017
|
|
|
|
|
|
|
} |
8018
|
0
|
|
|
|
|
0
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
8019
|
0
|
|
|
|
|
0
|
# $ @ # \ ' " / ? ( ) [ ] < > |
8020
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
8021
|
|
|
|
|
|
|
$e_string .= $1; |
8022
|
|
|
|
|
|
|
$slash = 'div'; |
8023
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
8024
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8025
|
0
|
|
|
|
|
0
|
# subroutines of package Esjis |
|
0
|
|
|
|
|
0
|
|
8026
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8027
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8028
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8029
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8030
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::eval \b /oxgc) { $e_string .= 'eval Sjis::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8031
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8032
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Esjis::chop'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8033
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8034
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8035
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::index \b /oxgc) { $e_string .= 'Sjis::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8036
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Esjis::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8037
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8038
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8039
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::rindex \b /oxgc) { $e_string .= 'Sjis::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8040
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Esjis::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8041
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8042
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lcfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8043
|
|
|
|
|
|
|
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::uc'; $slash = 'm//'; } |
8044
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::ucfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8045
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::fc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8046
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8047
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8048
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8049
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8050
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
6
|
|
8051
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
8052
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
8053
|
1
|
|
|
|
|
4
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
6
|
|
8054
|
1
|
|
|
|
|
3
|
|
|
0
|
|
|
|
|
0
|
|
8055
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8056
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8057
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8058
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8059
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
6
|
|
8060
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8061
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8062
|
1
|
|
|
|
|
3
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8063
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8064
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8065
|
0
|
|
|
|
|
0
|
{ $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8066
|
|
|
|
|
|
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
8067
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $e_string .= "Esjis::filetest qw($1),"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8068
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8069
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8070
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Esjis::$1(" . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8071
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8072
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8073
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
8
|
|
8074
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
8075
|
2
|
|
|
|
|
7
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
5
|
|
8076
|
1
|
|
|
|
|
4
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8077
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8078
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Esjis::$1(" . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8079
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8080
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8081
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
15
|
|
8082
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8083
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8084
|
2
|
|
|
|
|
6
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8085
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8086
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8087
|
0
|
|
|
|
|
0
|
{ $e_string .= "Esjis::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8088
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Esjis::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8089
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= "Esjis::$1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8090
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "Esjis::$1(::"."$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8091
|
|
|
|
|
|
|
elsif ($string =~ /\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-t $2"; $slash = 'm//'; } |
8092
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lstat'; $slash = 'm//'; } |
8093
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::stat'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8094
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8095
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
8096
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8097
|
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
|
|
8098
|
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
|
|
8099
|
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
|
|
8100
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
8101
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8102
|
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
|
|
8103
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8104
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8105
|
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
|
|
8106
|
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
|
|
8107
|
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
|
|
8108
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
8109
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
8110
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8111
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8112
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8113
|
0
|
|
|
|
|
0
|
{ $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8114
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; } |
8115
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8116
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8117
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8118
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8119
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8120
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8121
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8122
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8123
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::glob'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8124
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Esjis::lc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8125
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Esjis::lcfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8126
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Esjis::uc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8127
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Esjis::ucfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8128
|
|
|
|
|
|
|
elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Esjis::fc_'; $slash = 'm//'; } |
8129
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lstat \b /oxgc) { $e_string .= 'Esjis::lstat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8130
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat \b /oxgc) { $e_string .= 'Esjis::stat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8131
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8132
|
|
|
|
|
|
|
\b /oxgc) { $e_string .= "Esjis::filetest_(qw($1))"; $slash = 'm//'; } |
8133
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) \b /oxgc) { $e_string .= "Esjis::${1}_"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8134
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8135
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8136
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8137
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8138
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Esjis::chr_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8139
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8140
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8141
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Esjis::glob_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8142
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8143
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8144
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Esjis::opendir$1*"; $slash = 'm//'; } |
8145
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Esjis::opendir$1*"; $slash = 'm//'; } |
8146
|
|
|
|
|
|
|
elsif ($string =~ /\G \b unlink \b /oxgc) { $e_string .= 'Esjis::unlink'; $slash = 'm//'; } |
8147
|
0
|
|
|
|
|
0
|
|
8148
|
|
|
|
|
|
|
# chdir |
8149
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
8150
|
|
|
|
|
|
|
$slash = 'm//'; |
8151
|
0
|
|
|
|
|
0
|
|
8152
|
0
|
|
|
|
|
0
|
$e_string .= 'Esjis::chdir'; |
8153
|
|
|
|
|
|
|
|
8154
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
8155
|
|
|
|
|
|
|
$e_string .= $1; |
8156
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8157
|
|
|
|
|
|
|
|
8158
|
|
|
|
|
|
|
# end of chdir |
8159
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return $e_string; } |
|
0
|
|
|
|
|
0
|
|
8160
|
|
|
|
|
|
|
|
8161
|
|
|
|
|
|
|
# chdir scalar value |
8162
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= e_string($1); next E_STRING_LOOP; } |
8163
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8164
|
|
|
|
|
|
|
# chdir qq// |
8165
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8166
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8167
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8168
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8169
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8170
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
8171
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
8172
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
8173
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq < > --> qr < > |
8174
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq','{','}',$2); next E_STRING_LOOP; } # qq | | --> qr { } |
8175
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq * * --> qr * * |
8176
|
|
|
|
|
|
|
} |
8177
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8178
|
|
|
|
|
|
|
} |
8179
|
|
|
|
|
|
|
} |
8180
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8181
|
|
|
|
|
|
|
# chdir q// |
8182
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8183
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8184
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8185
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8186
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8187
|
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
|
|
8188
|
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
|
|
8189
|
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
|
|
8190
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q < > --> qr < > |
8191
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q','{','}',$2); next E_STRING_LOOP; } # q | | --> qr { } |
8192
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q * * --> qr * * |
8193
|
|
|
|
|
|
|
} |
8194
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8195
|
|
|
|
|
|
|
} |
8196
|
|
|
|
|
|
|
} |
8197
|
0
|
|
|
|
|
0
|
|
8198
|
0
|
|
|
|
|
0
|
# chdir '' |
8199
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8200
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
8201
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8202
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
8203
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } |
8204
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_chdir_q('',"'","'",$q_string); next E_STRING_LOOP; } |
8205
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
8206
|
|
|
|
|
|
|
} |
8207
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8208
|
|
|
|
|
|
|
} |
8209
|
0
|
|
|
|
|
0
|
|
8210
|
0
|
|
|
|
|
0
|
# chdir "" |
8211
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8212
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
8213
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8214
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
8215
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } |
8216
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_chdir('','"','"',$qq_string); next E_STRING_LOOP; } |
8217
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8218
|
|
|
|
|
|
|
} |
8219
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8220
|
|
|
|
|
|
|
} |
8221
|
|
|
|
|
|
|
} |
8222
|
0
|
|
|
|
|
0
|
|
8223
|
|
|
|
|
|
|
# split |
8224
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
8225
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8226
|
0
|
|
|
|
|
0
|
|
8227
|
|
|
|
|
|
|
my $e = ''; |
8228
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
8229
|
|
|
|
|
|
|
$e .= $1; |
8230
|
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
|
|
|
|
|
|
8231
|
|
|
|
|
|
|
|
8232
|
|
|
|
|
|
|
# end of split |
8233
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Esjis::split' . $e; } |
|
0
|
|
|
|
|
0
|
|
8234
|
|
|
|
|
|
|
|
8235
|
|
|
|
|
|
|
# split scalar value |
8236
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Esjis::split' . $e . e_string($1); next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8237
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8238
|
0
|
|
|
|
|
0
|
# split literal space |
|
0
|
|
|
|
|
0
|
|
8239
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8240
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8241
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8242
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8243
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8244
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8245
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8246
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8247
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8248
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8249
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8250
|
|
|
|
|
|
|
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
8251
|
|
|
|
|
|
|
elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Esjis::split' . $e . qq {' '}; next E_STRING_LOOP; } |
8252
|
|
|
|
|
|
|
elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Esjis::split' . $e . qq {" "}; next E_STRING_LOOP; } |
8253
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8254
|
|
|
|
|
|
|
# split qq// |
8255
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8256
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8257
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8258
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8259
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8260
|
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
|
|
8261
|
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
|
|
8262
|
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
|
|
8263
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < > |
8264
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { } |
8265
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * * |
8266
|
|
|
|
|
|
|
} |
8267
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8268
|
|
|
|
|
|
|
} |
8269
|
|
|
|
|
|
|
} |
8270
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8271
|
|
|
|
|
|
|
# split qr// |
8272
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qr) \b /oxgc) { |
8273
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # qr# # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8274
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8275
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8276
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8277
|
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
|
|
8278
|
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
|
|
8279
|
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
|
|
8280
|
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
|
|
8281
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' ' |
8282
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { } |
8283
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr * * |
8284
|
|
|
|
|
|
|
} |
8285
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8286
|
|
|
|
|
|
|
} |
8287
|
|
|
|
|
|
|
} |
8288
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8289
|
|
|
|
|
|
|
# split q// |
8290
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8291
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8292
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8293
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8294
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8295
|
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
|
|
8296
|
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
|
|
8297
|
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
|
|
8298
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < > |
8299
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { } |
8300
|
|
|
|
|
|
|
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 * * |
8301
|
|
|
|
|
|
|
} |
8302
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8303
|
|
|
|
|
|
|
} |
8304
|
|
|
|
|
|
|
} |
8305
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8306
|
|
|
|
|
|
|
# split m// |
8307
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (m) \b /oxgc) { |
8308
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # m# # --> qr # # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8309
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8310
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8311
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8312
|
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
|
|
8313
|
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
|
|
8314
|
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
|
|
8315
|
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
|
|
8316
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ' ' --> qr ' ' |
8317
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { } |
8318
|
|
|
|
|
|
|
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 * * |
8319
|
|
|
|
|
|
|
} |
8320
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8321
|
|
|
|
|
|
|
} |
8322
|
|
|
|
|
|
|
} |
8323
|
0
|
|
|
|
|
0
|
|
8324
|
0
|
|
|
|
|
0
|
# split '' |
8325
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8326
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
8327
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8328
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
8329
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
8330
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' ' |
8331
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
8332
|
|
|
|
|
|
|
} |
8333
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8334
|
|
|
|
|
|
|
} |
8335
|
0
|
|
|
|
|
0
|
|
8336
|
0
|
|
|
|
|
0
|
# split "" |
8337
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8338
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
8339
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8340
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
8341
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
8342
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " " |
8343
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8344
|
|
|
|
|
|
|
} |
8345
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8346
|
|
|
|
|
|
|
} |
8347
|
0
|
|
|
|
|
0
|
|
8348
|
0
|
|
|
|
|
0
|
# split // |
8349
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\/) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8350
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
8351
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8352
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; } |
8353
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
8354
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / / |
8355
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; } |
8356
|
|
|
|
|
|
|
} |
8357
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8358
|
|
|
|
|
|
|
} |
8359
|
|
|
|
|
|
|
} |
8360
|
0
|
|
|
|
|
0
|
|
8361
|
0
|
0
|
|
|
|
0
|
# qq// |
8362
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8363
|
|
|
|
|
|
|
my $ope = $1; |
8364
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# # |
8365
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
8366
|
0
|
|
|
|
|
0
|
} |
8367
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8368
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8369
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8370
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8371
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( ) |
|
0
|
|
|
|
|
0
|
|
8372
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { } |
|
0
|
|
|
|
|
0
|
|
8373
|
|
|
|
|
|
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ] |
8374
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < > |
8375
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * * |
8376
|
|
|
|
|
|
|
} |
8377
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8378
|
|
|
|
|
|
|
} |
8379
|
|
|
|
|
|
|
} |
8380
|
0
|
|
|
|
|
0
|
|
8381
|
0
|
0
|
|
|
|
0
|
# qx// |
8382
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qx) \b /oxgc) { |
8383
|
|
|
|
|
|
|
my $ope = $1; |
8384
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
8385
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
8386
|
0
|
|
|
|
|
0
|
} |
8387
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8388
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8389
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8390
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8391
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( ) |
|
0
|
|
|
|
|
0
|
|
8392
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { } |
|
0
|
|
|
|
|
0
|
|
8393
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ] |
|
0
|
|
|
|
|
0
|
|
8394
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < > |
8395
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' ' |
8396
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * * |
8397
|
|
|
|
|
|
|
} |
8398
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8399
|
|
|
|
|
|
|
} |
8400
|
|
|
|
|
|
|
} |
8401
|
0
|
|
|
|
|
0
|
|
8402
|
0
|
0
|
|
|
|
0
|
# q// |
8403
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8404
|
|
|
|
|
|
|
my $ope = $1; |
8405
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# # |
8406
|
0
|
|
|
|
|
0
|
$e_string .= e_q($ope,$1,$3,$2); |
8407
|
0
|
|
|
|
|
0
|
} |
8408
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8409
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8410
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8411
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8412
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( ) |
|
0
|
|
|
|
|
0
|
|
8413
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { } |
|
0
|
|
|
|
|
0
|
|
8414
|
|
|
|
|
|
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ] |
8415
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < > |
8416
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * * |
8417
|
|
|
|
|
|
|
} |
8418
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8419
|
|
|
|
|
|
|
} |
8420
|
0
|
|
|
|
|
0
|
} |
8421
|
|
|
|
|
|
|
|
8422
|
|
|
|
|
|
|
# '' |
8423
|
44
|
|
|
|
|
196
|
elsif ($string =~ /\G (?
|
8424
|
|
|
|
|
|
|
|
8425
|
|
|
|
|
|
|
# "" |
8426
|
6
|
|
|
|
|
74
|
elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8427
|
|
|
|
|
|
|
|
8428
|
|
|
|
|
|
|
# `` |
8429
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8430
|
|
|
|
|
|
|
|
8431
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
8432
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; } |
8433
|
|
|
|
|
|
|
|
8434
|
|
|
|
|
|
|
# <<= <=> <= < operator |
8435
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; } |
8436
|
|
|
|
|
|
|
|
8437
|
|
|
|
|
|
|
# |
8438
|
|
|
|
|
|
|
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; } |
8439
|
0
|
|
|
|
|
0
|
|
8440
|
|
|
|
|
|
|
# --- glob |
8441
|
|
|
|
|
|
|
elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) { |
8442
|
|
|
|
|
|
|
$e_string .= 'Esjis::glob("' . $1 . '")'; |
8443
|
|
|
|
|
|
|
} |
8444
|
0
|
|
|
|
|
0
|
|
8445
|
0
|
|
|
|
|
0
|
# << (bit shift) --- not here document |
8446
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { |
8447
|
|
|
|
|
|
|
$slash = 'm//'; |
8448
|
|
|
|
|
|
|
$e_string .= $1; |
8449
|
|
|
|
|
|
|
} |
8450
|
0
|
|
|
|
|
0
|
|
8451
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
8452
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
8453
|
|
|
|
|
|
|
$slash = 'm//'; |
8454
|
|
|
|
|
|
|
my $here_quote = $1; |
8455
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8456
|
0
|
|
|
|
|
0
|
|
8457
|
0
|
|
|
|
|
0
|
# get here document |
8458
|
|
|
|
|
|
|
if ($here_script eq '') { |
8459
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8460
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8461
|
0
|
|
|
|
|
0
|
} |
8462
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8463
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8464
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8465
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8466
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8467
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8468
|
|
|
|
|
|
|
} |
8469
|
0
|
|
|
|
|
0
|
else { |
8470
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8471
|
|
|
|
|
|
|
} |
8472
|
|
|
|
|
|
|
$e_string .= qq{<<'$delimiter'}; |
8473
|
|
|
|
|
|
|
} |
8474
|
0
|
|
|
|
|
0
|
|
8475
|
0
|
|
|
|
|
0
|
# <<~\HEREDOC |
8476
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
8477
|
|
|
|
|
|
|
$slash = 'm//'; |
8478
|
|
|
|
|
|
|
my $here_quote = $1; |
8479
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8480
|
0
|
|
|
|
|
0
|
|
8481
|
0
|
|
|
|
|
0
|
# get here document |
8482
|
|
|
|
|
|
|
if ($here_script eq '') { |
8483
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8484
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8485
|
0
|
|
|
|
|
0
|
} |
8486
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8487
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8488
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8489
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8490
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8491
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8492
|
|
|
|
|
|
|
} |
8493
|
0
|
|
|
|
|
0
|
else { |
8494
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8495
|
|
|
|
|
|
|
} |
8496
|
|
|
|
|
|
|
$e_string .= qq{<<\\$delimiter}; |
8497
|
|
|
|
|
|
|
} |
8498
|
0
|
|
|
|
|
0
|
|
8499
|
0
|
|
|
|
|
0
|
# <<~"HEREDOC" |
8500
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
8501
|
|
|
|
|
|
|
$slash = 'm//'; |
8502
|
|
|
|
|
|
|
my $here_quote = $1; |
8503
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8504
|
0
|
|
|
|
|
0
|
|
8505
|
0
|
|
|
|
|
0
|
# get here document |
8506
|
|
|
|
|
|
|
if ($here_script eq '') { |
8507
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8508
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8509
|
0
|
|
|
|
|
0
|
} |
8510
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8511
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8512
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8513
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8514
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8515
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8516
|
|
|
|
|
|
|
} |
8517
|
0
|
|
|
|
|
0
|
else { |
8518
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8519
|
|
|
|
|
|
|
} |
8520
|
|
|
|
|
|
|
$e_string .= qq{<<"$delimiter"}; |
8521
|
|
|
|
|
|
|
} |
8522
|
0
|
|
|
|
|
0
|
|
8523
|
0
|
|
|
|
|
0
|
# <<~HEREDOC |
8524
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
8525
|
|
|
|
|
|
|
$slash = 'm//'; |
8526
|
|
|
|
|
|
|
my $here_quote = $1; |
8527
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8528
|
0
|
|
|
|
|
0
|
|
8529
|
0
|
|
|
|
|
0
|
# get here document |
8530
|
|
|
|
|
|
|
if ($here_script eq '') { |
8531
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8532
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8533
|
0
|
|
|
|
|
0
|
} |
8534
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8535
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8536
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8537
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8538
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8539
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8540
|
|
|
|
|
|
|
} |
8541
|
0
|
|
|
|
|
0
|
else { |
8542
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8543
|
|
|
|
|
|
|
} |
8544
|
|
|
|
|
|
|
$e_string .= qq{<<$delimiter}; |
8545
|
|
|
|
|
|
|
} |
8546
|
0
|
|
|
|
|
0
|
|
8547
|
0
|
|
|
|
|
0
|
# <<~`HEREDOC` |
8548
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
8549
|
|
|
|
|
|
|
$slash = 'm//'; |
8550
|
|
|
|
|
|
|
my $here_quote = $1; |
8551
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8552
|
0
|
|
|
|
|
0
|
|
8553
|
0
|
|
|
|
|
0
|
# get here document |
8554
|
|
|
|
|
|
|
if ($here_script eq '') { |
8555
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8556
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8557
|
0
|
|
|
|
|
0
|
} |
8558
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8559
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8560
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8561
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8562
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8563
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8564
|
|
|
|
|
|
|
} |
8565
|
0
|
|
|
|
|
0
|
else { |
8566
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8567
|
|
|
|
|
|
|
} |
8568
|
|
|
|
|
|
|
$e_string .= qq{<<`$delimiter`}; |
8569
|
|
|
|
|
|
|
} |
8570
|
0
|
|
|
|
|
0
|
|
8571
|
0
|
|
|
|
|
0
|
# <<'HEREDOC' |
8572
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
8573
|
|
|
|
|
|
|
$slash = 'm//'; |
8574
|
|
|
|
|
|
|
my $here_quote = $1; |
8575
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8576
|
0
|
|
|
|
|
0
|
|
8577
|
0
|
|
|
|
|
0
|
# get here document |
8578
|
|
|
|
|
|
|
if ($here_script eq '') { |
8579
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8580
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8581
|
0
|
|
|
|
|
0
|
} |
8582
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8583
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8584
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8585
|
|
|
|
|
|
|
} |
8586
|
0
|
|
|
|
|
0
|
else { |
8587
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8588
|
|
|
|
|
|
|
} |
8589
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8590
|
|
|
|
|
|
|
} |
8591
|
0
|
|
|
|
|
0
|
|
8592
|
0
|
|
|
|
|
0
|
# <<\HEREDOC |
8593
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
8594
|
|
|
|
|
|
|
$slash = 'm//'; |
8595
|
|
|
|
|
|
|
my $here_quote = $1; |
8596
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8597
|
0
|
|
|
|
|
0
|
|
8598
|
0
|
|
|
|
|
0
|
# get here document |
8599
|
|
|
|
|
|
|
if ($here_script eq '') { |
8600
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8601
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8602
|
0
|
|
|
|
|
0
|
} |
8603
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8604
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8605
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8606
|
|
|
|
|
|
|
} |
8607
|
0
|
|
|
|
|
0
|
else { |
8608
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8609
|
|
|
|
|
|
|
} |
8610
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8611
|
|
|
|
|
|
|
} |
8612
|
0
|
|
|
|
|
0
|
|
8613
|
0
|
|
|
|
|
0
|
# <<"HEREDOC" |
8614
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
8615
|
|
|
|
|
|
|
$slash = 'm//'; |
8616
|
|
|
|
|
|
|
my $here_quote = $1; |
8617
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8618
|
0
|
|
|
|
|
0
|
|
8619
|
0
|
|
|
|
|
0
|
# get here document |
8620
|
|
|
|
|
|
|
if ($here_script eq '') { |
8621
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8622
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8623
|
0
|
|
|
|
|
0
|
} |
8624
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8625
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8626
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8627
|
|
|
|
|
|
|
} |
8628
|
0
|
|
|
|
|
0
|
else { |
8629
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8630
|
|
|
|
|
|
|
} |
8631
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8632
|
|
|
|
|
|
|
} |
8633
|
0
|
|
|
|
|
0
|
|
8634
|
0
|
|
|
|
|
0
|
# <
|
8635
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
8636
|
|
|
|
|
|
|
$slash = 'm//'; |
8637
|
|
|
|
|
|
|
my $here_quote = $1; |
8638
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8639
|
0
|
|
|
|
|
0
|
|
8640
|
0
|
|
|
|
|
0
|
# get here document |
8641
|
|
|
|
|
|
|
if ($here_script eq '') { |
8642
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8643
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8644
|
0
|
|
|
|
|
0
|
} |
8645
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8646
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8647
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8648
|
|
|
|
|
|
|
} |
8649
|
0
|
|
|
|
|
0
|
else { |
8650
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8651
|
|
|
|
|
|
|
} |
8652
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8653
|
|
|
|
|
|
|
} |
8654
|
0
|
|
|
|
|
0
|
|
8655
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
8656
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
8657
|
|
|
|
|
|
|
$slash = 'm//'; |
8658
|
|
|
|
|
|
|
my $here_quote = $1; |
8659
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8660
|
0
|
|
|
|
|
0
|
|
8661
|
0
|
|
|
|
|
0
|
# get here document |
8662
|
|
|
|
|
|
|
if ($here_script eq '') { |
8663
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8664
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8665
|
0
|
|
|
|
|
0
|
} |
8666
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8667
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8668
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8669
|
|
|
|
|
|
|
} |
8670
|
0
|
|
|
|
|
0
|
else { |
8671
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8672
|
|
|
|
|
|
|
} |
8673
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8674
|
|
|
|
|
|
|
} |
8675
|
|
|
|
|
|
|
|
8676
|
|
|
|
|
|
|
# any operator before div |
8677
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8678
|
0
|
|
|
|
|
0
|
-- | \+\+ | |
|
80
|
|
|
|
|
434
|
|
8679
|
|
|
|
|
|
|
[\)\}\]] |
8680
|
|
|
|
|
|
|
|
8681
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; $e_string .= $1; } |
8682
|
|
|
|
|
|
|
|
8683
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
8684
|
80
|
|
|
|
|
427
|
elsif ($string =~ /\G ( |
|
0
|
|
|
|
|
0
|
|
8685
|
|
|
|
|
|
|
\.\.\. |
8686
|
|
|
|
|
|
|
|
8687
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; } |
8688
|
|
|
|
|
|
|
|
8689
|
|
|
|
|
|
|
# any operator before m// |
8690
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?> |
8691
|
|
|
|
|
|
|
|
8692
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
8693
|
|
|
|
|
|
|
%= | % | |
8694
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
8695
|
|
|
|
|
|
|
-= | -> | - | |
8696
|
|
|
|
|
|
|
:(?>\s*)= | |
8697
|
|
|
|
|
|
|
: | |
8698
|
|
|
|
|
|
|
<<>> | |
8699
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
8700
|
|
|
|
|
|
|
== | => | =~ | = | |
8701
|
|
|
|
|
|
|
>>= | >> | >= | > | |
8702
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
8703
|
|
|
|
|
|
|
\+= | \+ | |
8704
|
|
|
|
|
|
|
\.\. | \.= | \. | |
8705
|
|
|
|
|
|
|
\/\/= | \/\/ | |
8706
|
|
|
|
|
|
|
\/= | \/ | |
8707
|
|
|
|
|
|
|
\? | |
8708
|
|
|
|
|
|
|
\\ | |
8709
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
8710
|
|
|
|
|
|
|
\b x= | |
8711
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
8712
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
8713
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
8714
|
|
|
|
|
|
|
\b(?: print )\b | |
8715
|
0
|
|
|
|
|
0
|
|
|
112
|
|
|
|
|
287
|
|
8716
|
|
|
|
|
|
|
[,;\(\{\[] |
8717
|
|
|
|
|
|
|
|
8718
|
112
|
|
|
|
|
699
|
)) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
8719
|
|
|
|
|
|
|
|
8720
|
|
|
|
|
|
|
# other any character |
8721
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; } |
8722
|
353
|
|
|
|
|
1464
|
|
8723
|
|
|
|
|
|
|
# system error |
8724
|
|
|
|
|
|
|
else { |
8725
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
8726
|
0
|
|
|
|
|
0
|
} |
8727
|
|
|
|
|
|
|
} |
8728
|
|
|
|
|
|
|
|
8729
|
|
|
|
|
|
|
return $e_string; |
8730
|
|
|
|
|
|
|
} |
8731
|
|
|
|
|
|
|
|
8732
|
|
|
|
|
|
|
# |
8733
|
79
|
|
|
5358
|
0
|
367
|
# character class |
8734
|
|
|
|
|
|
|
# |
8735
|
5358
|
100
|
|
|
|
10640
|
sub character_class { |
8736
|
5358
|
100
|
|
|
|
9029
|
my($char,$modifier) = @_; |
8737
|
115
|
|
|
|
|
331
|
|
8738
|
|
|
|
|
|
|
if ($char eq '.') { |
8739
|
|
|
|
|
|
|
if ($modifier =~ /s/) { |
8740
|
23
|
|
|
|
|
81
|
return '${Esjis::dot_s}'; |
8741
|
|
|
|
|
|
|
} |
8742
|
|
|
|
|
|
|
else { |
8743
|
|
|
|
|
|
|
return '${Esjis::dot}'; |
8744
|
92
|
|
|
|
|
207
|
} |
8745
|
|
|
|
|
|
|
} |
8746
|
|
|
|
|
|
|
else { |
8747
|
|
|
|
|
|
|
return Esjis::classic_character_class($char); |
8748
|
|
|
|
|
|
|
} |
8749
|
|
|
|
|
|
|
} |
8750
|
|
|
|
|
|
|
|
8751
|
|
|
|
|
|
|
# |
8752
|
|
|
|
|
|
|
# escape capture ($1, $2, $3, ...) |
8753
|
5243
|
|
|
637
|
0
|
9316
|
# |
8754
|
637
|
|
|
|
|
3047
|
sub e_capture { |
8755
|
|
|
|
|
|
|
|
8756
|
|
|
|
|
|
|
return join '', '${Esjis::capture(', $_[0], ')}'; |
8757
|
|
|
|
|
|
|
return join '', '${', $_[0], '}'; |
8758
|
|
|
|
|
|
|
} |
8759
|
|
|
|
|
|
|
|
8760
|
|
|
|
|
|
|
# |
8761
|
0
|
|
|
11
|
0
|
0
|
# escape transliteration (tr/// or y///) |
8762
|
11
|
|
|
|
|
70
|
# |
8763
|
11
|
|
100
|
|
|
19
|
sub e_tr { |
8764
|
|
|
|
|
|
|
my($variable,$charclass,$e,$charclass2,$modifier) = @_; |
8765
|
11
|
|
|
|
|
33
|
my $e_tr = ''; |
8766
|
|
|
|
|
|
|
$modifier ||= ''; |
8767
|
|
|
|
|
|
|
|
8768
|
11
|
|
|
|
|
15
|
$slash = 'div'; |
8769
|
|
|
|
|
|
|
|
8770
|
|
|
|
|
|
|
# quote character class 1 |
8771
|
11
|
|
|
|
|
26
|
$charclass = q_tr($charclass); |
8772
|
|
|
|
|
|
|
|
8773
|
|
|
|
|
|
|
# quote character class 2 |
8774
|
11
|
50
|
|
|
|
22
|
$charclass2 = q_tr($charclass2); |
8775
|
11
|
0
|
|
|
|
34
|
|
8776
|
0
|
|
|
|
|
0
|
# /b /B modifier |
8777
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
8778
|
|
|
|
|
|
|
if ($variable eq '') { |
8779
|
0
|
|
|
|
|
0
|
$e_tr = qq{tr$charclass$e$charclass2$modifier}; |
8780
|
|
|
|
|
|
|
} |
8781
|
|
|
|
|
|
|
else { |
8782
|
|
|
|
|
|
|
$e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier}; |
8783
|
0
|
100
|
|
|
|
0
|
} |
8784
|
11
|
|
|
|
|
20
|
} |
8785
|
|
|
|
|
|
|
else { |
8786
|
|
|
|
|
|
|
if ($variable eq '') { |
8787
|
2
|
|
|
|
|
6
|
$e_tr = qq{Esjis::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}; |
8788
|
|
|
|
|
|
|
} |
8789
|
|
|
|
|
|
|
else { |
8790
|
|
|
|
|
|
|
$e_tr = qq{Esjis::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}; |
8791
|
|
|
|
|
|
|
} |
8792
|
9
|
|
|
|
|
28
|
} |
8793
|
11
|
|
|
|
|
17
|
|
8794
|
|
|
|
|
|
|
# clear tr/// variable |
8795
|
11
|
|
|
|
|
13
|
$tr_variable = ''; |
8796
|
|
|
|
|
|
|
$bind_operator = ''; |
8797
|
|
|
|
|
|
|
|
8798
|
|
|
|
|
|
|
return $e_tr; |
8799
|
|
|
|
|
|
|
} |
8800
|
|
|
|
|
|
|
|
8801
|
|
|
|
|
|
|
# |
8802
|
11
|
|
|
22
|
0
|
64
|
# quote for escape transliteration (tr/// or y///) |
8803
|
|
|
|
|
|
|
# |
8804
|
|
|
|
|
|
|
sub q_tr { |
8805
|
22
|
50
|
|
|
|
36
|
my($charclass) = @_; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8806
|
22
|
|
|
|
|
45
|
|
8807
|
|
|
|
|
|
|
# quote character class |
8808
|
|
|
|
|
|
|
if ($charclass !~ /'/oxms) { |
8809
|
22
|
|
|
|
|
40
|
return e_q('', "'", "'", $charclass); # --> q' ' |
8810
|
|
|
|
|
|
|
} |
8811
|
|
|
|
|
|
|
elsif ($charclass !~ /\//oxms) { |
8812
|
0
|
|
|
|
|
0
|
return e_q('q', '/', '/', $charclass); # --> q/ / |
8813
|
|
|
|
|
|
|
} |
8814
|
|
|
|
|
|
|
elsif ($charclass !~ /\#/oxms) { |
8815
|
0
|
|
|
|
|
0
|
return e_q('q', '#', '#', $charclass); # --> q# # |
8816
|
|
|
|
|
|
|
} |
8817
|
|
|
|
|
|
|
elsif ($charclass !~ /[\<\>]/oxms) { |
8818
|
0
|
|
|
|
|
0
|
return e_q('q', '<', '>', $charclass); # --> q< > |
8819
|
|
|
|
|
|
|
} |
8820
|
|
|
|
|
|
|
elsif ($charclass !~ /[\(\)]/oxms) { |
8821
|
0
|
|
|
|
|
0
|
return e_q('q', '(', ')', $charclass); # --> q( ) |
8822
|
|
|
|
|
|
|
} |
8823
|
|
|
|
|
|
|
elsif ($charclass !~ /[\{\}]/oxms) { |
8824
|
0
|
|
|
|
|
0
|
return e_q('q', '{', '}', $charclass); # --> q{ } |
8825
|
0
|
0
|
|
|
|
0
|
} |
8826
|
0
|
|
|
|
|
0
|
else { |
8827
|
|
|
|
|
|
|
for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8828
|
|
|
|
|
|
|
if ($charclass !~ /\Q$char\E/xms) { |
8829
|
|
|
|
|
|
|
return e_q('q', $char, $char, $charclass); |
8830
|
|
|
|
|
|
|
} |
8831
|
0
|
|
|
|
|
0
|
} |
8832
|
|
|
|
|
|
|
} |
8833
|
|
|
|
|
|
|
|
8834
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); |
8835
|
|
|
|
|
|
|
} |
8836
|
|
|
|
|
|
|
|
8837
|
|
|
|
|
|
|
# |
8838
|
0
|
|
|
3990
|
0
|
0
|
# escape q string (q//, '') |
8839
|
|
|
|
|
|
|
# |
8840
|
3990
|
|
|
|
|
11914
|
sub e_q { |
8841
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8842
|
3990
|
|
|
|
|
6421
|
|
8843
|
3990
|
|
|
|
|
27700
|
$slash = 'div'; |
8844
|
|
|
|
|
|
|
|
8845
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>$q_char) /oxmsg; |
8846
|
3990
|
100
|
100
|
|
|
11927
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
100
|
100
|
|
|
|
|
8847
|
21330
|
|
|
|
|
149041
|
|
8848
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
8849
|
|
|
|
|
|
|
if ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
8850
|
1
|
|
|
|
|
6
|
$char[$i] = $1 . '\\' . $2; |
8851
|
|
|
|
|
|
|
} |
8852
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8853
|
22
|
100
|
100
|
|
|
105
|
$char[$i] = $1 . '\\' . $2; |
8854
|
3990
|
|
|
|
|
16633
|
} |
8855
|
|
|
|
|
|
|
} |
8856
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8857
|
204
|
|
|
|
|
673
|
$char[-1] = $1 . '\\' . $2; |
8858
|
3990
|
|
|
|
|
22773
|
} |
8859
|
|
|
|
|
|
|
|
8860
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8861
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8862
|
|
|
|
|
|
|
} |
8863
|
|
|
|
|
|
|
|
8864
|
|
|
|
|
|
|
# |
8865
|
0
|
|
|
9592
|
0
|
0
|
# escape qq string (qq//, "", qx//, ``) |
8866
|
|
|
|
|
|
|
# |
8867
|
9592
|
|
|
|
|
23299
|
sub e_qq { |
8868
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8869
|
9592
|
|
|
|
|
13823
|
|
8870
|
9592
|
|
|
|
|
12382
|
$slash = 'div'; |
8871
|
|
|
|
|
|
|
|
8872
|
|
|
|
|
|
|
my $left_e = 0; |
8873
|
9592
|
|
|
|
|
11305
|
my $right_e = 0; |
8874
|
|
|
|
|
|
|
|
8875
|
|
|
|
|
|
|
# split regexp |
8876
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8877
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
8878
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8879
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8880
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
8881
|
|
|
|
|
|
|
\\ $q_char | |
8882
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8883
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8884
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8885
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8886
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8887
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8888
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8889
|
9592
|
|
|
|
|
362737
|
$q_char |
8890
|
|
|
|
|
|
|
))/oxmsg; |
8891
|
|
|
|
|
|
|
|
8892
|
9592
|
50
|
66
|
|
|
31150
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8893
|
309941
|
|
|
|
|
1035042
|
|
8894
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
8895
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8896
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8897
|
|
|
|
|
|
|
} |
8898
|
0
|
|
|
|
|
0
|
|
8899
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
8900
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8901
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8902
|
|
|
|
|
|
|
} |
8903
|
0
|
|
|
|
|
0
|
|
8904
|
|
|
|
|
|
|
# octal escape sequence |
8905
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8906
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
8907
|
|
|
|
|
|
|
} |
8908
|
1
|
|
|
|
|
4
|
|
8909
|
|
|
|
|
|
|
# hexadecimal escape sequence |
8910
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8911
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
8912
|
|
|
|
|
|
|
} |
8913
|
1
|
|
|
|
|
6
|
|
8914
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
8915
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
8916
|
0
|
100
|
|
|
|
0
|
$char[$i] = $1; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8917
|
|
|
|
|
|
|
} |
8918
|
|
|
|
|
|
|
|
8919
|
|
|
|
|
|
|
if (0) { |
8920
|
|
|
|
|
|
|
} |
8921
|
|
|
|
|
|
|
|
8922
|
309941
|
|
|
|
|
2996218
|
# escape last octet of multiple-octet |
8923
|
0
|
|
|
|
|
0
|
# my $metachar = qr/[\@\\\|]/oxms; # '|' is for qx//, ``, open(), and system() |
8924
|
|
|
|
|
|
|
# variable $delimiter and $end_delimiter can be '' |
8925
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\@\\\|$delimiter$end_delimiter]) \z/xms) { |
8926
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8927
|
|
|
|
|
|
|
} |
8928
|
|
|
|
|
|
|
|
8929
|
|
|
|
|
|
|
# \F |
8930
|
|
|
|
|
|
|
# |
8931
|
|
|
|
|
|
|
# P.69 Table 2-6. Translation escapes |
8932
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
8933
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8934
|
|
|
|
|
|
|
# (and so on) |
8935
|
1342
|
50
|
|
|
|
4761
|
|
8936
|
650
|
|
|
|
|
1833
|
# \u \l \U \L \F \Q \E |
8937
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8938
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8939
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8940
|
|
|
|
|
|
|
} |
8941
|
|
|
|
|
|
|
} |
8942
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
8943
|
|
|
|
|
|
|
|
8944
|
|
|
|
|
|
|
# "STRING @{[ LIST EXPR ]} MORE STRING" |
8945
|
|
|
|
|
|
|
|
8946
|
|
|
|
|
|
|
# P.257 Other Tricks You Can Do with Hard References |
8947
|
|
|
|
|
|
|
# in Chapter 8: References |
8948
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
8949
|
|
|
|
|
|
|
|
8950
|
|
|
|
|
|
|
# P.353 Other Tricks You Can Do with Hard References |
8951
|
|
|
|
|
|
|
# in Chapter 8: References |
8952
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8953
|
0
|
|
|
|
|
0
|
|
8954
|
0
|
|
|
|
|
0
|
# (and so on) |
8955
|
|
|
|
|
|
|
|
8956
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
8957
|
0
|
|
|
|
|
0
|
$left_e++; |
8958
|
0
|
|
|
|
|
0
|
} |
8959
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
8960
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
8961
|
0
|
|
|
|
|
0
|
$left_e++; |
8962
|
0
|
|
|
|
|
0
|
} |
8963
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
8964
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
8965
|
0
|
|
|
|
|
0
|
$left_e++; |
8966
|
6
|
|
|
|
|
9
|
} |
8967
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
8968
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
8969
|
6
|
|
|
|
|
13
|
$left_e++; |
8970
|
9
|
|
|
|
|
27
|
} |
8971
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
8972
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
8973
|
9
|
|
|
|
|
25
|
$left_e++; |
8974
|
0
|
|
|
|
|
0
|
} |
8975
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
8976
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8977
|
0
|
50
|
|
|
|
0
|
$left_e++; |
8978
|
12
|
|
|
|
|
28
|
} |
8979
|
12
|
|
|
|
|
20
|
elsif ($char[$i] eq '\E') { |
8980
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8981
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8982
|
12
|
|
|
|
|
28
|
$right_e++; |
8983
|
|
|
|
|
|
|
} |
8984
|
|
|
|
|
|
|
else { |
8985
|
|
|
|
|
|
|
$char[$i] = ''; |
8986
|
0
|
|
|
|
|
0
|
} |
8987
|
0
|
0
|
|
|
|
0
|
} |
8988
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8989
|
|
|
|
|
|
|
while (1) { |
8990
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
8991
|
0
|
|
|
|
|
0
|
last; |
8992
|
|
|
|
|
|
|
} |
8993
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8994
|
|
|
|
|
|
|
last; |
8995
|
|
|
|
|
|
|
} |
8996
|
|
|
|
|
|
|
} |
8997
|
|
|
|
|
|
|
} |
8998
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
8999
|
|
|
|
|
|
|
} |
9000
|
|
|
|
|
|
|
|
9001
|
|
|
|
|
|
|
# $0 --> $0 |
9002
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9003
|
|
|
|
|
|
|
} |
9004
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9005
|
|
|
|
|
|
|
} |
9006
|
|
|
|
|
|
|
|
9007
|
|
|
|
|
|
|
# $$ --> $$ |
9008
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9009
|
|
|
|
|
|
|
} |
9010
|
|
|
|
|
|
|
|
9011
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9012
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9013
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9014
|
415
|
|
|
|
|
1421
|
$char[$i] = e_capture($1); |
9015
|
|
|
|
|
|
|
} |
9016
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9017
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9018
|
|
|
|
|
|
|
} |
9019
|
0
|
|
|
|
|
0
|
|
9020
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9021
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9022
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9023
|
|
|
|
|
|
|
} |
9024
|
0
|
|
|
|
|
0
|
|
9025
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
9026
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9027
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9028
|
|
|
|
|
|
|
} |
9029
|
0
|
|
|
|
|
0
|
|
9030
|
|
|
|
|
|
|
# $$foo |
9031
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9032
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9033
|
|
|
|
|
|
|
} |
9034
|
0
|
|
|
|
|
0
|
|
9035
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9036
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9037
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9038
|
|
|
|
|
|
|
} |
9039
|
44
|
|
|
|
|
157
|
|
9040
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9041
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9042
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9043
|
|
|
|
|
|
|
} |
9044
|
45
|
|
|
|
|
160
|
|
9045
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9046
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9047
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9048
|
|
|
|
|
|
|
} |
9049
|
|
|
|
|
|
|
|
9050
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
9051
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
9052
|
|
|
|
|
|
|
} |
9053
|
33
|
|
|
|
|
119
|
|
9054
|
|
|
|
|
|
|
# ${ ... } |
9055
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9056
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9057
|
|
|
|
|
|
|
} |
9058
|
0
|
100
|
|
|
|
0
|
} |
9059
|
9592
|
|
|
|
|
23412
|
|
9060
|
|
|
|
|
|
|
# return string |
9061
|
3
|
|
|
|
|
19
|
if ($left_e > $right_e) { |
9062
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter; |
9063
|
|
|
|
|
|
|
} |
9064
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
9065
|
|
|
|
|
|
|
} |
9066
|
|
|
|
|
|
|
|
9067
|
|
|
|
|
|
|
# |
9068
|
9589
|
|
|
34
|
0
|
83124
|
# escape qw string (qw//) |
9069
|
|
|
|
|
|
|
# |
9070
|
34
|
|
|
|
|
183
|
sub e_qw { |
9071
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
9072
|
|
|
|
|
|
|
|
9073
|
34
|
|
|
|
|
81
|
$slash = 'div'; |
|
34
|
|
|
|
|
357
|
|
9074
|
621
|
50
|
|
|
|
1080
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9075
|
34
|
|
|
|
|
189
|
# choice again delimiter |
9076
|
|
|
|
|
|
|
my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg); |
9077
|
|
|
|
|
|
|
if (not $octet{$end_delimiter}) { |
9078
|
34
|
|
|
|
|
255
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
9079
|
|
|
|
|
|
|
} |
9080
|
|
|
|
|
|
|
elsif (not $octet{')'}) { |
9081
|
0
|
|
|
|
|
0
|
return join '', $ope, '(', $string, ')'; |
9082
|
|
|
|
|
|
|
} |
9083
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9084
|
0
|
|
|
|
|
0
|
return join '', $ope, '{', $string, '}'; |
9085
|
|
|
|
|
|
|
} |
9086
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9087
|
0
|
|
|
|
|
0
|
return join '', $ope, '[', $string, ']'; |
9088
|
|
|
|
|
|
|
} |
9089
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9090
|
0
|
|
|
|
|
0
|
return join '', $ope, '<', $string, '>'; |
9091
|
0
|
0
|
|
|
|
0
|
} |
9092
|
0
|
|
|
|
|
0
|
else { |
9093
|
|
|
|
|
|
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9094
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9095
|
|
|
|
|
|
|
return join '', $ope, $char, $string, $char; |
9096
|
|
|
|
|
|
|
} |
9097
|
|
|
|
|
|
|
} |
9098
|
0
|
|
|
|
|
0
|
} |
9099
|
0
|
|
|
|
|
0
|
|
9100
|
0
|
|
|
|
|
0
|
# qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC') |
9101
|
0
|
|
|
|
|
0
|
my @string = CORE::split(/\s+/, $string); |
9102
|
0
|
0
|
|
|
|
0
|
for my $string (@string) { |
9103
|
0
|
|
|
|
|
0
|
my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
9104
|
|
|
|
|
|
|
for my $octet (@octet) { |
9105
|
|
|
|
|
|
|
if ($octet =~ /\A (['\\]) \z/oxms) { |
9106
|
0
|
|
|
|
|
0
|
$octet = '\\' . $1; |
9107
|
|
|
|
|
|
|
} |
9108
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
9109
|
|
|
|
|
|
|
$string = join '', @octet; |
9110
|
|
|
|
|
|
|
} |
9111
|
|
|
|
|
|
|
return join '', '(', (join ', ', map { "'$_'" } @string), ')'; |
9112
|
|
|
|
|
|
|
} |
9113
|
|
|
|
|
|
|
|
9114
|
|
|
|
|
|
|
# |
9115
|
0
|
|
|
108
|
0
|
0
|
# escape here document (<<"HEREDOC", <
|
9116
|
|
|
|
|
|
|
# |
9117
|
108
|
|
|
|
|
333
|
sub e_heredoc { |
9118
|
|
|
|
|
|
|
my($string) = @_; |
9119
|
108
|
|
|
|
|
197
|
|
9120
|
|
|
|
|
|
|
$slash = 'm//'; |
9121
|
108
|
|
|
|
|
437
|
|
9122
|
108
|
|
|
|
|
195
|
my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC` |
9123
|
|
|
|
|
|
|
|
9124
|
|
|
|
|
|
|
my $left_e = 0; |
9125
|
108
|
|
|
|
|
167
|
my $right_e = 0; |
9126
|
|
|
|
|
|
|
|
9127
|
|
|
|
|
|
|
# split regexp |
9128
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9129
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9130
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9131
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9132
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
9133
|
|
|
|
|
|
|
\\ $q_char | |
9134
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9135
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9136
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9137
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9138
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9139
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9140
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9141
|
108
|
|
|
|
|
12048
|
$q_char |
9142
|
|
|
|
|
|
|
))/oxmsg; |
9143
|
|
|
|
|
|
|
|
9144
|
108
|
50
|
66
|
|
|
589
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9145
|
3225
|
|
|
|
|
11534
|
|
9146
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
9147
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9148
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9149
|
|
|
|
|
|
|
} |
9150
|
0
|
|
|
|
|
0
|
|
9151
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
9152
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9153
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9154
|
|
|
|
|
|
|
} |
9155
|
0
|
|
|
|
|
0
|
|
9156
|
|
|
|
|
|
|
# octal escape sequence |
9157
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9158
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
9159
|
|
|
|
|
|
|
} |
9160
|
1
|
|
|
|
|
5
|
|
9161
|
|
|
|
|
|
|
# hexadecimal escape sequence |
9162
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9163
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
9164
|
|
|
|
|
|
|
} |
9165
|
1
|
|
|
|
|
4
|
|
9166
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
9167
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
9168
|
0
|
100
|
|
|
|
0
|
$char[$i] = $1; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9169
|
|
|
|
|
|
|
} |
9170
|
|
|
|
|
|
|
|
9171
|
|
|
|
|
|
|
if (0) { |
9172
|
3225
|
|
|
|
|
32301
|
} |
9173
|
0
|
|
|
|
|
0
|
|
9174
|
|
|
|
|
|
|
# escape character |
9175
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
9176
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9177
|
|
|
|
|
|
|
} |
9178
|
57
|
50
|
|
|
|
245
|
|
9179
|
72
|
|
|
|
|
163
|
# \u \l \U \L \F \Q \E |
9180
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
9181
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9182
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9183
|
0
|
|
|
|
|
0
|
} |
9184
|
0
|
|
|
|
|
0
|
} |
9185
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
9186
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
9187
|
0
|
|
|
|
|
0
|
$left_e++; |
9188
|
0
|
|
|
|
|
0
|
} |
9189
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
9190
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
9191
|
0
|
|
|
|
|
0
|
$left_e++; |
9192
|
0
|
|
|
|
|
0
|
} |
9193
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
9194
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
9195
|
0
|
|
|
|
|
0
|
$left_e++; |
9196
|
6
|
|
|
|
|
10
|
} |
9197
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
9198
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
9199
|
6
|
|
|
|
|
10
|
$left_e++; |
9200
|
0
|
|
|
|
|
0
|
} |
9201
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
9202
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
9203
|
0
|
|
|
|
|
0
|
$left_e++; |
9204
|
0
|
|
|
|
|
0
|
} |
9205
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
9206
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9207
|
0
|
50
|
|
|
|
0
|
$left_e++; |
9208
|
3
|
|
|
|
|
7
|
} |
9209
|
3
|
|
|
|
|
4
|
elsif ($char[$i] eq '\E') { |
9210
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9211
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9212
|
3
|
|
|
|
|
6
|
$right_e++; |
9213
|
|
|
|
|
|
|
} |
9214
|
|
|
|
|
|
|
else { |
9215
|
|
|
|
|
|
|
$char[$i] = ''; |
9216
|
0
|
|
|
|
|
0
|
} |
9217
|
0
|
0
|
|
|
|
0
|
} |
9218
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9219
|
|
|
|
|
|
|
while (1) { |
9220
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9221
|
0
|
|
|
|
|
0
|
last; |
9222
|
|
|
|
|
|
|
} |
9223
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9224
|
|
|
|
|
|
|
last; |
9225
|
|
|
|
|
|
|
} |
9226
|
|
|
|
|
|
|
} |
9227
|
|
|
|
|
|
|
} |
9228
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9229
|
|
|
|
|
|
|
} |
9230
|
|
|
|
|
|
|
|
9231
|
|
|
|
|
|
|
# $0 --> $0 |
9232
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9233
|
|
|
|
|
|
|
} |
9234
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9235
|
|
|
|
|
|
|
} |
9236
|
|
|
|
|
|
|
|
9237
|
|
|
|
|
|
|
# $$ --> $$ |
9238
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9239
|
|
|
|
|
|
|
} |
9240
|
|
|
|
|
|
|
|
9241
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9242
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9243
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9244
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9245
|
|
|
|
|
|
|
} |
9246
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9247
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9248
|
|
|
|
|
|
|
} |
9249
|
0
|
|
|
|
|
0
|
|
9250
|
|
|
|
|
|
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9251
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9252
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9253
|
|
|
|
|
|
|
} |
9254
|
0
|
|
|
|
|
0
|
|
9255
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
9256
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9257
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9258
|
|
|
|
|
|
|
} |
9259
|
0
|
|
|
|
|
0
|
|
9260
|
|
|
|
|
|
|
# $$foo |
9261
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9262
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9263
|
|
|
|
|
|
|
} |
9264
|
0
|
|
|
|
|
0
|
|
9265
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9266
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9267
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9268
|
|
|
|
|
|
|
} |
9269
|
8
|
|
|
|
|
58
|
|
9270
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9271
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9272
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9273
|
|
|
|
|
|
|
} |
9274
|
8
|
|
|
|
|
60
|
|
9275
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9276
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9277
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9278
|
|
|
|
|
|
|
} |
9279
|
|
|
|
|
|
|
|
9280
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
9281
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
9282
|
|
|
|
|
|
|
} |
9283
|
6
|
|
|
|
|
39
|
|
9284
|
|
|
|
|
|
|
# ${ ... } |
9285
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9286
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9287
|
|
|
|
|
|
|
} |
9288
|
0
|
100
|
|
|
|
0
|
} |
9289
|
108
|
|
|
|
|
328
|
|
9290
|
|
|
|
|
|
|
# return string |
9291
|
3
|
|
|
|
|
27
|
if ($left_e > $right_e) { |
9292
|
|
|
|
|
|
|
return join '', @char, '>]}' x ($left_e - $right_e); |
9293
|
|
|
|
|
|
|
} |
9294
|
|
|
|
|
|
|
return join '', @char; |
9295
|
|
|
|
|
|
|
} |
9296
|
|
|
|
|
|
|
|
9297
|
|
|
|
|
|
|
# |
9298
|
105
|
|
|
1835
|
0
|
925
|
# escape regexp (m//, qr//) |
9299
|
1835
|
|
100
|
|
|
7981
|
# |
9300
|
|
|
|
|
|
|
sub e_qr { |
9301
|
1835
|
|
|
|
|
6391
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9302
|
1835
|
50
|
|
|
|
3515
|
$modifier ||= ''; |
9303
|
1835
|
|
|
|
|
5003
|
|
9304
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9305
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9306
|
0
|
|
|
|
|
0
|
my $line = 0; |
9307
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9308
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9309
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9310
|
0
|
|
|
|
|
0
|
last; |
9311
|
|
|
|
|
|
|
} |
9312
|
|
|
|
|
|
|
} |
9313
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9314
|
|
|
|
|
|
|
} |
9315
|
|
|
|
|
|
|
|
9316
|
1835
|
100
|
|
|
|
3099
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9317
|
1835
|
|
|
|
|
5862
|
|
9318
|
8
|
|
|
|
|
14
|
# literal null string pattern |
9319
|
8
|
|
|
|
|
14
|
if ($string eq '') { |
9320
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9321
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9322
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9323
|
|
|
|
|
|
|
} |
9324
|
|
|
|
|
|
|
|
9325
|
|
|
|
|
|
|
# /b /B modifier |
9326
|
8
|
50
|
|
|
|
49
|
elsif ($modifier =~ tr/bB//d) { |
9327
|
240
|
|
|
|
|
589
|
|
9328
|
0
|
|
|
|
|
0
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9329
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9330
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
9331
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9332
|
|
|
|
|
|
|
if (not $octet{')'}) { |
9333
|
|
|
|
|
|
|
$delimiter = '('; |
9334
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
9335
|
0
|
|
|
|
|
0
|
} |
9336
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9337
|
|
|
|
|
|
|
$delimiter = '{'; |
9338
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
9339
|
0
|
|
|
|
|
0
|
} |
9340
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9341
|
|
|
|
|
|
|
$delimiter = '['; |
9342
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
9343
|
0
|
|
|
|
|
0
|
} |
9344
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9345
|
|
|
|
|
|
|
$delimiter = '<'; |
9346
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
9347
|
0
|
0
|
|
|
|
0
|
} |
9348
|
0
|
|
|
|
|
0
|
else { |
9349
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9350
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9351
|
|
|
|
|
|
|
$delimiter = $char; |
9352
|
|
|
|
|
|
|
$end_delimiter = $char; |
9353
|
|
|
|
|
|
|
last; |
9354
|
|
|
|
|
|
|
} |
9355
|
|
|
|
|
|
|
} |
9356
|
0
|
100
|
100
|
|
|
0
|
} |
9357
|
240
|
|
|
|
|
1174
|
} |
9358
|
|
|
|
|
|
|
|
9359
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9360
|
90
|
|
|
|
|
499
|
return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier; |
9361
|
|
|
|
|
|
|
} |
9362
|
|
|
|
|
|
|
else { |
9363
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9364
|
150
|
100
|
|
|
|
1018
|
} |
9365
|
1587
|
|
|
|
|
3975
|
} |
9366
|
|
|
|
|
|
|
|
9367
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9368
|
1587
|
|
|
|
|
6853
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9369
|
|
|
|
|
|
|
|
9370
|
|
|
|
|
|
|
# split regexp |
9371
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9372
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9373
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9374
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9375
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9376
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9377
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9378
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
9379
|
|
|
|
|
|
|
\\ $q_char | |
9380
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9381
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9382
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9383
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9384
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9385
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9386
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9387
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9388
|
|
|
|
|
|
|
\[\^ | |
9389
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9390
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9391
|
|
|
|
|
|
|
\(\? | |
9392
|
|
|
|
|
|
|
$q_char |
9393
|
1587
|
50
|
|
|
|
140906
|
))/oxmsg; |
9394
|
1587
|
|
|
|
|
7162
|
|
|
0
|
|
|
|
|
0
|
|
9395
|
0
|
0
|
|
|
|
0
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9396
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
9397
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9398
|
|
|
|
|
|
|
if (not $octet{')'}) { |
9399
|
|
|
|
|
|
|
$delimiter = '('; |
9400
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
9401
|
0
|
|
|
|
|
0
|
} |
9402
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9403
|
|
|
|
|
|
|
$delimiter = '{'; |
9404
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
9405
|
0
|
|
|
|
|
0
|
} |
9406
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9407
|
|
|
|
|
|
|
$delimiter = '['; |
9408
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
9409
|
0
|
|
|
|
|
0
|
} |
9410
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9411
|
|
|
|
|
|
|
$delimiter = '<'; |
9412
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
9413
|
0
|
0
|
|
|
|
0
|
} |
9414
|
0
|
|
|
|
|
0
|
else { |
9415
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9416
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9417
|
|
|
|
|
|
|
$delimiter = $char; |
9418
|
|
|
|
|
|
|
$end_delimiter = $char; |
9419
|
|
|
|
|
|
|
last; |
9420
|
|
|
|
|
|
|
} |
9421
|
|
|
|
|
|
|
} |
9422
|
0
|
|
|
|
|
0
|
} |
9423
|
1587
|
|
|
|
|
2551
|
} |
9424
|
1587
|
|
|
|
|
2226
|
|
9425
|
|
|
|
|
|
|
my $left_e = 0; |
9426
|
|
|
|
|
|
|
my $right_e = 0; |
9427
|
1587
|
50
|
66
|
|
|
4190
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9428
|
5437
|
|
|
|
|
29160
|
|
9429
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
9430
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9431
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9432
|
|
|
|
|
|
|
} |
9433
|
0
|
|
|
|
|
0
|
|
9434
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
9435
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9436
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9437
|
|
|
|
|
|
|
} |
9438
|
0
|
|
|
|
|
0
|
|
9439
|
|
|
|
|
|
|
# octal escape sequence |
9440
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9441
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
9442
|
|
|
|
|
|
|
} |
9443
|
1
|
|
|
|
|
4
|
|
9444
|
|
|
|
|
|
|
# hexadecimal escape sequence |
9445
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9446
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
9447
|
|
|
|
|
|
|
} |
9448
|
|
|
|
|
|
|
|
9449
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9450
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9451
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9452
|
1
|
|
|
|
|
4
|
# \p{PROPERTY} --> p\{PROPERTY} |
9453
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
9454
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
9455
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9456
|
|
|
|
|
|
|
} |
9457
|
6
|
|
|
|
|
23
|
|
9458
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
9459
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9460
|
4
|
100
|
100
|
|
|
14
|
$char[$i] = $1; |
|
|
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
|
|
|
|
|
|
9461
|
|
|
|
|
|
|
} |
9462
|
|
|
|
|
|
|
|
9463
|
|
|
|
|
|
|
if (0) { |
9464
|
5437
|
|
|
|
|
37096
|
} |
9465
|
0
|
|
|
|
|
0
|
|
9466
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
9467
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9468
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9469
|
|
|
|
|
|
|
} |
9470
|
77
|
50
|
33
|
|
|
327
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
9471
|
6
|
|
|
|
|
118
|
# join separated multiple-octet |
9472
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9473
|
|
|
|
|
|
|
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)) { |
9474
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9475
|
|
|
|
|
|
|
} |
9476
|
|
|
|
|
|
|
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)) { |
9477
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9478
|
|
|
|
|
|
|
} |
9479
|
|
|
|
|
|
|
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)) { |
9480
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9481
|
|
|
|
|
|
|
} |
9482
|
|
|
|
|
|
|
} |
9483
|
0
|
|
|
|
|
0
|
|
9484
|
|
|
|
|
|
|
# open character class [...] |
9485
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
9486
|
|
|
|
|
|
|
my $left = $i; |
9487
|
|
|
|
|
|
|
|
9488
|
586
|
100
|
|
|
|
1004
|
# [] make die "Unmatched [] in regexp ...\n" |
9489
|
586
|
|
|
|
|
1433
|
# (and so on) |
9490
|
|
|
|
|
|
|
|
9491
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9492
|
3
|
|
|
|
|
7
|
$i++; |
9493
|
586
|
50
|
|
|
|
776
|
} |
9494
|
2583
|
|
|
|
|
3777
|
|
9495
|
|
|
|
|
|
|
while (1) { |
9496
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
9497
|
2583
|
|
|
|
|
3997
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9498
|
|
|
|
|
|
|
} |
9499
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9500
|
586
|
100
|
|
|
|
790
|
my $right = $i; |
9501
|
586
|
|
|
|
|
3349
|
|
|
90
|
|
|
|
|
211
|
|
9502
|
|
|
|
|
|
|
# [...] |
9503
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9504
|
270
|
|
|
|
|
457
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9505
|
|
|
|
|
|
|
} |
9506
|
|
|
|
|
|
|
else { |
9507
|
496
|
|
|
|
|
2041
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
9508
|
586
|
|
|
|
|
1116
|
} |
9509
|
|
|
|
|
|
|
|
9510
|
|
|
|
|
|
|
$i = $left; |
9511
|
|
|
|
|
|
|
last; |
9512
|
|
|
|
|
|
|
} |
9513
|
|
|
|
|
|
|
} |
9514
|
|
|
|
|
|
|
} |
9515
|
586
|
|
|
|
|
1775
|
|
9516
|
|
|
|
|
|
|
# open character class [^...] |
9517
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
9518
|
|
|
|
|
|
|
my $left = $i; |
9519
|
|
|
|
|
|
|
|
9520
|
328
|
100
|
|
|
|
505
|
# [^] make die "Unmatched [] in regexp ...\n" |
9521
|
328
|
|
|
|
|
747
|
# (and so on) |
9522
|
|
|
|
|
|
|
|
9523
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9524
|
5
|
|
|
|
|
8
|
$i++; |
9525
|
328
|
50
|
|
|
|
424
|
} |
9526
|
1447
|
|
|
|
|
2100
|
|
9527
|
|
|
|
|
|
|
while (1) { |
9528
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
9529
|
1447
|
|
|
|
|
2133
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9530
|
|
|
|
|
|
|
} |
9531
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9532
|
328
|
100
|
|
|
|
433
|
my $right = $i; |
9533
|
328
|
|
|
|
|
1832
|
|
|
90
|
|
|
|
|
209
|
|
9534
|
|
|
|
|
|
|
# [^...] |
9535
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9536
|
270
|
|
|
|
|
458
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9537
|
|
|
|
|
|
|
} |
9538
|
|
|
|
|
|
|
else { |
9539
|
238
|
|
|
|
|
916
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9540
|
328
|
|
|
|
|
752
|
} |
9541
|
|
|
|
|
|
|
|
9542
|
|
|
|
|
|
|
$i = $left; |
9543
|
|
|
|
|
|
|
last; |
9544
|
|
|
|
|
|
|
} |
9545
|
|
|
|
|
|
|
} |
9546
|
|
|
|
|
|
|
} |
9547
|
328
|
|
|
|
|
940
|
|
9548
|
|
|
|
|
|
|
# rewrite character class or escape character |
9549
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9550
|
|
|
|
|
|
|
$char[$i] = $char; |
9551
|
|
|
|
|
|
|
} |
9552
|
215
|
50
|
|
|
|
678
|
|
9553
|
238
|
|
|
|
|
515
|
# /i modifier |
9554
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
9555
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
9556
|
238
|
|
|
|
|
426
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
9557
|
|
|
|
|
|
|
} |
9558
|
|
|
|
|
|
|
else { |
9559
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
9560
|
|
|
|
|
|
|
} |
9561
|
|
|
|
|
|
|
} |
9562
|
0
|
50
|
|
|
|
0
|
|
9563
|
1
|
|
|
|
|
7
|
# \u \l \U \L \F \Q \E |
9564
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9565
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9566
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9567
|
0
|
|
|
|
|
0
|
} |
9568
|
0
|
|
|
|
|
0
|
} |
9569
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
9570
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
9571
|
0
|
|
|
|
|
0
|
$left_e++; |
9572
|
0
|
|
|
|
|
0
|
} |
9573
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
9574
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
9575
|
0
|
|
|
|
|
0
|
$left_e++; |
9576
|
1
|
|
|
|
|
3
|
} |
9577
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
9578
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
9579
|
1
|
|
|
|
|
4
|
$left_e++; |
9580
|
1
|
|
|
|
|
3
|
} |
9581
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
9582
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
9583
|
1
|
|
|
|
|
3
|
$left_e++; |
9584
|
9
|
|
|
|
|
20
|
} |
9585
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
9586
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
9587
|
9
|
|
|
|
|
24
|
$left_e++; |
9588
|
22
|
|
|
|
|
42
|
} |
9589
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
9590
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9591
|
22
|
50
|
|
|
|
54
|
$left_e++; |
9592
|
33
|
|
|
|
|
77
|
} |
9593
|
33
|
|
|
|
|
48
|
elsif ($char[$i] eq '\E') { |
9594
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9595
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9596
|
33
|
|
|
|
|
84
|
$right_e++; |
9597
|
|
|
|
|
|
|
} |
9598
|
|
|
|
|
|
|
else { |
9599
|
|
|
|
|
|
|
$char[$i] = ''; |
9600
|
0
|
|
|
|
|
0
|
} |
9601
|
0
|
0
|
|
|
|
0
|
} |
9602
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9603
|
|
|
|
|
|
|
while (1) { |
9604
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9605
|
0
|
|
|
|
|
0
|
last; |
9606
|
|
|
|
|
|
|
} |
9607
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9608
|
|
|
|
|
|
|
last; |
9609
|
|
|
|
|
|
|
} |
9610
|
|
|
|
|
|
|
} |
9611
|
|
|
|
|
|
|
} |
9612
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9613
|
|
|
|
|
|
|
} |
9614
|
0
|
0
|
|
|
|
0
|
|
9615
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
9616
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9617
|
|
|
|
|
|
|
if ($ignorecase) { |
9618
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9619
|
0
|
0
|
|
|
|
0
|
} |
9620
|
0
|
|
|
|
|
0
|
} |
9621
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9622
|
|
|
|
|
|
|
if ($ignorecase) { |
9623
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9624
|
|
|
|
|
|
|
} |
9625
|
|
|
|
|
|
|
} |
9626
|
|
|
|
|
|
|
|
9627
|
|
|
|
|
|
|
# $$ --> $$ |
9628
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9629
|
|
|
|
|
|
|
} |
9630
|
|
|
|
|
|
|
|
9631
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9632
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9633
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9634
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9635
|
|
|
|
|
|
|
if ($ignorecase) { |
9636
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9637
|
0
|
|
|
|
|
0
|
} |
9638
|
0
|
0
|
|
|
|
0
|
} |
9639
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9640
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9641
|
|
|
|
|
|
|
if ($ignorecase) { |
9642
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9643
|
|
|
|
|
|
|
} |
9644
|
|
|
|
|
|
|
} |
9645
|
0
|
|
|
|
|
0
|
|
9646
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9647
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9648
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9649
|
|
|
|
|
|
|
if ($ignorecase) { |
9650
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9651
|
|
|
|
|
|
|
} |
9652
|
|
|
|
|
|
|
} |
9653
|
0
|
|
|
|
|
0
|
|
9654
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
9655
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9656
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9657
|
|
|
|
|
|
|
if ($ignorecase) { |
9658
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9659
|
|
|
|
|
|
|
} |
9660
|
|
|
|
|
|
|
} |
9661
|
0
|
|
|
|
|
0
|
|
9662
|
0
|
0
|
|
|
|
0
|
# $$foo |
9663
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9664
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9665
|
|
|
|
|
|
|
if ($ignorecase) { |
9666
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9667
|
|
|
|
|
|
|
} |
9668
|
|
|
|
|
|
|
} |
9669
|
0
|
50
|
|
|
|
0
|
|
9670
|
8
|
|
|
|
|
25
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9671
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9672
|
|
|
|
|
|
|
if ($ignorecase) { |
9673
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
9674
|
|
|
|
|
|
|
} |
9675
|
|
|
|
|
|
|
else { |
9676
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9677
|
|
|
|
|
|
|
} |
9678
|
|
|
|
|
|
|
} |
9679
|
8
|
50
|
|
|
|
33
|
|
9680
|
8
|
|
|
|
|
25
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9681
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9682
|
|
|
|
|
|
|
if ($ignorecase) { |
9683
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
9684
|
|
|
|
|
|
|
} |
9685
|
|
|
|
|
|
|
else { |
9686
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9687
|
|
|
|
|
|
|
} |
9688
|
|
|
|
|
|
|
} |
9689
|
8
|
50
|
|
|
|
32
|
|
9690
|
6
|
|
|
|
|
18
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9691
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9692
|
|
|
|
|
|
|
if ($ignorecase) { |
9693
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
9694
|
|
|
|
|
|
|
} |
9695
|
|
|
|
|
|
|
else { |
9696
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9697
|
|
|
|
|
|
|
} |
9698
|
|
|
|
|
|
|
} |
9699
|
6
|
0
|
|
|
|
21
|
|
9700
|
0
|
|
|
|
|
0
|
# ${ foo } |
9701
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
9702
|
|
|
|
|
|
|
if ($ignorecase) { |
9703
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9704
|
|
|
|
|
|
|
} |
9705
|
|
|
|
|
|
|
} |
9706
|
0
|
|
|
|
|
0
|
|
9707
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
9708
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9709
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9710
|
|
|
|
|
|
|
if ($ignorecase) { |
9711
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9712
|
|
|
|
|
|
|
} |
9713
|
|
|
|
|
|
|
} |
9714
|
0
|
|
|
|
|
0
|
|
9715
|
31
|
100
|
|
|
|
131
|
# $scalar or @array |
9716
|
31
|
|
|
|
|
110
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
9717
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
9718
|
|
|
|
|
|
|
if ($ignorecase) { |
9719
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9720
|
|
|
|
|
|
|
} |
9721
|
|
|
|
|
|
|
} |
9722
|
4
|
100
|
66
|
|
|
20
|
|
|
|
50
|
|
|
|
|
|
9723
|
|
|
|
|
|
|
# quote character before ? + * { |
9724
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9725
|
188
|
|
|
|
|
1549
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
9726
|
0
|
0
|
|
|
|
0
|
} |
9727
|
0
|
|
|
|
|
0
|
elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9728
|
|
|
|
|
|
|
my $char = $char[$i-1]; |
9729
|
|
|
|
|
|
|
if ($char[$i] eq '{') { |
9730
|
0
|
|
|
|
|
0
|
die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n}; |
9731
|
|
|
|
|
|
|
} |
9732
|
|
|
|
|
|
|
else { |
9733
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n}; |
9734
|
0
|
|
|
|
|
0
|
} |
9735
|
|
|
|
|
|
|
} |
9736
|
|
|
|
|
|
|
else { |
9737
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9738
|
|
|
|
|
|
|
} |
9739
|
|
|
|
|
|
|
} |
9740
|
187
|
|
|
|
|
817
|
} |
9741
|
1587
|
50
|
|
|
|
3090
|
|
9742
|
1587
|
0
|
0
|
|
|
3508
|
# make regexp string |
9743
|
0
|
|
|
|
|
0
|
$modifier =~ tr/i//d; |
9744
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
9745
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9746
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier; |
9747
|
|
|
|
|
|
|
} |
9748
|
|
|
|
|
|
|
else { |
9749
|
0
|
100
|
100
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
9750
|
1587
|
|
|
|
|
8373
|
} |
9751
|
|
|
|
|
|
|
} |
9752
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9753
|
94
|
|
|
|
|
705
|
return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier; |
9754
|
|
|
|
|
|
|
} |
9755
|
|
|
|
|
|
|
else { |
9756
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9757
|
|
|
|
|
|
|
} |
9758
|
|
|
|
|
|
|
} |
9759
|
|
|
|
|
|
|
|
9760
|
|
|
|
|
|
|
# |
9761
|
1493
|
|
|
540
|
0
|
14002
|
# double quote stuff |
9762
|
|
|
|
|
|
|
# |
9763
|
|
|
|
|
|
|
sub qq_stuff { |
9764
|
540
|
100
|
|
|
|
1020
|
my($delimiter,$end_delimiter,$stuff) = @_; |
9765
|
540
|
|
|
|
|
1277
|
|
9766
|
|
|
|
|
|
|
# scalar variable or array variable |
9767
|
|
|
|
|
|
|
if ($stuff =~ /\A [\$\@] /oxms) { |
9768
|
|
|
|
|
|
|
return $stuff; |
9769
|
300
|
|
|
|
|
1065
|
} |
|
240
|
|
|
|
|
671
|
|
9770
|
280
|
|
|
|
|
749
|
|
9771
|
240
|
50
|
|
|
|
594
|
# quote by delimiter |
9772
|
240
|
50
|
|
|
|
398
|
my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg); |
9773
|
240
|
50
|
|
|
|
380
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9774
|
240
|
|
|
|
|
431
|
next if $char eq $delimiter; |
9775
|
|
|
|
|
|
|
next if $char eq $end_delimiter; |
9776
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9777
|
240
|
|
|
|
|
947
|
return join '', 'qq', $char, $stuff, $char; |
9778
|
|
|
|
|
|
|
} |
9779
|
|
|
|
|
|
|
} |
9780
|
|
|
|
|
|
|
return join '', 'qq', '<', $stuff, '>'; |
9781
|
|
|
|
|
|
|
} |
9782
|
|
|
|
|
|
|
|
9783
|
|
|
|
|
|
|
# |
9784
|
0
|
|
|
163
|
0
|
0
|
# escape regexp (m'', qr'', and m''b, qr''b) |
9785
|
163
|
|
100
|
|
|
785
|
# |
9786
|
|
|
|
|
|
|
sub e_qr_q { |
9787
|
163
|
|
|
|
|
518
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9788
|
163
|
50
|
|
|
|
311
|
$modifier ||= ''; |
9789
|
163
|
|
|
|
|
474
|
|
9790
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9791
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9792
|
0
|
|
|
|
|
0
|
my $line = 0; |
9793
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9794
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9795
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9796
|
0
|
|
|
|
|
0
|
last; |
9797
|
|
|
|
|
|
|
} |
9798
|
|
|
|
|
|
|
} |
9799
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9800
|
|
|
|
|
|
|
} |
9801
|
|
|
|
|
|
|
|
9802
|
163
|
100
|
|
|
|
276
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9803
|
163
|
|
|
|
|
403
|
|
9804
|
8
|
|
|
|
|
11
|
# literal null string pattern |
9805
|
8
|
|
|
|
|
13
|
if ($string eq '') { |
9806
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9807
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9808
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9809
|
|
|
|
|
|
|
} |
9810
|
8
|
|
|
|
|
49
|
|
9811
|
|
|
|
|
|
|
# with /b /B modifier |
9812
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9813
|
|
|
|
|
|
|
return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
9814
|
|
|
|
|
|
|
} |
9815
|
89
|
|
|
|
|
225
|
|
9816
|
|
|
|
|
|
|
# without /b /B modifier |
9817
|
|
|
|
|
|
|
else { |
9818
|
|
|
|
|
|
|
return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
9819
|
|
|
|
|
|
|
} |
9820
|
|
|
|
|
|
|
} |
9821
|
|
|
|
|
|
|
|
9822
|
|
|
|
|
|
|
# |
9823
|
66
|
|
|
66
|
0
|
173
|
# escape regexp (m'', qr'') |
9824
|
|
|
|
|
|
|
# |
9825
|
66
|
100
|
|
|
|
174
|
sub e_qr_qt { |
9826
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9827
|
|
|
|
|
|
|
|
9828
|
66
|
|
|
|
|
172
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9829
|
|
|
|
|
|
|
|
9830
|
|
|
|
|
|
|
# split regexp |
9831
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9832
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\$\@\/] | |
9833
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9834
|
|
|
|
|
|
|
\[\^ | |
9835
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
9836
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
9837
|
|
|
|
|
|
|
[\$\@\/] | |
9838
|
|
|
|
|
|
|
\\ (?:$q_char) | |
9839
|
|
|
|
|
|
|
(?:$q_char) |
9840
|
66
|
|
|
|
|
710
|
))/oxmsg; |
9841
|
66
|
100
|
100
|
|
|
211
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9842
|
|
|
|
|
|
|
# unescape character |
9843
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9844
|
|
|
|
|
|
|
if (0) { |
9845
|
79
|
|
|
|
|
834
|
} |
9846
|
0
|
|
|
|
|
0
|
|
9847
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
9848
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9849
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9850
|
|
|
|
|
|
|
} |
9851
|
2
|
|
|
|
|
13
|
|
9852
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
9853
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
9854
|
|
|
|
|
|
|
my $left = $i; |
9855
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
9856
|
0
|
0
|
|
|
|
0
|
$i++; |
9857
|
0
|
|
|
|
|
0
|
} |
9858
|
|
|
|
|
|
|
while (1) { |
9859
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9860
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9861
|
|
|
|
|
|
|
} |
9862
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9863
|
0
|
|
|
|
|
0
|
my $right = $i; |
9864
|
|
|
|
|
|
|
|
9865
|
0
|
|
|
|
|
0
|
# [...] |
9866
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
9867
|
|
|
|
|
|
|
|
9868
|
|
|
|
|
|
|
$i = $left; |
9869
|
|
|
|
|
|
|
last; |
9870
|
|
|
|
|
|
|
} |
9871
|
|
|
|
|
|
|
} |
9872
|
|
|
|
|
|
|
} |
9873
|
0
|
|
|
|
|
0
|
|
9874
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
9875
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9876
|
|
|
|
|
|
|
my $left = $i; |
9877
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
9878
|
0
|
0
|
|
|
|
0
|
$i++; |
9879
|
0
|
|
|
|
|
0
|
} |
9880
|
|
|
|
|
|
|
while (1) { |
9881
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9882
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9883
|
|
|
|
|
|
|
} |
9884
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9885
|
0
|
|
|
|
|
0
|
my $right = $i; |
9886
|
|
|
|
|
|
|
|
9887
|
0
|
|
|
|
|
0
|
# [^...] |
9888
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9889
|
|
|
|
|
|
|
|
9890
|
|
|
|
|
|
|
$i = $left; |
9891
|
|
|
|
|
|
|
last; |
9892
|
|
|
|
|
|
|
} |
9893
|
|
|
|
|
|
|
} |
9894
|
|
|
|
|
|
|
} |
9895
|
0
|
|
|
|
|
0
|
|
9896
|
|
|
|
|
|
|
# escape $ @ / and \ |
9897
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9898
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9899
|
|
|
|
|
|
|
} |
9900
|
0
|
|
|
|
|
0
|
|
9901
|
|
|
|
|
|
|
# rewrite character class or escape character |
9902
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9903
|
|
|
|
|
|
|
$char[$i] = $char; |
9904
|
|
|
|
|
|
|
} |
9905
|
0
|
50
|
|
|
|
0
|
|
9906
|
16
|
|
|
|
|
44
|
# /i modifier |
9907
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
9908
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
9909
|
16
|
|
|
|
|
45
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
9910
|
|
|
|
|
|
|
} |
9911
|
|
|
|
|
|
|
else { |
9912
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
9913
|
|
|
|
|
|
|
} |
9914
|
|
|
|
|
|
|
} |
9915
|
0
|
0
|
|
|
|
0
|
|
9916
|
|
|
|
|
|
|
# quote character before ? + * { |
9917
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9918
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
9919
|
|
|
|
|
|
|
} |
9920
|
|
|
|
|
|
|
else { |
9921
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9922
|
|
|
|
|
|
|
} |
9923
|
0
|
|
|
|
|
0
|
} |
9924
|
66
|
|
|
|
|
131
|
} |
9925
|
|
|
|
|
|
|
|
9926
|
66
|
|
|
|
|
117
|
$delimiter = '/'; |
9927
|
66
|
|
|
|
|
105
|
$end_delimiter = '/'; |
9928
|
|
|
|
|
|
|
|
9929
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9930
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9931
|
|
|
|
|
|
|
} |
9932
|
|
|
|
|
|
|
|
9933
|
|
|
|
|
|
|
# |
9934
|
66
|
|
|
89
|
0
|
482
|
# escape regexp (m''b, qr''b) |
9935
|
|
|
|
|
|
|
# |
9936
|
|
|
|
|
|
|
sub e_qr_qb { |
9937
|
89
|
|
|
|
|
207
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9938
|
|
|
|
|
|
|
|
9939
|
|
|
|
|
|
|
# split regexp |
9940
|
89
|
|
|
|
|
347
|
my @char = $string =~ /\G ((?>[^\\]|\\\\|[\x00-\xFF])) /oxmsg; |
9941
|
89
|
50
|
|
|
|
259
|
|
|
|
50
|
|
|
|
|
|
9942
|
|
|
|
|
|
|
# unescape character |
9943
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9944
|
|
|
|
|
|
|
if (0) { |
9945
|
199
|
|
|
|
|
657
|
} |
9946
|
|
|
|
|
|
|
|
9947
|
|
|
|
|
|
|
# remain \\ |
9948
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
9949
|
|
|
|
|
|
|
} |
9950
|
0
|
|
|
|
|
0
|
|
9951
|
|
|
|
|
|
|
# escape $ @ / and \ |
9952
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9953
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9954
|
0
|
|
|
|
|
0
|
} |
9955
|
89
|
|
|
|
|
141
|
} |
9956
|
89
|
|
|
|
|
121
|
|
9957
|
|
|
|
|
|
|
$delimiter = '/'; |
9958
|
|
|
|
|
|
|
$end_delimiter = '/'; |
9959
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9960
|
|
|
|
|
|
|
} |
9961
|
|
|
|
|
|
|
|
9962
|
|
|
|
|
|
|
# |
9963
|
89
|
|
|
195
|
0
|
593
|
# escape regexp (s/here//) |
9964
|
195
|
|
100
|
|
|
562
|
# |
9965
|
|
|
|
|
|
|
sub e_s1 { |
9966
|
195
|
|
|
|
|
846
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9967
|
195
|
50
|
|
|
|
320
|
$modifier ||= ''; |
9968
|
195
|
|
|
|
|
723
|
|
9969
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9970
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9971
|
0
|
|
|
|
|
0
|
my $line = 0; |
9972
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9973
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9974
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9975
|
0
|
|
|
|
|
0
|
last; |
9976
|
|
|
|
|
|
|
} |
9977
|
|
|
|
|
|
|
} |
9978
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9979
|
|
|
|
|
|
|
} |
9980
|
|
|
|
|
|
|
|
9981
|
195
|
100
|
|
|
|
362
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9982
|
195
|
|
|
|
|
761
|
|
9983
|
8
|
|
|
|
|
14
|
# literal null string pattern |
9984
|
8
|
|
|
|
|
12
|
if ($string eq '') { |
9985
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9986
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9987
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9988
|
|
|
|
|
|
|
} |
9989
|
|
|
|
|
|
|
|
9990
|
|
|
|
|
|
|
# /b /B modifier |
9991
|
8
|
50
|
|
|
|
79
|
elsif ($modifier =~ tr/bB//d) { |
9992
|
44
|
|
|
|
|
96
|
|
9993
|
0
|
|
|
|
|
0
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9994
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9995
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
9996
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9997
|
|
|
|
|
|
|
if (not $octet{')'}) { |
9998
|
|
|
|
|
|
|
$delimiter = '('; |
9999
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
10000
|
0
|
|
|
|
|
0
|
} |
10001
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
10002
|
|
|
|
|
|
|
$delimiter = '{'; |
10003
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
10004
|
0
|
|
|
|
|
0
|
} |
10005
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
10006
|
|
|
|
|
|
|
$delimiter = '['; |
10007
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
10008
|
0
|
|
|
|
|
0
|
} |
10009
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
10010
|
|
|
|
|
|
|
$delimiter = '<'; |
10011
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
10012
|
0
|
0
|
|
|
|
0
|
} |
10013
|
0
|
|
|
|
|
0
|
else { |
10014
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
10015
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
10016
|
|
|
|
|
|
|
$delimiter = $char; |
10017
|
|
|
|
|
|
|
$end_delimiter = $char; |
10018
|
|
|
|
|
|
|
last; |
10019
|
|
|
|
|
|
|
} |
10020
|
|
|
|
|
|
|
} |
10021
|
0
|
|
|
|
|
0
|
} |
10022
|
44
|
|
|
|
|
77
|
} |
10023
|
44
|
|
|
|
|
63
|
|
10024
|
|
|
|
|
|
|
my $prematch = ''; |
10025
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10026
|
44
|
100
|
|
|
|
284
|
return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
10027
|
143
|
|
|
|
|
516
|
} |
10028
|
|
|
|
|
|
|
|
10029
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10030
|
143
|
|
|
|
|
700
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10031
|
|
|
|
|
|
|
|
10032
|
|
|
|
|
|
|
# split regexp |
10033
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10034
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10035
|
|
|
|
|
|
|
\\ (?>[1-9][0-9]*) | |
10036
|
|
|
|
|
|
|
\\g (?>\s*) (?>[1-9][0-9]*) | |
10037
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
10038
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
10039
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10040
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10041
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10042
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10043
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10044
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
10045
|
|
|
|
|
|
|
\\ $q_char | |
10046
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10047
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10048
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10049
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10050
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10051
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10052
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10053
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10054
|
|
|
|
|
|
|
\[\^ | |
10055
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10056
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10057
|
|
|
|
|
|
|
\(\? | |
10058
|
|
|
|
|
|
|
$q_char |
10059
|
143
|
50
|
|
|
|
38468
|
))/oxmsg; |
10060
|
143
|
|
|
|
|
1431
|
|
|
0
|
|
|
|
|
0
|
|
10061
|
0
|
0
|
|
|
|
0
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
10062
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
10063
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
10064
|
|
|
|
|
|
|
if (not $octet{')'}) { |
10065
|
|
|
|
|
|
|
$delimiter = '('; |
10066
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
10067
|
0
|
|
|
|
|
0
|
} |
10068
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
10069
|
|
|
|
|
|
|
$delimiter = '{'; |
10070
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
10071
|
0
|
|
|
|
|
0
|
} |
10072
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
10073
|
|
|
|
|
|
|
$delimiter = '['; |
10074
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
10075
|
0
|
|
|
|
|
0
|
} |
10076
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
10077
|
|
|
|
|
|
|
$delimiter = '<'; |
10078
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
10079
|
0
|
0
|
|
|
|
0
|
} |
10080
|
0
|
|
|
|
|
0
|
else { |
10081
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
10082
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
10083
|
|
|
|
|
|
|
$delimiter = $char; |
10084
|
|
|
|
|
|
|
$end_delimiter = $char; |
10085
|
|
|
|
|
|
|
last; |
10086
|
|
|
|
|
|
|
} |
10087
|
|
|
|
|
|
|
} |
10088
|
|
|
|
|
|
|
} |
10089
|
0
|
|
|
|
|
0
|
} |
|
143
|
|
|
|
|
351
|
|
10090
|
|
|
|
|
|
|
|
10091
|
477
|
|
|
|
|
903
|
# count '(' |
10092
|
143
|
|
|
|
|
255
|
my $parens = grep { $_ eq '(' } @char; |
10093
|
143
|
|
|
|
|
225
|
|
10094
|
|
|
|
|
|
|
my $left_e = 0; |
10095
|
|
|
|
|
|
|
my $right_e = 0; |
10096
|
143
|
50
|
33
|
|
|
497
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10097
|
398
|
|
|
|
|
2805
|
|
10098
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
10099
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10100
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10101
|
|
|
|
|
|
|
} |
10102
|
0
|
|
|
|
|
0
|
|
10103
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
10104
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
10105
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10106
|
|
|
|
|
|
|
} |
10107
|
0
|
|
|
|
|
0
|
|
10108
|
|
|
|
|
|
|
# octal escape sequence |
10109
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
10110
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
10111
|
|
|
|
|
|
|
} |
10112
|
1
|
|
|
|
|
3
|
|
10113
|
|
|
|
|
|
|
# hexadecimal escape sequence |
10114
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
10115
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
10116
|
|
|
|
|
|
|
} |
10117
|
|
|
|
|
|
|
|
10118
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
10119
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
10120
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
10121
|
1
|
|
|
|
|
4
|
# \p{PROPERTY} --> p\{PROPERTY} |
10122
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
10123
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
10124
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10125
|
|
|
|
|
|
|
} |
10126
|
0
|
|
|
|
|
0
|
|
10127
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
10128
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
10129
|
0
|
100
|
100
|
|
|
0
|
$char[$i] = $1; |
|
|
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
|
|
|
|
|
|
10130
|
|
|
|
|
|
|
} |
10131
|
|
|
|
|
|
|
|
10132
|
|
|
|
|
|
|
if (0) { |
10133
|
398
|
|
|
|
|
5037
|
} |
10134
|
0
|
|
|
|
|
0
|
|
10135
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10136
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10137
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10138
|
|
|
|
|
|
|
} |
10139
|
23
|
0
|
0
|
|
|
112
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
10140
|
0
|
|
|
|
|
0
|
# join separated multiple-octet |
10141
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
10142
|
|
|
|
|
|
|
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)) { |
10143
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
10144
|
|
|
|
|
|
|
} |
10145
|
|
|
|
|
|
|
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)) { |
10146
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
10147
|
|
|
|
|
|
|
} |
10148
|
|
|
|
|
|
|
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)) { |
10149
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
10150
|
|
|
|
|
|
|
} |
10151
|
|
|
|
|
|
|
} |
10152
|
0
|
|
|
|
|
0
|
|
10153
|
20
|
50
|
|
|
|
68
|
# open character class [...] |
10154
|
20
|
|
|
|
|
95
|
elsif ($char[$i] eq '[') { |
10155
|
|
|
|
|
|
|
my $left = $i; |
10156
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10157
|
20
|
50
|
|
|
|
46
|
$i++; |
10158
|
79
|
|
|
|
|
131
|
} |
10159
|
|
|
|
|
|
|
while (1) { |
10160
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
10161
|
79
|
|
|
|
|
222
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10162
|
|
|
|
|
|
|
} |
10163
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10164
|
20
|
50
|
|
|
|
40
|
my $right = $i; |
10165
|
20
|
|
|
|
|
143
|
|
|
0
|
|
|
|
|
0
|
|
10166
|
|
|
|
|
|
|
# [...] |
10167
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10168
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10169
|
|
|
|
|
|
|
} |
10170
|
|
|
|
|
|
|
else { |
10171
|
20
|
|
|
|
|
110
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
10172
|
20
|
|
|
|
|
39
|
} |
10173
|
|
|
|
|
|
|
|
10174
|
|
|
|
|
|
|
$i = $left; |
10175
|
|
|
|
|
|
|
last; |
10176
|
|
|
|
|
|
|
} |
10177
|
|
|
|
|
|
|
} |
10178
|
|
|
|
|
|
|
} |
10179
|
20
|
|
|
|
|
82
|
|
10180
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
10181
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10182
|
|
|
|
|
|
|
my $left = $i; |
10183
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10184
|
0
|
0
|
|
|
|
0
|
$i++; |
10185
|
0
|
|
|
|
|
0
|
} |
10186
|
|
|
|
|
|
|
while (1) { |
10187
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10188
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10189
|
|
|
|
|
|
|
} |
10190
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10191
|
0
|
0
|
|
|
|
0
|
my $right = $i; |
10192
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
10193
|
|
|
|
|
|
|
# [^...] |
10194
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10195
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10196
|
|
|
|
|
|
|
} |
10197
|
|
|
|
|
|
|
else { |
10198
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10199
|
0
|
|
|
|
|
0
|
} |
10200
|
|
|
|
|
|
|
|
10201
|
|
|
|
|
|
|
$i = $left; |
10202
|
|
|
|
|
|
|
last; |
10203
|
|
|
|
|
|
|
} |
10204
|
|
|
|
|
|
|
} |
10205
|
|
|
|
|
|
|
} |
10206
|
0
|
|
|
|
|
0
|
|
10207
|
|
|
|
|
|
|
# rewrite character class or escape character |
10208
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10209
|
|
|
|
|
|
|
$char[$i] = $char; |
10210
|
|
|
|
|
|
|
} |
10211
|
11
|
50
|
|
|
|
27
|
|
10212
|
11
|
|
|
|
|
28
|
# /i modifier |
10213
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
10214
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
10215
|
11
|
|
|
|
|
27
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
10216
|
|
|
|
|
|
|
} |
10217
|
|
|
|
|
|
|
else { |
10218
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
10219
|
|
|
|
|
|
|
} |
10220
|
|
|
|
|
|
|
} |
10221
|
0
|
50
|
|
|
|
0
|
|
10222
|
8
|
|
|
|
|
36
|
# \u \l \U \L \F \Q \E |
10223
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
10224
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10225
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10226
|
0
|
|
|
|
|
0
|
} |
10227
|
0
|
|
|
|
|
0
|
} |
10228
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
10229
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
10230
|
0
|
|
|
|
|
0
|
$left_e++; |
10231
|
0
|
|
|
|
|
0
|
} |
10232
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
10233
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
10234
|
0
|
|
|
|
|
0
|
$left_e++; |
10235
|
0
|
|
|
|
|
0
|
} |
10236
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
10237
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
10238
|
0
|
|
|
|
|
0
|
$left_e++; |
10239
|
0
|
|
|
|
|
0
|
} |
10240
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
10241
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
10242
|
0
|
|
|
|
|
0
|
$left_e++; |
10243
|
0
|
|
|
|
|
0
|
} |
10244
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
10245
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
10246
|
0
|
|
|
|
|
0
|
$left_e++; |
10247
|
7
|
|
|
|
|
14
|
} |
10248
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
10249
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
10250
|
7
|
50
|
|
|
|
16
|
$left_e++; |
10251
|
7
|
|
|
|
|
16
|
} |
10252
|
7
|
|
|
|
|
12
|
elsif ($char[$i] eq '\E') { |
10253
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10254
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
10255
|
7
|
|
|
|
|
16
|
$right_e++; |
10256
|
|
|
|
|
|
|
} |
10257
|
|
|
|
|
|
|
else { |
10258
|
|
|
|
|
|
|
$char[$i] = ''; |
10259
|
0
|
|
|
|
|
0
|
} |
10260
|
0
|
0
|
|
|
|
0
|
} |
10261
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10262
|
|
|
|
|
|
|
while (1) { |
10263
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10264
|
0
|
|
|
|
|
0
|
last; |
10265
|
|
|
|
|
|
|
} |
10266
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
10267
|
|
|
|
|
|
|
last; |
10268
|
|
|
|
|
|
|
} |
10269
|
|
|
|
|
|
|
} |
10270
|
|
|
|
|
|
|
} |
10271
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
10272
|
|
|
|
|
|
|
} |
10273
|
|
|
|
|
|
|
|
10274
|
|
|
|
|
|
|
# \0 --> \0 |
10275
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) { |
10276
|
|
|
|
|
|
|
} |
10277
|
|
|
|
|
|
|
|
10278
|
|
|
|
|
|
|
# \g{N}, \g{-N} |
10279
|
|
|
|
|
|
|
|
10280
|
|
|
|
|
|
|
# P.108 Using Simple Patterns |
10281
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
10282
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
10283
|
|
|
|
|
|
|
|
10284
|
|
|
|
|
|
|
# P.221 Capturing |
10285
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10286
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10287
|
|
|
|
|
|
|
|
10288
|
|
|
|
|
|
|
# \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3} |
10289
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10290
|
|
|
|
|
|
|
} |
10291
|
0
|
0
|
|
|
|
0
|
|
10292
|
0
|
|
|
|
|
0
|
# \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable) |
10293
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10294
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10295
|
|
|
|
|
|
|
$char[$i] = '\\g{' . ($1 + 1) . '}'; |
10296
|
|
|
|
|
|
|
} |
10297
|
|
|
|
|
|
|
} |
10298
|
0
|
0
|
|
|
|
0
|
|
10299
|
0
|
|
|
|
|
0
|
# \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable) |
10300
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
10301
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10302
|
|
|
|
|
|
|
$char[$i] = '\\g' . ($1 + 1); |
10303
|
|
|
|
|
|
|
} |
10304
|
|
|
|
|
|
|
} |
10305
|
0
|
0
|
|
|
|
0
|
|
10306
|
0
|
|
|
|
|
0
|
# \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable) |
10307
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
10308
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10309
|
|
|
|
|
|
|
$char[$i] = '\\' . ($1 + 1); |
10310
|
|
|
|
|
|
|
} |
10311
|
|
|
|
|
|
|
} |
10312
|
0
|
0
|
|
|
|
0
|
|
10313
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
10314
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
10315
|
|
|
|
|
|
|
if ($ignorecase) { |
10316
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10317
|
0
|
0
|
|
|
|
0
|
} |
10318
|
0
|
|
|
|
|
0
|
} |
10319
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
10320
|
|
|
|
|
|
|
if ($ignorecase) { |
10321
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10322
|
|
|
|
|
|
|
} |
10323
|
|
|
|
|
|
|
} |
10324
|
|
|
|
|
|
|
|
10325
|
|
|
|
|
|
|
# $$ --> $$ |
10326
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
10327
|
|
|
|
|
|
|
} |
10328
|
|
|
|
|
|
|
|
10329
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
10330
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
10331
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
10332
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10333
|
|
|
|
|
|
|
if ($ignorecase) { |
10334
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10335
|
0
|
|
|
|
|
0
|
} |
10336
|
0
|
0
|
|
|
|
0
|
} |
10337
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10338
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10339
|
|
|
|
|
|
|
if ($ignorecase) { |
10340
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10341
|
|
|
|
|
|
|
} |
10342
|
|
|
|
|
|
|
} |
10343
|
0
|
|
|
|
|
0
|
|
10344
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10345
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10346
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
10347
|
|
|
|
|
|
|
if ($ignorecase) { |
10348
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10349
|
|
|
|
|
|
|
} |
10350
|
|
|
|
|
|
|
} |
10351
|
0
|
|
|
|
|
0
|
|
10352
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10353
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10354
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
10355
|
|
|
|
|
|
|
if ($ignorecase) { |
10356
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10357
|
|
|
|
|
|
|
} |
10358
|
|
|
|
|
|
|
} |
10359
|
0
|
|
|
|
|
0
|
|
10360
|
0
|
0
|
|
|
|
0
|
# $$foo |
10361
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10362
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10363
|
|
|
|
|
|
|
if ($ignorecase) { |
10364
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10365
|
|
|
|
|
|
|
} |
10366
|
|
|
|
|
|
|
} |
10367
|
0
|
50
|
|
|
|
0
|
|
10368
|
4
|
|
|
|
|
17
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
10369
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10370
|
|
|
|
|
|
|
if ($ignorecase) { |
10371
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
10372
|
|
|
|
|
|
|
} |
10373
|
|
|
|
|
|
|
else { |
10374
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
10375
|
|
|
|
|
|
|
} |
10376
|
|
|
|
|
|
|
} |
10377
|
4
|
50
|
|
|
|
18
|
|
10378
|
4
|
|
|
|
|
18
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
10379
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10380
|
|
|
|
|
|
|
if ($ignorecase) { |
10381
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
10382
|
|
|
|
|
|
|
} |
10383
|
|
|
|
|
|
|
else { |
10384
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
10385
|
|
|
|
|
|
|
} |
10386
|
|
|
|
|
|
|
} |
10387
|
4
|
50
|
|
|
|
18
|
|
10388
|
3
|
|
|
|
|
11
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
10389
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10390
|
|
|
|
|
|
|
if ($ignorecase) { |
10391
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
10392
|
|
|
|
|
|
|
} |
10393
|
|
|
|
|
|
|
else { |
10394
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
10395
|
|
|
|
|
|
|
} |
10396
|
|
|
|
|
|
|
} |
10397
|
3
|
0
|
|
|
|
14
|
|
10398
|
0
|
|
|
|
|
0
|
# ${ foo } |
10399
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10400
|
|
|
|
|
|
|
if ($ignorecase) { |
10401
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10402
|
|
|
|
|
|
|
} |
10403
|
|
|
|
|
|
|
} |
10404
|
0
|
|
|
|
|
0
|
|
10405
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
10406
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10407
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10408
|
|
|
|
|
|
|
if ($ignorecase) { |
10409
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10410
|
|
|
|
|
|
|
} |
10411
|
|
|
|
|
|
|
} |
10412
|
0
|
|
|
|
|
0
|
|
10413
|
13
|
50
|
|
|
|
52
|
# $scalar or @array |
10414
|
13
|
|
|
|
|
59
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10415
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
10416
|
|
|
|
|
|
|
if ($ignorecase) { |
10417
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10418
|
|
|
|
|
|
|
} |
10419
|
|
|
|
|
|
|
} |
10420
|
0
|
50
|
|
|
|
0
|
|
10421
|
|
|
|
|
|
|
# quote character before ? + * { |
10422
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10423
|
23
|
|
|
|
|
131
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10424
|
|
|
|
|
|
|
} |
10425
|
|
|
|
|
|
|
else { |
10426
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10427
|
|
|
|
|
|
|
} |
10428
|
|
|
|
|
|
|
} |
10429
|
23
|
|
|
|
|
129
|
} |
10430
|
143
|
|
|
|
|
411
|
|
10431
|
143
|
|
|
|
|
360
|
# make regexp string |
10432
|
143
|
50
|
|
|
|
240
|
my $prematch = ''; |
10433
|
143
|
|
|
|
|
363
|
$prematch = "($anchor)"; |
10434
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10435
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
10436
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
10437
|
|
|
|
|
|
|
} |
10438
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10439
|
|
|
|
|
|
|
} |
10440
|
|
|
|
|
|
|
|
10441
|
|
|
|
|
|
|
# |
10442
|
143
|
|
|
96
|
0
|
1746
|
# escape regexp (s'here'' or s'here''b) |
10443
|
96
|
|
100
|
|
|
251
|
# |
10444
|
|
|
|
|
|
|
sub e_s1_q { |
10445
|
96
|
|
|
|
|
263
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10446
|
96
|
50
|
|
|
|
132
|
$modifier ||= ''; |
10447
|
96
|
|
|
|
|
315
|
|
10448
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10449
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10450
|
0
|
|
|
|
|
0
|
my $line = 0; |
10451
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10452
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10453
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10454
|
0
|
|
|
|
|
0
|
last; |
10455
|
|
|
|
|
|
|
} |
10456
|
|
|
|
|
|
|
} |
10457
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10458
|
|
|
|
|
|
|
} |
10459
|
|
|
|
|
|
|
|
10460
|
96
|
100
|
|
|
|
159
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
10461
|
96
|
|
|
|
|
247
|
|
10462
|
8
|
|
|
|
|
11
|
# literal null string pattern |
10463
|
8
|
|
|
|
|
11
|
if ($string eq '') { |
10464
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
10465
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10466
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
10467
|
|
|
|
|
|
|
} |
10468
|
8
|
|
|
|
|
66
|
|
10469
|
|
|
|
|
|
|
# with /b /B modifier |
10470
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
10471
|
|
|
|
|
|
|
return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
10472
|
|
|
|
|
|
|
} |
10473
|
44
|
|
|
|
|
97
|
|
10474
|
|
|
|
|
|
|
# without /b /B modifier |
10475
|
|
|
|
|
|
|
else { |
10476
|
|
|
|
|
|
|
return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
10477
|
|
|
|
|
|
|
} |
10478
|
|
|
|
|
|
|
} |
10479
|
|
|
|
|
|
|
|
10480
|
|
|
|
|
|
|
# |
10481
|
44
|
|
|
44
|
0
|
102
|
# escape regexp (s'here'') |
10482
|
|
|
|
|
|
|
# |
10483
|
44
|
100
|
|
|
|
108
|
sub e_s1_qt { |
10484
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10485
|
|
|
|
|
|
|
|
10486
|
44
|
|
|
|
|
105
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10487
|
|
|
|
|
|
|
|
10488
|
|
|
|
|
|
|
# split regexp |
10489
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10490
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\$\@\/] | |
10491
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10492
|
|
|
|
|
|
|
\[\^ | |
10493
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
10494
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
10495
|
|
|
|
|
|
|
[\$\@\/] | |
10496
|
|
|
|
|
|
|
\\ (?:$q_char) | |
10497
|
|
|
|
|
|
|
(?:$q_char) |
10498
|
44
|
|
|
|
|
563
|
))/oxmsg; |
10499
|
44
|
50
|
100
|
|
|
149
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10500
|
|
|
|
|
|
|
# unescape character |
10501
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10502
|
|
|
|
|
|
|
if (0) { |
10503
|
62
|
|
|
|
|
618
|
} |
10504
|
0
|
|
|
|
|
0
|
|
10505
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10506
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10507
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10508
|
|
|
|
|
|
|
} |
10509
|
0
|
|
|
|
|
0
|
|
10510
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
10511
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
10512
|
|
|
|
|
|
|
my $left = $i; |
10513
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10514
|
0
|
0
|
|
|
|
0
|
$i++; |
10515
|
0
|
|
|
|
|
0
|
} |
10516
|
|
|
|
|
|
|
while (1) { |
10517
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10518
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10519
|
|
|
|
|
|
|
} |
10520
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10521
|
0
|
|
|
|
|
0
|
my $right = $i; |
10522
|
|
|
|
|
|
|
|
10523
|
0
|
|
|
|
|
0
|
# [...] |
10524
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
10525
|
|
|
|
|
|
|
|
10526
|
|
|
|
|
|
|
$i = $left; |
10527
|
|
|
|
|
|
|
last; |
10528
|
|
|
|
|
|
|
} |
10529
|
|
|
|
|
|
|
} |
10530
|
|
|
|
|
|
|
} |
10531
|
0
|
|
|
|
|
0
|
|
10532
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
10533
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10534
|
|
|
|
|
|
|
my $left = $i; |
10535
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10536
|
0
|
0
|
|
|
|
0
|
$i++; |
10537
|
0
|
|
|
|
|
0
|
} |
10538
|
|
|
|
|
|
|
while (1) { |
10539
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10540
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10541
|
|
|
|
|
|
|
} |
10542
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10543
|
0
|
|
|
|
|
0
|
my $right = $i; |
10544
|
|
|
|
|
|
|
|
10545
|
0
|
|
|
|
|
0
|
# [^...] |
10546
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10547
|
|
|
|
|
|
|
|
10548
|
|
|
|
|
|
|
$i = $left; |
10549
|
|
|
|
|
|
|
last; |
10550
|
|
|
|
|
|
|
} |
10551
|
|
|
|
|
|
|
} |
10552
|
|
|
|
|
|
|
} |
10553
|
0
|
|
|
|
|
0
|
|
10554
|
|
|
|
|
|
|
# escape $ @ / and \ |
10555
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10556
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10557
|
|
|
|
|
|
|
} |
10558
|
0
|
|
|
|
|
0
|
|
10559
|
|
|
|
|
|
|
# rewrite character class or escape character |
10560
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10561
|
|
|
|
|
|
|
$char[$i] = $char; |
10562
|
|
|
|
|
|
|
} |
10563
|
6
|
50
|
|
|
|
14
|
|
10564
|
8
|
|
|
|
|
17
|
# /i modifier |
10565
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
10566
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
10567
|
8
|
|
|
|
|
20
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
10568
|
|
|
|
|
|
|
} |
10569
|
|
|
|
|
|
|
else { |
10570
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
10571
|
|
|
|
|
|
|
} |
10572
|
|
|
|
|
|
|
} |
10573
|
0
|
0
|
|
|
|
0
|
|
10574
|
|
|
|
|
|
|
# quote character before ? + * { |
10575
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10576
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
10577
|
|
|
|
|
|
|
} |
10578
|
|
|
|
|
|
|
else { |
10579
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10580
|
|
|
|
|
|
|
} |
10581
|
0
|
|
|
|
|
0
|
} |
10582
|
44
|
|
|
|
|
91
|
} |
10583
|
44
|
|
|
|
|
79
|
|
10584
|
44
|
|
|
|
|
61
|
$modifier =~ tr/i//d; |
10585
|
44
|
|
|
|
|
62
|
$delimiter = '/'; |
10586
|
44
|
|
|
|
|
93
|
$end_delimiter = '/'; |
10587
|
|
|
|
|
|
|
my $prematch = ''; |
10588
|
|
|
|
|
|
|
$prematch = "($anchor)"; |
10589
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10590
|
|
|
|
|
|
|
} |
10591
|
|
|
|
|
|
|
|
10592
|
|
|
|
|
|
|
# |
10593
|
44
|
|
|
44
|
0
|
351
|
# escape regexp (s'here''b) |
10594
|
|
|
|
|
|
|
# |
10595
|
|
|
|
|
|
|
sub e_s1_qb { |
10596
|
44
|
|
|
|
|
107
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10597
|
|
|
|
|
|
|
|
10598
|
|
|
|
|
|
|
# split regexp |
10599
|
44
|
|
|
|
|
173
|
my @char = $string =~ /\G (?>[^\\]|\\\\|[\x00-\xFF]) /oxmsg; |
10600
|
44
|
50
|
|
|
|
126
|
|
|
|
50
|
|
|
|
|
|
10601
|
|
|
|
|
|
|
# unescape character |
10602
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10603
|
|
|
|
|
|
|
if (0) { |
10604
|
98
|
|
|
|
|
320
|
} |
10605
|
|
|
|
|
|
|
|
10606
|
|
|
|
|
|
|
# remain \\ |
10607
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
10608
|
|
|
|
|
|
|
} |
10609
|
0
|
|
|
|
|
0
|
|
10610
|
|
|
|
|
|
|
# escape $ @ / and \ |
10611
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10612
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10613
|
0
|
|
|
|
|
0
|
} |
10614
|
44
|
|
|
|
|
71
|
} |
10615
|
44
|
|
|
|
|
56
|
|
10616
|
44
|
|
|
|
|
58
|
$delimiter = '/'; |
10617
|
44
|
|
|
|
|
69
|
$end_delimiter = '/'; |
10618
|
|
|
|
|
|
|
my $prematch = ''; |
10619
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10620
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10621
|
|
|
|
|
|
|
} |
10622
|
|
|
|
|
|
|
|
10623
|
|
|
|
|
|
|
# |
10624
|
44
|
|
|
91
|
0
|
339
|
# escape regexp (s''here') |
10625
|
|
|
|
|
|
|
# |
10626
|
91
|
|
|
|
|
193
|
sub e_s2_q { |
10627
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10628
|
91
|
|
|
|
|
127
|
|
10629
|
91
|
|
|
|
|
355
|
$slash = 'div'; |
10630
|
91
|
50
|
66
|
|
|
257
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
10631
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>[^\x81-\x9F\xE0-\xFC\\]|\\\\|$q_char) /oxmsg; |
10632
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10633
|
|
|
|
|
|
|
if (0) { |
10634
|
9
|
|
|
|
|
97
|
} |
10635
|
0
|
|
|
|
|
0
|
|
10636
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10637
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10638
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
10639
|
|
|
|
|
|
|
} |
10640
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10641
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10642
|
|
|
|
|
|
|
} |
10643
|
|
|
|
|
|
|
|
10644
|
|
|
|
|
|
|
# not escape \\ |
10645
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\\\ \z/oxms) { |
10646
|
|
|
|
|
|
|
} |
10647
|
0
|
|
|
|
|
0
|
|
10648
|
|
|
|
|
|
|
# escape $ @ / and \ |
10649
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10650
|
5
|
50
|
66
|
|
|
17
|
$char[$i] = '\\' . $char[$i]; |
10651
|
91
|
|
|
|
|
247
|
} |
10652
|
|
|
|
|
|
|
} |
10653
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10654
|
0
|
|
|
|
|
0
|
$char[-1] = $1 . '\\' . $2; |
10655
|
|
|
|
|
|
|
} |
10656
|
|
|
|
|
|
|
|
10657
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
10658
|
|
|
|
|
|
|
} |
10659
|
|
|
|
|
|
|
|
10660
|
|
|
|
|
|
|
# |
10661
|
91
|
|
|
291
|
0
|
313
|
# escape regexp (s/here/and here/modifier) |
10662
|
291
|
|
100
|
|
|
2377
|
# |
10663
|
|
|
|
|
|
|
sub e_sub { |
10664
|
291
|
|
|
|
|
1245
|
my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_; |
10665
|
291
|
50
|
|
|
|
575
|
$modifier ||= ''; |
10666
|
291
|
|
|
|
|
1149
|
|
10667
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10668
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10669
|
0
|
|
|
|
|
0
|
my $line = 0; |
10670
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10671
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10672
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10673
|
0
|
|
|
|
|
0
|
last; |
10674
|
|
|
|
|
|
|
} |
10675
|
|
|
|
|
|
|
} |
10676
|
0
|
100
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10677
|
291
|
|
|
|
|
740
|
} |
10678
|
37
|
|
|
|
|
55
|
|
10679
|
|
|
|
|
|
|
if ($variable eq '') { |
10680
|
|
|
|
|
|
|
$variable = '$_'; |
10681
|
37
|
|
|
|
|
53
|
$bind_operator = ' =~ '; |
10682
|
|
|
|
|
|
|
} |
10683
|
|
|
|
|
|
|
|
10684
|
|
|
|
|
|
|
$slash = 'div'; |
10685
|
|
|
|
|
|
|
|
10686
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
10687
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
10688
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
10689
|
|
|
|
|
|
|
# P.312 Iterative Matching: Scalar Context, with /g |
10690
|
|
|
|
|
|
|
# in Chapter 7: Perl |
10691
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
10692
|
|
|
|
|
|
|
|
10693
|
|
|
|
|
|
|
# P.181 Where You Left Off: The \G Assertion |
10694
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10695
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10696
|
|
|
|
|
|
|
|
10697
|
|
|
|
|
|
|
# P.220 Where You Left Off: The \G Assertion |
10698
|
291
|
|
|
|
|
479
|
# in Chapter 5: Pattern Matching |
10699
|
291
|
|
|
|
|
478
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10700
|
|
|
|
|
|
|
|
10701
|
291
|
|
|
|
|
439
|
my $e_modifier = $modifier =~ tr/e//d; |
10702
|
291
|
50
|
|
|
|
422
|
my $r_modifier = $modifier =~ tr/r//d; |
10703
|
291
|
|
|
|
|
749
|
|
10704
|
0
|
|
|
|
|
0
|
my $my = ''; |
10705
|
0
|
|
|
|
|
0
|
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) { |
10706
|
|
|
|
|
|
|
$my = $variable; |
10707
|
|
|
|
|
|
|
$variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms; |
10708
|
0
|
|
|
|
|
0
|
$variable =~ s/ = .+ \z//oxms; |
10709
|
291
|
|
|
|
|
837
|
} |
10710
|
|
|
|
|
|
|
|
10711
|
|
|
|
|
|
|
(my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms; |
10712
|
291
|
|
|
|
|
534
|
$variable_basename =~ s/ \s+ \z//oxms; |
10713
|
291
|
100
|
|
|
|
420
|
|
10714
|
291
|
|
|
|
|
634
|
# quote replacement string |
10715
|
17
|
|
|
|
|
36
|
my $e_replacement = ''; |
10716
|
|
|
|
|
|
|
if ($e_modifier >= 1) { |
10717
|
|
|
|
|
|
|
$e_replacement = e_qq('', '', '', $replacement); |
10718
|
17
|
100
|
|
|
|
26
|
$e_modifier--; |
10719
|
274
|
|
|
|
|
651
|
} |
10720
|
|
|
|
|
|
|
else { |
10721
|
|
|
|
|
|
|
if ($delimiter2 eq "'") { |
10722
|
91
|
|
|
|
|
204
|
$e_replacement = e_s2_q('qq', '/', '/', $replacement); |
10723
|
|
|
|
|
|
|
} |
10724
|
|
|
|
|
|
|
else { |
10725
|
|
|
|
|
|
|
$e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement); |
10726
|
183
|
|
|
|
|
457
|
} |
10727
|
|
|
|
|
|
|
} |
10728
|
|
|
|
|
|
|
|
10729
|
291
|
100
|
|
|
|
544
|
my $sub = ''; |
10730
|
291
|
100
|
|
|
|
640
|
|
|
|
50
|
|
|
|
|
|
10731
|
|
|
|
|
|
|
# with /r |
10732
|
|
|
|
|
|
|
if ($r_modifier) { |
10733
|
|
|
|
|
|
|
if (0) { |
10734
|
8
|
|
|
|
|
22
|
} |
10735
|
0
|
50
|
|
|
|
0
|
|
10736
|
|
|
|
|
|
|
# s///gr with multibyte anchoring |
10737
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10738
|
|
|
|
|
|
|
$sub = sprintf( |
10739
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10740
|
|
|
|
|
|
|
q, |
10741
|
|
|
|
|
|
|
|
10742
|
|
|
|
|
|
|
$variable, # 1 |
10743
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10744
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10745
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10746
|
|
|
|
|
|
|
$s_matched, # 3 |
10747
|
|
|
|
|
|
|
$e_replacement, # 4 |
10748
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10749
|
|
|
|
|
|
|
); |
10750
|
|
|
|
|
|
|
} |
10751
|
4
|
0
|
|
|
|
16
|
|
10752
|
|
|
|
|
|
|
# s///gr without multibyte anchoring |
10753
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10754
|
|
|
|
|
|
|
$sub = sprintf( |
10755
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10756
|
|
|
|
|
|
|
q, |
10757
|
|
|
|
|
|
|
|
10758
|
|
|
|
|
|
|
$variable, # 1 |
10759
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10760
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10761
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10762
|
|
|
|
|
|
|
$s_matched, # 3 |
10763
|
|
|
|
|
|
|
$e_replacement, # 4 |
10764
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10765
|
|
|
|
|
|
|
); |
10766
|
|
|
|
|
|
|
} |
10767
|
|
|
|
|
|
|
|
10768
|
0
|
|
|
|
|
0
|
# s///r |
10769
|
4
|
|
|
|
|
5
|
else { |
10770
|
|
|
|
|
|
|
|
10771
|
4
|
50
|
|
|
|
6
|
my $prematch = q{$`}; |
10772
|
|
|
|
|
|
|
$prematch = q{${1}}; |
10773
|
|
|
|
|
|
|
|
10774
|
|
|
|
|
|
|
$sub = sprintf( |
10775
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 |
10776
|
|
|
|
|
|
|
q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s"%s$Esjis::re_r$'" } : %s>, |
10777
|
|
|
|
|
|
|
|
10778
|
|
|
|
|
|
|
$variable, # 1 |
10779
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10780
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10781
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10782
|
|
|
|
|
|
|
$s_matched, # 3 |
10783
|
|
|
|
|
|
|
$e_replacement, # 4 |
10784
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10785
|
|
|
|
|
|
|
$prematch, # 6 |
10786
|
|
|
|
|
|
|
$variable, # 7 |
10787
|
|
|
|
|
|
|
); |
10788
|
4
|
50
|
|
|
|
13
|
} |
10789
|
8
|
|
|
|
|
22
|
|
10790
|
|
|
|
|
|
|
# $var !~ s///r doesn't make sense |
10791
|
|
|
|
|
|
|
if ($bind_operator =~ / !~ /oxms) { |
10792
|
|
|
|
|
|
|
$sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub; |
10793
|
|
|
|
|
|
|
} |
10794
|
|
|
|
|
|
|
} |
10795
|
0
|
100
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
10796
|
|
|
|
|
|
|
# without /r |
10797
|
|
|
|
|
|
|
else { |
10798
|
|
|
|
|
|
|
if (0) { |
10799
|
283
|
|
|
|
|
892
|
} |
10800
|
0
|
100
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
10801
|
|
|
|
|
|
|
# s///g with multibyte anchoring |
10802
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10803
|
|
|
|
|
|
|
$sub = sprintf( |
10804
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 |
10805
|
|
|
|
|
|
|
q, |
10806
|
|
|
|
|
|
|
|
10807
|
|
|
|
|
|
|
$variable, # 1 |
10808
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10809
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10810
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10811
|
|
|
|
|
|
|
$s_matched, # 3 |
10812
|
|
|
|
|
|
|
$e_replacement, # 4 |
10813
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10814
|
|
|
|
|
|
|
$variable, # 6 |
10815
|
|
|
|
|
|
|
$variable, # 7 |
10816
|
|
|
|
|
|
|
$variable, # 8 |
10817
|
|
|
|
|
|
|
$variable, # 9 |
10818
|
|
|
|
|
|
|
|
10819
|
|
|
|
|
|
|
# Binary "!~" is just like "=~" except the return value is negated in the logical sense. |
10820
|
|
|
|
|
|
|
# It returns false if the match succeeds, and true if it fails. |
10821
|
|
|
|
|
|
|
# (and so on) |
10822
|
|
|
|
|
|
|
|
10823
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 10 |
10824
|
|
|
|
|
|
|
); |
10825
|
|
|
|
|
|
|
} |
10826
|
36
|
0
|
|
|
|
207
|
|
|
|
0
|
|
|
|
|
|
10827
|
|
|
|
|
|
|
# s///g without multibyte anchoring |
10828
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10829
|
|
|
|
|
|
|
$sub = sprintf( |
10830
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10831
|
|
|
|
|
|
|
q, |
10832
|
|
|
|
|
|
|
|
10833
|
|
|
|
|
|
|
$variable, # 1 |
10834
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10835
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10836
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10837
|
|
|
|
|
|
|
$s_matched, # 3 |
10838
|
|
|
|
|
|
|
$e_replacement, # 4 |
10839
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10840
|
|
|
|
|
|
|
$variable, # 6 |
10841
|
|
|
|
|
|
|
$variable, # 7 |
10842
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 8 |
10843
|
|
|
|
|
|
|
); |
10844
|
|
|
|
|
|
|
} |
10845
|
|
|
|
|
|
|
|
10846
|
0
|
|
|
|
|
0
|
# s/// |
10847
|
247
|
|
|
|
|
544
|
else { |
10848
|
|
|
|
|
|
|
|
10849
|
247
|
100
|
|
|
|
374
|
my $prematch = q{$`}; |
|
|
100
|
|
|
|
|
|
10850
|
|
|
|
|
|
|
$prematch = q{${1}}; |
10851
|
|
|
|
|
|
|
|
10852
|
|
|
|
|
|
|
$sub = sprintf( |
10853
|
|
|
|
|
|
|
|
10854
|
|
|
|
|
|
|
($bind_operator =~ / =~ /oxms) ? |
10855
|
|
|
|
|
|
|
|
10856
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10857
|
|
|
|
|
|
|
q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s%s="%s$Esjis::re_r$'"; 1 } : undef> : |
10858
|
|
|
|
|
|
|
|
10859
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10860
|
|
|
|
|
|
|
q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s%s="%s$Esjis::re_r$'"; undef }>, |
10861
|
|
|
|
|
|
|
|
10862
|
|
|
|
|
|
|
$variable, # 1 |
10863
|
|
|
|
|
|
|
$bind_operator, # 2 |
10864
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 3 |
10865
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10866
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10867
|
|
|
|
|
|
|
$s_matched, # 4 |
10868
|
|
|
|
|
|
|
$e_replacement, # 5 |
10869
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 6 |
10870
|
|
|
|
|
|
|
$variable, # 7 |
10871
|
|
|
|
|
|
|
$prematch, # 8 |
10872
|
|
|
|
|
|
|
); |
10873
|
|
|
|
|
|
|
} |
10874
|
247
|
50
|
|
|
|
1323
|
} |
10875
|
291
|
|
|
|
|
804
|
|
10876
|
|
|
|
|
|
|
# (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1] |
10877
|
|
|
|
|
|
|
if ($my ne '') { |
10878
|
|
|
|
|
|
|
$sub = "($my, $sub)[1]"; |
10879
|
0
|
|
|
|
|
0
|
} |
10880
|
291
|
|
|
|
|
439
|
|
10881
|
|
|
|
|
|
|
# clear s/// variable |
10882
|
291
|
|
|
|
|
406
|
$sub_variable = ''; |
10883
|
|
|
|
|
|
|
$bind_operator = ''; |
10884
|
|
|
|
|
|
|
|
10885
|
|
|
|
|
|
|
return $sub; |
10886
|
|
|
|
|
|
|
} |
10887
|
|
|
|
|
|
|
|
10888
|
|
|
|
|
|
|
# |
10889
|
291
|
|
|
0
|
0
|
2264
|
# escape chdir (qq//, "") |
10890
|
|
|
|
|
|
|
# |
10891
|
0
|
0
|
|
|
|
0
|
sub e_chdir { |
10892
|
0
|
0
|
|
|
|
0
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10893
|
0
|
0
|
|
|
|
0
|
|
10894
|
0
|
|
|
|
|
0
|
if ($^W) { |
10895
|
0
|
|
|
|
|
0
|
if (Esjis::_MSWin32_5Cended_path($string)) { |
10896
|
|
|
|
|
|
|
if ($] !~ /^5\.005/oxms) { |
10897
|
|
|
|
|
|
|
warn <
|
10898
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10899
|
|
|
|
|
|
|
|
10900
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10901
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10902
|
|
|
|
|
|
|
END |
10903
|
|
|
|
|
|
|
} |
10904
|
0
|
|
|
|
|
0
|
} |
10905
|
|
|
|
|
|
|
} |
10906
|
|
|
|
|
|
|
|
10907
|
|
|
|
|
|
|
return e_qq($ope,$delimiter,$end_delimiter,$string); |
10908
|
|
|
|
|
|
|
} |
10909
|
|
|
|
|
|
|
|
10910
|
|
|
|
|
|
|
# |
10911
|
0
|
|
|
2
|
0
|
0
|
# escape chdir (q//, '') |
10912
|
|
|
|
|
|
|
# |
10913
|
2
|
50
|
|
|
|
6
|
sub e_chdir_q { |
10914
|
2
|
0
|
|
|
|
6
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10915
|
0
|
0
|
|
|
|
0
|
|
10916
|
0
|
|
|
|
|
0
|
if ($^W) { |
10917
|
0
|
|
|
|
|
0
|
if (Esjis::_MSWin32_5Cended_path($string)) { |
10918
|
|
|
|
|
|
|
if ($] !~ /^5\.005/oxms) { |
10919
|
|
|
|
|
|
|
warn <
|
10920
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10921
|
|
|
|
|
|
|
|
10922
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10923
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10924
|
|
|
|
|
|
|
END |
10925
|
|
|
|
|
|
|
} |
10926
|
0
|
|
|
|
|
0
|
} |
10927
|
|
|
|
|
|
|
} |
10928
|
|
|
|
|
|
|
|
10929
|
|
|
|
|
|
|
return e_q($ope,$delimiter,$end_delimiter,$string); |
10930
|
|
|
|
|
|
|
} |
10931
|
|
|
|
|
|
|
|
10932
|
|
|
|
|
|
|
# |
10933
|
2
|
|
|
273
|
0
|
14
|
# escape regexp of split qr// |
10934
|
273
|
|
100
|
|
|
1396
|
# |
10935
|
|
|
|
|
|
|
sub e_split { |
10936
|
273
|
|
|
|
|
1181
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10937
|
273
|
50
|
|
|
|
587
|
$modifier ||= ''; |
10938
|
273
|
|
|
|
|
809
|
|
10939
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10940
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10941
|
0
|
|
|
|
|
0
|
my $line = 0; |
10942
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10943
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10944
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10945
|
0
|
|
|
|
|
0
|
last; |
10946
|
|
|
|
|
|
|
} |
10947
|
|
|
|
|
|
|
} |
10948
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10949
|
|
|
|
|
|
|
} |
10950
|
|
|
|
|
|
|
|
10951
|
273
|
100
|
|
|
|
498
|
$slash = 'div'; |
10952
|
273
|
|
|
|
|
646
|
|
10953
|
|
|
|
|
|
|
# /b /B modifier |
10954
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
10955
|
84
|
100
|
|
|
|
470
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
10956
|
189
|
|
|
|
|
719
|
} |
10957
|
|
|
|
|
|
|
|
10958
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10959
|
189
|
|
|
|
|
890
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10960
|
|
|
|
|
|
|
|
10961
|
|
|
|
|
|
|
# split regexp |
10962
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10963
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10964
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10965
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10966
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10967
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10968
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10969
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
10970
|
|
|
|
|
|
|
\\ $q_char | |
10971
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10972
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10973
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10974
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10975
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10976
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10977
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10978
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10979
|
|
|
|
|
|
|
\[\^ | |
10980
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10981
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10982
|
|
|
|
|
|
|
\(\? | |
10983
|
189
|
|
|
|
|
18692
|
$q_char |
10984
|
189
|
|
|
|
|
641
|
))/oxmsg; |
10985
|
189
|
|
|
|
|
351
|
|
10986
|
|
|
|
|
|
|
my $left_e = 0; |
10987
|
|
|
|
|
|
|
my $right_e = 0; |
10988
|
189
|
50
|
33
|
|
|
621
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10989
|
372
|
|
|
|
|
2992
|
|
10990
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
10991
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10992
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10993
|
|
|
|
|
|
|
} |
10994
|
0
|
|
|
|
|
0
|
|
10995
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
10996
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
10997
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10998
|
|
|
|
|
|
|
} |
10999
|
0
|
|
|
|
|
0
|
|
11000
|
|
|
|
|
|
|
# octal escape sequence |
11001
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
11002
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
11003
|
|
|
|
|
|
|
} |
11004
|
1
|
|
|
|
|
3
|
|
11005
|
|
|
|
|
|
|
# hexadecimal escape sequence |
11006
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
11007
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
11008
|
|
|
|
|
|
|
} |
11009
|
|
|
|
|
|
|
|
11010
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
11011
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
11012
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
11013
|
1
|
|
|
|
|
4
|
# \p{PROPERTY} --> p\{PROPERTY} |
11014
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
11015
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
11016
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11017
|
|
|
|
|
|
|
} |
11018
|
0
|
|
|
|
|
0
|
|
11019
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
11020
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
11021
|
0
|
50
|
100
|
|
|
0
|
$char[$i] = $1; |
|
|
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
|
|
|
|
|
|
11022
|
|
|
|
|
|
|
} |
11023
|
|
|
|
|
|
|
|
11024
|
|
|
|
|
|
|
if (0) { |
11025
|
372
|
|
|
|
|
11621
|
} |
11026
|
0
|
|
|
|
|
0
|
|
11027
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
11028
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11029
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11030
|
|
|
|
|
|
|
} |
11031
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
11032
|
0
|
|
|
|
|
0
|
# join separated multiple-octet |
11033
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
11034
|
|
|
|
|
|
|
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)) { |
11035
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
11036
|
|
|
|
|
|
|
} |
11037
|
|
|
|
|
|
|
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)) { |
11038
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
11039
|
|
|
|
|
|
|
} |
11040
|
|
|
|
|
|
|
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)) { |
11041
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
11042
|
|
|
|
|
|
|
} |
11043
|
|
|
|
|
|
|
} |
11044
|
0
|
|
|
|
|
0
|
|
11045
|
3
|
50
|
|
|
|
8
|
# open character class [...] |
11046
|
3
|
|
|
|
|
12
|
elsif ($char[$i] eq '[') { |
11047
|
|
|
|
|
|
|
my $left = $i; |
11048
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11049
|
3
|
50
|
|
|
|
6
|
$i++; |
11050
|
7
|
|
|
|
|
17
|
} |
11051
|
|
|
|
|
|
|
while (1) { |
11052
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
11053
|
7
|
|
|
|
|
14
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11054
|
|
|
|
|
|
|
} |
11055
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11056
|
3
|
50
|
|
|
|
6
|
my $right = $i; |
11057
|
3
|
|
|
|
|
24
|
|
|
0
|
|
|
|
|
0
|
|
11058
|
|
|
|
|
|
|
# [...] |
11059
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
11060
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
11061
|
|
|
|
|
|
|
} |
11062
|
|
|
|
|
|
|
else { |
11063
|
3
|
|
|
|
|
21
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
11064
|
3
|
|
|
|
|
6
|
} |
11065
|
|
|
|
|
|
|
|
11066
|
|
|
|
|
|
|
$i = $left; |
11067
|
|
|
|
|
|
|
last; |
11068
|
|
|
|
|
|
|
} |
11069
|
|
|
|
|
|
|
} |
11070
|
|
|
|
|
|
|
} |
11071
|
3
|
|
|
|
|
12
|
|
11072
|
1
|
50
|
|
|
|
3
|
# open character class [^...] |
11073
|
1
|
|
|
|
|
4
|
elsif ($char[$i] eq '[^') { |
11074
|
|
|
|
|
|
|
my $left = $i; |
11075
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11076
|
1
|
50
|
|
|
|
3
|
$i++; |
11077
|
2
|
|
|
|
|
5
|
} |
11078
|
|
|
|
|
|
|
while (1) { |
11079
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
11080
|
2
|
|
|
|
|
6
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11081
|
|
|
|
|
|
|
} |
11082
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11083
|
1
|
50
|
|
|
|
2
|
my $right = $i; |
11084
|
1
|
|
|
|
|
30
|
|
|
0
|
|
|
|
|
0
|
|
11085
|
|
|
|
|
|
|
# [^...] |
11086
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
11087
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Esjis::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
11088
|
|
|
|
|
|
|
} |
11089
|
|
|
|
|
|
|
else { |
11090
|
1
|
|
|
|
|
18
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11091
|
1
|
|
|
|
|
2
|
} |
11092
|
|
|
|
|
|
|
|
11093
|
|
|
|
|
|
|
$i = $left; |
11094
|
|
|
|
|
|
|
last; |
11095
|
|
|
|
|
|
|
} |
11096
|
|
|
|
|
|
|
} |
11097
|
|
|
|
|
|
|
} |
11098
|
1
|
|
|
|
|
115
|
|
11099
|
|
|
|
|
|
|
# rewrite character class or escape character |
11100
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11101
|
|
|
|
|
|
|
$char[$i] = $char; |
11102
|
|
|
|
|
|
|
} |
11103
|
|
|
|
|
|
|
|
11104
|
|
|
|
|
|
|
# P.794 29.2.161. split |
11105
|
|
|
|
|
|
|
# in Chapter 29: Functions |
11106
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11107
|
|
|
|
|
|
|
|
11108
|
|
|
|
|
|
|
# P.951 split |
11109
|
|
|
|
|
|
|
# in Chapter 27: Functions |
11110
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11111
|
|
|
|
|
|
|
|
11112
|
|
|
|
|
|
|
# said "The //m modifier is assumed when you split on the pattern /^/", |
11113
|
|
|
|
|
|
|
# but perl5.008 is not so. Therefore, this software adds //m. |
11114
|
|
|
|
|
|
|
# (and so on) |
11115
|
5
|
|
|
|
|
20
|
|
11116
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
11117
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11118
|
|
|
|
|
|
|
$modifier .= 'm'; |
11119
|
|
|
|
|
|
|
} |
11120
|
11
|
50
|
|
|
|
40
|
|
11121
|
18
|
|
|
|
|
48
|
# /i modifier |
11122
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
11123
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
11124
|
18
|
|
|
|
|
58
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
11125
|
|
|
|
|
|
|
} |
11126
|
|
|
|
|
|
|
else { |
11127
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
11128
|
|
|
|
|
|
|
} |
11129
|
|
|
|
|
|
|
} |
11130
|
0
|
50
|
|
|
|
0
|
|
11131
|
2
|
|
|
|
|
9
|
# \u \l \U \L \F \Q \E |
11132
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
11133
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
11134
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
11135
|
0
|
|
|
|
|
0
|
} |
11136
|
0
|
|
|
|
|
0
|
} |
11137
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
11138
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
11139
|
0
|
|
|
|
|
0
|
$left_e++; |
11140
|
0
|
|
|
|
|
0
|
} |
11141
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
11142
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
11143
|
0
|
|
|
|
|
0
|
$left_e++; |
11144
|
0
|
|
|
|
|
0
|
} |
11145
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
11146
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
11147
|
0
|
|
|
|
|
0
|
$left_e++; |
11148
|
0
|
|
|
|
|
0
|
} |
11149
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
11150
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
11151
|
0
|
|
|
|
|
0
|
$left_e++; |
11152
|
0
|
|
|
|
|
0
|
} |
11153
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
11154
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
11155
|
0
|
|
|
|
|
0
|
$left_e++; |
11156
|
0
|
|
|
|
|
0
|
} |
11157
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
11158
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
11159
|
0
|
0
|
|
|
|
0
|
$left_e++; |
11160
|
0
|
|
|
|
|
0
|
} |
11161
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\E') { |
11162
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
11163
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
11164
|
0
|
|
|
|
|
0
|
$right_e++; |
11165
|
|
|
|
|
|
|
} |
11166
|
|
|
|
|
|
|
else { |
11167
|
|
|
|
|
|
|
$char[$i] = ''; |
11168
|
0
|
|
|
|
|
0
|
} |
11169
|
0
|
0
|
|
|
|
0
|
} |
11170
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
11171
|
|
|
|
|
|
|
while (1) { |
11172
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11173
|
0
|
|
|
|
|
0
|
last; |
11174
|
|
|
|
|
|
|
} |
11175
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
11176
|
|
|
|
|
|
|
last; |
11177
|
|
|
|
|
|
|
} |
11178
|
|
|
|
|
|
|
} |
11179
|
|
|
|
|
|
|
} |
11180
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
11181
|
|
|
|
|
|
|
} |
11182
|
0
|
0
|
|
|
|
0
|
|
11183
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
11184
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
11185
|
|
|
|
|
|
|
if ($ignorecase) { |
11186
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11187
|
0
|
0
|
|
|
|
0
|
} |
11188
|
0
|
|
|
|
|
0
|
} |
11189
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
11190
|
|
|
|
|
|
|
if ($ignorecase) { |
11191
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11192
|
|
|
|
|
|
|
} |
11193
|
|
|
|
|
|
|
} |
11194
|
|
|
|
|
|
|
|
11195
|
|
|
|
|
|
|
# $$ --> $$ |
11196
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
11197
|
|
|
|
|
|
|
} |
11198
|
|
|
|
|
|
|
|
11199
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
11200
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
11201
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
11202
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11203
|
|
|
|
|
|
|
if ($ignorecase) { |
11204
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11205
|
0
|
|
|
|
|
0
|
} |
11206
|
0
|
0
|
|
|
|
0
|
} |
11207
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
11208
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11209
|
|
|
|
|
|
|
if ($ignorecase) { |
11210
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11211
|
|
|
|
|
|
|
} |
11212
|
|
|
|
|
|
|
} |
11213
|
0
|
|
|
|
|
0
|
|
11214
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
11215
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
11216
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
11217
|
|
|
|
|
|
|
if ($ignorecase) { |
11218
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11219
|
|
|
|
|
|
|
} |
11220
|
|
|
|
|
|
|
} |
11221
|
0
|
|
|
|
|
0
|
|
11222
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
11223
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
11224
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
11225
|
|
|
|
|
|
|
if ($ignorecase) { |
11226
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11227
|
|
|
|
|
|
|
} |
11228
|
|
|
|
|
|
|
} |
11229
|
0
|
|
|
|
|
0
|
|
11230
|
0
|
0
|
|
|
|
0
|
# $$foo |
11231
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
11232
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11233
|
|
|
|
|
|
|
if ($ignorecase) { |
11234
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11235
|
|
|
|
|
|
|
} |
11236
|
|
|
|
|
|
|
} |
11237
|
0
|
50
|
|
|
|
0
|
|
11238
|
12
|
|
|
|
|
40
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
11239
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
11240
|
|
|
|
|
|
|
if ($ignorecase) { |
11241
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
11242
|
|
|
|
|
|
|
} |
11243
|
|
|
|
|
|
|
else { |
11244
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
11245
|
|
|
|
|
|
|
} |
11246
|
|
|
|
|
|
|
} |
11247
|
12
|
50
|
|
|
|
75
|
|
11248
|
12
|
|
|
|
|
39
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
11249
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
11250
|
|
|
|
|
|
|
if ($ignorecase) { |
11251
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
11252
|
|
|
|
|
|
|
} |
11253
|
|
|
|
|
|
|
else { |
11254
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
11255
|
|
|
|
|
|
|
} |
11256
|
|
|
|
|
|
|
} |
11257
|
12
|
50
|
|
|
|
64
|
|
11258
|
9
|
|
|
|
|
34
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
11259
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
11260
|
|
|
|
|
|
|
if ($ignorecase) { |
11261
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
11262
|
|
|
|
|
|
|
} |
11263
|
|
|
|
|
|
|
else { |
11264
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
11265
|
|
|
|
|
|
|
} |
11266
|
|
|
|
|
|
|
} |
11267
|
9
|
0
|
|
|
|
54
|
|
11268
|
0
|
|
|
|
|
0
|
# ${ foo } |
11269
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
11270
|
|
|
|
|
|
|
if ($ignorecase) { |
11271
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $1 . ')]}'; |
11272
|
|
|
|
|
|
|
} |
11273
|
|
|
|
|
|
|
} |
11274
|
0
|
|
|
|
|
0
|
|
11275
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
11276
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
11277
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11278
|
|
|
|
|
|
|
if ($ignorecase) { |
11279
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11280
|
|
|
|
|
|
|
} |
11281
|
|
|
|
|
|
|
} |
11282
|
0
|
|
|
|
|
0
|
|
11283
|
3
|
50
|
|
|
|
12
|
# $scalar or @array |
11284
|
3
|
|
|
|
|
17
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
11285
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
11286
|
|
|
|
|
|
|
if ($ignorecase) { |
11287
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11288
|
|
|
|
|
|
|
} |
11289
|
|
|
|
|
|
|
} |
11290
|
0
|
100
|
|
|
|
0
|
|
11291
|
|
|
|
|
|
|
# quote character before ? + * { |
11292
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11293
|
7
|
|
|
|
|
51
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
11294
|
|
|
|
|
|
|
} |
11295
|
|
|
|
|
|
|
else { |
11296
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11297
|
|
|
|
|
|
|
} |
11298
|
|
|
|
|
|
|
} |
11299
|
4
|
|
|
|
|
25
|
} |
11300
|
189
|
50
|
|
|
|
484
|
|
11301
|
189
|
|
|
|
|
499
|
# make regexp string |
11302
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11303
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
11304
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier; |
11305
|
|
|
|
|
|
|
} |
11306
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11307
|
|
|
|
|
|
|
} |
11308
|
|
|
|
|
|
|
|
11309
|
|
|
|
|
|
|
# |
11310
|
189
|
|
|
112
|
0
|
1866
|
# escape regexp of split qr'' |
11311
|
112
|
|
100
|
|
|
599
|
# |
11312
|
|
|
|
|
|
|
sub e_split_q { |
11313
|
112
|
|
|
|
|
395
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
11314
|
112
|
50
|
|
|
|
241
|
$modifier ||= ''; |
11315
|
112
|
|
|
|
|
311
|
|
11316
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
11317
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
11318
|
0
|
|
|
|
|
0
|
my $line = 0; |
11319
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
11320
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
11321
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
11322
|
0
|
|
|
|
|
0
|
last; |
11323
|
|
|
|
|
|
|
} |
11324
|
|
|
|
|
|
|
} |
11325
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
11326
|
|
|
|
|
|
|
} |
11327
|
|
|
|
|
|
|
|
11328
|
112
|
100
|
|
|
|
196
|
$slash = 'div'; |
11329
|
112
|
|
|
|
|
235
|
|
11330
|
|
|
|
|
|
|
# /b /B modifier |
11331
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
11332
|
56
|
100
|
|
|
|
307
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
11333
|
|
|
|
|
|
|
} |
11334
|
|
|
|
|
|
|
|
11335
|
56
|
|
|
|
|
147
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
11336
|
|
|
|
|
|
|
|
11337
|
|
|
|
|
|
|
# split regexp |
11338
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
11339
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[] | |
11340
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
11341
|
|
|
|
|
|
|
\[\^ | |
11342
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
11343
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
11344
|
|
|
|
|
|
|
\\ (?:$q_char) | |
11345
|
|
|
|
|
|
|
(?:$q_char) |
11346
|
56
|
|
|
|
|
368
|
))/oxmsg; |
11347
|
56
|
50
|
33
|
|
|
181
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
11348
|
|
|
|
|
|
|
# unescape character |
11349
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
11350
|
|
|
|
|
|
|
if (0) { |
11351
|
56
|
|
|
|
|
573
|
} |
11352
|
0
|
|
|
|
|
0
|
|
11353
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
11354
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11355
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11356
|
|
|
|
|
|
|
} |
11357
|
0
|
|
|
|
|
0
|
|
11358
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
11359
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
11360
|
|
|
|
|
|
|
my $left = $i; |
11361
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11362
|
0
|
0
|
|
|
|
0
|
$i++; |
11363
|
0
|
|
|
|
|
0
|
} |
11364
|
|
|
|
|
|
|
while (1) { |
11365
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11366
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11367
|
|
|
|
|
|
|
} |
11368
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11369
|
0
|
|
|
|
|
0
|
my $right = $i; |
11370
|
|
|
|
|
|
|
|
11371
|
0
|
|
|
|
|
0
|
# [...] |
11372
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
11373
|
|
|
|
|
|
|
|
11374
|
|
|
|
|
|
|
$i = $left; |
11375
|
|
|
|
|
|
|
last; |
11376
|
|
|
|
|
|
|
} |
11377
|
|
|
|
|
|
|
} |
11378
|
|
|
|
|
|
|
} |
11379
|
0
|
|
|
|
|
0
|
|
11380
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
11381
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
11382
|
|
|
|
|
|
|
my $left = $i; |
11383
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11384
|
0
|
0
|
|
|
|
0
|
$i++; |
11385
|
0
|
|
|
|
|
0
|
} |
11386
|
|
|
|
|
|
|
while (1) { |
11387
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11388
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11389
|
|
|
|
|
|
|
} |
11390
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11391
|
0
|
|
|
|
|
0
|
my $right = $i; |
11392
|
|
|
|
|
|
|
|
11393
|
0
|
|
|
|
|
0
|
# [^...] |
11394
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11395
|
|
|
|
|
|
|
|
11396
|
|
|
|
|
|
|
$i = $left; |
11397
|
|
|
|
|
|
|
last; |
11398
|
|
|
|
|
|
|
} |
11399
|
|
|
|
|
|
|
} |
11400
|
|
|
|
|
|
|
} |
11401
|
0
|
|
|
|
|
0
|
|
11402
|
|
|
|
|
|
|
# rewrite character class or escape character |
11403
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11404
|
|
|
|
|
|
|
$char[$i] = $char; |
11405
|
|
|
|
|
|
|
} |
11406
|
0
|
|
|
|
|
0
|
|
11407
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
11408
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11409
|
|
|
|
|
|
|
$modifier .= 'm'; |
11410
|
|
|
|
|
|
|
} |
11411
|
0
|
50
|
|
|
|
0
|
|
11412
|
12
|
|
|
|
|
38
|
# /i modifier |
11413
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
11414
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
11415
|
12
|
|
|
|
|
35
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
11416
|
|
|
|
|
|
|
} |
11417
|
|
|
|
|
|
|
else { |
11418
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
11419
|
|
|
|
|
|
|
} |
11420
|
|
|
|
|
|
|
} |
11421
|
0
|
0
|
|
|
|
0
|
|
11422
|
|
|
|
|
|
|
# quote character before ? + * { |
11423
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11424
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
11425
|
|
|
|
|
|
|
} |
11426
|
|
|
|
|
|
|
else { |
11427
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11428
|
|
|
|
|
|
|
} |
11429
|
0
|
|
|
|
|
0
|
} |
11430
|
56
|
|
|
|
|
127
|
} |
11431
|
|
|
|
|
|
|
|
11432
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11433
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11434
|
|
|
|
|
|
|
} |
11435
|
|
|
|
|
|
|
|
11436
|
|
|
|
|
|
|
# |
11437
|
56
|
|
|
0
|
0
|
342
|
# escape use without import |
11438
|
|
|
|
|
|
|
# |
11439
|
0
|
|
|
|
|
|
sub e_use_noimport { |
11440
|
|
|
|
|
|
|
my($module) = @_; |
11441
|
0
|
|
|
|
|
|
|
11442
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11443
|
|
|
|
|
|
|
|
11444
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11445
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11446
|
0
|
|
|
|
|
|
|
11447
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11448
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11449
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11450
|
0
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11451
|
|
|
|
|
|
|
|
11452
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11453
|
|
|
|
|
|
|
return qq; |
11454
|
|
|
|
|
|
|
} |
11455
|
|
|
|
|
|
|
last; |
11456
|
0
|
|
|
|
|
|
} |
11457
|
|
|
|
|
|
|
} |
11458
|
|
|
|
|
|
|
|
11459
|
|
|
|
|
|
|
return qq |
11460
|
|
|
|
|
|
|
} |
11461
|
|
|
|
|
|
|
|
11462
|
|
|
|
|
|
|
# |
11463
|
0
|
|
|
0
|
0
|
|
# escape no without unimport |
11464
|
|
|
|
|
|
|
# |
11465
|
0
|
|
|
|
|
|
sub e_no_nounimport { |
11466
|
|
|
|
|
|
|
my($module) = @_; |
11467
|
0
|
|
|
|
|
|
|
11468
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11469
|
|
|
|
|
|
|
|
11470
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11471
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11472
|
0
|
|
|
|
|
|
|
11473
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11474
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11475
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11476
|
0
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11477
|
|
|
|
|
|
|
|
11478
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11479
|
|
|
|
|
|
|
return qq; |
11480
|
|
|
|
|
|
|
} |
11481
|
|
|
|
|
|
|
last; |
11482
|
0
|
|
|
|
|
|
} |
11483
|
|
|
|
|
|
|
} |
11484
|
|
|
|
|
|
|
|
11485
|
|
|
|
|
|
|
return qq; |
11486
|
|
|
|
|
|
|
} |
11487
|
|
|
|
|
|
|
|
11488
|
|
|
|
|
|
|
# |
11489
|
0
|
|
|
0
|
0
|
|
# escape use with import no parameter |
11490
|
|
|
|
|
|
|
# |
11491
|
0
|
|
|
|
|
|
sub e_use_noparam { |
11492
|
|
|
|
|
|
|
my($module) = @_; |
11493
|
0
|
|
|
|
|
|
|
11494
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11495
|
|
|
|
|
|
|
|
11496
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11497
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11498
|
0
|
|
|
|
|
|
|
11499
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11500
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11501
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11502
|
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11503
|
|
|
|
|
|
|
|
11504
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11505
|
|
|
|
|
|
|
|
11506
|
|
|
|
|
|
|
# P.326 UNIVERSAL: The Ultimate Ancestor Class |
11507
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11508
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11509
|
|
|
|
|
|
|
|
11510
|
|
|
|
|
|
|
# P.435 UNIVERSAL: The Ultimate Ancestor Class |
11511
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11512
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11513
|
0
|
|
|
|
|
|
|
11514
|
|
|
|
|
|
|
# (and so on) |
11515
|
0
|
|
|
|
|
|
|
11516
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->import() if $module->can('import'); }]; |
11517
|
|
|
|
|
|
|
} |
11518
|
|
|
|
|
|
|
last; |
11519
|
0
|
|
|
|
|
|
} |
11520
|
|
|
|
|
|
|
} |
11521
|
|
|
|
|
|
|
|
11522
|
|
|
|
|
|
|
return qq |
11523
|
|
|
|
|
|
|
} |
11524
|
|
|
|
|
|
|
|
11525
|
|
|
|
|
|
|
# |
11526
|
0
|
|
|
0
|
0
|
|
# escape no with unimport no parameter |
11527
|
|
|
|
|
|
|
# |
11528
|
0
|
|
|
|
|
|
sub e_no_noparam { |
11529
|
|
|
|
|
|
|
my($module) = @_; |
11530
|
0
|
|
|
|
|
|
|
11531
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11532
|
|
|
|
|
|
|
|
11533
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11534
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11535
|
0
|
|
|
|
|
|
|
11536
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11537
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11538
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11539
|
0
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11540
|
|
|
|
|
|
|
|
11541
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11542
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->unimport() if $module->can('unimport'); }]; |
11543
|
|
|
|
|
|
|
} |
11544
|
|
|
|
|
|
|
last; |
11545
|
0
|
|
|
|
|
|
} |
11546
|
|
|
|
|
|
|
} |
11547
|
|
|
|
|
|
|
|
11548
|
|
|
|
|
|
|
return qq; |
11549
|
|
|
|
|
|
|
} |
11550
|
|
|
|
|
|
|
|
11551
|
|
|
|
|
|
|
# |
11552
|
0
|
|
|
0
|
0
|
|
# escape use with import parameters |
11553
|
|
|
|
|
|
|
# |
11554
|
0
|
|
|
|
|
|
sub e_use { |
11555
|
|
|
|
|
|
|
my($module,$list) = @_; |
11556
|
0
|
|
|
|
|
|
|
11557
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11558
|
|
|
|
|
|
|
|
11559
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11560
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11561
|
0
|
|
|
|
|
|
|
11562
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11563
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11564
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11565
|
0
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11566
|
|
|
|
|
|
|
|
11567
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11568
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->import($list) if $module->can('import'); }]; |
11569
|
|
|
|
|
|
|
} |
11570
|
|
|
|
|
|
|
last; |
11571
|
0
|
|
|
|
|
|
} |
11572
|
|
|
|
|
|
|
} |
11573
|
|
|
|
|
|
|
|
11574
|
|
|
|
|
|
|
return qq |
11575
|
|
|
|
|
|
|
} |
11576
|
|
|
|
|
|
|
|
11577
|
|
|
|
|
|
|
# |
11578
|
0
|
|
|
0
|
0
|
|
# escape no with unimport parameters |
11579
|
|
|
|
|
|
|
# |
11580
|
0
|
|
|
|
|
|
sub e_no { |
11581
|
|
|
|
|
|
|
my($module,$list) = @_; |
11582
|
0
|
|
|
|
|
|
|
11583
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11584
|
|
|
|
|
|
|
|
11585
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11586
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11587
|
0
|
|
|
|
|
|
|
11588
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11589
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11590
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11591
|
0
|
|
|
|
|
|
close($fh) or die __FILE__, ": Can't close file: $realfilename\n"; |
11592
|
|
|
|
|
|
|
|
11593
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11594
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->unimport($list) if $module->can('unimport'); }]; |
11595
|
|
|
|
|
|
|
} |
11596
|
|
|
|
|
|
|
last; |
11597
|
0
|
|
|
|
|
|
} |
11598
|
|
|
|
|
|
|
} |
11599
|
|
|
|
|
|
|
|
11600
|
|
|
|
|
|
|
return qq; |
11601
|
|
|
|
|
|
|
} |
11602
|
|
|
|
|
|
|
|
11603
|
|
|
|
|
|
|
# |
11604
|
0
|
|
|
0
|
|
|
# file path of module |
11605
|
|
|
|
|
|
|
# |
11606
|
0
|
0
|
|
|
|
|
sub _pathof { |
11607
|
0
|
|
|
|
|
|
my($expr) = @_; |
11608
|
|
|
|
|
|
|
|
11609
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11610
|
0
|
|
|
|
|
|
$expr =~ s#::#:#g; |
11611
|
|
|
|
|
|
|
} |
11612
|
0
|
0
|
|
|
|
|
else { |
11613
|
|
|
|
|
|
|
$expr =~ s#::#/#g; |
11614
|
0
|
|
|
|
|
|
} |
11615
|
|
|
|
|
|
|
$expr .= '.pm' if $expr !~ / \.pm \z/oxmsi; |
11616
|
|
|
|
|
|
|
|
11617
|
|
|
|
|
|
|
return $expr; |
11618
|
|
|
|
|
|
|
} |
11619
|
|
|
|
|
|
|
|
11620
|
|
|
|
|
|
|
# |
11621
|
0
|
|
|
0
|
|
|
# real file name of module |
11622
|
|
|
|
|
|
|
# |
11623
|
0
|
0
|
|
|
|
|
sub _realfilename { |
11624
|
0
|
|
|
|
|
|
my($expr) = @_; |
|
0
|
|
|
|
|
|
|
11625
|
|
|
|
|
|
|
|
11626
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11627
|
0
|
|
|
|
|
|
return map {"$_$expr"} @INC; |
|
0
|
|
|
|
|
|
|
11628
|
|
|
|
|
|
|
} |
11629
|
|
|
|
|
|
|
else { |
11630
|
|
|
|
|
|
|
return map {"$_/$expr"} @INC; |
11631
|
|
|
|
|
|
|
} |
11632
|
|
|
|
|
|
|
} |
11633
|
|
|
|
|
|
|
|
11634
|
|
|
|
|
|
|
# |
11635
|
0
|
|
|
0
|
0
|
|
# instead of Carp::carp |
11636
|
0
|
|
|
|
|
|
# |
11637
|
|
|
|
|
|
|
sub carp { |
11638
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11639
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11640
|
|
|
|
|
|
|
} |
11641
|
|
|
|
|
|
|
|
11642
|
|
|
|
|
|
|
# |
11643
|
0
|
|
|
0
|
0
|
|
# instead of Carp::croak |
11644
|
0
|
|
|
|
|
|
# |
11645
|
0
|
|
|
|
|
|
sub croak { |
11646
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11647
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11648
|
|
|
|
|
|
|
die "\n"; |
11649
|
|
|
|
|
|
|
} |
11650
|
|
|
|
|
|
|
|
11651
|
|
|
|
|
|
|
# |
11652
|
0
|
|
|
0
|
0
|
|
# instead of Carp::cluck |
11653
|
0
|
|
|
|
|
|
# |
11654
|
0
|
|
|
|
|
|
sub cluck { |
11655
|
0
|
|
|
|
|
|
my $i = 0; |
11656
|
0
|
|
|
|
|
|
my @cluck = (); |
11657
|
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11658
|
0
|
|
|
|
|
|
push @cluck, "[$i] $filename($line) $package::$subroutine\n"; |
11659
|
0
|
|
|
|
|
|
$i++; |
11660
|
0
|
|
|
|
|
|
} |
11661
|
|
|
|
|
|
|
print STDERR CORE::reverse @cluck; |
11662
|
|
|
|
|
|
|
print STDERR "\n"; |
11663
|
|
|
|
|
|
|
print STDERR @_; |
11664
|
|
|
|
|
|
|
} |
11665
|
|
|
|
|
|
|
|
11666
|
|
|
|
|
|
|
# |
11667
|
0
|
|
|
0
|
0
|
|
# instead of Carp::confess |
11668
|
0
|
|
|
|
|
|
# |
11669
|
0
|
|
|
|
|
|
sub confess { |
11670
|
0
|
|
|
|
|
|
my $i = 0; |
11671
|
0
|
|
|
|
|
|
my @confess = (); |
11672
|
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11673
|
0
|
|
|
|
|
|
push @confess, "[$i] $filename($line) $package::$subroutine\n"; |
11674
|
0
|
|
|
|
|
|
$i++; |
11675
|
0
|
|
|
|
|
|
} |
11676
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @confess; |
11677
|
|
|
|
|
|
|
print STDERR "\n"; |
11678
|
|
|
|
|
|
|
print STDERR @_; |
11679
|
|
|
|
|
|
|
die "\n"; |
11680
|
|
|
|
|
|
|
} |
11681
|
|
|
|
|
|
|
|
11682
|
|
|
|
|
|
|
1; |
11683
|
|
|
|
|
|
|
|
11684
|
|
|
|
|
|
|
__END__ |