line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Esjis; |
2
|
390
|
|
|
390
|
|
15584
|
use strict; |
|
390
|
|
|
|
|
4395
|
|
|
390
|
|
|
|
|
28238
|
|
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
|
|
7888
|
use 5.00503; # Galapagos Consensus 1998 for primetools |
|
390
|
|
|
|
|
1127
|
|
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
|
|
4087
|
use vars qw($VERSION); |
|
390
|
|
|
|
|
2133
|
|
|
390
|
|
|
|
|
81041
|
|
28
|
|
|
|
|
|
|
$VERSION = '1.13'; |
29
|
|
|
|
|
|
|
$VERSION = $VERSION; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BEGIN { |
32
|
390
|
50
|
|
390
|
|
8584
|
if ($^X =~ / jperl /oxmsi) { |
33
|
0
|
|
|
|
|
0
|
die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n"; |
34
|
|
|
|
|
|
|
} |
35
|
390
|
|
|
|
|
753
|
if (CORE::ord('A') == 193) { |
36
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n"; |
37
|
|
|
|
|
|
|
} |
38
|
390
|
|
|
|
|
58775
|
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
|
|
41006
|
CORE::eval q{ |
|
390
|
|
|
390
|
|
4661
|
|
|
390
|
|
|
134
|
|
815
|
|
|
390
|
|
|
|
|
55531
|
|
|
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
|
|
|
|
199925
|
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
|
0
|
if ($] < 5.006) { |
69
|
0
|
|
|
|
|
0
|
return \do { local *_ }; |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
0
|
|
|
|
|
0
|
return undef; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub qualify ($$) { |
77
|
0
|
|
|
1155
|
0
|
0
|
my($name) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1155
|
50
|
|
|
|
2790
|
if (ref $name) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
80
|
1155
|
|
|
|
|
4803
|
return $name; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif (Esjis::index($name,'::') >= 0) { |
83
|
0
|
|
|
|
|
0
|
return $name; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif (Esjis::index($name,"'") >= 0) { |
86
|
0
|
|
|
|
|
0
|
return $name; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# special character, "^xyz" |
90
|
|
|
|
|
|
|
elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# RGS 2001-11-05 : translate leading ^X to control-char |
93
|
0
|
|
|
|
|
0
|
$name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee; |
|
0
|
|
|
|
|
0
|
|
94
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Global names |
98
|
|
|
|
|
|
|
elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) { |
99
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# or other |
103
|
|
|
|
|
|
|
elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) { |
104
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
elsif (defined $_[1]) { |
108
|
0
|
|
|
|
|
0
|
return $_[1] . '::' . $name; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
1155
|
|
|
|
|
9564
|
return (caller)[0] . '::' . $name; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub qualify_to_ref ($;$) { |
116
|
0
|
50
|
|
1155
|
0
|
0
|
if (defined $_[1]) { |
117
|
390
|
|
|
390
|
|
5329
|
no strict qw(refs); |
|
390
|
|
|
|
|
2551
|
|
|
390
|
|
|
|
|
29526
|
|
118
|
1155
|
|
|
|
|
3530
|
return \*{ qualify $_[0], $_[1] }; |
|
0
|
|
|
|
|
0
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
390
|
|
|
390
|
|
8052
|
no strict qw(refs); |
|
390
|
|
|
0
|
|
2209
|
|
|
390
|
|
|
|
|
82334
|
|
122
|
0
|
|
|
|
|
0
|
return \*{ qualify $_[0], (caller)[0] }; |
|
1155
|
|
|
|
|
1815
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# P.714 29.2.39. flock |
128
|
|
|
|
|
|
|
# in Chapter 29: Functions |
129
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# P.863 flock |
132
|
|
|
|
|
|
|
# in Chapter 27: Functions |
133
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub LOCK_SH() {1} |
136
|
|
|
|
|
|
|
sub LOCK_EX() {2} |
137
|
|
|
|
|
|
|
sub LOCK_UN() {8} |
138
|
|
|
|
|
|
|
sub LOCK_NB() {4} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# instead of Carp.pm |
141
|
|
|
|
|
|
|
sub carp; |
142
|
|
|
|
|
|
|
sub croak; |
143
|
|
|
|
|
|
|
sub cluck; |
144
|
|
|
|
|
|
|
sub confess; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# 6.18. Matching Multiple-Byte Characters |
147
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
148
|
|
|
|
|
|
|
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook. |
149
|
|
|
|
|
|
|
# (and so on) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# regexp of character |
152
|
|
|
|
|
|
|
my $your_char = q{[\x81-\x9F\xE0-\xFC][\x00-\xFF]|[\x00-\xFF]}; |
153
|
390
|
|
|
390
|
|
2708
|
use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms; |
|
390
|
|
|
|
|
4022
|
|
|
390
|
|
|
|
|
26300
|
|
154
|
390
|
|
|
390
|
|
2566
|
use vars qw($q_char); $q_char = qr/$your_char/oxms; |
|
390
|
|
|
|
|
2290
|
|
|
390
|
|
|
|
|
710267
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# |
157
|
|
|
|
|
|
|
# ShiftJIS character range per length |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
my %range_tr = (); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# |
162
|
|
|
|
|
|
|
# ShiftJIS case conversion |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
my %lc = (); |
165
|
|
|
|
|
|
|
@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)} = |
166
|
|
|
|
|
|
|
qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); |
167
|
|
|
|
|
|
|
my %uc = (); |
168
|
|
|
|
|
|
|
@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)} = |
169
|
|
|
|
|
|
|
qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); |
170
|
|
|
|
|
|
|
my %fc = (); |
171
|
|
|
|
|
|
|
@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)} = |
172
|
|
|
|
|
|
|
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); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if (0) { |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b E s j i s \z/oxms) { # escape from build system |
178
|
|
|
|
|
|
|
%range_tr = ( |
179
|
|
|
|
|
|
|
1 => [ [0x00..0x80], |
180
|
|
|
|
|
|
|
[0xA0..0xDF], |
181
|
|
|
|
|
|
|
[0xFD..0xFF], |
182
|
|
|
|
|
|
|
], |
183
|
|
|
|
|
|
|
2 => [ [0x81..0x9F],[0x40..0x7E], |
184
|
|
|
|
|
|
|
[0x81..0x9F],[0x80..0xFC], |
185
|
|
|
|
|
|
|
[0xE0..0xFC],[0x40..0x7E], |
186
|
|
|
|
|
|
|
[0xE0..0xFC],[0x80..0xFC], |
187
|
|
|
|
|
|
|
], |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
else { |
192
|
|
|
|
|
|
|
croak "Don't know my package name '@{[__PACKAGE__]}'"; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# |
196
|
|
|
|
|
|
|
# @ARGV wildcard globbing |
197
|
|
|
|
|
|
|
# |
198
|
|
|
|
|
|
|
sub import { |
199
|
|
|
|
|
|
|
|
200
|
1155
|
50
|
|
5
|
|
6376
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
201
|
5
|
|
|
|
|
93
|
my @argv = (); |
202
|
0
|
|
|
|
|
0
|
for (@ARGV) { |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# has space |
205
|
0
|
0
|
|
|
|
0
|
if (/\A (?:$q_char)*? [ ] /oxms) { |
|
|
0
|
|
|
|
|
|
206
|
0
|
0
|
|
|
|
0
|
if (my @glob = Esjis::glob(qq{"$_"})) { |
207
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
else { |
210
|
0
|
|
|
|
|
0
|
push @argv, $_; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# has wildcard metachar |
215
|
|
|
|
|
|
|
elsif (/\A (?:$q_char)*? [*?] /oxms) { |
216
|
0
|
0
|
|
|
|
0
|
if (my @glob = Esjis::glob($_)) { |
217
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
else { |
220
|
0
|
|
|
|
|
0
|
push @argv, $_; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# no wildcard globbing |
225
|
|
|
|
|
|
|
else { |
226
|
0
|
|
|
|
|
0
|
push @argv, $_; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
0
|
|
|
|
|
0
|
@ARGV = @argv; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
0
|
*Char::ord = \&Sjis::ord; |
233
|
5
|
|
|
|
|
25
|
*Char::ord_ = \&Sjis::ord_; |
234
|
5
|
|
|
|
|
13
|
*Char::reverse = \&Sjis::reverse; |
235
|
5
|
|
|
|
|
11
|
*Char::getc = \&Sjis::getc; |
236
|
5
|
|
|
|
|
10
|
*Char::length = \&Sjis::length; |
237
|
5
|
|
|
|
|
11
|
*Char::substr = \&Sjis::substr; |
238
|
5
|
|
|
|
|
8
|
*Char::index = \&Sjis::index; |
239
|
5
|
|
|
|
|
10
|
*Char::rindex = \&Sjis::rindex; |
240
|
5
|
|
|
|
|
12
|
*Char::eval = \&Sjis::eval; |
241
|
5
|
|
|
|
|
19
|
*Char::escape = \&Sjis::escape; |
242
|
5
|
|
|
|
|
12
|
*Char::escape_token = \&Sjis::escape_token; |
243
|
5
|
|
|
|
|
10
|
*Char::escape_script = \&Sjis::escape_script; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# P.230 Care with Prototypes |
247
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
248
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
249
|
|
|
|
|
|
|
# |
250
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
251
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
252
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
253
|
|
|
|
|
|
|
# the world a better place. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# P.332 Care with Prototypes |
256
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
257
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
258
|
|
|
|
|
|
|
# |
259
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
260
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
261
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
262
|
|
|
|
|
|
|
# the world a better place. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# |
265
|
|
|
|
|
|
|
# Prototypes of subroutines |
266
|
|
|
|
|
|
|
# |
267
|
|
|
|
0
|
|
|
sub unimport {} |
268
|
|
|
|
|
|
|
sub Esjis::split(;$$$); |
269
|
|
|
|
|
|
|
sub Esjis::tr($$$$;$); |
270
|
|
|
|
|
|
|
sub Esjis::chop(@); |
271
|
|
|
|
|
|
|
sub Esjis::index($$;$); |
272
|
|
|
|
|
|
|
sub Esjis::rindex($$;$); |
273
|
|
|
|
|
|
|
sub Esjis::lcfirst(@); |
274
|
|
|
|
|
|
|
sub Esjis::lcfirst_(); |
275
|
|
|
|
|
|
|
sub Esjis::lc(@); |
276
|
|
|
|
|
|
|
sub Esjis::lc_(); |
277
|
|
|
|
|
|
|
sub Esjis::ucfirst(@); |
278
|
|
|
|
|
|
|
sub Esjis::ucfirst_(); |
279
|
|
|
|
|
|
|
sub Esjis::uc(@); |
280
|
|
|
|
|
|
|
sub Esjis::uc_(); |
281
|
|
|
|
|
|
|
sub Esjis::fc(@); |
282
|
|
|
|
|
|
|
sub Esjis::fc_(); |
283
|
|
|
|
|
|
|
sub Esjis::ignorecase; |
284
|
|
|
|
|
|
|
sub Esjis::classic_character_class; |
285
|
|
|
|
|
|
|
sub Esjis::capture; |
286
|
|
|
|
|
|
|
sub Esjis::chr(;$); |
287
|
|
|
|
|
|
|
sub Esjis::chr_(); |
288
|
|
|
|
|
|
|
sub Esjis::filetest; |
289
|
|
|
|
|
|
|
sub Esjis::r(;*@); |
290
|
|
|
|
|
|
|
sub Esjis::w(;*@); |
291
|
|
|
|
|
|
|
sub Esjis::x(;*@); |
292
|
|
|
|
|
|
|
sub Esjis::o(;*@); |
293
|
|
|
|
|
|
|
sub Esjis::R(;*@); |
294
|
|
|
|
|
|
|
sub Esjis::W(;*@); |
295
|
|
|
|
|
|
|
sub Esjis::X(;*@); |
296
|
|
|
|
|
|
|
sub Esjis::O(;*@); |
297
|
|
|
|
|
|
|
sub Esjis::e(;*@); |
298
|
|
|
|
|
|
|
sub Esjis::z(;*@); |
299
|
|
|
|
|
|
|
sub Esjis::s(;*@); |
300
|
|
|
|
|
|
|
sub Esjis::f(;*@); |
301
|
|
|
|
|
|
|
sub Esjis::d(;*@); |
302
|
|
|
|
|
|
|
sub Esjis::l(;*@); |
303
|
|
|
|
|
|
|
sub Esjis::p(;*@); |
304
|
|
|
|
|
|
|
sub Esjis::S(;*@); |
305
|
|
|
|
|
|
|
sub Esjis::b(;*@); |
306
|
|
|
|
|
|
|
sub Esjis::c(;*@); |
307
|
|
|
|
|
|
|
sub Esjis::u(;*@); |
308
|
|
|
|
|
|
|
sub Esjis::g(;*@); |
309
|
|
|
|
|
|
|
sub Esjis::k(;*@); |
310
|
|
|
|
|
|
|
sub Esjis::T(;*@); |
311
|
|
|
|
|
|
|
sub Esjis::B(;*@); |
312
|
|
|
|
|
|
|
sub Esjis::M(;*@); |
313
|
|
|
|
|
|
|
sub Esjis::A(;*@); |
314
|
|
|
|
|
|
|
sub Esjis::C(;*@); |
315
|
|
|
|
|
|
|
sub Esjis::filetest_; |
316
|
|
|
|
|
|
|
sub Esjis::r_(); |
317
|
|
|
|
|
|
|
sub Esjis::w_(); |
318
|
|
|
|
|
|
|
sub Esjis::x_(); |
319
|
|
|
|
|
|
|
sub Esjis::o_(); |
320
|
|
|
|
|
|
|
sub Esjis::R_(); |
321
|
|
|
|
|
|
|
sub Esjis::W_(); |
322
|
|
|
|
|
|
|
sub Esjis::X_(); |
323
|
|
|
|
|
|
|
sub Esjis::O_(); |
324
|
|
|
|
|
|
|
sub Esjis::e_(); |
325
|
|
|
|
|
|
|
sub Esjis::z_(); |
326
|
|
|
|
|
|
|
sub Esjis::s_(); |
327
|
|
|
|
|
|
|
sub Esjis::f_(); |
328
|
|
|
|
|
|
|
sub Esjis::d_(); |
329
|
|
|
|
|
|
|
sub Esjis::l_(); |
330
|
|
|
|
|
|
|
sub Esjis::p_(); |
331
|
|
|
|
|
|
|
sub Esjis::S_(); |
332
|
|
|
|
|
|
|
sub Esjis::b_(); |
333
|
|
|
|
|
|
|
sub Esjis::c_(); |
334
|
|
|
|
|
|
|
sub Esjis::u_(); |
335
|
|
|
|
|
|
|
sub Esjis::g_(); |
336
|
|
|
|
|
|
|
sub Esjis::k_(); |
337
|
|
|
|
|
|
|
sub Esjis::T_(); |
338
|
|
|
|
|
|
|
sub Esjis::B_(); |
339
|
|
|
|
|
|
|
sub Esjis::M_(); |
340
|
|
|
|
|
|
|
sub Esjis::A_(); |
341
|
|
|
|
|
|
|
sub Esjis::C_(); |
342
|
|
|
|
|
|
|
sub Esjis::glob($); |
343
|
|
|
|
|
|
|
sub Esjis::glob_(); |
344
|
|
|
|
|
|
|
sub Esjis::lstat(*); |
345
|
|
|
|
|
|
|
sub Esjis::lstat_(); |
346
|
|
|
|
|
|
|
sub Esjis::opendir(*$); |
347
|
|
|
|
|
|
|
sub Esjis::stat(*); |
348
|
|
|
|
|
|
|
sub Esjis::stat_(); |
349
|
|
|
|
|
|
|
sub Esjis::unlink(@); |
350
|
|
|
|
|
|
|
sub Esjis::chdir(;$); |
351
|
|
|
|
|
|
|
sub Esjis::do($); |
352
|
|
|
|
|
|
|
sub Esjis::require(;$); |
353
|
|
|
|
|
|
|
sub Esjis::telldir(*); |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub Sjis::ord(;$); |
356
|
|
|
|
|
|
|
sub Sjis::ord_(); |
357
|
|
|
|
|
|
|
sub Sjis::reverse(@); |
358
|
|
|
|
|
|
|
sub Sjis::getc(;*@); |
359
|
|
|
|
|
|
|
sub Sjis::length(;$); |
360
|
|
|
|
|
|
|
sub Sjis::substr($$;$$); |
361
|
|
|
|
|
|
|
sub Sjis::index($$;$); |
362
|
|
|
|
|
|
|
sub Sjis::rindex($$;$); |
363
|
|
|
|
|
|
|
sub Sjis::escape(;$); |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# |
366
|
|
|
|
|
|
|
# Regexp work |
367
|
|
|
|
|
|
|
# |
368
|
390
|
|
|
|
|
42840
|
use vars qw( |
369
|
|
|
|
|
|
|
$re_a |
370
|
|
|
|
|
|
|
$re_t |
371
|
|
|
|
|
|
|
$re_n |
372
|
|
|
|
|
|
|
$re_r |
373
|
390
|
|
|
390
|
|
12658
|
); |
|
390
|
|
|
|
|
2044
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
# |
376
|
|
|
|
|
|
|
# Character class |
377
|
|
|
|
|
|
|
# |
378
|
390
|
|
|
|
|
124882
|
use vars qw( |
379
|
|
|
|
|
|
|
$dot |
380
|
|
|
|
|
|
|
$dot_s |
381
|
|
|
|
|
|
|
$eD |
382
|
|
|
|
|
|
|
$eS |
383
|
|
|
|
|
|
|
$eW |
384
|
|
|
|
|
|
|
$eH |
385
|
|
|
|
|
|
|
$eV |
386
|
|
|
|
|
|
|
$eR |
387
|
|
|
|
|
|
|
$eN |
388
|
|
|
|
|
|
|
$not_alnum |
389
|
|
|
|
|
|
|
$not_alpha |
390
|
|
|
|
|
|
|
$not_ascii |
391
|
|
|
|
|
|
|
$not_blank |
392
|
|
|
|
|
|
|
$not_cntrl |
393
|
|
|
|
|
|
|
$not_digit |
394
|
|
|
|
|
|
|
$not_graph |
395
|
|
|
|
|
|
|
$not_lower |
396
|
|
|
|
|
|
|
$not_lower_i |
397
|
|
|
|
|
|
|
$not_print |
398
|
|
|
|
|
|
|
$not_punct |
399
|
|
|
|
|
|
|
$not_space |
400
|
|
|
|
|
|
|
$not_upper |
401
|
|
|
|
|
|
|
$not_upper_i |
402
|
|
|
|
|
|
|
$not_word |
403
|
|
|
|
|
|
|
$not_xdigit |
404
|
|
|
|
|
|
|
$eb |
405
|
|
|
|
|
|
|
$eB |
406
|
390
|
|
|
390
|
|
4317
|
); |
|
390
|
|
|
|
|
2512
|
|
407
|
|
|
|
|
|
|
|
408
|
390
|
|
|
|
|
5150055
|
use vars qw( |
409
|
|
|
|
|
|
|
$anchor |
410
|
|
|
|
|
|
|
$matched |
411
|
390
|
|
|
390
|
|
3020
|
); |
|
390
|
|
|
|
|
624
|
|
412
|
|
|
|
|
|
|
${Esjis::anchor} = qr{\G(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?}oxms; |
413
|
|
|
|
|
|
|
my $q_char_SADAHIRO_Tomoyuki_2002_01_17 = ''; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# Quantifiers |
416
|
|
|
|
|
|
|
# {n,m} --- Match at least n but not more than m times |
417
|
|
|
|
|
|
|
# |
418
|
|
|
|
|
|
|
# n and m are limited to non-negative integral values less than a |
419
|
|
|
|
|
|
|
# preset limit defined when perl is built. This is usually 32766 on |
420
|
|
|
|
|
|
|
# the most common platforms. |
421
|
|
|
|
|
|
|
# |
422
|
|
|
|
|
|
|
# The following code is an attempt to solve the above limitations |
423
|
|
|
|
|
|
|
# in a multi-byte anchoring. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
# avoid "Segmentation fault" and "Error: Parse exception" |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# perl5101delta |
428
|
|
|
|
|
|
|
# http://perldoc.perl.org/perl5101delta.html |
429
|
|
|
|
|
|
|
# In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767} |
430
|
|
|
|
|
|
|
# [RT #60034, #60464]. For example, this match would fail: |
431
|
|
|
|
|
|
|
# ("ab" x 32768) =~ /^(ab)*$/ |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# SEE ALSO |
434
|
|
|
|
|
|
|
# |
435
|
|
|
|
|
|
|
# Complex regular subexpression recursion limit |
436
|
|
|
|
|
|
|
# http://www.perlmonks.org/?node_id=810857 |
437
|
|
|
|
|
|
|
# |
438
|
|
|
|
|
|
|
# regexp iteration limits |
439
|
|
|
|
|
|
|
# http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html |
440
|
|
|
|
|
|
|
# |
441
|
|
|
|
|
|
|
# latest Perl won't match certain regexes more than 32768 characters long |
442
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long |
443
|
|
|
|
|
|
|
# |
444
|
|
|
|
|
|
|
# Break through the limitations of regular expressions of Perl |
445
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20110212/1297512479 |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
if (($] >= 5.010001) or |
448
|
|
|
|
|
|
|
# ActivePerl 5.6 or later (include 5.10.0) |
449
|
|
|
|
|
|
|
(defined($ActivePerl::VERSION) and ($ActivePerl::VERSION > 800)) or |
450
|
|
|
|
|
|
|
(($^O eq 'MSWin32') and ($] =~ /\A 5\.006/oxms)) |
451
|
|
|
|
|
|
|
) { |
452
|
|
|
|
|
|
|
my $sbcs = ''; # Single Byte Character Set |
453
|
|
|
|
|
|
|
for my $range (@{ $range_tr{1} }) { |
454
|
|
|
|
|
|
|
$sbcs .= sprintf('\\x%02X-\\x%02X', $range->[0], $range->[-1]); |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
if (0) { |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
# other encoding |
461
|
|
|
|
|
|
|
else { |
462
|
|
|
|
|
|
|
${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[$sbcs](?:[^$sbcs][^$sbcs])*?}oxms; |
463
|
|
|
|
|
|
|
# ******* octets not in multiple octet char (always char boundary) |
464
|
|
|
|
|
|
|
# **************** 2 octet chars |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17} = |
468
|
|
|
|
|
|
|
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; |
469
|
|
|
|
|
|
|
# qr{ |
470
|
|
|
|
|
|
|
# \G # (1), (2) |
471
|
|
|
|
|
|
|
# (? # (3) |
472
|
|
|
|
|
|
|
# (?=.{0,32766}\z) # (4) |
473
|
|
|
|
|
|
|
# (?:[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?| # (5) |
474
|
|
|
|
|
|
|
# (?(?=[$sbcs]+\z) # (6) |
475
|
|
|
|
|
|
|
# .*?| #(7) |
476
|
|
|
|
|
|
|
# (?:${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}) # (8) |
477
|
|
|
|
|
|
|
# ))}oxms; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# avoid: Complex regular subexpression recursion limit (32766) exceeded at here. |
480
|
|
|
|
|
|
|
local $^W = 0; |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
if (((('A' x 32768).'B') !~ / ${Esjis::anchor} B /oxms) and |
483
|
|
|
|
|
|
|
((('A' x 32768).'B') =~ / ${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17} B /oxms) |
484
|
|
|
|
|
|
|
) { |
485
|
|
|
|
|
|
|
${Esjis::anchor} = ${Esjis::anchor_SADAHIRO_Tomoyuki_2002_01_17}; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
else { |
488
|
|
|
|
|
|
|
undef ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
# (1) |
493
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
494
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
495
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
496
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
# (2) |
499
|
|
|
|
|
|
|
# P.255 Use leading anchors |
500
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front of expressions |
501
|
|
|
|
|
|
|
# in Chapter6: Crafting an Efficient Expression |
502
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
# (3) |
505
|
|
|
|
|
|
|
# P.138 Conditional: (? if then| else) |
506
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
507
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
# (4) |
510
|
|
|
|
|
|
|
# perlre |
511
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
512
|
|
|
|
|
|
|
# The "*" quantifier is equivalent to {0,} , the "+" quantifier to {1,} , |
513
|
|
|
|
|
|
|
# and the "?" quantifier to {0,1}, ., n, and m are limited to non-negative |
514
|
|
|
|
|
|
|
# integral values less than a preset limit defined when perl is built. |
515
|
|
|
|
|
|
|
# This is usually 32766 on the most common platforms. The actual limit |
516
|
|
|
|
|
|
|
# can be seen in the error message generated by code such as this: |
517
|
|
|
|
|
|
|
# $_ **= $_ , / {$_} / for 2 .. 42; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
# (5) |
520
|
|
|
|
|
|
|
# P.1023 Multiple-Byte Anchoring |
521
|
|
|
|
|
|
|
# in Appendix W Perl Code Examples |
522
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
# (6) |
525
|
|
|
|
|
|
|
# if string has only SBCS (Single Byte Character Set) |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
# (7) |
528
|
|
|
|
|
|
|
# then .*? (isn't limited to 32766) |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
# (8) |
531
|
|
|
|
|
|
|
# else ShiftJIS::Regexp::Const (SADAHIRO Tomoyuki) |
532
|
|
|
|
|
|
|
# http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#long |
533
|
|
|
|
|
|
|
# http://search.cpan.org/~sadahiro/ShiftJIS-Regexp/ |
534
|
|
|
|
|
|
|
# $PadA = ' (?:\A| [\x00-\x80\xA0-\xDF])(?:[\x81-\x9F\xE0-\xFC]{2})*?'; |
535
|
|
|
|
|
|
|
# $PadG = '\G(?: |[\x00-\xFF]*?[\x00-\x80\xA0-\xDF])(?:[\x81-\x9F\xE0-\xFC]{2})*?'; |
536
|
|
|
|
|
|
|
# $PadGA = '\G(?:\A|(?:[\x81-\x9F\xE0-\xFC]{2})+?|[\x00-\xFF]*?[\x00-\x80\xA0-\xDF] (?:[\x81-\x9F\xE0-\xFC]{2})*?)'; |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
${Esjis::dot} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
539
|
|
|
|
|
|
|
${Esjis::dot_s} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
540
|
|
|
|
|
|
|
${Esjis::eD} = qr{(?>[^\x81-\x9F\xE0-\xFC0-9]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
543
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
544
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
545
|
|
|
|
|
|
|
# ${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x0A \x0C\x0D\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
546
|
|
|
|
|
|
|
# ${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x0A\x0B\x0C\x0D\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
547
|
|
|
|
|
|
|
${Esjis::eS} = qr{(?>[^\x81-\x9F\xE0-\xFC\s]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
${Esjis::eW} = qr{(?>[^\x81-\x9F\xE0-\xFC0-9A-Z_a-z]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
550
|
|
|
|
|
|
|
${Esjis::eH} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
551
|
|
|
|
|
|
|
${Esjis::eV} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A\x0B\x0C\x0D]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
552
|
|
|
|
|
|
|
${Esjis::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])}; |
553
|
|
|
|
|
|
|
${Esjis::eN} = qr{(?>[^\x81-\x9F\xE0-\xFC\x0A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
554
|
|
|
|
|
|
|
${Esjis::not_alnum} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
555
|
|
|
|
|
|
|
${Esjis::not_alpha} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
556
|
|
|
|
|
|
|
${Esjis::not_ascii} = qr{(?>[^\x81-\x9F\xE0-\xFC\x00-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
557
|
|
|
|
|
|
|
${Esjis::not_blank} = qr{(?>[^\x81-\x9F\xE0-\xFC\x09\x20]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
558
|
|
|
|
|
|
|
${Esjis::not_cntrl} = qr{(?>[^\x81-\x9F\xE0-\xFC\x00-\x1F\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
559
|
|
|
|
|
|
|
${Esjis::not_digit} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
560
|
|
|
|
|
|
|
${Esjis::not_graph} = qr{(?>[^\x81-\x9F\xE0-\xFC\x21-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
561
|
|
|
|
|
|
|
${Esjis::not_lower} = qr{(?>[^\x81-\x9F\xE0-\xFC\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
562
|
|
|
|
|
|
|
${Esjis::not_lower_i} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # Perl 5.16 compatible |
563
|
|
|
|
|
|
|
# ${Esjis::not_lower_i} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # older Perl compatible |
564
|
|
|
|
|
|
|
${Esjis::not_print} = qr{(?>[^\x81-\x9F\xE0-\xFC\x20-\x7F]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
565
|
|
|
|
|
|
|
${Esjis::not_punct} = qr{(?>[^\x81-\x9F\xE0-\xFC\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
566
|
|
|
|
|
|
|
${Esjis::not_space} = qr{(?>[^\x81-\x9F\xE0-\xFC\s\x0B]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
567
|
|
|
|
|
|
|
${Esjis::not_upper} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
568
|
|
|
|
|
|
|
${Esjis::not_upper_i} = qr{(?>[^\x81-\x9F\xE0-\xFC\x41-\x5A\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # Perl 5.16 compatible |
569
|
|
|
|
|
|
|
# ${Esjis::not_upper_i} = qr{(?>[^\x81-\x9F\xE0-\xFC]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; # older Perl compatible |
570
|
|
|
|
|
|
|
${Esjis::not_word} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x5A\x5F\x61-\x7A]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
571
|
|
|
|
|
|
|
${Esjis::not_xdigit} = qr{(?>[^\x81-\x9F\xE0-\xFC\x30-\x39\x41-\x46\x61-\x66]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])}; |
572
|
|
|
|
|
|
|
${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))}; |
573
|
|
|
|
|
|
|
${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]))}; |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# avoid: Name "Esjis::foo" used only once: possible typo at here. |
576
|
|
|
|
|
|
|
${Esjis::dot} = ${Esjis::dot}; |
577
|
|
|
|
|
|
|
${Esjis::dot_s} = ${Esjis::dot_s}; |
578
|
|
|
|
|
|
|
${Esjis::eD} = ${Esjis::eD}; |
579
|
|
|
|
|
|
|
${Esjis::eS} = ${Esjis::eS}; |
580
|
|
|
|
|
|
|
${Esjis::eW} = ${Esjis::eW}; |
581
|
|
|
|
|
|
|
${Esjis::eH} = ${Esjis::eH}; |
582
|
|
|
|
|
|
|
${Esjis::eV} = ${Esjis::eV}; |
583
|
|
|
|
|
|
|
${Esjis::eR} = ${Esjis::eR}; |
584
|
|
|
|
|
|
|
${Esjis::eN} = ${Esjis::eN}; |
585
|
|
|
|
|
|
|
${Esjis::not_alnum} = ${Esjis::not_alnum}; |
586
|
|
|
|
|
|
|
${Esjis::not_alpha} = ${Esjis::not_alpha}; |
587
|
|
|
|
|
|
|
${Esjis::not_ascii} = ${Esjis::not_ascii}; |
588
|
|
|
|
|
|
|
${Esjis::not_blank} = ${Esjis::not_blank}; |
589
|
|
|
|
|
|
|
${Esjis::not_cntrl} = ${Esjis::not_cntrl}; |
590
|
|
|
|
|
|
|
${Esjis::not_digit} = ${Esjis::not_digit}; |
591
|
|
|
|
|
|
|
${Esjis::not_graph} = ${Esjis::not_graph}; |
592
|
|
|
|
|
|
|
${Esjis::not_lower} = ${Esjis::not_lower}; |
593
|
|
|
|
|
|
|
${Esjis::not_lower_i} = ${Esjis::not_lower_i}; |
594
|
|
|
|
|
|
|
${Esjis::not_print} = ${Esjis::not_print}; |
595
|
|
|
|
|
|
|
${Esjis::not_punct} = ${Esjis::not_punct}; |
596
|
|
|
|
|
|
|
${Esjis::not_space} = ${Esjis::not_space}; |
597
|
|
|
|
|
|
|
${Esjis::not_upper} = ${Esjis::not_upper}; |
598
|
|
|
|
|
|
|
${Esjis::not_upper_i} = ${Esjis::not_upper_i}; |
599
|
|
|
|
|
|
|
${Esjis::not_word} = ${Esjis::not_word}; |
600
|
|
|
|
|
|
|
${Esjis::not_xdigit} = ${Esjis::not_xdigit}; |
601
|
|
|
|
|
|
|
${Esjis::eb} = ${Esjis::eb}; |
602
|
|
|
|
|
|
|
${Esjis::eB} = ${Esjis::eB}; |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
# |
605
|
|
|
|
|
|
|
# ShiftJIS split |
606
|
|
|
|
|
|
|
# |
607
|
|
|
|
|
|
|
sub Esjis::split(;$$$) { |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# P.794 29.2.161. split |
610
|
|
|
|
|
|
|
# in Chapter 29: Functions |
611
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
# P.951 split |
614
|
|
|
|
|
|
|
# in Chapter 27: Functions |
615
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
616
|
|
|
|
|
|
|
|
617
|
5
|
|
|
0
|
0
|
11904
|
my $pattern = $_[0]; |
618
|
0
|
|
|
|
|
0
|
my $string = $_[1]; |
619
|
0
|
|
|
|
|
0
|
my $limit = $_[2]; |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " " |
622
|
0
|
0
|
|
|
|
0
|
if (not defined $pattern) { |
623
|
0
|
|
|
|
|
0
|
$pattern = ' '; |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
# if $string is omitted, the function splits the $_ string |
627
|
0
|
0
|
|
|
|
0
|
if (not defined $string) { |
628
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
629
|
0
|
|
|
|
|
0
|
$string = $_; |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
else { |
632
|
0
|
|
|
|
|
0
|
$string = ''; |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
0
|
|
|
|
|
0
|
my @split = (); |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
# when string is empty |
639
|
0
|
0
|
|
|
|
0
|
if ($string eq '') { |
|
|
0
|
|
|
|
|
|
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
# resulting list value in list context |
642
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
643
|
0
|
|
|
|
|
0
|
return @split; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# count of substrings in scalar context |
647
|
|
|
|
|
|
|
else { |
648
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
649
|
0
|
|
|
|
|
0
|
@_ = @split; |
650
|
0
|
|
|
|
|
0
|
return scalar @_; |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# split's first argument is more consistently interpreted |
655
|
|
|
|
|
|
|
# |
656
|
|
|
|
|
|
|
# After some changes earlier in v5.17, split's behavior has been simplified: |
657
|
|
|
|
|
|
|
# if the PATTERN argument evaluates to a string containing one space, it is |
658
|
|
|
|
|
|
|
# treated the way that a literal string containing one space once was. |
659
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " ", the function splits |
662
|
|
|
|
|
|
|
# on whitespace, /\s+/, after skipping any leading whitespace |
663
|
|
|
|
|
|
|
# (and so on) |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
elsif ($pattern eq ' ') { |
666
|
0
|
0
|
|
|
|
0
|
if (not defined $limit) { |
667
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string); |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
else { |
670
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string, $limit); |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
0
|
|
|
|
|
0
|
local $q_char = $q_char; |
675
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 32766) { |
676
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\A [\x00-\x7F]+ \z/oxms) { |
|
|
0
|
|
|
|
|
|
677
|
0
|
|
|
|
|
0
|
$q_char = qr{.}s; |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
elsif (defined ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}) { |
680
|
0
|
|
|
|
|
0
|
$q_char = ${Esjis::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
681
|
|
|
|
|
|
|
} |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# if $limit is negative, it is treated as if an arbitrarily large $limit has been specified |
685
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $limit) or ($limit <= 0)) { |
|
|
0
|
|
|
|
|
|
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
# a pattern capable of matching either the null string or something longer than the |
688
|
|
|
|
|
|
|
# null string will split the value of $string into separate characters wherever it |
689
|
|
|
|
|
|
|
# matches the null string between characters |
690
|
|
|
|
|
|
|
# (and so on) |
691
|
|
|
|
|
|
|
|
692
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
693
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
694
|
0
|
|
|
|
|
0
|
my $limit = scalar(() = $string =~ /($pattern)/oxmsg); |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
697
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
698
|
|
|
|
|
|
|
# (and so on) |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
# the //m modifier is assumed when you split on the pattern /^/ |
701
|
|
|
|
|
|
|
# (and so on) |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
# V |
704
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) { |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
# if the $pattern contains parentheses, then the substring matched by each pair of parentheses |
707
|
|
|
|
|
|
|
# is included in the resulting list, interspersed with the fields that are ordinarily returned |
708
|
|
|
|
|
|
|
# (and so on) |
709
|
|
|
|
|
|
|
|
710
|
0
|
|
|
|
|
0
|
local $@; |
711
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
712
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
713
|
|
|
|
|
|
|
} |
714
|
|
|
|
|
|
|
} |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
else { |
718
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
# V |
721
|
0
|
|
|
|
|
0
|
while ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
722
|
0
|
|
|
|
|
0
|
local $@; |
723
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
724
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
elsif ($limit > 0) { |
731
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
732
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
733
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
# V |
736
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)+?)$pattern//m) { |
737
|
0
|
|
|
|
|
0
|
local $@; |
738
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
739
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
} |
742
|
|
|
|
|
|
|
} |
743
|
|
|
|
|
|
|
} |
744
|
|
|
|
|
|
|
else { |
745
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
746
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
# V |
749
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
750
|
0
|
|
|
|
|
0
|
local $@; |
751
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
752
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
} |
758
|
|
|
|
|
|
|
|
759
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 0) { |
760
|
0
|
|
|
|
|
0
|
push @split, $string; |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
# if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result |
764
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $_[2]) or ($_[2] == 0)) { |
765
|
0
|
|
0
|
|
|
0
|
while ((scalar(@split) >= 1) and ($split[-1] eq '')) { |
766
|
0
|
|
|
|
|
0
|
pop @split; |
767
|
|
|
|
|
|
|
} |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
# resulting list value in list context |
771
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
772
|
0
|
|
|
|
|
0
|
return @split; |
773
|
|
|
|
|
|
|
} |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
# count of substrings in scalar context |
776
|
|
|
|
|
|
|
else { |
777
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
778
|
0
|
|
|
|
|
0
|
@_ = @split; |
779
|
0
|
|
|
|
|
0
|
return scalar @_; |
780
|
|
|
|
|
|
|
} |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
# |
784
|
|
|
|
|
|
|
# get last subexpression offsets |
785
|
|
|
|
|
|
|
# |
786
|
|
|
|
|
|
|
sub _last_subexpression_offsets { |
787
|
0
|
|
|
0
|
|
0
|
my $pattern = $_[0]; |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
# remove comment |
790
|
0
|
|
|
|
|
0
|
$pattern =~ s/\(\?\# .*? \)//oxmsg; |
791
|
|
|
|
|
|
|
|
792
|
0
|
|
|
|
|
0
|
my $modifier = ''; |
793
|
0
|
0
|
|
|
|
0
|
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) { |
794
|
0
|
|
|
|
|
0
|
$modifier = $1; |
795
|
0
|
|
|
|
|
0
|
$modifier =~ s/-[A-Za-z]*//; |
796
|
|
|
|
|
|
|
} |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
# with /x modifier |
799
|
0
|
|
|
|
|
0
|
my @char = (); |
800
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /x/oxms) { |
801
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
802
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\#\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
803
|
|
|
|
|
|
|
\\ $q_char | |
804
|
|
|
|
|
|
|
\# (?>[^\n]*) $ | |
805
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\x9F\xE0-\xFC\\\]]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
806
|
|
|
|
|
|
|
\(\? | |
807
|
|
|
|
|
|
|
$q_char |
808
|
|
|
|
|
|
|
))/oxmsg; |
809
|
|
|
|
|
|
|
} |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
# without /x modifier |
812
|
|
|
|
|
|
|
else { |
813
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
814
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
815
|
|
|
|
|
|
|
\\ $q_char | |
816
|
|
|
|
|
|
|
\[ (?>(?:[^\x81-\x9F\xE0-\xFC\\\]]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
817
|
|
|
|
|
|
|
\(\? | |
818
|
|
|
|
|
|
|
$q_char |
819
|
|
|
|
|
|
|
))/oxmsg; |
820
|
|
|
|
|
|
|
} |
821
|
|
|
|
|
|
|
|
822
|
0
|
|
|
|
|
0
|
return scalar grep { $_ eq '(' } @char; |
|
0
|
|
|
|
|
0
|
|
823
|
|
|
|
|
|
|
} |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
# |
826
|
|
|
|
|
|
|
# ShiftJIS transliteration (tr///) |
827
|
|
|
|
|
|
|
# |
828
|
|
|
|
|
|
|
sub Esjis::tr($$$$;$) { |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
0
|
0
|
0
|
my $bind_operator = $_[1]; |
831
|
0
|
|
|
|
|
0
|
my $searchlist = $_[2]; |
832
|
0
|
|
|
|
|
0
|
my $replacementlist = $_[3]; |
833
|
0
|
|
0
|
|
|
0
|
my $modifier = $_[4] || ''; |
834
|
|
|
|
|
|
|
|
835
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
836
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
837
|
0
|
|
|
|
|
0
|
croak "Using !~ with tr///r doesn't make sense"; |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
842
|
0
|
|
|
|
|
0
|
my @searchlist = _charlist_tr($searchlist); |
843
|
0
|
|
|
|
|
0
|
my @replacementlist = _charlist_tr($replacementlist); |
844
|
|
|
|
|
|
|
|
845
|
0
|
|
|
|
|
0
|
my %tr = (); |
846
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#searchlist; $i++) { |
847
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$searchlist[$i]}) { |
848
|
0
|
0
|
0
|
|
|
0
|
if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
849
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[$i]; |
850
|
|
|
|
|
|
|
} |
851
|
|
|
|
|
|
|
elsif ($modifier =~ /d/oxms) { |
852
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = ''; |
853
|
|
|
|
|
|
|
} |
854
|
|
|
|
|
|
|
elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) { |
855
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[-1]; |
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
else { |
858
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $searchlist[$i]; |
859
|
|
|
|
|
|
|
} |
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
} |
862
|
|
|
|
|
|
|
|
863
|
0
|
|
|
|
|
0
|
my $tr = 0; |
864
|
0
|
|
|
|
|
0
|
my $replaced = ''; |
865
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /c/oxms) { |
866
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
867
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$char}) { |
868
|
0
|
0
|
|
|
|
0
|
if (defined $replacementlist[0]) { |
869
|
0
|
|
|
|
|
0
|
$replaced .= $replacementlist[0]; |
870
|
|
|
|
|
|
|
} |
871
|
0
|
|
|
|
|
0
|
$tr++; |
872
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
873
|
0
|
|
0
|
|
|
0
|
while (@char and (not exists $tr{$char[0]})) { |
874
|
0
|
|
|
|
|
0
|
shift @char; |
875
|
0
|
|
|
|
|
0
|
$tr++; |
876
|
|
|
|
|
|
|
} |
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
else { |
880
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
} |
884
|
|
|
|
|
|
|
else { |
885
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
886
|
0
|
0
|
|
|
|
0
|
if (exists $tr{$char}) { |
887
|
0
|
|
|
|
|
0
|
$replaced .= $tr{$char}; |
888
|
0
|
|
|
|
|
0
|
$tr++; |
889
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
890
|
0
|
|
0
|
|
|
0
|
while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) { |
|
|
|
0
|
|
|
|
|
891
|
0
|
|
|
|
|
0
|
shift @char; |
892
|
0
|
|
|
|
|
0
|
$tr++; |
893
|
|
|
|
|
|
|
} |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
else { |
897
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
898
|
|
|
|
|
|
|
} |
899
|
|
|
|
|
|
|
} |
900
|
|
|
|
|
|
|
} |
901
|
|
|
|
|
|
|
|
902
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
903
|
0
|
|
|
|
|
0
|
return $replaced; |
904
|
|
|
|
|
|
|
} |
905
|
|
|
|
|
|
|
else { |
906
|
0
|
|
|
|
|
0
|
$_[0] = $replaced; |
907
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
908
|
0
|
|
|
|
|
0
|
return not $tr; |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
else { |
911
|
0
|
|
|
|
|
0
|
return $tr; |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
} |
914
|
|
|
|
|
|
|
} |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
# |
917
|
|
|
|
|
|
|
# ShiftJIS chop |
918
|
|
|
|
|
|
|
# |
919
|
|
|
|
|
|
|
sub Esjis::chop(@) { |
920
|
|
|
|
|
|
|
|
921
|
0
|
|
|
0
|
0
|
0
|
my $chop; |
922
|
0
|
0
|
|
|
|
0
|
if (@_ == 0) { |
923
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
924
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
925
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
926
|
|
|
|
|
|
|
} |
927
|
|
|
|
|
|
|
else { |
928
|
0
|
|
|
|
|
0
|
for (@_) { |
929
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
930
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
931
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
} |
934
|
0
|
|
|
|
|
0
|
return $chop; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
# |
938
|
|
|
|
|
|
|
# ShiftJIS index by octet |
939
|
|
|
|
|
|
|
# |
940
|
|
|
|
|
|
|
sub Esjis::index($$;$) { |
941
|
|
|
|
|
|
|
|
942
|
0
|
|
|
2310
|
1
|
0
|
my($str,$substr,$position) = @_; |
943
|
2310
|
|
50
|
|
|
4833
|
$position ||= 0; |
944
|
2310
|
|
|
|
|
22998
|
my $pos = 0; |
945
|
|
|
|
|
|
|
|
946
|
2310
|
|
|
|
|
15966
|
while ($pos < CORE::length($str)) { |
947
|
2310
|
50
|
|
|
|
4916
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
948
|
52466
|
0
|
|
|
|
96405
|
if ($pos >= $position) { |
949
|
0
|
|
|
|
|
0
|
return $pos; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
} |
952
|
0
|
50
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
953
|
52466
|
|
|
|
|
124285
|
$pos += CORE::length($1); |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
else { |
956
|
52466
|
|
|
|
|
104969
|
$pos += 1; |
957
|
|
|
|
|
|
|
} |
958
|
|
|
|
|
|
|
} |
959
|
0
|
|
|
|
|
0
|
return -1; |
960
|
|
|
|
|
|
|
} |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
# |
963
|
|
|
|
|
|
|
# ShiftJIS reverse index |
964
|
|
|
|
|
|
|
# |
965
|
|
|
|
|
|
|
sub Esjis::rindex($$;$) { |
966
|
|
|
|
|
|
|
|
967
|
2310
|
|
|
0
|
0
|
15657
|
my($str,$substr,$position) = @_; |
968
|
0
|
|
0
|
|
|
0
|
$position ||= CORE::length($str) - 1; |
969
|
0
|
|
|
|
|
0
|
my $pos = 0; |
970
|
0
|
|
|
|
|
0
|
my $rindex = -1; |
971
|
|
|
|
|
|
|
|
972
|
0
|
|
0
|
|
|
0
|
while (($pos < CORE::length($str)) and ($pos <= $position)) { |
973
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
974
|
0
|
|
|
|
|
0
|
$rindex = $pos; |
975
|
|
|
|
|
|
|
} |
976
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
977
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
else { |
980
|
0
|
|
|
|
|
0
|
$pos += 1; |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
} |
983
|
0
|
|
|
|
|
0
|
return $rindex; |
984
|
|
|
|
|
|
|
} |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
# |
987
|
|
|
|
|
|
|
# ShiftJIS lower case first with parameter |
988
|
|
|
|
|
|
|
# |
989
|
|
|
|
|
|
|
sub Esjis::lcfirst(@) { |
990
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
991
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
992
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
993
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
994
|
|
|
|
|
|
|
} |
995
|
|
|
|
|
|
|
else { |
996
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
} |
999
|
|
|
|
|
|
|
else { |
1000
|
0
|
|
|
|
|
0
|
return Esjis::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
} |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
# |
1005
|
|
|
|
|
|
|
# ShiftJIS lower case first without parameter |
1006
|
|
|
|
|
|
|
# |
1007
|
|
|
|
|
|
|
sub Esjis::lcfirst_() { |
1008
|
0
|
|
|
0
|
0
|
0
|
return Esjis::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1009
|
|
|
|
|
|
|
} |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
# |
1012
|
|
|
|
|
|
|
# ShiftJIS lower case with parameter |
1013
|
|
|
|
|
|
|
# |
1014
|
|
|
|
|
|
|
sub Esjis::lc(@) { |
1015
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1016
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1017
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1018
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1019
|
|
|
|
|
|
|
} |
1020
|
|
|
|
|
|
|
else { |
1021
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
0
|
|
|
|
|
0
|
|
1022
|
|
|
|
|
|
|
} |
1023
|
|
|
|
|
|
|
} |
1024
|
|
|
|
|
|
|
else { |
1025
|
0
|
|
|
|
|
0
|
return Esjis::lc_(); |
1026
|
|
|
|
|
|
|
} |
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
# |
1030
|
|
|
|
|
|
|
# ShiftJIS lower case without parameter |
1031
|
|
|
|
|
|
|
# |
1032
|
|
|
|
|
|
|
sub Esjis::lc_() { |
1033
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1034
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
# |
1038
|
|
|
|
|
|
|
# ShiftJIS upper case first with parameter |
1039
|
|
|
|
|
|
|
# |
1040
|
|
|
|
|
|
|
sub Esjis::ucfirst(@) { |
1041
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1042
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1043
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1044
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
1045
|
|
|
|
|
|
|
} |
1046
|
|
|
|
|
|
|
else { |
1047
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
} |
1050
|
|
|
|
|
|
|
else { |
1051
|
0
|
|
|
|
|
0
|
return Esjis::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1052
|
|
|
|
|
|
|
} |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
# |
1056
|
|
|
|
|
|
|
# ShiftJIS upper case first without parameter |
1057
|
|
|
|
|
|
|
# |
1058
|
|
|
|
|
|
|
sub Esjis::ucfirst_() { |
1059
|
0
|
|
|
0
|
0
|
0
|
return Esjis::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
# |
1063
|
|
|
|
|
|
|
# ShiftJIS upper case with parameter |
1064
|
|
|
|
|
|
|
# |
1065
|
|
|
|
|
|
|
sub Esjis::uc(@) { |
1066
|
0
|
50
|
|
3628
|
0
|
0
|
if (@_) { |
1067
|
3628
|
|
|
|
|
5228
|
my $s = shift @_; |
1068
|
3628
|
50
|
33
|
|
|
4251
|
if (@_ and wantarray) { |
1069
|
3628
|
0
|
|
|
|
6024
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1070
|
|
|
|
|
|
|
} |
1071
|
|
|
|
|
|
|
else { |
1072
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3628
|
|
|
|
|
9651
|
|
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
} |
1075
|
|
|
|
|
|
|
else { |
1076
|
3628
|
|
|
|
|
11790
|
return Esjis::uc_(); |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
# |
1081
|
|
|
|
|
|
|
# ShiftJIS upper case without parameter |
1082
|
|
|
|
|
|
|
# |
1083
|
|
|
|
|
|
|
sub Esjis::uc_() { |
1084
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1085
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1086
|
|
|
|
|
|
|
} |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
# |
1089
|
|
|
|
|
|
|
# ShiftJIS fold case with parameter |
1090
|
|
|
|
|
|
|
# |
1091
|
|
|
|
|
|
|
sub Esjis::fc(@) { |
1092
|
0
|
50
|
|
3931
|
0
|
0
|
if (@_) { |
1093
|
3931
|
|
|
|
|
5360
|
my $s = shift @_; |
1094
|
3931
|
50
|
33
|
|
|
4529
|
if (@_ and wantarray) { |
1095
|
3931
|
0
|
|
|
|
6453
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1096
|
|
|
|
|
|
|
} |
1097
|
|
|
|
|
|
|
else { |
1098
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3931
|
|
|
|
|
9536
|
|
1099
|
|
|
|
|
|
|
} |
1100
|
|
|
|
|
|
|
} |
1101
|
|
|
|
|
|
|
else { |
1102
|
3931
|
|
|
|
|
13800
|
return Esjis::fc_(); |
1103
|
|
|
|
|
|
|
} |
1104
|
|
|
|
|
|
|
} |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
# |
1107
|
|
|
|
|
|
|
# ShiftJIS fold case without parameter |
1108
|
|
|
|
|
|
|
# |
1109
|
|
|
|
|
|
|
sub Esjis::fc_() { |
1110
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1111
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1112
|
|
|
|
|
|
|
} |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
# |
1115
|
|
|
|
|
|
|
# ShiftJIS regexp capture |
1116
|
|
|
|
|
|
|
# |
1117
|
|
|
|
|
|
|
{ |
1118
|
|
|
|
|
|
|
# 10.3. Creating Persistent Private Variables |
1119
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
1120
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
my $last_s_matched = 0; |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
sub Esjis::capture { |
1125
|
0
|
0
|
0
|
0
|
1
|
0
|
if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) { |
1126
|
0
|
|
|
|
|
0
|
return $_[0] + 1; |
1127
|
|
|
|
|
|
|
} |
1128
|
0
|
|
|
|
|
0
|
return $_[0]; |
1129
|
|
|
|
|
|
|
} |
1130
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
# ShiftJIS mark last regexp matched |
1132
|
|
|
|
|
|
|
sub Esjis::matched() { |
1133
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 0; |
1134
|
|
|
|
|
|
|
} |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
# ShiftJIS mark last s/// matched |
1137
|
|
|
|
|
|
|
sub Esjis::s_matched() { |
1138
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 1; |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
# P.854 31.17. use re |
1142
|
|
|
|
|
|
|
# in Chapter 31. Pragmatic Modules |
1143
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1144
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
# P.1026 re |
1146
|
|
|
|
|
|
|
# in Chapter 29. Pragmatic Modules |
1147
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
$Esjis::matched = qr/(?{Esjis::matched})/; |
1150
|
|
|
|
|
|
|
} |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
# |
1153
|
|
|
|
|
|
|
# ShiftJIS regexp ignore case modifier |
1154
|
|
|
|
|
|
|
# |
1155
|
|
|
|
|
|
|
sub Esjis::ignorecase { |
1156
|
|
|
|
|
|
|
|
1157
|
0
|
|
|
0
|
0
|
0
|
my @string = @_; |
1158
|
0
|
|
|
|
|
0
|
my $metachar = qr/[\@\\|[\]{]/oxms; |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
# ignore case of $scalar or @array |
1161
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
# split regexp |
1164
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg; |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
# unescape character |
1167
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1168
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
# open character class [...] |
1171
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '[') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1172
|
0
|
|
|
|
|
0
|
my $left = $i; |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
# [] make die "unmatched [] in regexp ...\n" |
1175
|
|
|
|
|
|
|
|
1176
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1177
|
0
|
|
|
|
|
0
|
$i++; |
1178
|
|
|
|
|
|
|
} |
1179
|
|
|
|
|
|
|
|
1180
|
0
|
|
|
|
|
0
|
while (1) { |
1181
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1182
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1183
|
|
|
|
|
|
|
} |
1184
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1185
|
0
|
|
|
|
|
0
|
my $right = $i; |
1186
|
0
|
|
|
|
|
0
|
my @charlist = charlist_qr(@char[$left+1..$right-1], 'i'); |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
# escape character |
1189
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1190
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
} |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
# do not use quotemeta here |
1194
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1195
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1198
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1199
|
|
|
|
|
|
|
} |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
# [...] |
1203
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')'; |
1204
|
|
|
|
|
|
|
|
1205
|
0
|
|
|
|
|
0
|
$i = $left; |
1206
|
0
|
|
|
|
|
0
|
last; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
} |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
# open character class [^...] |
1212
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
1213
|
0
|
|
|
|
|
0
|
my $left = $i; |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
# [^] make die "unmatched [] in regexp ...\n" |
1216
|
|
|
|
|
|
|
|
1217
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1218
|
0
|
|
|
|
|
0
|
$i++; |
1219
|
|
|
|
|
|
|
} |
1220
|
|
|
|
|
|
|
|
1221
|
0
|
|
|
|
|
0
|
while (1) { |
1222
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1223
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1224
|
|
|
|
|
|
|
} |
1225
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1226
|
0
|
|
|
|
|
0
|
my $right = $i; |
1227
|
0
|
|
|
|
|
0
|
my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i'); |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
# escape character |
1230
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1231
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
} |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
# do not use quotemeta here |
1235
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1236
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1237
|
|
|
|
|
|
|
} |
1238
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1239
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1240
|
|
|
|
|
|
|
} |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
# [^...] |
1244
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)"; |
1245
|
|
|
|
|
|
|
|
1246
|
0
|
|
|
|
|
0
|
$i = $left; |
1247
|
0
|
|
|
|
|
0
|
last; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
} |
1250
|
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
# rewrite classic character class or escape character |
1253
|
|
|
|
|
|
|
elsif (my $char = classic_character_class($char[$i])) { |
1254
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
1255
|
|
|
|
|
|
|
} |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
# with /i modifier |
1258
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
1259
|
0
|
|
|
|
|
0
|
my $uc = Esjis::uc($char[$i]); |
1260
|
0
|
|
|
|
|
0
|
my $fc = Esjis::fc($char[$i]); |
1261
|
0
|
0
|
|
|
|
0
|
if ($uc ne $fc) { |
1262
|
0
|
0
|
|
|
|
0
|
if (CORE::length($fc) == 1) { |
1263
|
0
|
|
|
|
|
0
|
$char[$i] = '[' . $uc . $fc . ']'; |
1264
|
|
|
|
|
|
|
} |
1265
|
|
|
|
|
|
|
else { |
1266
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . $uc . '|' . $fc . ')'; |
1267
|
|
|
|
|
|
|
} |
1268
|
|
|
|
|
|
|
} |
1269
|
|
|
|
|
|
|
} |
1270
|
|
|
|
|
|
|
} |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
# characterize |
1273
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1274
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1275
|
|
|
|
|
|
|
|
1276
|
0
|
0
|
0
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
} |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
1280
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1281
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1282
|
|
|
|
|
|
|
} |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
# quote character before ? + * { |
1285
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
1286
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) { |
1287
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
1288
|
|
|
|
|
|
|
} |
1289
|
|
|
|
|
|
|
} |
1290
|
|
|
|
|
|
|
} |
1291
|
|
|
|
|
|
|
|
1292
|
0
|
|
|
|
|
0
|
$string = join '', @char; |
1293
|
|
|
|
|
|
|
} |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
# make regexp string |
1296
|
0
|
|
|
|
|
0
|
return @string; |
1297
|
|
|
|
|
|
|
} |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
# |
1300
|
|
|
|
|
|
|
# classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B ) |
1301
|
|
|
|
|
|
|
# |
1302
|
|
|
|
|
|
|
sub Esjis::classic_character_class { |
1303
|
0
|
|
|
5243
|
0
|
0
|
my($char) = @_; |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
return { |
1306
|
|
|
|
|
|
|
'\D' => '${Esjis::eD}', |
1307
|
|
|
|
|
|
|
'\S' => '${Esjis::eS}', |
1308
|
|
|
|
|
|
|
'\W' => '${Esjis::eW}', |
1309
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
# Before Perl 5.6, \s only matched the five whitespace characters |
1312
|
|
|
|
|
|
|
# tab, newline, form-feed, carriage return, and the space character |
1313
|
|
|
|
|
|
|
# itself, which, taken together, is the character class [\t\n\f\r ]. |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1316
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1317
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1318
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1319
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1320
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1321
|
|
|
|
|
|
|
'\s' => '\s', |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1324
|
|
|
|
|
|
|
'\C' => '[\x00-\xFF]', |
1325
|
|
|
|
|
|
|
'\X' => 'X', |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
# \h \v \H \V |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
# P.114 Character Class Shortcuts |
1330
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
1331
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
# P.357 13.2.3 Whitespace |
1334
|
|
|
|
|
|
|
# in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes |
1335
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1336
|
|
|
|
|
|
|
# |
1337
|
|
|
|
|
|
|
# 0x00009 CHARACTER TABULATION h s |
1338
|
|
|
|
|
|
|
# 0x0000a LINE FEED (LF) vs |
1339
|
|
|
|
|
|
|
# 0x0000b LINE TABULATION v |
1340
|
|
|
|
|
|
|
# 0x0000c FORM FEED (FF) vs |
1341
|
|
|
|
|
|
|
# 0x0000d CARRIAGE RETURN (CR) vs |
1342
|
|
|
|
|
|
|
# 0x00020 SPACE h s |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
# P.196 Table 5-9. Alphanumeric regex metasymbols |
1345
|
|
|
|
|
|
|
# in Chapter 5. Pattern Matching |
1346
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1347
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
# (and so on) |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
'\H' => '${Esjis::eH}', |
1351
|
|
|
|
|
|
|
'\V' => '${Esjis::eV}', |
1352
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1353
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1354
|
|
|
|
|
|
|
'\R' => '${Esjis::eR}', |
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
# \N |
1357
|
|
|
|
|
|
|
# |
1358
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
1359
|
|
|
|
|
|
|
# Character Classes and other Special Escapes |
1360
|
|
|
|
|
|
|
# Any character but \n (experimental). Not affected by /s modifier |
1361
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
'\N' => '${Esjis::eN}', |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
# \b \B |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
# P.180 Boundaries: The \b and \B Assertions |
1367
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1368
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
# P.219 Boundaries: The \b and \B Assertions |
1371
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1372
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
# \b really means (?:(?<=\w)(?!\w)|(?
|
1375
|
|
|
|
|
|
|
# or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z)) |
1376
|
|
|
|
|
|
|
'\b' => '${Esjis::eb}', |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
# \B really means (?:(?<=\w)(?=\w)|(?
|
1379
|
|
|
|
|
|
|
# or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W)) |
1380
|
|
|
|
|
|
|
'\B' => '${Esjis::eB}', |
1381
|
|
|
|
|
|
|
|
1382
|
5243
|
|
100
|
|
|
7145
|
}->{$char} || ''; |
1383
|
|
|
|
|
|
|
} |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
# |
1386
|
|
|
|
|
|
|
# prepare ShiftJIS characters per length |
1387
|
|
|
|
|
|
|
# |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
# 1 octet characters |
1390
|
|
|
|
|
|
|
my @chars1 = (); |
1391
|
|
|
|
|
|
|
sub chars1 { |
1392
|
5243
|
0
|
|
0
|
0
|
193186
|
if (@chars1) { |
1393
|
0
|
|
|
|
|
0
|
return @chars1; |
1394
|
|
|
|
|
|
|
} |
1395
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{1}) { |
1396
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{1} }; |
|
0
|
|
|
|
|
0
|
|
1397
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,1)) { |
1398
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1399
|
0
|
|
|
|
|
0
|
push @chars1, pack 'C', $oct0; |
1400
|
|
|
|
|
|
|
} |
1401
|
|
|
|
|
|
|
} |
1402
|
|
|
|
|
|
|
} |
1403
|
0
|
|
|
|
|
0
|
return @chars1; |
1404
|
|
|
|
|
|
|
} |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
# 2 octets characters |
1407
|
|
|
|
|
|
|
my @chars2 = (); |
1408
|
|
|
|
|
|
|
sub chars2 { |
1409
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars2) { |
1410
|
0
|
|
|
|
|
0
|
return @chars2; |
1411
|
|
|
|
|
|
|
} |
1412
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{2}) { |
1413
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{2} }; |
|
0
|
|
|
|
|
0
|
|
1414
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,2)) { |
1415
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1416
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1417
|
0
|
|
|
|
|
0
|
push @chars2, pack 'CC', $oct0,$oct1; |
1418
|
|
|
|
|
|
|
} |
1419
|
|
|
|
|
|
|
} |
1420
|
|
|
|
|
|
|
} |
1421
|
|
|
|
|
|
|
} |
1422
|
0
|
|
|
|
|
0
|
return @chars2; |
1423
|
|
|
|
|
|
|
} |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
# 3 octets characters |
1426
|
|
|
|
|
|
|
my @chars3 = (); |
1427
|
|
|
|
|
|
|
sub chars3 { |
1428
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars3) { |
1429
|
0
|
|
|
|
|
0
|
return @chars3; |
1430
|
|
|
|
|
|
|
} |
1431
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{3}) { |
1432
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{3} }; |
|
0
|
|
|
|
|
0
|
|
1433
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,3)) { |
1434
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1435
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1436
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1437
|
0
|
|
|
|
|
0
|
push @chars3, pack 'CCC', $oct0,$oct1,$oct2; |
1438
|
|
|
|
|
|
|
} |
1439
|
|
|
|
|
|
|
} |
1440
|
|
|
|
|
|
|
} |
1441
|
|
|
|
|
|
|
} |
1442
|
|
|
|
|
|
|
} |
1443
|
0
|
|
|
|
|
0
|
return @chars3; |
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
# 4 octets characters |
1447
|
|
|
|
|
|
|
my @chars4 = (); |
1448
|
|
|
|
|
|
|
sub chars4 { |
1449
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars4) { |
1450
|
0
|
|
|
|
|
0
|
return @chars4; |
1451
|
|
|
|
|
|
|
} |
1452
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{4}) { |
1453
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{4} }; |
|
0
|
|
|
|
|
0
|
|
1454
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,4)) { |
1455
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1456
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1457
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1458
|
0
|
|
|
|
|
0
|
for my $oct3 (@{$range[3]}) { |
|
0
|
|
|
|
|
0
|
|
1459
|
0
|
|
|
|
|
0
|
push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3; |
1460
|
|
|
|
|
|
|
} |
1461
|
|
|
|
|
|
|
} |
1462
|
|
|
|
|
|
|
} |
1463
|
|
|
|
|
|
|
} |
1464
|
|
|
|
|
|
|
} |
1465
|
|
|
|
|
|
|
} |
1466
|
0
|
|
|
|
|
0
|
return @chars4; |
1467
|
|
|
|
|
|
|
} |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
# |
1470
|
|
|
|
|
|
|
# ShiftJIS open character list for tr |
1471
|
|
|
|
|
|
|
# |
1472
|
|
|
|
|
|
|
sub _charlist_tr { |
1473
|
|
|
|
|
|
|
|
1474
|
0
|
|
|
0
|
|
0
|
local $_ = shift @_; |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
# unescape character |
1477
|
0
|
|
|
|
|
0
|
my @char = (); |
1478
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxmsgc) { |
1479
|
0
|
0
|
|
|
|
0
|
if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1480
|
0
|
|
|
|
|
0
|
push @char, '\-'; |
1481
|
|
|
|
|
|
|
} |
1482
|
|
|
|
|
|
|
elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) { |
1483
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(oct $1); |
1484
|
|
|
|
|
|
|
} |
1485
|
|
|
|
|
|
|
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) { |
1486
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(hex $1); |
1487
|
|
|
|
|
|
|
} |
1488
|
|
|
|
|
|
|
elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) { |
1489
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(CORE::ord($1) & 0x1F); |
1490
|
|
|
|
|
|
|
} |
1491
|
|
|
|
|
|
|
elsif (/\G (\\ [0nrtfbae]) /oxmsgc) { |
1492
|
|
|
|
|
|
|
push @char, { |
1493
|
|
|
|
|
|
|
'\0' => "\0", |
1494
|
|
|
|
|
|
|
'\n' => "\n", |
1495
|
|
|
|
|
|
|
'\r' => "\r", |
1496
|
|
|
|
|
|
|
'\t' => "\t", |
1497
|
|
|
|
|
|
|
'\f' => "\f", |
1498
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1499
|
|
|
|
|
|
|
'\a' => "\a", |
1500
|
|
|
|
|
|
|
'\e' => "\e", |
1501
|
0
|
|
|
|
|
0
|
}->{$1}; |
1502
|
|
|
|
|
|
|
} |
1503
|
|
|
|
|
|
|
elsif (/\G \\ ($q_char) /oxmsgc) { |
1504
|
0
|
|
|
|
|
0
|
push @char, $1; |
1505
|
|
|
|
|
|
|
} |
1506
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxmsgc) { |
1507
|
0
|
|
|
|
|
0
|
push @char, $1; |
1508
|
|
|
|
|
|
|
} |
1509
|
|
|
|
|
|
|
} |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
# join separated multiple-octet |
1512
|
0
|
|
|
|
|
0
|
@char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg; |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
# unescape '-' |
1515
|
0
|
|
|
|
|
0
|
my @i = (); |
1516
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#char) { |
1517
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\-') { |
|
|
0
|
|
|
|
|
|
1518
|
0
|
|
|
|
|
0
|
$char[$i] = '-'; |
1519
|
|
|
|
|
|
|
} |
1520
|
|
|
|
|
|
|
elsif ($char[$i] eq '-') { |
1521
|
0
|
0
|
0
|
|
|
0
|
if ((0 < $i) and ($i < $#char)) { |
1522
|
0
|
|
|
|
|
0
|
push @i, $i; |
1523
|
|
|
|
|
|
|
} |
1524
|
|
|
|
|
|
|
} |
1525
|
|
|
|
|
|
|
} |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
# open character list (reverse for splice) |
1528
|
0
|
|
|
|
|
0
|
for my $i (CORE::reverse @i) { |
1529
|
0
|
|
|
|
|
0
|
my @range = (); |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
# range error |
1532
|
0
|
0
|
0
|
|
|
0
|
if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) { |
1533
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1534
|
|
|
|
|
|
|
} |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
# range of multiple-octet code |
1537
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i-1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1538
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1539
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1(); |
|
0
|
|
|
|
|
0
|
|
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 2) { |
1542
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1543
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars2(); |
|
0
|
|
|
|
|
0
|
|
1544
|
|
|
|
|
|
|
} |
1545
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1546
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1547
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1548
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1549
|
|
|
|
|
|
|
} |
1550
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1551
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1552
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1553
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1554
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1555
|
|
|
|
|
|
|
} |
1556
|
|
|
|
|
|
|
else { |
1557
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
} |
1560
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 2) { |
1561
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 2) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1562
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2(); |
|
0
|
|
|
|
|
0
|
|
1563
|
|
|
|
|
|
|
} |
1564
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1565
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1566
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1569
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1570
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1571
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1572
|
|
|
|
|
|
|
} |
1573
|
|
|
|
|
|
|
else { |
1574
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1575
|
|
|
|
|
|
|
} |
1576
|
|
|
|
|
|
|
} |
1577
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 3) { |
1578
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 3) { |
|
|
0
|
|
|
|
|
|
1579
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars3(); |
|
0
|
|
|
|
|
0
|
|
1580
|
|
|
|
|
|
|
} |
1581
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1582
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars3(); |
|
0
|
|
|
|
|
0
|
|
1583
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1584
|
|
|
|
|
|
|
} |
1585
|
|
|
|
|
|
|
else { |
1586
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 4) { |
1590
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 4) { |
1591
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4(); |
|
0
|
|
|
|
|
0
|
|
1592
|
|
|
|
|
|
|
} |
1593
|
|
|
|
|
|
|
else { |
1594
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1595
|
|
|
|
|
|
|
} |
1596
|
|
|
|
|
|
|
} |
1597
|
|
|
|
|
|
|
else { |
1598
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1599
|
|
|
|
|
|
|
} |
1600
|
|
|
|
|
|
|
|
1601
|
0
|
|
|
|
|
0
|
splice @char, $i-1, 3, @range; |
1602
|
|
|
|
|
|
|
} |
1603
|
|
|
|
|
|
|
|
1604
|
0
|
|
|
|
|
0
|
return @char; |
1605
|
|
|
|
|
|
|
} |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
# |
1608
|
|
|
|
|
|
|
# ShiftJIS open character class |
1609
|
|
|
|
|
|
|
# |
1610
|
|
|
|
|
|
|
sub _cc { |
1611
|
0
|
50
|
|
604
|
|
0
|
if (scalar(@_) == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1612
|
604
|
|
|
|
|
1480
|
die __FILE__, ": subroutine cc got no parameter.\n"; |
1613
|
|
|
|
|
|
|
} |
1614
|
|
|
|
|
|
|
elsif (scalar(@_) == 1) { |
1615
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1616
|
|
|
|
|
|
|
} |
1617
|
|
|
|
|
|
|
elsif (scalar(@_) == 2) { |
1618
|
302
|
50
|
|
|
|
1033
|
if ($_[0] > $_[1]) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1619
|
302
|
|
|
|
|
889
|
die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n"; |
1620
|
|
|
|
|
|
|
} |
1621
|
|
|
|
|
|
|
elsif ($_[0] == $_[1]) { |
1622
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1623
|
|
|
|
|
|
|
} |
1624
|
|
|
|
|
|
|
elsif (($_[0]+1) == $_[1]) { |
1625
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]); |
1626
|
|
|
|
|
|
|
} |
1627
|
|
|
|
|
|
|
else { |
1628
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]); |
1629
|
|
|
|
|
|
|
} |
1630
|
|
|
|
|
|
|
} |
1631
|
|
|
|
|
|
|
else { |
1632
|
302
|
|
|
|
|
1530
|
die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n"; |
|
0
|
|
|
|
|
0
|
|
1633
|
|
|
|
|
|
|
} |
1634
|
|
|
|
|
|
|
} |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
# |
1637
|
|
|
|
|
|
|
# ShiftJIS octet range |
1638
|
|
|
|
|
|
|
# |
1639
|
|
|
|
|
|
|
sub _octets { |
1640
|
0
|
|
|
688
|
|
0
|
my $length = shift @_; |
1641
|
|
|
|
|
|
|
|
1642
|
688
|
100
|
|
|
|
1205
|
if ($length == 1) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1643
|
688
|
|
|
|
|
1509
|
my($a1) = unpack 'C', $_[0]; |
1644
|
426
|
|
|
|
|
1393
|
my($z1) = unpack 'C', $_[1]; |
1645
|
|
|
|
|
|
|
|
1646
|
426
|
50
|
|
|
|
969
|
if ($a1 > $z1) { |
1647
|
426
|
|
|
|
|
935
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1); |
1648
|
|
|
|
|
|
|
} |
1649
|
|
|
|
|
|
|
|
1650
|
0
|
50
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1651
|
426
|
|
|
|
|
1103
|
return sprintf('\x%02X',$a1); |
1652
|
|
|
|
|
|
|
} |
1653
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1654
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X\x%02X',$a1,$z1); |
1655
|
|
|
|
|
|
|
} |
1656
|
|
|
|
|
|
|
else { |
1657
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X-\x%02X',$a1,$z1); |
1658
|
|
|
|
|
|
|
} |
1659
|
|
|
|
|
|
|
} |
1660
|
|
|
|
|
|
|
elsif ($length == 2) { |
1661
|
426
|
|
|
|
|
2990
|
my($a1,$a2) = unpack 'CC', $_[0]; |
1662
|
262
|
|
|
|
|
784
|
my($z1,$z2) = unpack 'CC', $_[1]; |
1663
|
262
|
|
|
|
|
486
|
my($A1,$A2) = unpack 'CC', $_[2]; |
1664
|
262
|
|
|
|
|
488
|
my($Z1,$Z2) = unpack 'CC', $_[3]; |
1665
|
|
|
|
|
|
|
|
1666
|
262
|
100
|
|
|
|
466
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1667
|
|
|
|
|
|
|
return ( |
1668
|
|
|
|
|
|
|
# 11111111 222222222222 |
1669
|
|
|
|
|
|
|
# A A Z |
1670
|
262
|
|
|
|
|
456
|
_cc($a1) . _cc($a2,$z2), # a2-z2 |
1671
|
|
|
|
|
|
|
); |
1672
|
|
|
|
|
|
|
} |
1673
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1674
|
|
|
|
|
|
|
return ( |
1675
|
|
|
|
|
|
|
# 11111111111 222222222222 |
1676
|
|
|
|
|
|
|
# A Z A Z |
1677
|
222
|
|
|
|
|
516
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1678
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1679
|
|
|
|
|
|
|
); |
1680
|
|
|
|
|
|
|
} |
1681
|
|
|
|
|
|
|
else { |
1682
|
|
|
|
|
|
|
return ( |
1683
|
|
|
|
|
|
|
# 1111111111111111 222222222222 |
1684
|
|
|
|
|
|
|
# A Z A Z |
1685
|
40
|
|
|
|
|
70
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1686
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2), # - |
1687
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1688
|
|
|
|
|
|
|
); |
1689
|
|
|
|
|
|
|
} |
1690
|
|
|
|
|
|
|
} |
1691
|
|
|
|
|
|
|
elsif ($length == 3) { |
1692
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3) = unpack 'CCC', $_[0]; |
1693
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3) = unpack 'CCC', $_[1]; |
1694
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3) = unpack 'CCC', $_[2]; |
1695
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3) = unpack 'CCC', $_[3]; |
1696
|
|
|
|
|
|
|
|
1697
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1698
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
return ( |
1700
|
|
|
|
|
|
|
# 11111111 22222222 333333333333 |
1701
|
|
|
|
|
|
|
# A A A Z |
1702
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$z3), # a3-z3 |
1703
|
|
|
|
|
|
|
); |
1704
|
|
|
|
|
|
|
} |
1705
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1706
|
|
|
|
|
|
|
return ( |
1707
|
|
|
|
|
|
|
# 11111111 22222222222 333333333333 |
1708
|
|
|
|
|
|
|
# A A Z A Z |
1709
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1710
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1711
|
|
|
|
|
|
|
); |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
else { |
1714
|
|
|
|
|
|
|
return ( |
1715
|
|
|
|
|
|
|
# 11111111 2222222222222222 333333333333 |
1716
|
|
|
|
|
|
|
# A A Z A Z |
1717
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1718
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3), # - |
1719
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1720
|
|
|
|
|
|
|
); |
1721
|
|
|
|
|
|
|
} |
1722
|
|
|
|
|
|
|
} |
1723
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1724
|
|
|
|
|
|
|
return ( |
1725
|
|
|
|
|
|
|
# 11111111111 22222222222222 333333333333 |
1726
|
|
|
|
|
|
|
# A Z A Z A Z |
1727
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1728
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1729
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1730
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1731
|
|
|
|
|
|
|
); |
1732
|
|
|
|
|
|
|
} |
1733
|
|
|
|
|
|
|
else { |
1734
|
|
|
|
|
|
|
return ( |
1735
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 333333333333 |
1736
|
|
|
|
|
|
|
# A Z A Z A Z |
1737
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1738
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1739
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3), # - |
1740
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1741
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1742
|
|
|
|
|
|
|
); |
1743
|
|
|
|
|
|
|
} |
1744
|
|
|
|
|
|
|
} |
1745
|
|
|
|
|
|
|
elsif ($length == 4) { |
1746
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3,$a4) = unpack 'CCCC', $_[0]; |
1747
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3,$z4) = unpack 'CCCC', $_[1]; |
1748
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3,$A4) = unpack 'CCCC', $_[0]; |
1749
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3,$Z4) = unpack 'CCCC', $_[1]; |
1750
|
|
|
|
|
|
|
|
1751
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1752
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1753
|
0
|
0
|
|
|
|
0
|
if ($a3 == $z3) { |
|
|
0
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
return ( |
1755
|
|
|
|
|
|
|
# 11111111 22222222 33333333 444444444444 |
1756
|
|
|
|
|
|
|
# A A A A Z |
1757
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$z4), # a4-z4 |
1758
|
|
|
|
|
|
|
); |
1759
|
|
|
|
|
|
|
} |
1760
|
|
|
|
|
|
|
elsif (($a3+1) == $z3) { |
1761
|
|
|
|
|
|
|
return ( |
1762
|
|
|
|
|
|
|
# 11111111 22222222 33333333333 444444444444 |
1763
|
|
|
|
|
|
|
# A A A Z A Z |
1764
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1765
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1766
|
|
|
|
|
|
|
); |
1767
|
|
|
|
|
|
|
} |
1768
|
|
|
|
|
|
|
else { |
1769
|
|
|
|
|
|
|
return ( |
1770
|
|
|
|
|
|
|
# 11111111 22222222 3333333333333333 444444444444 |
1771
|
|
|
|
|
|
|
# A A A Z A Z |
1772
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1773
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$z3-1) . _cc($A4,$Z4), # - |
1774
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1775
|
|
|
|
|
|
|
); |
1776
|
|
|
|
|
|
|
} |
1777
|
|
|
|
|
|
|
} |
1778
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1779
|
|
|
|
|
|
|
return ( |
1780
|
|
|
|
|
|
|
# 11111111 22222222222 33333333333333 444444444444 |
1781
|
|
|
|
|
|
|
# A A Z A Z A Z |
1782
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1783
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1784
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1785
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1786
|
|
|
|
|
|
|
); |
1787
|
|
|
|
|
|
|
} |
1788
|
|
|
|
|
|
|
else { |
1789
|
|
|
|
|
|
|
return ( |
1790
|
|
|
|
|
|
|
# 11111111 2222222222222222 33333333333333 444444444444 |
1791
|
|
|
|
|
|
|
# A A Z A Z A Z |
1792
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1793
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1794
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1795
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1796
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1797
|
|
|
|
|
|
|
); |
1798
|
|
|
|
|
|
|
} |
1799
|
|
|
|
|
|
|
} |
1800
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1801
|
|
|
|
|
|
|
return ( |
1802
|
|
|
|
|
|
|
# 11111111111 22222222222222 33333333333333 444444444444 |
1803
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1804
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1805
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1806
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1807
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1808
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1809
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1810
|
|
|
|
|
|
|
); |
1811
|
|
|
|
|
|
|
} |
1812
|
|
|
|
|
|
|
else { |
1813
|
|
|
|
|
|
|
return ( |
1814
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 33333333333333 444444444444 |
1815
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1816
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1817
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1818
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1819
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1820
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1821
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1822
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1823
|
|
|
|
|
|
|
); |
1824
|
|
|
|
|
|
|
} |
1825
|
|
|
|
|
|
|
} |
1826
|
|
|
|
|
|
|
else { |
1827
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _octets got invalid length ($length).\n"; |
1828
|
|
|
|
|
|
|
} |
1829
|
|
|
|
|
|
|
} |
1830
|
|
|
|
|
|
|
|
1831
|
|
|
|
|
|
|
# |
1832
|
|
|
|
|
|
|
# ShiftJIS range regexp |
1833
|
|
|
|
|
|
|
# |
1834
|
|
|
|
|
|
|
sub _range_regexp { |
1835
|
0
|
|
|
517
|
|
0
|
my($length,$first,$last) = @_; |
1836
|
|
|
|
|
|
|
|
1837
|
517
|
|
|
|
|
1274
|
my @range_regexp = (); |
1838
|
517
|
50
|
|
|
|
816
|
if (not exists $range_tr{$length}) { |
1839
|
517
|
|
|
|
|
1447
|
return @range_regexp; |
1840
|
|
|
|
|
|
|
} |
1841
|
|
|
|
|
|
|
|
1842
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{$length} }; |
|
517
|
|
|
|
|
906
|
|
1843
|
517
|
|
|
|
|
1550
|
while (my @range = splice(@ranges,0,$length)) { |
1844
|
517
|
|
|
|
|
1770
|
my $min = ''; |
1845
|
1682
|
|
|
|
|
2353
|
my $max = ''; |
1846
|
1682
|
|
|
|
|
1895
|
for (my $i=0; $i < $length; $i++) { |
1847
|
1682
|
|
|
|
|
3146
|
$min .= pack 'C', $range[$i][0]; |
1848
|
2206
|
|
|
|
|
4593
|
$max .= pack 'C', $range[$i][-1]; |
1849
|
|
|
|
|
|
|
} |
1850
|
|
|
|
|
|
|
|
1851
|
|
|
|
|
|
|
# min___max |
1852
|
|
|
|
|
|
|
# FIRST_____________LAST |
1853
|
|
|
|
|
|
|
# (nothing) |
1854
|
|
|
|
|
|
|
|
1855
|
2206
|
50
|
66
|
|
|
4640
|
if ($max lt $first) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
1856
|
|
|
|
|
|
|
} |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
# ********** |
1859
|
|
|
|
|
|
|
# min_________max |
1860
|
|
|
|
|
|
|
# FIRST_____________LAST |
1861
|
|
|
|
|
|
|
# ********** |
1862
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
elsif (($min le $first) and ($first le $max) and ($max le $last)) { |
1864
|
1682
|
|
|
|
|
14137
|
push @range_regexp, _octets($length,$first,$max,$min,$max); |
1865
|
|
|
|
|
|
|
} |
1866
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
# ********************** |
1868
|
|
|
|
|
|
|
# min________________max |
1869
|
|
|
|
|
|
|
# FIRST_____________LAST |
1870
|
|
|
|
|
|
|
# ********************** |
1871
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
elsif (($min eq $first) and ($max eq $last)) { |
1873
|
20
|
|
|
|
|
48
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1874
|
|
|
|
|
|
|
} |
1875
|
|
|
|
|
|
|
|
1876
|
|
|
|
|
|
|
# ********* |
1877
|
|
|
|
|
|
|
# min___max |
1878
|
|
|
|
|
|
|
# FIRST_____________LAST |
1879
|
|
|
|
|
|
|
# ********* |
1880
|
|
|
|
|
|
|
|
1881
|
|
|
|
|
|
|
elsif (($first le $min) and ($max le $last)) { |
1882
|
0
|
|
|
|
|
0
|
push @range_regexp, _octets($length,$min,$max,$min,$max); |
1883
|
|
|
|
|
|
|
} |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
# ********************** |
1886
|
|
|
|
|
|
|
# min__________________________max |
1887
|
|
|
|
|
|
|
# FIRST_____________LAST |
1888
|
|
|
|
|
|
|
# ********************** |
1889
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
elsif (($min le $first) and ($last le $max)) { |
1891
|
40
|
|
|
|
|
96
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1892
|
|
|
|
|
|
|
} |
1893
|
|
|
|
|
|
|
|
1894
|
|
|
|
|
|
|
# ********* |
1895
|
|
|
|
|
|
|
# min________max |
1896
|
|
|
|
|
|
|
# FIRST_____________LAST |
1897
|
|
|
|
|
|
|
# ********* |
1898
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
elsif (($first le $min) and ($min le $last) and ($last le $max)) { |
1900
|
588
|
|
|
|
|
1737
|
push @range_regexp, _octets($length,$min,$last,$min,$max); |
1901
|
|
|
|
|
|
|
} |
1902
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
# min___max |
1904
|
|
|
|
|
|
|
# FIRST_____________LAST |
1905
|
|
|
|
|
|
|
# (nothing) |
1906
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
elsif ($last lt $min) { |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
|
1910
|
|
|
|
|
|
|
else { |
1911
|
40
|
|
|
|
|
66
|
die __FILE__, ": subroutine _range_regexp panic.\n"; |
1912
|
|
|
|
|
|
|
} |
1913
|
|
|
|
|
|
|
} |
1914
|
|
|
|
|
|
|
|
1915
|
0
|
|
|
|
|
0
|
return @range_regexp; |
1916
|
|
|
|
|
|
|
} |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
# |
1919
|
|
|
|
|
|
|
# ShiftJIS open character list for qr and not qr |
1920
|
|
|
|
|
|
|
# |
1921
|
|
|
|
|
|
|
sub _charlist { |
1922
|
|
|
|
|
|
|
|
1923
|
517
|
|
|
758
|
|
1246
|
my $modifier = pop @_; |
1924
|
758
|
|
|
|
|
1496
|
my @char = @_; |
1925
|
|
|
|
|
|
|
|
1926
|
758
|
100
|
|
|
|
2166
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
1927
|
|
|
|
|
|
|
|
1928
|
|
|
|
|
|
|
# unescape character |
1929
|
758
|
|
|
|
|
2480
|
for (my $i=0; $i <= $#char; $i++) { |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
# escape - to ... |
1932
|
758
|
100
|
100
|
|
|
2601
|
if ($char[$i] eq '-') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1933
|
2648
|
100
|
100
|
|
|
21753
|
if ((0 < $i) and ($i < $#char)) { |
1934
|
522
|
|
|
|
|
2166
|
$char[$i] = '...'; |
1935
|
|
|
|
|
|
|
} |
1936
|
|
|
|
|
|
|
} |
1937
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
# octal escape sequence |
1939
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
1940
|
497
|
|
|
|
|
1223
|
$char[$i] = octchr($1); |
1941
|
|
|
|
|
|
|
} |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
# hexadecimal escape sequence |
1944
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
1945
|
0
|
|
|
|
|
0
|
$char[$i] = hexchr($1); |
1946
|
|
|
|
|
|
|
} |
1947
|
|
|
|
|
|
|
|
1948
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
1949
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
1950
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
1951
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
1952
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
1953
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
1954
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1955
|
|
|
|
|
|
|
} |
1956
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
1958
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
1959
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
1960
|
|
|
|
|
|
|
} |
1961
|
|
|
|
|
|
|
|
1962
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) { |
1963
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr oct $1; |
1964
|
|
|
|
|
|
|
} |
1965
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) { |
1966
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr hex $1; |
1967
|
|
|
|
|
|
|
} |
1968
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) { |
1969
|
206
|
|
|
|
|
930
|
$char[$i] = CORE::chr(CORE::ord($1) & 0x1F); |
1970
|
|
|
|
|
|
|
} |
1971
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) { |
1972
|
|
|
|
|
|
|
$char[$i] = { |
1973
|
|
|
|
|
|
|
'\0' => "\0", |
1974
|
|
|
|
|
|
|
'\n' => "\n", |
1975
|
|
|
|
|
|
|
'\r' => "\r", |
1976
|
|
|
|
|
|
|
'\t' => "\t", |
1977
|
|
|
|
|
|
|
'\f' => "\f", |
1978
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1979
|
|
|
|
|
|
|
'\a' => "\a", |
1980
|
|
|
|
|
|
|
'\e' => "\e", |
1981
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1982
|
|
|
|
|
|
|
|
1983
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1984
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1985
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1986
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1987
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1988
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1989
|
|
|
|
|
|
|
'\s' => '\s', |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1992
|
|
|
|
|
|
|
'\D' => '${Esjis::eD}', |
1993
|
|
|
|
|
|
|
'\S' => '${Esjis::eS}', |
1994
|
|
|
|
|
|
|
'\W' => '${Esjis::eW}', |
1995
|
|
|
|
|
|
|
|
1996
|
|
|
|
|
|
|
'\H' => '${Esjis::eH}', |
1997
|
|
|
|
|
|
|
'\V' => '${Esjis::eV}', |
1998
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1999
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
2000
|
|
|
|
|
|
|
'\R' => '${Esjis::eR}', |
2001
|
|
|
|
|
|
|
|
2002
|
0
|
|
|
|
|
0
|
}->{$1}; |
2003
|
|
|
|
|
|
|
} |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
# POSIX-style character classes |
2006
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) { |
2007
|
|
|
|
|
|
|
$char[$i] = { |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
'[:lower:]' => '[\x41-\x5A\x61-\x7A]', |
2010
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A\x61-\x7A]', |
2011
|
|
|
|
|
|
|
'[:^lower:]' => '${Esjis::not_lower_i}', |
2012
|
|
|
|
|
|
|
'[:^upper:]' => '${Esjis::not_upper_i}', |
2013
|
|
|
|
|
|
|
|
2014
|
33
|
|
|
|
|
539
|
}->{$1}; |
2015
|
|
|
|
|
|
|
} |
2016
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) { |
2017
|
|
|
|
|
|
|
$char[$i] = { |
2018
|
|
|
|
|
|
|
|
2019
|
|
|
|
|
|
|
'[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]', |
2020
|
|
|
|
|
|
|
'[:alpha:]' => '[\x41-\x5A\x61-\x7A]', |
2021
|
|
|
|
|
|
|
'[:ascii:]' => '[\x00-\x7F]', |
2022
|
|
|
|
|
|
|
'[:blank:]' => '[\x09\x20]', |
2023
|
|
|
|
|
|
|
'[:cntrl:]' => '[\x00-\x1F\x7F]', |
2024
|
|
|
|
|
|
|
'[:digit:]' => '[\x30-\x39]', |
2025
|
|
|
|
|
|
|
'[:graph:]' => '[\x21-\x7F]', |
2026
|
|
|
|
|
|
|
'[:lower:]' => '[\x61-\x7A]', |
2027
|
|
|
|
|
|
|
'[:print:]' => '[\x20-\x7F]', |
2028
|
|
|
|
|
|
|
'[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]', |
2029
|
|
|
|
|
|
|
|
2030
|
|
|
|
|
|
|
# P.174 POSIX-Style Character Classes |
2031
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2032
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2033
|
|
|
|
|
|
|
|
2034
|
|
|
|
|
|
|
# P.311 11.2.4 Character Classes and other Special Escapes |
2035
|
|
|
|
|
|
|
# in Chapter 11: perlre: Perl regular expressions |
2036
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
2037
|
|
|
|
|
|
|
|
2038
|
|
|
|
|
|
|
# P.210 POSIX-Style Character Classes |
2039
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2040
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
'[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK") |
2043
|
|
|
|
|
|
|
|
2044
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A]', |
2045
|
|
|
|
|
|
|
'[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]', |
2046
|
|
|
|
|
|
|
'[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]', |
2047
|
|
|
|
|
|
|
'[:^alnum:]' => '${Esjis::not_alnum}', |
2048
|
|
|
|
|
|
|
'[:^alpha:]' => '${Esjis::not_alpha}', |
2049
|
|
|
|
|
|
|
'[:^ascii:]' => '${Esjis::not_ascii}', |
2050
|
|
|
|
|
|
|
'[:^blank:]' => '${Esjis::not_blank}', |
2051
|
|
|
|
|
|
|
'[:^cntrl:]' => '${Esjis::not_cntrl}', |
2052
|
|
|
|
|
|
|
'[:^digit:]' => '${Esjis::not_digit}', |
2053
|
|
|
|
|
|
|
'[:^graph:]' => '${Esjis::not_graph}', |
2054
|
|
|
|
|
|
|
'[:^lower:]' => '${Esjis::not_lower}', |
2055
|
|
|
|
|
|
|
'[:^print:]' => '${Esjis::not_print}', |
2056
|
|
|
|
|
|
|
'[:^punct:]' => '${Esjis::not_punct}', |
2057
|
|
|
|
|
|
|
'[:^space:]' => '${Esjis::not_space}', |
2058
|
|
|
|
|
|
|
'[:^upper:]' => '${Esjis::not_upper}', |
2059
|
|
|
|
|
|
|
'[:^word:]' => '${Esjis::not_word}', |
2060
|
|
|
|
|
|
|
'[:^xdigit:]' => '${Esjis::not_xdigit}', |
2061
|
|
|
|
|
|
|
|
2062
|
8
|
|
|
|
|
62
|
}->{$1}; |
2063
|
|
|
|
|
|
|
} |
2064
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) { |
2065
|
70
|
|
|
|
|
1558
|
$char[$i] = $1; |
2066
|
|
|
|
|
|
|
} |
2067
|
|
|
|
|
|
|
} |
2068
|
|
|
|
|
|
|
|
2069
|
|
|
|
|
|
|
# open character list |
2070
|
7
|
|
|
|
|
36
|
my @singleoctet = (); |
2071
|
758
|
|
|
|
|
1307
|
my @multipleoctet = (); |
2072
|
758
|
|
|
|
|
1157
|
for (my $i=0; $i <= $#char; ) { |
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
# escaped - |
2075
|
758
|
100
|
100
|
|
|
1818
|
if (defined($char[$i+1]) and ($char[$i+1] eq '...')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2076
|
2151
|
|
|
|
|
10191
|
$i += 1; |
2077
|
497
|
|
|
|
|
665
|
next; |
2078
|
|
|
|
|
|
|
} |
2079
|
|
|
|
|
|
|
|
2080
|
|
|
|
|
|
|
# make range regexp |
2081
|
|
|
|
|
|
|
elsif ($char[$i] eq '...') { |
2082
|
|
|
|
|
|
|
|
2083
|
|
|
|
|
|
|
# range error |
2084
|
497
|
50
|
|
|
|
1024
|
if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) { |
|
|
100
|
|
|
|
|
|
2085
|
497
|
|
|
|
|
2459
|
croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2086
|
|
|
|
|
|
|
} |
2087
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) { |
2088
|
0
|
50
|
|
|
|
0
|
if ($char[$i-1] gt $char[$i+1]) { |
2089
|
477
|
|
|
|
|
1361
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2090
|
|
|
|
|
|
|
} |
2091
|
|
|
|
|
|
|
} |
2092
|
|
|
|
|
|
|
|
2093
|
|
|
|
|
|
|
# make range regexp per length |
2094
|
0
|
|
|
|
|
0
|
for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) { |
2095
|
497
|
|
|
|
|
1608
|
my @regexp = (); |
2096
|
|
|
|
|
|
|
|
2097
|
|
|
|
|
|
|
# is first and last |
2098
|
517
|
100
|
100
|
|
|
1120
|
if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2099
|
517
|
|
|
|
|
2019
|
push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]); |
2100
|
|
|
|
|
|
|
} |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
# is first |
2103
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i-1])) { |
2104
|
477
|
|
|
|
|
1711
|
push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length); |
2105
|
|
|
|
|
|
|
} |
2106
|
|
|
|
|
|
|
|
2107
|
|
|
|
|
|
|
# is inside in first and last |
2108
|
|
|
|
|
|
|
elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) { |
2109
|
20
|
|
|
|
|
68
|
push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length); |
2110
|
|
|
|
|
|
|
} |
2111
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
# is last |
2113
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i+1])) { |
2114
|
0
|
|
|
|
|
0
|
push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]); |
2115
|
|
|
|
|
|
|
} |
2116
|
|
|
|
|
|
|
|
2117
|
|
|
|
|
|
|
else { |
2118
|
20
|
|
|
|
|
85
|
die __FILE__, ": subroutine make_regexp panic.\n"; |
2119
|
|
|
|
|
|
|
} |
2120
|
|
|
|
|
|
|
|
2121
|
0
|
100
|
|
|
|
0
|
if ($length == 1) { |
2122
|
517
|
|
|
|
|
1054
|
push @singleoctet, @regexp; |
2123
|
|
|
|
|
|
|
} |
2124
|
|
|
|
|
|
|
else { |
2125
|
386
|
|
|
|
|
884
|
push @multipleoctet, @regexp; |
2126
|
|
|
|
|
|
|
} |
2127
|
|
|
|
|
|
|
} |
2128
|
|
|
|
|
|
|
|
2129
|
131
|
|
|
|
|
314
|
$i += 2; |
2130
|
|
|
|
|
|
|
} |
2131
|
|
|
|
|
|
|
|
2132
|
|
|
|
|
|
|
# with /i modifier |
2133
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
2134
|
497
|
100
|
|
|
|
1022
|
if ($modifier =~ /i/oxms) { |
2135
|
764
|
|
|
|
|
1431
|
my $uc = Esjis::uc($char[$i]); |
2136
|
192
|
|
|
|
|
383
|
my $fc = Esjis::fc($char[$i]); |
2137
|
192
|
50
|
|
|
|
451
|
if ($uc ne $fc) { |
2138
|
192
|
50
|
|
|
|
359
|
if (CORE::length($fc) == 1) { |
2139
|
192
|
|
|
|
|
316
|
push @singleoctet, $uc, $fc; |
2140
|
|
|
|
|
|
|
} |
2141
|
|
|
|
|
|
|
else { |
2142
|
192
|
|
|
|
|
799
|
push @singleoctet, $uc; |
2143
|
0
|
|
|
|
|
0
|
push @multipleoctet, $fc; |
2144
|
|
|
|
|
|
|
} |
2145
|
|
|
|
|
|
|
} |
2146
|
|
|
|
|
|
|
else { |
2147
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2148
|
|
|
|
|
|
|
} |
2149
|
|
|
|
|
|
|
} |
2150
|
|
|
|
|
|
|
else { |
2151
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2152
|
|
|
|
|
|
|
} |
2153
|
572
|
|
|
|
|
868
|
$i += 1; |
2154
|
|
|
|
|
|
|
} |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
# single character of single octet code |
2157
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) { |
2158
|
764
|
|
|
|
|
2009
|
push @singleoctet, "\t", "\x20"; |
2159
|
0
|
|
|
|
|
0
|
$i += 1; |
2160
|
|
|
|
|
|
|
} |
2161
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) { |
2162
|
0
|
|
|
|
|
0
|
push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D"; |
2163
|
0
|
|
|
|
|
0
|
$i += 1; |
2164
|
|
|
|
|
|
|
} |
2165
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) { |
2166
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2167
|
2
|
|
|
|
|
6
|
$i += 1; |
2168
|
|
|
|
|
|
|
} |
2169
|
|
|
|
|
|
|
|
2170
|
|
|
|
|
|
|
# single character of multiple-octet code |
2171
|
|
|
|
|
|
|
else { |
2172
|
2
|
|
|
|
|
18
|
push @multipleoctet, $char[$i]; |
2173
|
391
|
|
|
|
|
734
|
$i += 1; |
2174
|
|
|
|
|
|
|
} |
2175
|
|
|
|
|
|
|
} |
2176
|
|
|
|
|
|
|
|
2177
|
|
|
|
|
|
|
# quote metachar |
2178
|
391
|
|
|
|
|
720
|
for (@singleoctet) { |
2179
|
758
|
50
|
|
|
|
1787
|
if ($_ eq '...') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2180
|
1384
|
|
|
|
|
6635
|
$_ = '-'; |
2181
|
|
|
|
|
|
|
} |
2182
|
|
|
|
|
|
|
elsif (/\A \n \z/oxms) { |
2183
|
0
|
|
|
|
|
0
|
$_ = '\n'; |
2184
|
|
|
|
|
|
|
} |
2185
|
|
|
|
|
|
|
elsif (/\A \r \z/oxms) { |
2186
|
8
|
|
|
|
|
29
|
$_ = '\r'; |
2187
|
|
|
|
|
|
|
} |
2188
|
|
|
|
|
|
|
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) { |
2189
|
8
|
|
|
|
|
19
|
$_ = sprintf('\x%02X', CORE::ord $1); |
2190
|
|
|
|
|
|
|
} |
2191
|
|
|
|
|
|
|
elsif (/\A [\x00-\xFF] \z/oxms) { |
2192
|
1
|
|
|
|
|
6
|
$_ = quotemeta $_; |
2193
|
|
|
|
|
|
|
} |
2194
|
|
|
|
|
|
|
} |
2195
|
939
|
|
|
|
|
1454
|
for (@multipleoctet) { |
2196
|
758
|
100
|
|
|
|
1691
|
if (/\A ([\x80-\xFF].*) ([\x00-\xFF]) \z/oxms) { |
2197
|
693
|
|
|
|
|
2027
|
$_ = $1 . quotemeta $2; |
2198
|
|
|
|
|
|
|
} |
2199
|
|
|
|
|
|
|
} |
2200
|
|
|
|
|
|
|
|
2201
|
|
|
|
|
|
|
# return character list |
2202
|
307
|
|
|
|
|
738
|
return \@singleoctet, \@multipleoctet; |
2203
|
|
|
|
|
|
|
} |
2204
|
|
|
|
|
|
|
|
2205
|
|
|
|
|
|
|
# |
2206
|
|
|
|
|
|
|
# ShiftJIS octal escape sequence |
2207
|
|
|
|
|
|
|
# |
2208
|
|
|
|
|
|
|
sub octchr { |
2209
|
758
|
|
|
5
|
0
|
3684
|
my($octdigit) = @_; |
2210
|
|
|
|
|
|
|
|
2211
|
5
|
|
|
|
|
191
|
my @binary = (); |
2212
|
5
|
|
|
|
|
14
|
for my $octal (split(//,$octdigit)) { |
2213
|
|
|
|
|
|
|
push @binary, { |
2214
|
|
|
|
|
|
|
'0' => '000', |
2215
|
|
|
|
|
|
|
'1' => '001', |
2216
|
|
|
|
|
|
|
'2' => '010', |
2217
|
|
|
|
|
|
|
'3' => '011', |
2218
|
|
|
|
|
|
|
'4' => '100', |
2219
|
|
|
|
|
|
|
'5' => '101', |
2220
|
|
|
|
|
|
|
'6' => '110', |
2221
|
|
|
|
|
|
|
'7' => '111', |
2222
|
5
|
|
|
|
|
65
|
}->{$octal}; |
2223
|
|
|
|
|
|
|
} |
2224
|
50
|
|
|
|
|
254
|
my $binary = join '', @binary; |
2225
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
my $octchr = { |
2227
|
|
|
|
|
|
|
# 1234567 |
2228
|
|
|
|
|
|
|
1 => pack('B*', "0000000$binary"), |
2229
|
|
|
|
|
|
|
2 => pack('B*', "000000$binary"), |
2230
|
|
|
|
|
|
|
3 => pack('B*', "00000$binary"), |
2231
|
|
|
|
|
|
|
4 => pack('B*', "0000$binary"), |
2232
|
|
|
|
|
|
|
5 => pack('B*', "000$binary"), |
2233
|
|
|
|
|
|
|
6 => pack('B*', "00$binary"), |
2234
|
|
|
|
|
|
|
7 => pack('B*', "0$binary"), |
2235
|
|
|
|
|
|
|
0 => pack('B*', "$binary"), |
2236
|
|
|
|
|
|
|
|
2237
|
5
|
|
|
|
|
21
|
}->{CORE::length($binary) % 8}; |
2238
|
|
|
|
|
|
|
|
2239
|
5
|
|
|
|
|
139
|
return $octchr; |
2240
|
|
|
|
|
|
|
} |
2241
|
|
|
|
|
|
|
|
2242
|
|
|
|
|
|
|
# |
2243
|
|
|
|
|
|
|
# ShiftJIS hexadecimal escape sequence |
2244
|
|
|
|
|
|
|
# |
2245
|
|
|
|
|
|
|
sub hexchr { |
2246
|
5
|
|
|
5
|
0
|
26
|
my($hexdigit) = @_; |
2247
|
|
|
|
|
|
|
|
2248
|
|
|
|
|
|
|
my $hexchr = { |
2249
|
|
|
|
|
|
|
1 => pack('H*', "0$hexdigit"), |
2250
|
|
|
|
|
|
|
0 => pack('H*', "$hexdigit"), |
2251
|
|
|
|
|
|
|
|
2252
|
5
|
|
|
|
|
21
|
}->{CORE::length($_[0]) % 2}; |
2253
|
|
|
|
|
|
|
|
2254
|
5
|
|
|
|
|
55
|
return $hexchr; |
2255
|
|
|
|
|
|
|
} |
2256
|
|
|
|
|
|
|
|
2257
|
|
|
|
|
|
|
# |
2258
|
|
|
|
|
|
|
# ShiftJIS open character list for qr |
2259
|
|
|
|
|
|
|
# |
2260
|
|
|
|
|
|
|
sub charlist_qr { |
2261
|
|
|
|
|
|
|
|
2262
|
5
|
|
|
519
|
0
|
18
|
my $modifier = pop @_; |
2263
|
519
|
|
|
|
|
1129
|
my @char = @_; |
2264
|
|
|
|
|
|
|
|
2265
|
519
|
|
|
|
|
1574
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2266
|
519
|
|
|
|
|
1969
|
my @singleoctet = @$singleoctet; |
2267
|
519
|
|
|
|
|
1225
|
my @multipleoctet = @$multipleoctet; |
2268
|
|
|
|
|
|
|
|
2269
|
|
|
|
|
|
|
# return character list |
2270
|
519
|
100
|
|
|
|
899
|
if (scalar(@singleoctet) >= 1) { |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
# with /i modifier |
2273
|
519
|
100
|
|
|
|
1568
|
if ($modifier =~ m/i/oxms) { |
2274
|
384
|
|
|
|
|
953
|
my %singleoctet_ignorecase = (); |
2275
|
107
|
|
|
|
|
236
|
for (@singleoctet) { |
2276
|
107
|
|
66
|
|
|
234
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2277
|
277
|
|
|
|
|
1056
|
for my $ord (hex($1) .. hex($2)) { |
2278
|
85
|
|
|
|
|
462
|
my $char = CORE::chr($ord); |
2279
|
1376
|
|
|
|
|
1964
|
my $uc = Esjis::uc($char); |
2280
|
1376
|
|
|
|
|
1828
|
my $fc = Esjis::fc($char); |
2281
|
1376
|
100
|
|
|
|
1884
|
if ($uc eq $fc) { |
2282
|
1376
|
|
|
|
|
1947
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2283
|
|
|
|
|
|
|
} |
2284
|
|
|
|
|
|
|
else { |
2285
|
787
|
50
|
|
|
|
1801
|
if (CORE::length($fc) == 1) { |
2286
|
589
|
|
|
|
|
799
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2287
|
589
|
|
|
|
|
1227
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2288
|
|
|
|
|
|
|
} |
2289
|
|
|
|
|
|
|
else { |
2290
|
589
|
|
|
|
|
1572
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2291
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2292
|
|
|
|
|
|
|
} |
2293
|
|
|
|
|
|
|
} |
2294
|
|
|
|
|
|
|
} |
2295
|
|
|
|
|
|
|
} |
2296
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2297
|
277
|
|
|
|
|
573
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2298
|
|
|
|
|
|
|
} |
2299
|
|
|
|
|
|
|
} |
2300
|
192
|
|
|
|
|
586
|
my $i = 0; |
2301
|
107
|
|
|
|
|
162
|
my @singleoctet_ignorecase = (); |
2302
|
107
|
|
|
|
|
214
|
for my $ord (0 .. 255) { |
2303
|
107
|
100
|
|
|
|
242
|
if (exists $singleoctet_ignorecase{$ord}) { |
2304
|
27392
|
|
|
|
|
35750
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1907
|
|
|
|
|
2185
|
|
2305
|
|
|
|
|
|
|
} |
2306
|
|
|
|
|
|
|
else { |
2307
|
1907
|
|
|
|
|
3161
|
$i++; |
2308
|
|
|
|
|
|
|
} |
2309
|
|
|
|
|
|
|
} |
2310
|
25485
|
|
|
|
|
27574
|
@singleoctet = (); |
2311
|
107
|
|
|
|
|
255
|
for my $range (@singleoctet_ignorecase) { |
2312
|
107
|
100
|
|
|
|
333
|
if (ref $range) { |
2313
|
11082
|
50
|
|
|
|
18855
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
248
|
|
2314
|
219
|
|
|
|
|
475
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
0
|
|
|
|
|
0
|
|
2315
|
|
|
|
|
|
|
} |
2316
|
0
|
|
|
|
|
0
|
elsif (scalar(@{$range}) == 2) { |
2317
|
219
|
|
|
|
|
435
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
else { |
2320
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
219
|
|
|
|
|
312
|
|
|
219
|
|
|
|
|
297
|
|
2321
|
|
|
|
|
|
|
} |
2322
|
|
|
|
|
|
|
} |
2323
|
|
|
|
|
|
|
} |
2324
|
|
|
|
|
|
|
} |
2325
|
|
|
|
|
|
|
|
2326
|
219
|
|
|
|
|
1572
|
my $not_anchor = ''; |
2327
|
384
|
|
|
|
|
748
|
$not_anchor = '(?![\x81-\x9F\xE0-\xFC])'; |
2328
|
|
|
|
|
|
|
|
2329
|
384
|
|
|
|
|
690
|
push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' ); |
2330
|
|
|
|
|
|
|
} |
2331
|
384
|
100
|
|
|
|
1341
|
if (scalar(@multipleoctet) >= 2) { |
2332
|
519
|
|
|
|
|
2396
|
return '(?:' . join('|', @multipleoctet) . ')'; |
2333
|
|
|
|
|
|
|
} |
2334
|
|
|
|
|
|
|
else { |
2335
|
131
|
|
|
|
|
1225
|
return $multipleoctet[0]; |
2336
|
|
|
|
|
|
|
} |
2337
|
|
|
|
|
|
|
} |
2338
|
|
|
|
|
|
|
|
2339
|
|
|
|
|
|
|
# |
2340
|
|
|
|
|
|
|
# ShiftJIS open character list for not qr |
2341
|
|
|
|
|
|
|
# |
2342
|
|
|
|
|
|
|
sub charlist_not_qr { |
2343
|
|
|
|
|
|
|
|
2344
|
388
|
|
|
239
|
0
|
1790
|
my $modifier = pop @_; |
2345
|
239
|
|
|
|
|
470
|
my @char = @_; |
2346
|
|
|
|
|
|
|
|
2347
|
239
|
|
|
|
|
633
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2348
|
239
|
|
|
|
|
833
|
my @singleoctet = @$singleoctet; |
2349
|
239
|
|
|
|
|
529
|
my @multipleoctet = @$multipleoctet; |
2350
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
# with /i modifier |
2352
|
239
|
100
|
|
|
|
502
|
if ($modifier =~ m/i/oxms) { |
2353
|
239
|
|
|
|
|
665
|
my %singleoctet_ignorecase = (); |
2354
|
128
|
|
|
|
|
209
|
for (@singleoctet) { |
2355
|
128
|
|
66
|
|
|
221
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2356
|
277
|
|
|
|
|
932
|
for my $ord (hex($1) .. hex($2)) { |
2357
|
85
|
|
|
|
|
346
|
my $char = CORE::chr($ord); |
2358
|
1376
|
|
|
|
|
1808
|
my $uc = Esjis::uc($char); |
2359
|
1376
|
|
|
|
|
1788
|
my $fc = Esjis::fc($char); |
2360
|
1376
|
100
|
|
|
|
1960
|
if ($uc eq $fc) { |
2361
|
1376
|
|
|
|
|
1969
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2362
|
|
|
|
|
|
|
} |
2363
|
|
|
|
|
|
|
else { |
2364
|
787
|
50
|
|
|
|
2078
|
if (CORE::length($fc) == 1) { |
2365
|
589
|
|
|
|
|
784
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2366
|
589
|
|
|
|
|
1207
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2367
|
|
|
|
|
|
|
} |
2368
|
|
|
|
|
|
|
else { |
2369
|
589
|
|
|
|
|
1441
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2370
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2371
|
|
|
|
|
|
|
} |
2372
|
|
|
|
|
|
|
} |
2373
|
|
|
|
|
|
|
} |
2374
|
|
|
|
|
|
|
} |
2375
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2376
|
277
|
|
|
|
|
453
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2377
|
|
|
|
|
|
|
} |
2378
|
|
|
|
|
|
|
} |
2379
|
192
|
|
|
|
|
508
|
my $i = 0; |
2380
|
128
|
|
|
|
|
184
|
my @singleoctet_ignorecase = (); |
2381
|
128
|
|
|
|
|
184
|
for my $ord (0 .. 255) { |
2382
|
128
|
100
|
|
|
|
239
|
if (exists $singleoctet_ignorecase{$ord}) { |
2383
|
32768
|
|
|
|
|
36794
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1907
|
|
|
|
|
1686
|
|
2384
|
|
|
|
|
|
|
} |
2385
|
|
|
|
|
|
|
else { |
2386
|
1907
|
|
|
|
|
2941
|
$i++; |
2387
|
|
|
|
|
|
|
} |
2388
|
|
|
|
|
|
|
} |
2389
|
30861
|
|
|
|
|
38130
|
@singleoctet = (); |
2390
|
128
|
|
|
|
|
215
|
for my $range (@singleoctet_ignorecase) { |
2391
|
128
|
100
|
|
|
|
304
|
if (ref $range) { |
2392
|
11082
|
50
|
|
|
|
16942
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
264
|
|
2393
|
219
|
|
|
|
|
335
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
0
|
|
|
|
|
0
|
|
2394
|
|
|
|
|
|
|
} |
2395
|
0
|
|
|
|
|
0
|
elsif (scalar(@{$range}) == 2) { |
2396
|
219
|
|
|
|
|
334
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2397
|
|
|
|
|
|
|
} |
2398
|
|
|
|
|
|
|
else { |
2399
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
219
|
|
|
|
|
320
|
|
|
219
|
|
|
|
|
302
|
|
2400
|
|
|
|
|
|
|
} |
2401
|
|
|
|
|
|
|
} |
2402
|
|
|
|
|
|
|
} |
2403
|
|
|
|
|
|
|
} |
2404
|
|
|
|
|
|
|
|
2405
|
|
|
|
|
|
|
# return character list |
2406
|
219
|
100
|
|
|
|
1092
|
if (scalar(@multipleoctet) >= 1) { |
2407
|
239
|
100
|
|
|
|
554
|
if (scalar(@singleoctet) >= 1) { |
2408
|
|
|
|
|
|
|
|
2409
|
|
|
|
|
|
|
# any character other than multiple-octet and single octet character class |
2410
|
114
|
|
|
|
|
292
|
return '(?!' . join('|', @multipleoctet) . ')(?:[^\x81-\x9F\xE0-\xFC' . join('', @singleoctet) . ']|[\x81-\x9F\xE0-\xFC][\x00-\xFF])'; |
2411
|
|
|
|
|
|
|
} |
2412
|
|
|
|
|
|
|
else { |
2413
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
# any character other than multiple-octet character class |
2415
|
70
|
|
|
|
|
548
|
return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)"; |
2416
|
|
|
|
|
|
|
} |
2417
|
|
|
|
|
|
|
} |
2418
|
|
|
|
|
|
|
else { |
2419
|
44
|
50
|
|
|
|
276
|
if (scalar(@singleoctet) >= 1) { |
2420
|
|
|
|
|
|
|
|
2421
|
|
|
|
|
|
|
# any character other than single octet character class |
2422
|
125
|
|
|
|
|
319
|
return '(?:[^\x81-\x9F\xE0-\xFC' . join('', @singleoctet) . ']|[\x81-\x9F\xE0-\xFC][\x00-\xFF])'; |
2423
|
|
|
|
|
|
|
} |
2424
|
|
|
|
|
|
|
else { |
2425
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
# any character |
2427
|
125
|
|
|
|
|
963
|
return "(?:$your_char)"; |
2428
|
|
|
|
|
|
|
} |
2429
|
|
|
|
|
|
|
} |
2430
|
|
|
|
|
|
|
} |
2431
|
|
|
|
|
|
|
|
2432
|
|
|
|
|
|
|
# |
2433
|
|
|
|
|
|
|
# open file in read mode |
2434
|
|
|
|
|
|
|
# |
2435
|
|
|
|
|
|
|
sub _open_r { |
2436
|
0
|
|
|
770
|
|
0
|
my(undef,$file) = @_; |
2437
|
390
|
|
|
390
|
|
4603
|
use Fcntl qw(O_RDONLY); |
|
390
|
|
|
|
|
2398
|
|
|
390
|
|
|
|
|
77815
|
|
2438
|
770
|
|
|
|
|
2455
|
return CORE::sysopen($_[0], $file, &O_RDONLY); |
2439
|
|
|
|
|
|
|
} |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
# |
2442
|
|
|
|
|
|
|
# open file in append mode |
2443
|
|
|
|
|
|
|
# |
2444
|
|
|
|
|
|
|
sub _open_a { |
2445
|
770
|
|
|
385
|
|
34516
|
my(undef,$file) = @_; |
2446
|
390
|
|
|
390
|
|
2722
|
use Fcntl qw(O_WRONLY O_APPEND O_CREAT); |
|
390
|
|
|
|
|
2528
|
|
|
390
|
|
|
|
|
7476037
|
|
2447
|
385
|
|
|
|
|
1224
|
return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT); |
2448
|
|
|
|
|
|
|
} |
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
# |
2451
|
|
|
|
|
|
|
# safe system |
2452
|
|
|
|
|
|
|
# |
2453
|
|
|
|
|
|
|
sub _systemx { |
2454
|
|
|
|
|
|
|
|
2455
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2456
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2457
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2458
|
|
|
|
|
|
|
# |
2459
|
|
|
|
|
|
|
# Be aware that in older releases of Perl, exec (and system) did not flush |
2460
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2461
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output in the case of exec, or |
2462
|
|
|
|
|
|
|
# misordererd output in the case of system. This situation was largely remedied |
2463
|
|
|
|
|
|
|
# in the 5.6 release of Perl. (So, 5.005 release not yet.) |
2464
|
|
|
|
|
|
|
|
2465
|
|
|
|
|
|
|
# P.855 exec |
2466
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2467
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2468
|
|
|
|
|
|
|
# |
2469
|
|
|
|
|
|
|
# In very old release of Perl (before v5.6), exec (and system) did not flush |
2470
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2471
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output with exec or misordered |
2472
|
|
|
|
|
|
|
# output with system. |
2473
|
|
|
|
|
|
|
|
2474
|
385
|
|
|
385
|
|
62319
|
$| = 1; |
2475
|
|
|
|
|
|
|
|
2476
|
|
|
|
|
|
|
# P.565 23.1.2. Cleaning Up Your Environment |
2477
|
|
|
|
|
|
|
# in Chapter 23: Security |
2478
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2479
|
|
|
|
|
|
|
|
2480
|
|
|
|
|
|
|
# P.656 Cleaning Up Your Environment |
2481
|
|
|
|
|
|
|
# in Chapter 20: Security |
2482
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2483
|
|
|
|
|
|
|
|
2484
|
|
|
|
|
|
|
# local $ENV{'PATH'} = '.'; |
2485
|
385
|
|
|
|
|
1563
|
local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer |
2486
|
|
|
|
|
|
|
|
2487
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2488
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2489
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2490
|
|
|
|
|
|
|
# |
2491
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as an |
2492
|
|
|
|
|
|
|
# indication that it should bypass shell processing. However, there is one |
2493
|
|
|
|
|
|
|
# place where you might still get tripped up. The exec call (and system, too) |
2494
|
|
|
|
|
|
|
# will not distinguish between a single scalar argument and an array containing |
2495
|
|
|
|
|
|
|
# only one element. |
2496
|
|
|
|
|
|
|
# |
2497
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2498
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2499
|
|
|
|
|
|
|
# or die "exec: $!"; # because @args == 1 |
2500
|
|
|
|
|
|
|
# |
2501
|
|
|
|
|
|
|
# To avoid this, you can use the PATHNAME syntax, explicitly duplicating the |
2502
|
|
|
|
|
|
|
# first argument as the pathname, which forces the rest of the arguments to be |
2503
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2504
|
|
|
|
|
|
|
# |
2505
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2506
|
|
|
|
|
|
|
# or die "can't exec @args: $!"; |
2507
|
|
|
|
|
|
|
|
2508
|
|
|
|
|
|
|
# P.855 exec |
2509
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2510
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2511
|
|
|
|
|
|
|
# |
2512
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as a |
2513
|
|
|
|
|
|
|
# directive to bypass shell processing. However, there is one place where |
2514
|
|
|
|
|
|
|
# you might still get tripped up. The exec call (and system, too) cannot |
2515
|
|
|
|
|
|
|
# distinguish between a single scalar argument and an array containing |
2516
|
|
|
|
|
|
|
# only one element. |
2517
|
|
|
|
|
|
|
# |
2518
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2519
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2520
|
|
|
|
|
|
|
# || die "exec: $!"; # because @args == 1 |
2521
|
|
|
|
|
|
|
# |
2522
|
|
|
|
|
|
|
# To avoid this, use the PATHNAME syntax, explicitly duplicating the first |
2523
|
|
|
|
|
|
|
# argument as the pathname, which forces the rest of the arguments to be |
2524
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2525
|
|
|
|
|
|
|
# |
2526
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2527
|
|
|
|
|
|
|
# || die "can't exec @args: $!"; |
2528
|
|
|
|
|
|
|
|
2529
|
385
|
|
|
|
|
4048
|
return CORE::system { $_[0] } @_; # safe even with one-argument list |
|
385
|
|
|
|
|
1294
|
|
2530
|
|
|
|
|
|
|
} |
2531
|
|
|
|
|
|
|
|
2532
|
|
|
|
|
|
|
# |
2533
|
|
|
|
|
|
|
# ShiftJIS order to character (with parameter) |
2534
|
|
|
|
|
|
|
# |
2535
|
|
|
|
|
|
|
sub Esjis::chr(;$) { |
2536
|
|
|
|
|
|
|
|
2537
|
385
|
0
|
|
0
|
0
|
53857343
|
my $c = @_ ? $_[0] : $_; |
2538
|
|
|
|
|
|
|
|
2539
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2540
|
0
|
|
|
|
|
0
|
return "\x00"; |
2541
|
|
|
|
|
|
|
} |
2542
|
|
|
|
|
|
|
else { |
2543
|
0
|
|
|
|
|
0
|
my @chr = (); |
2544
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2545
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2546
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2547
|
|
|
|
|
|
|
} |
2548
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2549
|
|
|
|
|
|
|
} |
2550
|
|
|
|
|
|
|
} |
2551
|
|
|
|
|
|
|
|
2552
|
|
|
|
|
|
|
# |
2553
|
|
|
|
|
|
|
# ShiftJIS order to character (without parameter) |
2554
|
|
|
|
|
|
|
# |
2555
|
|
|
|
|
|
|
sub Esjis::chr_() { |
2556
|
|
|
|
|
|
|
|
2557
|
0
|
|
|
0
|
0
|
0
|
my $c = $_; |
2558
|
|
|
|
|
|
|
|
2559
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2560
|
0
|
|
|
|
|
0
|
return "\x00"; |
2561
|
|
|
|
|
|
|
} |
2562
|
|
|
|
|
|
|
else { |
2563
|
0
|
|
|
|
|
0
|
my @chr = (); |
2564
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2565
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2566
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2567
|
|
|
|
|
|
|
} |
2568
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2569
|
|
|
|
|
|
|
} |
2570
|
|
|
|
|
|
|
} |
2571
|
|
|
|
|
|
|
|
2572
|
|
|
|
|
|
|
# |
2573
|
|
|
|
|
|
|
# ShiftJIS stacked file test expr |
2574
|
|
|
|
|
|
|
# |
2575
|
|
|
|
|
|
|
sub Esjis::filetest { |
2576
|
|
|
|
|
|
|
|
2577
|
0
|
|
|
0
|
0
|
0
|
my $file = pop @_; |
2578
|
0
|
|
|
|
|
0
|
my $filetest = substr(pop @_, 1); |
2579
|
|
|
|
|
|
|
|
2580
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Esjis::$filetest(\$file)}) { |
2581
|
0
|
|
|
|
|
0
|
return ''; |
2582
|
|
|
|
|
|
|
} |
2583
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
2584
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
2585
|
0
|
|
|
|
|
0
|
return ''; |
2586
|
|
|
|
|
|
|
} |
2587
|
|
|
|
|
|
|
} |
2588
|
0
|
|
|
|
|
0
|
return 1; |
2589
|
|
|
|
|
|
|
} |
2590
|
|
|
|
|
|
|
|
2591
|
|
|
|
|
|
|
# |
2592
|
|
|
|
|
|
|
# ShiftJIS file test -r expr |
2593
|
|
|
|
|
|
|
# |
2594
|
|
|
|
|
|
|
sub Esjis::r(;*@) { |
2595
|
|
|
|
|
|
|
|
2596
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2597
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -r (Esjis::r)' if @_ and not wantarray; |
2598
|
|
|
|
|
|
|
|
2599
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2600
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2601
|
|
|
|
|
|
|
} |
2602
|
|
|
|
|
|
|
|
2603
|
|
|
|
|
|
|
# P.908 32.39. Symbol |
2604
|
|
|
|
|
|
|
# in Chapter 32: Standard Modules |
2605
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2606
|
|
|
|
|
|
|
|
2607
|
|
|
|
|
|
|
# P.326 Prototypes |
2608
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
2609
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
# (and so on) |
2612
|
|
|
|
|
|
|
|
2613
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2614
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r $fh,@_) : -r $fh; |
2615
|
|
|
|
|
|
|
} |
2616
|
|
|
|
|
|
|
elsif (-e $_) { |
2617
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2618
|
|
|
|
|
|
|
} |
2619
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2620
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2621
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2622
|
|
|
|
|
|
|
} |
2623
|
|
|
|
|
|
|
else { |
2624
|
|
|
|
|
|
|
|
2625
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::*() |
2626
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
2627
|
|
|
|
|
|
|
# (and so on) |
2628
|
|
|
|
|
|
|
|
2629
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2630
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2631
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
2632
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2633
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($r,@_) : $r; |
2634
|
|
|
|
|
|
|
} |
2635
|
|
|
|
|
|
|
} |
2636
|
|
|
|
|
|
|
} |
2637
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2638
|
|
|
|
|
|
|
} |
2639
|
|
|
|
|
|
|
|
2640
|
|
|
|
|
|
|
# |
2641
|
|
|
|
|
|
|
# ShiftJIS file test -w expr |
2642
|
|
|
|
|
|
|
# |
2643
|
|
|
|
|
|
|
sub Esjis::w(;*@) { |
2644
|
|
|
|
|
|
|
|
2645
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2646
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -w (Esjis::w)' if @_ and not wantarray; |
2647
|
|
|
|
|
|
|
|
2648
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2649
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2650
|
|
|
|
|
|
|
} |
2651
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2652
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w $fh,@_) : -w $fh; |
2653
|
|
|
|
|
|
|
} |
2654
|
|
|
|
|
|
|
elsif (-e $_) { |
2655
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2656
|
|
|
|
|
|
|
} |
2657
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2658
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2659
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2660
|
|
|
|
|
|
|
} |
2661
|
|
|
|
|
|
|
else { |
2662
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2663
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2664
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
2665
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2666
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($w,@_) : $w; |
2667
|
|
|
|
|
|
|
} |
2668
|
|
|
|
|
|
|
} |
2669
|
|
|
|
|
|
|
} |
2670
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2671
|
|
|
|
|
|
|
} |
2672
|
|
|
|
|
|
|
|
2673
|
|
|
|
|
|
|
# |
2674
|
|
|
|
|
|
|
# ShiftJIS file test -x expr |
2675
|
|
|
|
|
|
|
# |
2676
|
|
|
|
|
|
|
sub Esjis::x(;*@) { |
2677
|
|
|
|
|
|
|
|
2678
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2679
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -x (Esjis::x)' if @_ and not wantarray; |
2680
|
|
|
|
|
|
|
|
2681
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2682
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2683
|
|
|
|
|
|
|
} |
2684
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2685
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x $fh,@_) : -x $fh; |
2686
|
|
|
|
|
|
|
} |
2687
|
|
|
|
|
|
|
elsif (-e $_) { |
2688
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2689
|
|
|
|
|
|
|
} |
2690
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2691
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2692
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2693
|
|
|
|
|
|
|
} |
2694
|
|
|
|
|
|
|
else { |
2695
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2696
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2697
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
2698
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2699
|
|
|
|
|
|
|
} |
2700
|
|
|
|
|
|
|
|
2701
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2702
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2703
|
|
|
|
|
|
|
} |
2704
|
|
|
|
|
|
|
} |
2705
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2706
|
|
|
|
|
|
|
} |
2707
|
|
|
|
|
|
|
|
2708
|
|
|
|
|
|
|
# |
2709
|
|
|
|
|
|
|
# ShiftJIS file test -o expr |
2710
|
|
|
|
|
|
|
# |
2711
|
|
|
|
|
|
|
sub Esjis::o(;*@) { |
2712
|
|
|
|
|
|
|
|
2713
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2714
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -o (Esjis::o)' if @_ and not wantarray; |
2715
|
|
|
|
|
|
|
|
2716
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2717
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2718
|
|
|
|
|
|
|
} |
2719
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2720
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o $fh,@_) : -o $fh; |
2721
|
|
|
|
|
|
|
} |
2722
|
|
|
|
|
|
|
elsif (-e $_) { |
2723
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2724
|
|
|
|
|
|
|
} |
2725
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2726
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2727
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2728
|
|
|
|
|
|
|
} |
2729
|
|
|
|
|
|
|
else { |
2730
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2731
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2732
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
2733
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2734
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($o,@_) : $o; |
2735
|
|
|
|
|
|
|
} |
2736
|
|
|
|
|
|
|
} |
2737
|
|
|
|
|
|
|
} |
2738
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2739
|
|
|
|
|
|
|
} |
2740
|
|
|
|
|
|
|
|
2741
|
|
|
|
|
|
|
# |
2742
|
|
|
|
|
|
|
# ShiftJIS file test -R expr |
2743
|
|
|
|
|
|
|
# |
2744
|
|
|
|
|
|
|
sub Esjis::R(;*@) { |
2745
|
|
|
|
|
|
|
|
2746
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2747
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -R (Esjis::R)' if @_ and not wantarray; |
2748
|
|
|
|
|
|
|
|
2749
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2750
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2751
|
|
|
|
|
|
|
} |
2752
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2753
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R $fh,@_) : -R $fh; |
2754
|
|
|
|
|
|
|
} |
2755
|
|
|
|
|
|
|
elsif (-e $_) { |
2756
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2757
|
|
|
|
|
|
|
} |
2758
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2759
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2760
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2761
|
|
|
|
|
|
|
} |
2762
|
|
|
|
|
|
|
else { |
2763
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2764
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2765
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
2766
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2767
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($R,@_) : $R; |
2768
|
|
|
|
|
|
|
} |
2769
|
|
|
|
|
|
|
} |
2770
|
|
|
|
|
|
|
} |
2771
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2772
|
|
|
|
|
|
|
} |
2773
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
# |
2775
|
|
|
|
|
|
|
# ShiftJIS file test -W expr |
2776
|
|
|
|
|
|
|
# |
2777
|
|
|
|
|
|
|
sub Esjis::W(;*@) { |
2778
|
|
|
|
|
|
|
|
2779
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2780
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -W (Esjis::W)' if @_ and not wantarray; |
2781
|
|
|
|
|
|
|
|
2782
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2783
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2784
|
|
|
|
|
|
|
} |
2785
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2786
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W $fh,@_) : -W $fh; |
2787
|
|
|
|
|
|
|
} |
2788
|
|
|
|
|
|
|
elsif (-e $_) { |
2789
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2790
|
|
|
|
|
|
|
} |
2791
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2792
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2793
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2794
|
|
|
|
|
|
|
} |
2795
|
|
|
|
|
|
|
else { |
2796
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2797
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2798
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
2799
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2800
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($W,@_) : $W; |
2801
|
|
|
|
|
|
|
} |
2802
|
|
|
|
|
|
|
} |
2803
|
|
|
|
|
|
|
} |
2804
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2805
|
|
|
|
|
|
|
} |
2806
|
|
|
|
|
|
|
|
2807
|
|
|
|
|
|
|
# |
2808
|
|
|
|
|
|
|
# ShiftJIS file test -X expr |
2809
|
|
|
|
|
|
|
# |
2810
|
|
|
|
|
|
|
sub Esjis::X(;*@) { |
2811
|
|
|
|
|
|
|
|
2812
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
2813
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -X (Esjis::X)' if @_ and not wantarray; |
2814
|
|
|
|
|
|
|
|
2815
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2816
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2817
|
|
|
|
|
|
|
} |
2818
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2819
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X $fh,@_) : -X $fh; |
2820
|
|
|
|
|
|
|
} |
2821
|
|
|
|
|
|
|
elsif (-e $_) { |
2822
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2823
|
|
|
|
|
|
|
} |
2824
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2825
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2826
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2827
|
|
|
|
|
|
|
} |
2828
|
|
|
|
|
|
|
else { |
2829
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2830
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2831
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
2832
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2833
|
|
|
|
|
|
|
} |
2834
|
|
|
|
|
|
|
|
2835
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2836
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2837
|
|
|
|
|
|
|
} |
2838
|
|
|
|
|
|
|
} |
2839
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2840
|
|
|
|
|
|
|
} |
2841
|
|
|
|
|
|
|
|
2842
|
|
|
|
|
|
|
# |
2843
|
|
|
|
|
|
|
# ShiftJIS file test -O expr |
2844
|
|
|
|
|
|
|
# |
2845
|
|
|
|
|
|
|
sub Esjis::O(;*@) { |
2846
|
|
|
|
|
|
|
|
2847
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2848
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -O (Esjis::O)' if @_ and not wantarray; |
2849
|
|
|
|
|
|
|
|
2850
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2851
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2852
|
|
|
|
|
|
|
} |
2853
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2854
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O $fh,@_) : -O $fh; |
2855
|
|
|
|
|
|
|
} |
2856
|
|
|
|
|
|
|
elsif (-e $_) { |
2857
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2858
|
|
|
|
|
|
|
} |
2859
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2860
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2861
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2862
|
|
|
|
|
|
|
} |
2863
|
|
|
|
|
|
|
else { |
2864
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2865
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2866
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
2867
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2868
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($O,@_) : $O; |
2869
|
|
|
|
|
|
|
} |
2870
|
|
|
|
|
|
|
} |
2871
|
|
|
|
|
|
|
} |
2872
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2873
|
|
|
|
|
|
|
} |
2874
|
|
|
|
|
|
|
|
2875
|
|
|
|
|
|
|
# |
2876
|
|
|
|
|
|
|
# ShiftJIS file test -e expr |
2877
|
|
|
|
|
|
|
# |
2878
|
|
|
|
|
|
|
sub Esjis::e(;*@) { |
2879
|
|
|
|
|
|
|
|
2880
|
0
|
50
|
|
770
|
0
|
0
|
local $_ = shift if @_; |
2881
|
770
|
50
|
33
|
|
|
2865
|
croak 'Too many arguments for -e (Esjis::e)' if @_ and not wantarray; |
2882
|
|
|
|
|
|
|
|
2883
|
770
|
|
|
|
|
3157
|
local $^W = 0; |
2884
|
|
|
|
|
|
|
|
2885
|
770
|
|
|
|
|
2472
|
my $fh = qualify_to_ref $_; |
2886
|
770
|
50
|
|
|
|
2315
|
if ($_ eq '_') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2887
|
770
|
0
|
|
|
|
4640
|
return wantarray ? (-e _,@_) : -e _; |
2888
|
|
|
|
|
|
|
} |
2889
|
|
|
|
|
|
|
|
2890
|
|
|
|
|
|
|
# return false if directory handle |
2891
|
|
|
|
|
|
|
elsif (defined Esjis::telldir($fh)) { |
2892
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2893
|
|
|
|
|
|
|
} |
2894
|
|
|
|
|
|
|
|
2895
|
|
|
|
|
|
|
# return true if file handle |
2896
|
|
|
|
|
|
|
elsif (defined fileno $fh) { |
2897
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2898
|
|
|
|
|
|
|
} |
2899
|
|
|
|
|
|
|
|
2900
|
|
|
|
|
|
|
elsif (-e $_) { |
2901
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2902
|
|
|
|
|
|
|
} |
2903
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2904
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2905
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2906
|
|
|
|
|
|
|
} |
2907
|
|
|
|
|
|
|
else { |
2908
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2909
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2910
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
2911
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2912
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($e,@_) : $e; |
2913
|
|
|
|
|
|
|
} |
2914
|
|
|
|
|
|
|
} |
2915
|
|
|
|
|
|
|
} |
2916
|
0
|
50
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2917
|
|
|
|
|
|
|
} |
2918
|
|
|
|
|
|
|
|
2919
|
|
|
|
|
|
|
# |
2920
|
|
|
|
|
|
|
# ShiftJIS file test -z expr |
2921
|
|
|
|
|
|
|
# |
2922
|
|
|
|
|
|
|
sub Esjis::z(;*@) { |
2923
|
|
|
|
|
|
|
|
2924
|
770
|
0
|
|
0
|
0
|
4363
|
local $_ = shift if @_; |
2925
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -z (Esjis::z)' if @_ and not wantarray; |
2926
|
|
|
|
|
|
|
|
2927
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2928
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2929
|
|
|
|
|
|
|
} |
2930
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2931
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z $fh,@_) : -z $fh; |
2932
|
|
|
|
|
|
|
} |
2933
|
|
|
|
|
|
|
elsif (-e $_) { |
2934
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2935
|
|
|
|
|
|
|
} |
2936
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2937
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2938
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2939
|
|
|
|
|
|
|
} |
2940
|
|
|
|
|
|
|
else { |
2941
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2942
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2943
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
2944
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2945
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($z,@_) : $z; |
2946
|
|
|
|
|
|
|
} |
2947
|
|
|
|
|
|
|
} |
2948
|
|
|
|
|
|
|
} |
2949
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2950
|
|
|
|
|
|
|
} |
2951
|
|
|
|
|
|
|
|
2952
|
|
|
|
|
|
|
# |
2953
|
|
|
|
|
|
|
# ShiftJIS file test -s expr |
2954
|
|
|
|
|
|
|
# |
2955
|
|
|
|
|
|
|
sub Esjis::s(;*@) { |
2956
|
|
|
|
|
|
|
|
2957
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2958
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -s (Esjis::s)' if @_ and not wantarray; |
2959
|
|
|
|
|
|
|
|
2960
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2961
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2962
|
|
|
|
|
|
|
} |
2963
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2964
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s $fh,@_) : -s $fh; |
2965
|
|
|
|
|
|
|
} |
2966
|
|
|
|
|
|
|
elsif (-e $_) { |
2967
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2968
|
|
|
|
|
|
|
} |
2969
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2970
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2971
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2972
|
|
|
|
|
|
|
} |
2973
|
|
|
|
|
|
|
else { |
2974
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2975
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2976
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
2977
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2978
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($s,@_) : $s; |
2979
|
|
|
|
|
|
|
} |
2980
|
|
|
|
|
|
|
} |
2981
|
|
|
|
|
|
|
} |
2982
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2983
|
|
|
|
|
|
|
} |
2984
|
|
|
|
|
|
|
|
2985
|
|
|
|
|
|
|
# |
2986
|
|
|
|
|
|
|
# ShiftJIS file test -f expr |
2987
|
|
|
|
|
|
|
# |
2988
|
|
|
|
|
|
|
sub Esjis::f(;*@) { |
2989
|
|
|
|
|
|
|
|
2990
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2991
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -f (Esjis::f)' if @_ and not wantarray; |
2992
|
|
|
|
|
|
|
|
2993
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2994
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
2995
|
|
|
|
|
|
|
} |
2996
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2997
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f $fh,@_) : -f $fh; |
2998
|
|
|
|
|
|
|
} |
2999
|
|
|
|
|
|
|
elsif (-e $_) { |
3000
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
3001
|
|
|
|
|
|
|
} |
3002
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3003
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3004
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3005
|
|
|
|
|
|
|
} |
3006
|
|
|
|
|
|
|
else { |
3007
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3008
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3009
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3010
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3011
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($f,@_) : $f; |
3012
|
|
|
|
|
|
|
} |
3013
|
|
|
|
|
|
|
} |
3014
|
|
|
|
|
|
|
} |
3015
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3016
|
|
|
|
|
|
|
} |
3017
|
|
|
|
|
|
|
|
3018
|
|
|
|
|
|
|
# |
3019
|
|
|
|
|
|
|
# ShiftJIS file test -d expr |
3020
|
|
|
|
|
|
|
# |
3021
|
|
|
|
|
|
|
sub Esjis::d(;*@) { |
3022
|
|
|
|
|
|
|
|
3023
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3024
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -d (Esjis::d)' if @_ and not wantarray; |
3025
|
|
|
|
|
|
|
|
3026
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3027
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3028
|
|
|
|
|
|
|
} |
3029
|
|
|
|
|
|
|
|
3030
|
|
|
|
|
|
|
# return false if file handle or directory handle |
3031
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3032
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3033
|
|
|
|
|
|
|
} |
3034
|
|
|
|
|
|
|
elsif (-e $_) { |
3035
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3036
|
|
|
|
|
|
|
} |
3037
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3038
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d "$_/.",@_) : -d "$_/."; |
3039
|
|
|
|
|
|
|
} |
3040
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3041
|
|
|
|
|
|
|
} |
3042
|
|
|
|
|
|
|
|
3043
|
|
|
|
|
|
|
# |
3044
|
|
|
|
|
|
|
# ShiftJIS file test -l expr |
3045
|
|
|
|
|
|
|
# |
3046
|
|
|
|
|
|
|
sub Esjis::l(;*@) { |
3047
|
|
|
|
|
|
|
|
3048
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3049
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -l (Esjis::l)' if @_ and not wantarray; |
3050
|
|
|
|
|
|
|
|
3051
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3052
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3053
|
|
|
|
|
|
|
} |
3054
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3055
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l $fh,@_) : -l $fh; |
3056
|
|
|
|
|
|
|
} |
3057
|
|
|
|
|
|
|
elsif (-e $_) { |
3058
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3059
|
|
|
|
|
|
|
} |
3060
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3061
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3062
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3063
|
|
|
|
|
|
|
} |
3064
|
|
|
|
|
|
|
else { |
3065
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3066
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3067
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3068
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3069
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($l,@_) : $l; |
3070
|
|
|
|
|
|
|
} |
3071
|
|
|
|
|
|
|
} |
3072
|
|
|
|
|
|
|
} |
3073
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3074
|
|
|
|
|
|
|
} |
3075
|
|
|
|
|
|
|
|
3076
|
|
|
|
|
|
|
# |
3077
|
|
|
|
|
|
|
# ShiftJIS file test -p expr |
3078
|
|
|
|
|
|
|
# |
3079
|
|
|
|
|
|
|
sub Esjis::p(;*@) { |
3080
|
|
|
|
|
|
|
|
3081
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3082
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -p (Esjis::p)' if @_ and not wantarray; |
3083
|
|
|
|
|
|
|
|
3084
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3085
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3086
|
|
|
|
|
|
|
} |
3087
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3088
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p $fh,@_) : -p $fh; |
3089
|
|
|
|
|
|
|
} |
3090
|
|
|
|
|
|
|
elsif (-e $_) { |
3091
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3092
|
|
|
|
|
|
|
} |
3093
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3094
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3095
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3096
|
|
|
|
|
|
|
} |
3097
|
|
|
|
|
|
|
else { |
3098
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3099
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3100
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3101
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3102
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($p,@_) : $p; |
3103
|
|
|
|
|
|
|
} |
3104
|
|
|
|
|
|
|
} |
3105
|
|
|
|
|
|
|
} |
3106
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3107
|
|
|
|
|
|
|
} |
3108
|
|
|
|
|
|
|
|
3109
|
|
|
|
|
|
|
# |
3110
|
|
|
|
|
|
|
# ShiftJIS file test -S expr |
3111
|
|
|
|
|
|
|
# |
3112
|
|
|
|
|
|
|
sub Esjis::S(;*@) { |
3113
|
|
|
|
|
|
|
|
3114
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3115
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -S (Esjis::S)' if @_ and not wantarray; |
3116
|
|
|
|
|
|
|
|
3117
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3118
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3119
|
|
|
|
|
|
|
} |
3120
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3121
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S $fh,@_) : -S $fh; |
3122
|
|
|
|
|
|
|
} |
3123
|
|
|
|
|
|
|
elsif (-e $_) { |
3124
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3125
|
|
|
|
|
|
|
} |
3126
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3127
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3128
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3129
|
|
|
|
|
|
|
} |
3130
|
|
|
|
|
|
|
else { |
3131
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3132
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3133
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3134
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3135
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($S,@_) : $S; |
3136
|
|
|
|
|
|
|
} |
3137
|
|
|
|
|
|
|
} |
3138
|
|
|
|
|
|
|
} |
3139
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3140
|
|
|
|
|
|
|
} |
3141
|
|
|
|
|
|
|
|
3142
|
|
|
|
|
|
|
# |
3143
|
|
|
|
|
|
|
# ShiftJIS file test -b expr |
3144
|
|
|
|
|
|
|
# |
3145
|
|
|
|
|
|
|
sub Esjis::b(;*@) { |
3146
|
|
|
|
|
|
|
|
3147
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3148
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -b (Esjis::b)' if @_ and not wantarray; |
3149
|
|
|
|
|
|
|
|
3150
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3151
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3152
|
|
|
|
|
|
|
} |
3153
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3154
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b $fh,@_) : -b $fh; |
3155
|
|
|
|
|
|
|
} |
3156
|
|
|
|
|
|
|
elsif (-e $_) { |
3157
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3158
|
|
|
|
|
|
|
} |
3159
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3160
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3161
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3162
|
|
|
|
|
|
|
} |
3163
|
|
|
|
|
|
|
else { |
3164
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3165
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3166
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
3167
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3168
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($b,@_) : $b; |
3169
|
|
|
|
|
|
|
} |
3170
|
|
|
|
|
|
|
} |
3171
|
|
|
|
|
|
|
} |
3172
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3173
|
|
|
|
|
|
|
} |
3174
|
|
|
|
|
|
|
|
3175
|
|
|
|
|
|
|
# |
3176
|
|
|
|
|
|
|
# ShiftJIS file test -c expr |
3177
|
|
|
|
|
|
|
# |
3178
|
|
|
|
|
|
|
sub Esjis::c(;*@) { |
3179
|
|
|
|
|
|
|
|
3180
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3181
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -c (Esjis::c)' if @_ and not wantarray; |
3182
|
|
|
|
|
|
|
|
3183
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3184
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3185
|
|
|
|
|
|
|
} |
3186
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3187
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c $fh,@_) : -c $fh; |
3188
|
|
|
|
|
|
|
} |
3189
|
|
|
|
|
|
|
elsif (-e $_) { |
3190
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3191
|
|
|
|
|
|
|
} |
3192
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3193
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3194
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3195
|
|
|
|
|
|
|
} |
3196
|
|
|
|
|
|
|
else { |
3197
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3198
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3199
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
3200
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3201
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($c,@_) : $c; |
3202
|
|
|
|
|
|
|
} |
3203
|
|
|
|
|
|
|
} |
3204
|
|
|
|
|
|
|
} |
3205
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3206
|
|
|
|
|
|
|
} |
3207
|
|
|
|
|
|
|
|
3208
|
|
|
|
|
|
|
# |
3209
|
|
|
|
|
|
|
# ShiftJIS file test -u expr |
3210
|
|
|
|
|
|
|
# |
3211
|
|
|
|
|
|
|
sub Esjis::u(;*@) { |
3212
|
|
|
|
|
|
|
|
3213
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3214
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -u (Esjis::u)' if @_ and not wantarray; |
3215
|
|
|
|
|
|
|
|
3216
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3217
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3218
|
|
|
|
|
|
|
} |
3219
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3220
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u $fh,@_) : -u $fh; |
3221
|
|
|
|
|
|
|
} |
3222
|
|
|
|
|
|
|
elsif (-e $_) { |
3223
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3224
|
|
|
|
|
|
|
} |
3225
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3226
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3227
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3228
|
|
|
|
|
|
|
} |
3229
|
|
|
|
|
|
|
else { |
3230
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3231
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3232
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
3233
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3234
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($u,@_) : $u; |
3235
|
|
|
|
|
|
|
} |
3236
|
|
|
|
|
|
|
} |
3237
|
|
|
|
|
|
|
} |
3238
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3239
|
|
|
|
|
|
|
} |
3240
|
|
|
|
|
|
|
|
3241
|
|
|
|
|
|
|
# |
3242
|
|
|
|
|
|
|
# ShiftJIS file test -g expr |
3243
|
|
|
|
|
|
|
# |
3244
|
|
|
|
|
|
|
sub Esjis::g(;*@) { |
3245
|
|
|
|
|
|
|
|
3246
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3247
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -g (Esjis::g)' if @_ and not wantarray; |
3248
|
|
|
|
|
|
|
|
3249
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3250
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3251
|
|
|
|
|
|
|
} |
3252
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3253
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g $fh,@_) : -g $fh; |
3254
|
|
|
|
|
|
|
} |
3255
|
|
|
|
|
|
|
elsif (-e $_) { |
3256
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3257
|
|
|
|
|
|
|
} |
3258
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3259
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3260
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3261
|
|
|
|
|
|
|
} |
3262
|
|
|
|
|
|
|
else { |
3263
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3264
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3265
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
3266
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3267
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($g,@_) : $g; |
3268
|
|
|
|
|
|
|
} |
3269
|
|
|
|
|
|
|
} |
3270
|
|
|
|
|
|
|
} |
3271
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3272
|
|
|
|
|
|
|
} |
3273
|
|
|
|
|
|
|
|
3274
|
|
|
|
|
|
|
# |
3275
|
|
|
|
|
|
|
# ShiftJIS file test -k expr |
3276
|
|
|
|
|
|
|
# |
3277
|
|
|
|
|
|
|
sub Esjis::k(;*@) { |
3278
|
|
|
|
|
|
|
|
3279
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3280
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -k (Esjis::k)' if @_ and not wantarray; |
3281
|
|
|
|
|
|
|
|
3282
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3283
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3284
|
|
|
|
|
|
|
} |
3285
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3286
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3287
|
|
|
|
|
|
|
} |
3288
|
|
|
|
|
|
|
elsif ($] =~ /^5\.008/oxms) { |
3289
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3290
|
|
|
|
|
|
|
} |
3291
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
3292
|
|
|
|
|
|
|
} |
3293
|
|
|
|
|
|
|
|
3294
|
|
|
|
|
|
|
# |
3295
|
|
|
|
|
|
|
# ShiftJIS file test -T expr |
3296
|
|
|
|
|
|
|
# |
3297
|
|
|
|
|
|
|
sub Esjis::T(;*@) { |
3298
|
|
|
|
|
|
|
|
3299
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3300
|
|
|
|
|
|
|
|
3301
|
|
|
|
|
|
|
# Use of croak without parentheses makes die on Strawberry Perl 5.008 and 5.010, like: |
3302
|
|
|
|
|
|
|
# croak 'Too many arguments for -T (Esjis::T)'; |
3303
|
|
|
|
|
|
|
# Must be used by parentheses like: |
3304
|
|
|
|
|
|
|
# croak('Too many arguments for -T (Esjis::T)'); |
3305
|
|
|
|
|
|
|
|
3306
|
0
|
0
|
0
|
|
|
0
|
if (@_ and not wantarray) { |
3307
|
0
|
|
|
|
|
0
|
croak('Too many arguments for -T (Esjis::T)'); |
3308
|
|
|
|
|
|
|
} |
3309
|
|
|
|
|
|
|
|
3310
|
0
|
|
|
|
|
0
|
my $T = 1; |
3311
|
|
|
|
|
|
|
|
3312
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3313
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3314
|
|
|
|
|
|
|
|
3315
|
0
|
0
|
|
|
|
0
|
if (defined Esjis::telldir($fh)) { |
3316
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3317
|
|
|
|
|
|
|
} |
3318
|
|
|
|
|
|
|
|
3319
|
|
|
|
|
|
|
# P.813 29.2.176. tell |
3320
|
|
|
|
|
|
|
# in Chapter 29: Functions |
3321
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
3322
|
|
|
|
|
|
|
|
3323
|
|
|
|
|
|
|
# P.970 tell |
3324
|
|
|
|
|
|
|
# in Chapter 27: Functions |
3325
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3326
|
|
|
|
|
|
|
|
3327
|
|
|
|
|
|
|
# (and so on) |
3328
|
|
|
|
|
|
|
|
3329
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3330
|
|
|
|
|
|
|
|
3331
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3332
|
|
|
|
|
|
|
|
3333
|
|
|
|
|
|
|
# P.163 Binary file check in Little Perl Parlor 16 |
3334
|
|
|
|
|
|
|
# of Book No. T1008901080816 ZASSHI 08901-8 UNIX MAGAZINE 1993 Aug VOL8#8 |
3335
|
|
|
|
|
|
|
# (and so on) |
3336
|
|
|
|
|
|
|
|
3337
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3338
|
0
|
|
|
|
|
0
|
$T = ''; |
3339
|
|
|
|
|
|
|
} |
3340
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3341
|
0
|
|
|
|
|
0
|
$T = ''; |
3342
|
|
|
|
|
|
|
} |
3343
|
|
|
|
|
|
|
} |
3344
|
|
|
|
|
|
|
|
3345
|
|
|
|
|
|
|
# 0 byte or eof |
3346
|
|
|
|
|
|
|
else { |
3347
|
0
|
|
|
|
|
0
|
$T = 1; |
3348
|
|
|
|
|
|
|
} |
3349
|
|
|
|
|
|
|
|
3350
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3351
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3352
|
|
|
|
|
|
|
} |
3353
|
|
|
|
|
|
|
else { |
3354
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3355
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3356
|
|
|
|
|
|
|
} |
3357
|
|
|
|
|
|
|
|
3358
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3359
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3360
|
|
|
|
|
|
|
} |
3361
|
|
|
|
|
|
|
else { |
3362
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3363
|
|
|
|
|
|
|
} |
3364
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3365
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3366
|
0
|
|
|
|
|
0
|
$T = ''; |
3367
|
|
|
|
|
|
|
} |
3368
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3369
|
0
|
|
|
|
|
0
|
$T = ''; |
3370
|
|
|
|
|
|
|
} |
3371
|
|
|
|
|
|
|
} |
3372
|
|
|
|
|
|
|
|
3373
|
|
|
|
|
|
|
# 0 byte or eof |
3374
|
|
|
|
|
|
|
else { |
3375
|
0
|
|
|
|
|
0
|
$T = 1; |
3376
|
|
|
|
|
|
|
} |
3377
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3378
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3379
|
|
|
|
|
|
|
} |
3380
|
|
|
|
|
|
|
|
3381
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($T,@_) : $T; |
3382
|
|
|
|
|
|
|
} |
3383
|
|
|
|
|
|
|
|
3384
|
|
|
|
|
|
|
# |
3385
|
|
|
|
|
|
|
# ShiftJIS file test -B expr |
3386
|
|
|
|
|
|
|
# |
3387
|
|
|
|
|
|
|
sub Esjis::B(;*@) { |
3388
|
|
|
|
|
|
|
|
3389
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3390
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -B (Esjis::B)' if @_ and not wantarray; |
3391
|
0
|
|
|
|
|
0
|
my $B = ''; |
3392
|
|
|
|
|
|
|
|
3393
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3394
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3395
|
|
|
|
|
|
|
|
3396
|
0
|
0
|
|
|
|
0
|
if (defined Esjis::telldir($fh)) { |
3397
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3398
|
|
|
|
|
|
|
} |
3399
|
|
|
|
|
|
|
|
3400
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3401
|
|
|
|
|
|
|
|
3402
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3403
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3404
|
0
|
|
|
|
|
0
|
$B = 1; |
3405
|
|
|
|
|
|
|
} |
3406
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3407
|
0
|
|
|
|
|
0
|
$B = 1; |
3408
|
|
|
|
|
|
|
} |
3409
|
|
|
|
|
|
|
} |
3410
|
|
|
|
|
|
|
|
3411
|
|
|
|
|
|
|
# 0 byte or eof |
3412
|
|
|
|
|
|
|
else { |
3413
|
0
|
|
|
|
|
0
|
$B = 1; |
3414
|
|
|
|
|
|
|
} |
3415
|
|
|
|
|
|
|
|
3416
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3417
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3418
|
|
|
|
|
|
|
} |
3419
|
|
|
|
|
|
|
else { |
3420
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3421
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3422
|
|
|
|
|
|
|
} |
3423
|
|
|
|
|
|
|
|
3424
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3425
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3426
|
|
|
|
|
|
|
} |
3427
|
|
|
|
|
|
|
else { |
3428
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3429
|
|
|
|
|
|
|
} |
3430
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3431
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3432
|
0
|
|
|
|
|
0
|
$B = 1; |
3433
|
|
|
|
|
|
|
} |
3434
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3435
|
0
|
|
|
|
|
0
|
$B = 1; |
3436
|
|
|
|
|
|
|
} |
3437
|
|
|
|
|
|
|
} |
3438
|
|
|
|
|
|
|
|
3439
|
|
|
|
|
|
|
# 0 byte or eof |
3440
|
|
|
|
|
|
|
else { |
3441
|
0
|
|
|
|
|
0
|
$B = 1; |
3442
|
|
|
|
|
|
|
} |
3443
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3444
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3445
|
|
|
|
|
|
|
} |
3446
|
|
|
|
|
|
|
|
3447
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($B,@_) : $B; |
3448
|
|
|
|
|
|
|
} |
3449
|
|
|
|
|
|
|
|
3450
|
|
|
|
|
|
|
# |
3451
|
|
|
|
|
|
|
# ShiftJIS file test -M expr |
3452
|
|
|
|
|
|
|
# |
3453
|
|
|
|
|
|
|
sub Esjis::M(;*@) { |
3454
|
|
|
|
|
|
|
|
3455
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3456
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -M (Esjis::M)' if @_ and not wantarray; |
3457
|
|
|
|
|
|
|
|
3458
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3459
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3460
|
|
|
|
|
|
|
} |
3461
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3462
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M $fh,@_) : -M $fh; |
3463
|
|
|
|
|
|
|
} |
3464
|
|
|
|
|
|
|
elsif (-e $_) { |
3465
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3466
|
|
|
|
|
|
|
} |
3467
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3468
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3469
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3470
|
|
|
|
|
|
|
} |
3471
|
|
|
|
|
|
|
else { |
3472
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3473
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3474
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3475
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3476
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
3477
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($M,@_) : $M; |
3478
|
|
|
|
|
|
|
} |
3479
|
|
|
|
|
|
|
} |
3480
|
|
|
|
|
|
|
} |
3481
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3482
|
|
|
|
|
|
|
} |
3483
|
|
|
|
|
|
|
|
3484
|
|
|
|
|
|
|
# |
3485
|
|
|
|
|
|
|
# ShiftJIS file test -A expr |
3486
|
|
|
|
|
|
|
# |
3487
|
|
|
|
|
|
|
sub Esjis::A(;*@) { |
3488
|
|
|
|
|
|
|
|
3489
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3490
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -A (Esjis::A)' if @_ and not wantarray; |
3491
|
|
|
|
|
|
|
|
3492
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3493
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3494
|
|
|
|
|
|
|
} |
3495
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3496
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A $fh,@_) : -A $fh; |
3497
|
|
|
|
|
|
|
} |
3498
|
|
|
|
|
|
|
elsif (-e $_) { |
3499
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3500
|
|
|
|
|
|
|
} |
3501
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3502
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3503
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3504
|
|
|
|
|
|
|
} |
3505
|
|
|
|
|
|
|
else { |
3506
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3507
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3508
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3509
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3510
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
3511
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($A,@_) : $A; |
3512
|
|
|
|
|
|
|
} |
3513
|
|
|
|
|
|
|
} |
3514
|
|
|
|
|
|
|
} |
3515
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3516
|
|
|
|
|
|
|
} |
3517
|
|
|
|
|
|
|
|
3518
|
|
|
|
|
|
|
# |
3519
|
|
|
|
|
|
|
# ShiftJIS file test -C expr |
3520
|
|
|
|
|
|
|
# |
3521
|
|
|
|
|
|
|
sub Esjis::C(;*@) { |
3522
|
|
|
|
|
|
|
|
3523
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3524
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -C (Esjis::C)' if @_ and not wantarray; |
3525
|
|
|
|
|
|
|
|
3526
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3527
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3528
|
|
|
|
|
|
|
} |
3529
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3530
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C $fh,@_) : -C $fh; |
3531
|
|
|
|
|
|
|
} |
3532
|
|
|
|
|
|
|
elsif (-e $_) { |
3533
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3534
|
|
|
|
|
|
|
} |
3535
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3536
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3537
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3538
|
|
|
|
|
|
|
} |
3539
|
|
|
|
|
|
|
else { |
3540
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3541
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3542
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3543
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3544
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
3545
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($C,@_) : $C; |
3546
|
|
|
|
|
|
|
} |
3547
|
|
|
|
|
|
|
} |
3548
|
|
|
|
|
|
|
} |
3549
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3550
|
|
|
|
|
|
|
} |
3551
|
|
|
|
|
|
|
|
3552
|
|
|
|
|
|
|
# |
3553
|
|
|
|
|
|
|
# ShiftJIS stacked file test $_ |
3554
|
|
|
|
|
|
|
# |
3555
|
|
|
|
|
|
|
sub Esjis::filetest_ { |
3556
|
|
|
|
|
|
|
|
3557
|
0
|
|
|
0
|
0
|
0
|
my $filetest = substr(pop @_, 1); |
3558
|
|
|
|
|
|
|
|
3559
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Esjis::${filetest}_}) { |
3560
|
0
|
|
|
|
|
0
|
return ''; |
3561
|
|
|
|
|
|
|
} |
3562
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
3563
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
3564
|
0
|
|
|
|
|
0
|
return ''; |
3565
|
|
|
|
|
|
|
} |
3566
|
|
|
|
|
|
|
} |
3567
|
0
|
|
|
|
|
0
|
return 1; |
3568
|
|
|
|
|
|
|
} |
3569
|
|
|
|
|
|
|
|
3570
|
|
|
|
|
|
|
# |
3571
|
|
|
|
|
|
|
# ShiftJIS file test -r $_ |
3572
|
|
|
|
|
|
|
# |
3573
|
|
|
|
|
|
|
sub Esjis::r_() { |
3574
|
|
|
|
|
|
|
|
3575
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3576
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3577
|
|
|
|
|
|
|
} |
3578
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3579
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3580
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3581
|
|
|
|
|
|
|
} |
3582
|
|
|
|
|
|
|
else { |
3583
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3584
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3585
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
3586
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3587
|
0
|
0
|
|
|
|
0
|
return $r ? 1 : ''; |
3588
|
|
|
|
|
|
|
} |
3589
|
|
|
|
|
|
|
} |
3590
|
|
|
|
|
|
|
} |
3591
|
|
|
|
|
|
|
|
3592
|
|
|
|
|
|
|
# 10.10. Returning Failure |
3593
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
3594
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
3595
|
|
|
|
|
|
|
# (and so on) |
3596
|
|
|
|
|
|
|
|
3597
|
|
|
|
|
|
|
# 2010-01-26 The difference of "return;" and "return undef;" |
3598
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20100126/1264474754 |
3599
|
|
|
|
|
|
|
# |
3600
|
|
|
|
|
|
|
# "Perl Best Practices" recommends to use "return;"*1 to return nothing, but |
3601
|
|
|
|
|
|
|
# it might be wrong in some cases. If you use this idiom for those functions |
3602
|
|
|
|
|
|
|
# which are expected to return a scalar value, e.g. searching functions, the |
3603
|
|
|
|
|
|
|
# user of those functions will be surprised at what they return in list |
3604
|
|
|
|
|
|
|
# context, an empty list - note that many functions and all the methods |
3605
|
|
|
|
|
|
|
# evaluate their arguments in list context. You'd better to use "return undef;" |
3606
|
|
|
|
|
|
|
# for such scalar functions. |
3607
|
|
|
|
|
|
|
# |
3608
|
|
|
|
|
|
|
# sub search_something { |
3609
|
|
|
|
|
|
|
# my($arg) = @_; |
3610
|
|
|
|
|
|
|
# # search_something... |
3611
|
|
|
|
|
|
|
# if(defined $found){ |
3612
|
|
|
|
|
|
|
# return $found; |
3613
|
|
|
|
|
|
|
# } |
3614
|
|
|
|
|
|
|
# return; # XXX: you'd better to "return undef;" |
3615
|
|
|
|
|
|
|
# } |
3616
|
|
|
|
|
|
|
# |
3617
|
|
|
|
|
|
|
# # ... |
3618
|
|
|
|
|
|
|
# |
3619
|
|
|
|
|
|
|
# # you'll get what you want, but ... |
3620
|
|
|
|
|
|
|
# my $something = search_something($source); |
3621
|
|
|
|
|
|
|
# |
3622
|
|
|
|
|
|
|
# # you won't get what you want here. |
3623
|
|
|
|
|
|
|
# # @_ for doit() is (-foo => $opt), not (undef, -foo => $opt). |
3624
|
|
|
|
|
|
|
# $obj->doit(search_something($source), -option=> $optval); |
3625
|
|
|
|
|
|
|
# |
3626
|
|
|
|
|
|
|
# # you have to use the "scalar" operator in such a case. |
3627
|
|
|
|
|
|
|
# $obj->doit(scalar search_something($source), ...); |
3628
|
|
|
|
|
|
|
# |
3629
|
|
|
|
|
|
|
# *1: it returns an empty list in list context, or returns undef in scalar |
3630
|
|
|
|
|
|
|
# context |
3631
|
|
|
|
|
|
|
# |
3632
|
|
|
|
|
|
|
# (and so on) |
3633
|
|
|
|
|
|
|
|
3634
|
0
|
|
|
|
|
0
|
return undef; |
3635
|
|
|
|
|
|
|
} |
3636
|
|
|
|
|
|
|
|
3637
|
|
|
|
|
|
|
# |
3638
|
|
|
|
|
|
|
# ShiftJIS file test -w $_ |
3639
|
|
|
|
|
|
|
# |
3640
|
|
|
|
|
|
|
sub Esjis::w_() { |
3641
|
|
|
|
|
|
|
|
3642
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3643
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3644
|
|
|
|
|
|
|
} |
3645
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3646
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3647
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3648
|
|
|
|
|
|
|
} |
3649
|
|
|
|
|
|
|
else { |
3650
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3651
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3652
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
3653
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3654
|
0
|
0
|
|
|
|
0
|
return $w ? 1 : ''; |
3655
|
|
|
|
|
|
|
} |
3656
|
|
|
|
|
|
|
} |
3657
|
|
|
|
|
|
|
} |
3658
|
0
|
|
|
|
|
0
|
return undef; |
3659
|
|
|
|
|
|
|
} |
3660
|
|
|
|
|
|
|
|
3661
|
|
|
|
|
|
|
# |
3662
|
|
|
|
|
|
|
# ShiftJIS file test -x $_ |
3663
|
|
|
|
|
|
|
# |
3664
|
|
|
|
|
|
|
sub Esjis::x_() { |
3665
|
|
|
|
|
|
|
|
3666
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3667
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3668
|
|
|
|
|
|
|
} |
3669
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3670
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3671
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3672
|
|
|
|
|
|
|
} |
3673
|
|
|
|
|
|
|
else { |
3674
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3675
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3676
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
3677
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3678
|
|
|
|
|
|
|
} |
3679
|
|
|
|
|
|
|
|
3680
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3681
|
0
|
|
|
|
|
0
|
return ''; |
3682
|
|
|
|
|
|
|
} |
3683
|
|
|
|
|
|
|
} |
3684
|
0
|
|
|
|
|
0
|
return undef; |
3685
|
|
|
|
|
|
|
} |
3686
|
|
|
|
|
|
|
|
3687
|
|
|
|
|
|
|
# |
3688
|
|
|
|
|
|
|
# ShiftJIS file test -o $_ |
3689
|
|
|
|
|
|
|
# |
3690
|
|
|
|
|
|
|
sub Esjis::o_() { |
3691
|
|
|
|
|
|
|
|
3692
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3693
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3694
|
|
|
|
|
|
|
} |
3695
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3696
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3697
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3698
|
|
|
|
|
|
|
} |
3699
|
|
|
|
|
|
|
else { |
3700
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3701
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3702
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
3703
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3704
|
0
|
0
|
|
|
|
0
|
return $o ? 1 : ''; |
3705
|
|
|
|
|
|
|
} |
3706
|
|
|
|
|
|
|
} |
3707
|
|
|
|
|
|
|
} |
3708
|
0
|
|
|
|
|
0
|
return undef; |
3709
|
|
|
|
|
|
|
} |
3710
|
|
|
|
|
|
|
|
3711
|
|
|
|
|
|
|
# |
3712
|
|
|
|
|
|
|
# ShiftJIS file test -R $_ |
3713
|
|
|
|
|
|
|
# |
3714
|
|
|
|
|
|
|
sub Esjis::R_() { |
3715
|
|
|
|
|
|
|
|
3716
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3717
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3718
|
|
|
|
|
|
|
} |
3719
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3720
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3721
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3722
|
|
|
|
|
|
|
} |
3723
|
|
|
|
|
|
|
else { |
3724
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3725
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3726
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
3727
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3728
|
0
|
0
|
|
|
|
0
|
return $R ? 1 : ''; |
3729
|
|
|
|
|
|
|
} |
3730
|
|
|
|
|
|
|
} |
3731
|
|
|
|
|
|
|
} |
3732
|
0
|
|
|
|
|
0
|
return undef; |
3733
|
|
|
|
|
|
|
} |
3734
|
|
|
|
|
|
|
|
3735
|
|
|
|
|
|
|
# |
3736
|
|
|
|
|
|
|
# ShiftJIS file test -W $_ |
3737
|
|
|
|
|
|
|
# |
3738
|
|
|
|
|
|
|
sub Esjis::W_() { |
3739
|
|
|
|
|
|
|
|
3740
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3741
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3742
|
|
|
|
|
|
|
} |
3743
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3744
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3745
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3746
|
|
|
|
|
|
|
} |
3747
|
|
|
|
|
|
|
else { |
3748
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3749
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3750
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
3751
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3752
|
0
|
0
|
|
|
|
0
|
return $W ? 1 : ''; |
3753
|
|
|
|
|
|
|
} |
3754
|
|
|
|
|
|
|
} |
3755
|
|
|
|
|
|
|
} |
3756
|
0
|
|
|
|
|
0
|
return undef; |
3757
|
|
|
|
|
|
|
} |
3758
|
|
|
|
|
|
|
|
3759
|
|
|
|
|
|
|
# |
3760
|
|
|
|
|
|
|
# ShiftJIS file test -X $_ |
3761
|
|
|
|
|
|
|
# |
3762
|
|
|
|
|
|
|
sub Esjis::X_() { |
3763
|
|
|
|
|
|
|
|
3764
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3765
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3766
|
|
|
|
|
|
|
} |
3767
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3768
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3769
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3770
|
|
|
|
|
|
|
} |
3771
|
|
|
|
|
|
|
else { |
3772
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3773
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3774
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
3775
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3776
|
|
|
|
|
|
|
} |
3777
|
|
|
|
|
|
|
|
3778
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3779
|
0
|
|
|
|
|
0
|
return ''; |
3780
|
|
|
|
|
|
|
} |
3781
|
|
|
|
|
|
|
} |
3782
|
0
|
|
|
|
|
0
|
return undef; |
3783
|
|
|
|
|
|
|
} |
3784
|
|
|
|
|
|
|
|
3785
|
|
|
|
|
|
|
# |
3786
|
|
|
|
|
|
|
# ShiftJIS file test -O $_ |
3787
|
|
|
|
|
|
|
# |
3788
|
|
|
|
|
|
|
sub Esjis::O_() { |
3789
|
|
|
|
|
|
|
|
3790
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3791
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3792
|
|
|
|
|
|
|
} |
3793
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3794
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3795
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3796
|
|
|
|
|
|
|
} |
3797
|
|
|
|
|
|
|
else { |
3798
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3799
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3800
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
3801
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3802
|
0
|
0
|
|
|
|
0
|
return $O ? 1 : ''; |
3803
|
|
|
|
|
|
|
} |
3804
|
|
|
|
|
|
|
} |
3805
|
|
|
|
|
|
|
} |
3806
|
0
|
|
|
|
|
0
|
return undef; |
3807
|
|
|
|
|
|
|
} |
3808
|
|
|
|
|
|
|
|
3809
|
|
|
|
|
|
|
# |
3810
|
|
|
|
|
|
|
# ShiftJIS file test -e $_ |
3811
|
|
|
|
|
|
|
# |
3812
|
|
|
|
|
|
|
sub Esjis::e_() { |
3813
|
|
|
|
|
|
|
|
3814
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3815
|
0
|
|
|
|
|
0
|
return 1; |
3816
|
|
|
|
|
|
|
} |
3817
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3818
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3819
|
0
|
|
|
|
|
0
|
return 1; |
3820
|
|
|
|
|
|
|
} |
3821
|
|
|
|
|
|
|
else { |
3822
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3823
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3824
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
3825
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3826
|
0
|
0
|
|
|
|
0
|
return $e ? 1 : ''; |
3827
|
|
|
|
|
|
|
} |
3828
|
|
|
|
|
|
|
} |
3829
|
|
|
|
|
|
|
} |
3830
|
0
|
|
|
|
|
0
|
return undef; |
3831
|
|
|
|
|
|
|
} |
3832
|
|
|
|
|
|
|
|
3833
|
|
|
|
|
|
|
# |
3834
|
|
|
|
|
|
|
# ShiftJIS file test -z $_ |
3835
|
|
|
|
|
|
|
# |
3836
|
|
|
|
|
|
|
sub Esjis::z_() { |
3837
|
|
|
|
|
|
|
|
3838
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3839
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3840
|
|
|
|
|
|
|
} |
3841
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3842
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3843
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3844
|
|
|
|
|
|
|
} |
3845
|
|
|
|
|
|
|
else { |
3846
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3847
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3848
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
3849
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3850
|
0
|
0
|
|
|
|
0
|
return $z ? 1 : ''; |
3851
|
|
|
|
|
|
|
} |
3852
|
|
|
|
|
|
|
} |
3853
|
|
|
|
|
|
|
} |
3854
|
0
|
|
|
|
|
0
|
return undef; |
3855
|
|
|
|
|
|
|
} |
3856
|
|
|
|
|
|
|
|
3857
|
|
|
|
|
|
|
# |
3858
|
|
|
|
|
|
|
# ShiftJIS file test -s $_ |
3859
|
|
|
|
|
|
|
# |
3860
|
|
|
|
|
|
|
sub Esjis::s_() { |
3861
|
|
|
|
|
|
|
|
3862
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3863
|
0
|
|
|
|
|
0
|
return -s _; |
3864
|
|
|
|
|
|
|
} |
3865
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3866
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3867
|
0
|
|
|
|
|
0
|
return -s _; |
3868
|
|
|
|
|
|
|
} |
3869
|
|
|
|
|
|
|
else { |
3870
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3871
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3872
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
3873
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3874
|
0
|
|
|
|
|
0
|
return $s; |
3875
|
|
|
|
|
|
|
} |
3876
|
|
|
|
|
|
|
} |
3877
|
|
|
|
|
|
|
} |
3878
|
0
|
|
|
|
|
0
|
return undef; |
3879
|
|
|
|
|
|
|
} |
3880
|
|
|
|
|
|
|
|
3881
|
|
|
|
|
|
|
# |
3882
|
|
|
|
|
|
|
# ShiftJIS file test -f $_ |
3883
|
|
|
|
|
|
|
# |
3884
|
|
|
|
|
|
|
sub Esjis::f_() { |
3885
|
|
|
|
|
|
|
|
3886
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3887
|
0
|
0
|
|
|
|
0
|
return -f _ ? 1 : ''; |
3888
|
|
|
|
|
|
|
} |
3889
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3890
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3891
|
0
|
|
|
|
|
0
|
return ''; |
3892
|
|
|
|
|
|
|
} |
3893
|
|
|
|
|
|
|
else { |
3894
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3895
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3896
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3897
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3898
|
0
|
0
|
|
|
|
0
|
return $f ? 1 : ''; |
3899
|
|
|
|
|
|
|
} |
3900
|
|
|
|
|
|
|
} |
3901
|
|
|
|
|
|
|
} |
3902
|
0
|
|
|
|
|
0
|
return undef; |
3903
|
|
|
|
|
|
|
} |
3904
|
|
|
|
|
|
|
|
3905
|
|
|
|
|
|
|
# |
3906
|
|
|
|
|
|
|
# ShiftJIS file test -d $_ |
3907
|
|
|
|
|
|
|
# |
3908
|
|
|
|
|
|
|
sub Esjis::d_() { |
3909
|
|
|
|
|
|
|
|
3910
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3911
|
0
|
0
|
|
|
|
0
|
return -d _ ? 1 : ''; |
3912
|
|
|
|
|
|
|
} |
3913
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3914
|
0
|
0
|
|
|
|
0
|
return -d "$_/." ? 1 : ''; |
3915
|
|
|
|
|
|
|
} |
3916
|
0
|
|
|
|
|
0
|
return undef; |
3917
|
|
|
|
|
|
|
} |
3918
|
|
|
|
|
|
|
|
3919
|
|
|
|
|
|
|
# |
3920
|
|
|
|
|
|
|
# ShiftJIS file test -l $_ |
3921
|
|
|
|
|
|
|
# |
3922
|
|
|
|
|
|
|
sub Esjis::l_() { |
3923
|
|
|
|
|
|
|
|
3924
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3925
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3926
|
|
|
|
|
|
|
} |
3927
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3928
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3929
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3930
|
|
|
|
|
|
|
} |
3931
|
|
|
|
|
|
|
else { |
3932
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3933
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3934
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3935
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3936
|
0
|
0
|
|
|
|
0
|
return $l ? 1 : ''; |
3937
|
|
|
|
|
|
|
} |
3938
|
|
|
|
|
|
|
} |
3939
|
|
|
|
|
|
|
} |
3940
|
0
|
|
|
|
|
0
|
return undef; |
3941
|
|
|
|
|
|
|
} |
3942
|
|
|
|
|
|
|
|
3943
|
|
|
|
|
|
|
# |
3944
|
|
|
|
|
|
|
# ShiftJIS file test -p $_ |
3945
|
|
|
|
|
|
|
# |
3946
|
|
|
|
|
|
|
sub Esjis::p_() { |
3947
|
|
|
|
|
|
|
|
3948
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3949
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3950
|
|
|
|
|
|
|
} |
3951
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3952
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3953
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3954
|
|
|
|
|
|
|
} |
3955
|
|
|
|
|
|
|
else { |
3956
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3957
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3958
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3959
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3960
|
0
|
0
|
|
|
|
0
|
return $p ? 1 : ''; |
3961
|
|
|
|
|
|
|
} |
3962
|
|
|
|
|
|
|
} |
3963
|
|
|
|
|
|
|
} |
3964
|
0
|
|
|
|
|
0
|
return undef; |
3965
|
|
|
|
|
|
|
} |
3966
|
|
|
|
|
|
|
|
3967
|
|
|
|
|
|
|
# |
3968
|
|
|
|
|
|
|
# ShiftJIS file test -S $_ |
3969
|
|
|
|
|
|
|
# |
3970
|
|
|
|
|
|
|
sub Esjis::S_() { |
3971
|
|
|
|
|
|
|
|
3972
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3973
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3974
|
|
|
|
|
|
|
} |
3975
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3976
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3977
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3978
|
|
|
|
|
|
|
} |
3979
|
|
|
|
|
|
|
else { |
3980
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3981
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3982
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3983
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3984
|
0
|
0
|
|
|
|
0
|
return $S ? 1 : ''; |
3985
|
|
|
|
|
|
|
} |
3986
|
|
|
|
|
|
|
} |
3987
|
|
|
|
|
|
|
} |
3988
|
0
|
|
|
|
|
0
|
return undef; |
3989
|
|
|
|
|
|
|
} |
3990
|
|
|
|
|
|
|
|
3991
|
|
|
|
|
|
|
# |
3992
|
|
|
|
|
|
|
# ShiftJIS file test -b $_ |
3993
|
|
|
|
|
|
|
# |
3994
|
|
|
|
|
|
|
sub Esjis::b_() { |
3995
|
|
|
|
|
|
|
|
3996
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3997
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
3998
|
|
|
|
|
|
|
} |
3999
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4000
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4001
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
4002
|
|
|
|
|
|
|
} |
4003
|
|
|
|
|
|
|
else { |
4004
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4005
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4006
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
4007
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4008
|
0
|
0
|
|
|
|
0
|
return $b ? 1 : ''; |
4009
|
|
|
|
|
|
|
} |
4010
|
|
|
|
|
|
|
} |
4011
|
|
|
|
|
|
|
} |
4012
|
0
|
|
|
|
|
0
|
return undef; |
4013
|
|
|
|
|
|
|
} |
4014
|
|
|
|
|
|
|
|
4015
|
|
|
|
|
|
|
# |
4016
|
|
|
|
|
|
|
# ShiftJIS file test -c $_ |
4017
|
|
|
|
|
|
|
# |
4018
|
|
|
|
|
|
|
sub Esjis::c_() { |
4019
|
|
|
|
|
|
|
|
4020
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4021
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4022
|
|
|
|
|
|
|
} |
4023
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4024
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4025
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4026
|
|
|
|
|
|
|
} |
4027
|
|
|
|
|
|
|
else { |
4028
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4029
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4030
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
4031
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4032
|
0
|
0
|
|
|
|
0
|
return $c ? 1 : ''; |
4033
|
|
|
|
|
|
|
} |
4034
|
|
|
|
|
|
|
} |
4035
|
|
|
|
|
|
|
} |
4036
|
0
|
|
|
|
|
0
|
return undef; |
4037
|
|
|
|
|
|
|
} |
4038
|
|
|
|
|
|
|
|
4039
|
|
|
|
|
|
|
# |
4040
|
|
|
|
|
|
|
# ShiftJIS file test -u $_ |
4041
|
|
|
|
|
|
|
# |
4042
|
|
|
|
|
|
|
sub Esjis::u_() { |
4043
|
|
|
|
|
|
|
|
4044
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4045
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4046
|
|
|
|
|
|
|
} |
4047
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4048
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4049
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4050
|
|
|
|
|
|
|
} |
4051
|
|
|
|
|
|
|
else { |
4052
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4053
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4054
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
4055
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4056
|
0
|
0
|
|
|
|
0
|
return $u ? 1 : ''; |
4057
|
|
|
|
|
|
|
} |
4058
|
|
|
|
|
|
|
} |
4059
|
|
|
|
|
|
|
} |
4060
|
0
|
|
|
|
|
0
|
return undef; |
4061
|
|
|
|
|
|
|
} |
4062
|
|
|
|
|
|
|
|
4063
|
|
|
|
|
|
|
# |
4064
|
|
|
|
|
|
|
# ShiftJIS file test -g $_ |
4065
|
|
|
|
|
|
|
# |
4066
|
|
|
|
|
|
|
sub Esjis::g_() { |
4067
|
|
|
|
|
|
|
|
4068
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4069
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4070
|
|
|
|
|
|
|
} |
4071
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4072
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4073
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4074
|
|
|
|
|
|
|
} |
4075
|
|
|
|
|
|
|
else { |
4076
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4077
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4078
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
4079
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4080
|
0
|
0
|
|
|
|
0
|
return $g ? 1 : ''; |
4081
|
|
|
|
|
|
|
} |
4082
|
|
|
|
|
|
|
} |
4083
|
|
|
|
|
|
|
} |
4084
|
0
|
|
|
|
|
0
|
return undef; |
4085
|
|
|
|
|
|
|
} |
4086
|
|
|
|
|
|
|
|
4087
|
|
|
|
|
|
|
# |
4088
|
|
|
|
|
|
|
# ShiftJIS file test -k $_ |
4089
|
|
|
|
|
|
|
# |
4090
|
|
|
|
|
|
|
sub Esjis::k_() { |
4091
|
|
|
|
|
|
|
|
4092
|
0
|
0
|
|
0
|
0
|
0
|
if ($] =~ /^5\.008/oxms) { |
4093
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
4094
|
|
|
|
|
|
|
} |
4095
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
4096
|
|
|
|
|
|
|
} |
4097
|
|
|
|
|
|
|
|
4098
|
|
|
|
|
|
|
# |
4099
|
|
|
|
|
|
|
# ShiftJIS file test -T $_ |
4100
|
|
|
|
|
|
|
# |
4101
|
|
|
|
|
|
|
sub Esjis::T_() { |
4102
|
|
|
|
|
|
|
|
4103
|
0
|
|
|
0
|
0
|
0
|
my $T = 1; |
4104
|
|
|
|
|
|
|
|
4105
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4106
|
0
|
|
|
|
|
0
|
return undef; |
4107
|
|
|
|
|
|
|
} |
4108
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4109
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4110
|
|
|
|
|
|
|
} |
4111
|
|
|
|
|
|
|
else { |
4112
|
0
|
|
|
|
|
0
|
return undef; |
4113
|
|
|
|
|
|
|
} |
4114
|
|
|
|
|
|
|
|
4115
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4116
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4117
|
0
|
|
|
|
|
0
|
$T = ''; |
4118
|
|
|
|
|
|
|
} |
4119
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4120
|
0
|
|
|
|
|
0
|
$T = ''; |
4121
|
|
|
|
|
|
|
} |
4122
|
|
|
|
|
|
|
} |
4123
|
|
|
|
|
|
|
|
4124
|
|
|
|
|
|
|
# 0 byte or eof |
4125
|
|
|
|
|
|
|
else { |
4126
|
0
|
|
|
|
|
0
|
$T = 1; |
4127
|
|
|
|
|
|
|
} |
4128
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
4129
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4130
|
|
|
|
|
|
|
|
4131
|
0
|
|
|
|
|
0
|
return $T; |
4132
|
|
|
|
|
|
|
} |
4133
|
|
|
|
|
|
|
|
4134
|
|
|
|
|
|
|
# |
4135
|
|
|
|
|
|
|
# ShiftJIS file test -B $_ |
4136
|
|
|
|
|
|
|
# |
4137
|
|
|
|
|
|
|
sub Esjis::B_() { |
4138
|
|
|
|
|
|
|
|
4139
|
0
|
|
|
0
|
0
|
0
|
my $B = ''; |
4140
|
|
|
|
|
|
|
|
4141
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4142
|
0
|
|
|
|
|
0
|
return undef; |
4143
|
|
|
|
|
|
|
} |
4144
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4145
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4146
|
|
|
|
|
|
|
} |
4147
|
|
|
|
|
|
|
else { |
4148
|
0
|
|
|
|
|
0
|
return undef; |
4149
|
|
|
|
|
|
|
} |
4150
|
|
|
|
|
|
|
|
4151
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4152
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4153
|
0
|
|
|
|
|
0
|
$B = 1; |
4154
|
|
|
|
|
|
|
} |
4155
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4156
|
0
|
|
|
|
|
0
|
$B = 1; |
4157
|
|
|
|
|
|
|
} |
4158
|
|
|
|
|
|
|
} |
4159
|
|
|
|
|
|
|
|
4160
|
|
|
|
|
|
|
# 0 byte or eof |
4161
|
|
|
|
|
|
|
else { |
4162
|
0
|
|
|
|
|
0
|
$B = 1; |
4163
|
|
|
|
|
|
|
} |
4164
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
4165
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4166
|
|
|
|
|
|
|
|
4167
|
0
|
|
|
|
|
0
|
return $B; |
4168
|
|
|
|
|
|
|
} |
4169
|
|
|
|
|
|
|
|
4170
|
|
|
|
|
|
|
# |
4171
|
|
|
|
|
|
|
# ShiftJIS file test -M $_ |
4172
|
|
|
|
|
|
|
# |
4173
|
|
|
|
|
|
|
sub Esjis::M_() { |
4174
|
|
|
|
|
|
|
|
4175
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4176
|
0
|
|
|
|
|
0
|
return -M _; |
4177
|
|
|
|
|
|
|
} |
4178
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4179
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4180
|
0
|
|
|
|
|
0
|
return -M _; |
4181
|
|
|
|
|
|
|
} |
4182
|
|
|
|
|
|
|
else { |
4183
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4184
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4185
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4186
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4187
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
4188
|
0
|
|
|
|
|
0
|
return $M; |
4189
|
|
|
|
|
|
|
} |
4190
|
|
|
|
|
|
|
} |
4191
|
|
|
|
|
|
|
} |
4192
|
0
|
|
|
|
|
0
|
return undef; |
4193
|
|
|
|
|
|
|
} |
4194
|
|
|
|
|
|
|
|
4195
|
|
|
|
|
|
|
# |
4196
|
|
|
|
|
|
|
# ShiftJIS file test -A $_ |
4197
|
|
|
|
|
|
|
# |
4198
|
|
|
|
|
|
|
sub Esjis::A_() { |
4199
|
|
|
|
|
|
|
|
4200
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4201
|
0
|
|
|
|
|
0
|
return -A _; |
4202
|
|
|
|
|
|
|
} |
4203
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4204
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4205
|
0
|
|
|
|
|
0
|
return -A _; |
4206
|
|
|
|
|
|
|
} |
4207
|
|
|
|
|
|
|
else { |
4208
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4209
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4210
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4211
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4212
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
4213
|
0
|
|
|
|
|
0
|
return $A; |
4214
|
|
|
|
|
|
|
} |
4215
|
|
|
|
|
|
|
} |
4216
|
|
|
|
|
|
|
} |
4217
|
0
|
|
|
|
|
0
|
return undef; |
4218
|
|
|
|
|
|
|
} |
4219
|
|
|
|
|
|
|
|
4220
|
|
|
|
|
|
|
# |
4221
|
|
|
|
|
|
|
# ShiftJIS file test -C $_ |
4222
|
|
|
|
|
|
|
# |
4223
|
|
|
|
|
|
|
sub Esjis::C_() { |
4224
|
|
|
|
|
|
|
|
4225
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4226
|
0
|
|
|
|
|
0
|
return -C _; |
4227
|
|
|
|
|
|
|
} |
4228
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4229
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4230
|
0
|
|
|
|
|
0
|
return -C _; |
4231
|
|
|
|
|
|
|
} |
4232
|
|
|
|
|
|
|
else { |
4233
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4234
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4235
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4236
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4237
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
4238
|
0
|
|
|
|
|
0
|
return $C; |
4239
|
|
|
|
|
|
|
} |
4240
|
|
|
|
|
|
|
} |
4241
|
|
|
|
|
|
|
} |
4242
|
0
|
|
|
|
|
0
|
return undef; |
4243
|
|
|
|
|
|
|
} |
4244
|
|
|
|
|
|
|
|
4245
|
|
|
|
|
|
|
# |
4246
|
|
|
|
|
|
|
# ShiftJIS path globbing (with parameter) |
4247
|
|
|
|
|
|
|
# |
4248
|
|
|
|
|
|
|
sub Esjis::glob($) { |
4249
|
|
|
|
|
|
|
|
4250
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4251
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(@_); |
4252
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4253
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4254
|
|
|
|
|
|
|
} |
4255
|
0
|
|
|
|
|
0
|
return @glob; |
4256
|
|
|
|
|
|
|
} |
4257
|
|
|
|
|
|
|
else { |
4258
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(@_); |
4259
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4260
|
0
|
|
|
|
|
0
|
return $glob; |
4261
|
|
|
|
|
|
|
} |
4262
|
|
|
|
|
|
|
} |
4263
|
|
|
|
|
|
|
|
4264
|
|
|
|
|
|
|
# |
4265
|
|
|
|
|
|
|
# ShiftJIS path globbing (without parameter) |
4266
|
|
|
|
|
|
|
# |
4267
|
|
|
|
|
|
|
sub Esjis::glob_() { |
4268
|
|
|
|
|
|
|
|
4269
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4270
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(); |
4271
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4272
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4273
|
|
|
|
|
|
|
} |
4274
|
0
|
|
|
|
|
0
|
return @glob; |
4275
|
|
|
|
|
|
|
} |
4276
|
|
|
|
|
|
|
else { |
4277
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(); |
4278
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4279
|
0
|
|
|
|
|
0
|
return $glob; |
4280
|
|
|
|
|
|
|
} |
4281
|
|
|
|
|
|
|
} |
4282
|
|
|
|
|
|
|
|
4283
|
|
|
|
|
|
|
# |
4284
|
|
|
|
|
|
|
# ShiftJIS path globbing via File::DosGlob 1.10 |
4285
|
|
|
|
|
|
|
# |
4286
|
|
|
|
|
|
|
# Often I confuse "_dosglob" and "_doglob". |
4287
|
|
|
|
|
|
|
# So, I renamed "_dosglob" to "_DOS_like_glob". |
4288
|
|
|
|
|
|
|
# |
4289
|
|
|
|
|
|
|
my %iter; |
4290
|
|
|
|
|
|
|
my %entries; |
4291
|
|
|
|
|
|
|
sub _DOS_like_glob { |
4292
|
|
|
|
|
|
|
|
4293
|
|
|
|
|
|
|
# context (keyed by second cxix argument provided by core) |
4294
|
0
|
|
|
0
|
|
0
|
my($expr,$cxix) = @_; |
4295
|
|
|
|
|
|
|
|
4296
|
|
|
|
|
|
|
# glob without args defaults to $_ |
4297
|
0
|
0
|
|
|
|
0
|
$expr = $_ if not defined $expr; |
4298
|
|
|
|
|
|
|
|
4299
|
|
|
|
|
|
|
# represents the current user's home directory |
4300
|
|
|
|
|
|
|
# |
4301
|
|
|
|
|
|
|
# 7.3. Expanding Tildes in Filenames |
4302
|
|
|
|
|
|
|
# in Chapter 7. File Access |
4303
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4304
|
|
|
|
|
|
|
# |
4305
|
|
|
|
|
|
|
# and File::HomeDir, File::HomeDir::Windows module |
4306
|
|
|
|
|
|
|
|
4307
|
|
|
|
|
|
|
# DOS-like system |
4308
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
|
|
0
|
|
|
|
|
|
4309
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ (?= [^/\\] ) } |
|
0
|
|
|
|
|
0
|
|
4310
|
|
|
|
|
|
|
{ my_home_MSWin32() }oxmse; |
4311
|
|
|
|
|
|
|
} |
4312
|
|
|
|
|
|
|
|
4313
|
|
|
|
|
|
|
# Mac OS system |
4314
|
0
|
0
|
|
|
|
0
|
elsif ($^O eq 'MacOS') { |
4315
|
0
|
|
|
|
|
0
|
if ($expr =~ / \A ~ /oxms) { |
|
0
|
|
|
|
|
0
|
|
4316
|
|
|
|
|
|
|
$expr =~ s{ \A ~ (?= [^/:] ) } |
4317
|
|
|
|
|
|
|
{ my_home_MacOS() }oxmse; |
4318
|
|
|
|
|
|
|
} |
4319
|
|
|
|
|
|
|
} |
4320
|
|
|
|
|
|
|
|
4321
|
0
|
0
|
0
|
|
|
0
|
# UNIX-like system |
|
0
|
|
|
|
|
0
|
|
4322
|
|
|
|
|
|
|
else { |
4323
|
|
|
|
|
|
|
$expr =~ s{ \A ~ ( (?:[^\x81-\x9F\xE0-\xFC/]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])* ) } |
4324
|
|
|
|
|
|
|
{ $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse; |
4325
|
0
|
0
|
|
|
|
0
|
} |
4326
|
0
|
0
|
|
|
|
0
|
|
4327
|
|
|
|
|
|
|
# assume global context if not provided one |
4328
|
|
|
|
|
|
|
$cxix = '_G_' if not defined $cxix; |
4329
|
0
|
0
|
|
|
|
0
|
$iter{$cxix} = 0 if not exists $iter{$cxix}; |
4330
|
0
|
0
|
|
|
|
0
|
|
4331
|
|
|
|
|
|
|
# if we're just beginning, do it all first |
4332
|
|
|
|
|
|
|
if ($iter{$cxix} == 0) { |
4333
|
0
|
|
|
|
|
0
|
if ($^O eq 'MacOS') { |
4334
|
|
|
|
|
|
|
|
4335
|
|
|
|
|
|
|
# first, take care of updirs and trailing colons |
4336
|
0
|
|
|
|
|
0
|
my @expr = _canonpath_MacOS(_parse_line($expr)); |
4337
|
|
|
|
|
|
|
|
4338
|
0
|
0
|
|
|
|
0
|
# expand volume names |
|
0
|
|
|
|
|
0
|
|
4339
|
|
|
|
|
|
|
@expr = _expand_volume_MacOS(@expr); |
4340
|
|
|
|
|
|
|
|
4341
|
0
|
|
|
|
|
0
|
$entries{$cxix} = (@expr) ? [ map { _unescape_MacOS($_) } _do_glob_MacOS(1,@expr) ] : [()]; |
4342
|
|
|
|
|
|
|
} |
4343
|
|
|
|
|
|
|
else { |
4344
|
|
|
|
|
|
|
$entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ]; |
4345
|
|
|
|
|
|
|
} |
4346
|
0
|
0
|
|
|
|
0
|
} |
4347
|
0
|
|
|
|
|
0
|
|
4348
|
0
|
|
|
|
|
0
|
# chuck it all out, quick or slow |
|
0
|
|
|
|
|
0
|
|
4349
|
|
|
|
|
|
|
if (wantarray) { |
4350
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4351
|
0
|
0
|
|
|
|
0
|
return @{delete $entries{$cxix}}; |
|
0
|
|
|
|
|
0
|
|
4352
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4353
|
|
|
|
|
|
|
else { |
4354
|
|
|
|
|
|
|
if ($iter{$cxix} = scalar @{$entries{$cxix}}) { |
4355
|
|
|
|
|
|
|
return shift @{$entries{$cxix}}; |
4356
|
0
|
|
|
|
|
0
|
} |
4357
|
0
|
|
|
|
|
0
|
else { |
4358
|
0
|
|
|
|
|
0
|
# return undef for EOL |
4359
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4360
|
|
|
|
|
|
|
delete $entries{$cxix}; |
4361
|
|
|
|
|
|
|
return undef; |
4362
|
|
|
|
|
|
|
} |
4363
|
|
|
|
|
|
|
} |
4364
|
|
|
|
|
|
|
} |
4365
|
|
|
|
|
|
|
|
4366
|
|
|
|
|
|
|
# |
4367
|
|
|
|
|
|
|
# ShiftJIS path globbing subroutine |
4368
|
0
|
|
|
0
|
|
0
|
# |
4369
|
0
|
|
|
|
|
0
|
sub _do_glob { |
4370
|
0
|
|
|
|
|
0
|
|
4371
|
|
|
|
|
|
|
my($cond,@expr) = @_; |
4372
|
|
|
|
|
|
|
my @glob = (); |
4373
|
0
|
|
|
|
|
0
|
my $fix_drive_relative_paths = 0; |
4374
|
0
|
0
|
|
|
|
0
|
|
4375
|
0
|
0
|
|
|
|
0
|
OUTER: |
4376
|
|
|
|
|
|
|
for my $expr (@expr) { |
4377
|
0
|
|
|
|
|
0
|
next OUTER if not defined $expr; |
4378
|
0
|
|
|
|
|
0
|
next OUTER if $expr eq ''; |
4379
|
0
|
|
|
|
|
0
|
|
4380
|
0
|
|
|
|
|
0
|
my @matched = (); |
4381
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4382
|
|
|
|
|
|
|
my $head = '.'; |
4383
|
|
|
|
|
|
|
my $pathsep = '/'; |
4384
|
0
|
0
|
|
|
|
0
|
my $tail; |
4385
|
0
|
|
|
|
|
0
|
|
4386
|
0
|
0
|
|
|
|
0
|
# if argument is within quotes strip em and do no globbing |
4387
|
0
|
0
|
|
|
|
0
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4388
|
0
|
|
|
|
|
0
|
$expr = $1; |
4389
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4390
|
|
|
|
|
|
|
if (Esjis::d $expr) { |
4391
|
|
|
|
|
|
|
push @glob, $expr; |
4392
|
0
|
0
|
|
|
|
0
|
} |
4393
|
0
|
|
|
|
|
0
|
} |
4394
|
|
|
|
|
|
|
else { |
4395
|
|
|
|
|
|
|
if (Esjis::e $expr) { |
4396
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
4397
|
|
|
|
|
|
|
} |
4398
|
|
|
|
|
|
|
} |
4399
|
|
|
|
|
|
|
next OUTER; |
4400
|
|
|
|
|
|
|
} |
4401
|
0
|
0
|
|
|
|
0
|
|
4402
|
0
|
0
|
|
|
|
0
|
# wildcards with a drive prefix such as h:*.pm must be changed |
4403
|
0
|
|
|
|
|
0
|
# to h:./*.pm to expand correctly |
4404
|
|
|
|
|
|
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4405
|
|
|
|
|
|
|
if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^\x81-\x9F\xE0-\xFC/\\]|[\x81-\x9F\xE0-\xFC][\x00-\xFF]) #$1./$2#oxms) { |
4406
|
|
|
|
|
|
|
$fix_drive_relative_paths = 1; |
4407
|
0
|
0
|
|
|
|
0
|
} |
4408
|
0
|
0
|
|
|
|
0
|
} |
4409
|
0
|
|
|
|
|
0
|
|
4410
|
0
|
|
|
|
|
0
|
if (($head, $tail) = _parse_path($expr,$pathsep)) { |
4411
|
|
|
|
|
|
|
if ($tail eq '') { |
4412
|
0
|
0
|
|
|
|
0
|
push @glob, $expr; |
4413
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4414
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4415
|
0
|
|
|
|
|
0
|
if ($head =~ / \A (?:$q_char)*? [*?] /oxms) { |
4416
|
|
|
|
|
|
|
if (@globdir = _do_glob('d', $head)) { |
4417
|
|
|
|
|
|
|
push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir); |
4418
|
0
|
0
|
0
|
|
|
0
|
next OUTER; |
4419
|
0
|
|
|
|
|
0
|
} |
4420
|
|
|
|
|
|
|
} |
4421
|
0
|
|
|
|
|
0
|
if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) { |
4422
|
|
|
|
|
|
|
$head .= $pathsep; |
4423
|
|
|
|
|
|
|
} |
4424
|
|
|
|
|
|
|
$expr = $tail; |
4425
|
0
|
0
|
|
|
|
0
|
} |
4426
|
0
|
0
|
|
|
|
0
|
|
4427
|
0
|
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4428
|
|
|
|
|
|
|
if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) { |
4429
|
0
|
0
|
0
|
|
|
0
|
if ($head eq '.') { |
4430
|
0
|
|
|
|
|
0
|
$head = ''; |
4431
|
|
|
|
|
|
|
} |
4432
|
0
|
|
|
|
|
0
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4433
|
0
|
0
|
|
|
|
0
|
$head .= $pathsep; |
4434
|
0
|
0
|
|
|
|
0
|
} |
4435
|
0
|
|
|
|
|
0
|
$head .= $expr; |
4436
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4437
|
|
|
|
|
|
|
if (Esjis::d $head) { |
4438
|
|
|
|
|
|
|
push @glob, $head; |
4439
|
0
|
0
|
|
|
|
0
|
} |
4440
|
0
|
|
|
|
|
0
|
} |
4441
|
|
|
|
|
|
|
else { |
4442
|
|
|
|
|
|
|
if (Esjis::e $head) { |
4443
|
0
|
|
|
|
|
0
|
push @glob, $head; |
4444
|
|
|
|
|
|
|
} |
4445
|
0
|
0
|
|
|
|
0
|
} |
4446
|
0
|
|
|
|
|
0
|
next OUTER; |
4447
|
0
|
|
|
|
|
0
|
} |
4448
|
|
|
|
|
|
|
Esjis::opendir(*DIR, $head) or next OUTER; |
4449
|
0
|
0
|
|
|
|
0
|
my @leaf = readdir DIR; |
4450
|
0
|
|
|
|
|
0
|
closedir DIR; |
4451
|
|
|
|
|
|
|
|
4452
|
0
|
0
|
0
|
|
|
0
|
if ($head eq '.') { |
4453
|
0
|
|
|
|
|
0
|
$head = ''; |
4454
|
|
|
|
|
|
|
} |
4455
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4456
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4457
|
0
|
|
|
|
|
0
|
} |
4458
|
0
|
|
|
|
|
0
|
|
4459
|
|
|
|
|
|
|
my $pattern = ''; |
4460
|
|
|
|
|
|
|
while ($expr =~ / \G ($q_char) /oxgc) { |
4461
|
|
|
|
|
|
|
my $char = $1; |
4462
|
|
|
|
|
|
|
|
4463
|
|
|
|
|
|
|
# 6.9. Matching Shell Globs as Regular Expressions |
4464
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
4465
|
0
|
0
|
|
|
|
0
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4466
|
0
|
|
|
|
|
0
|
# (and so on) |
4467
|
|
|
|
|
|
|
|
4468
|
|
|
|
|
|
|
if ($char eq '*') { |
4469
|
0
|
|
|
|
|
0
|
$pattern .= "(?:$your_char)*", |
4470
|
|
|
|
|
|
|
} |
4471
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4472
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)?", # DOS style |
4473
|
0
|
|
|
|
|
0
|
# $pattern .= "(?:$your_char)", # UNIX style |
4474
|
|
|
|
|
|
|
} |
4475
|
|
|
|
|
|
|
elsif ((my $fc = Esjis::fc($char)) ne $char) { |
4476
|
0
|
|
|
|
|
0
|
$pattern .= $fc; |
4477
|
|
|
|
|
|
|
} |
4478
|
|
|
|
|
|
|
else { |
4479
|
0
|
|
|
0
|
|
0
|
$pattern .= quotemeta $char; |
|
0
|
|
|
|
|
0
|
|
4480
|
|
|
|
|
|
|
} |
4481
|
|
|
|
|
|
|
} |
4482
|
|
|
|
|
|
|
my $matchsub = sub { Esjis::fc($_[0]) =~ /\A $pattern \z/xms }; |
4483
|
|
|
|
|
|
|
|
4484
|
|
|
|
|
|
|
# if ($@) { |
4485
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4486
|
|
|
|
|
|
|
# next OUTER; |
4487
|
0
|
|
|
|
|
0
|
# } |
4488
|
0
|
0
|
0
|
|
|
0
|
|
4489
|
0
|
|
|
|
|
0
|
INNER: |
4490
|
|
|
|
|
|
|
for my $leaf (@leaf) { |
4491
|
0
|
0
|
0
|
|
|
0
|
if ($leaf eq '.' or $leaf eq '..') { |
4492
|
0
|
|
|
|
|
0
|
next INNER; |
4493
|
|
|
|
|
|
|
} |
4494
|
|
|
|
|
|
|
if ($cond eq 'd' and not Esjis::d "$head$leaf") { |
4495
|
0
|
0
|
|
|
|
0
|
next INNER; |
4496
|
0
|
|
|
|
|
0
|
} |
4497
|
0
|
|
|
|
|
0
|
|
4498
|
|
|
|
|
|
|
if (&$matchsub($leaf)) { |
4499
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4500
|
|
|
|
|
|
|
next INNER; |
4501
|
|
|
|
|
|
|
} |
4502
|
|
|
|
|
|
|
|
4503
|
0
|
0
|
0
|
|
|
0
|
# [DOS compatibility special case] |
|
|
|
0
|
|
|
|
|
4504
|
|
|
|
|
|
|
# Failed, add a trailing dot and try again, but only... |
4505
|
|
|
|
|
|
|
|
4506
|
|
|
|
|
|
|
if (Esjis::index($leaf,'.') == -1 and # if name does not have a dot in it *and* |
4507
|
0
|
0
|
|
|
|
0
|
CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and* |
4508
|
0
|
|
|
|
|
0
|
Esjis::index($pattern,'\\.') != -1 # pattern has a dot. |
4509
|
0
|
|
|
|
|
0
|
) { |
4510
|
|
|
|
|
|
|
if (&$matchsub("$leaf.")) { |
4511
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4512
|
|
|
|
|
|
|
next INNER; |
4513
|
0
|
0
|
|
|
|
0
|
} |
4514
|
0
|
|
|
|
|
0
|
} |
4515
|
|
|
|
|
|
|
} |
4516
|
|
|
|
|
|
|
if (@matched) { |
4517
|
0
|
0
|
|
|
|
0
|
push @glob, @matched; |
4518
|
0
|
|
|
|
|
0
|
} |
4519
|
0
|
|
|
|
|
0
|
} |
4520
|
|
|
|
|
|
|
if ($fix_drive_relative_paths) { |
4521
|
|
|
|
|
|
|
for my $glob (@glob) { |
4522
|
0
|
|
|
|
|
0
|
$glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms; |
4523
|
|
|
|
|
|
|
} |
4524
|
|
|
|
|
|
|
} |
4525
|
|
|
|
|
|
|
return @glob; |
4526
|
|
|
|
|
|
|
} |
4527
|
|
|
|
|
|
|
|
4528
|
|
|
|
|
|
|
# |
4529
|
|
|
|
|
|
|
# ShiftJIS parse line |
4530
|
0
|
|
|
0
|
|
0
|
# |
4531
|
|
|
|
|
|
|
sub _parse_line { |
4532
|
0
|
|
|
|
|
0
|
|
4533
|
0
|
|
|
|
|
0
|
my($line) = @_; |
4534
|
0
|
|
|
|
|
0
|
|
4535
|
|
|
|
|
|
|
$line .= ' '; |
4536
|
|
|
|
|
|
|
my @piece = (); |
4537
|
|
|
|
|
|
|
while ($line =~ / |
4538
|
|
|
|
|
|
|
" ( (?>(?: [^\x81-\x9F\xE0-\xFC"] |[\x81-\x9F\xE0-\xFC][\x00-\xFF] )* ) ) " (?>\s+) | |
4539
|
0
|
0
|
|
|
|
0
|
( (?>(?: [^\x81-\x9F\xE0-\xFC"\s]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] )* ) ) (?>\s+) |
4540
|
|
|
|
|
|
|
/oxmsg |
4541
|
0
|
|
|
|
|
0
|
) { |
4542
|
|
|
|
|
|
|
push @piece, defined($1) ? $1 : $2; |
4543
|
|
|
|
|
|
|
} |
4544
|
|
|
|
|
|
|
return @piece; |
4545
|
|
|
|
|
|
|
} |
4546
|
|
|
|
|
|
|
|
4547
|
|
|
|
|
|
|
# |
4548
|
|
|
|
|
|
|
# ShiftJIS parse path |
4549
|
0
|
|
|
0
|
|
0
|
# |
4550
|
|
|
|
|
|
|
sub _parse_path { |
4551
|
0
|
|
|
|
|
0
|
|
4552
|
0
|
|
|
|
|
0
|
my($path,$pathsep) = @_; |
4553
|
0
|
|
|
|
|
0
|
|
4554
|
|
|
|
|
|
|
$path .= '/'; |
4555
|
|
|
|
|
|
|
my @subpath = (); |
4556
|
|
|
|
|
|
|
while ($path =~ / |
4557
|
0
|
|
|
|
|
0
|
((?: [^\x81-\x9F\xE0-\xFC\/\\]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] )+?) [\/\\] |
4558
|
|
|
|
|
|
|
/oxmsg |
4559
|
|
|
|
|
|
|
) { |
4560
|
0
|
|
|
|
|
0
|
push @subpath, $1; |
4561
|
0
|
|
|
|
|
0
|
} |
4562
|
0
|
|
|
|
|
0
|
|
4563
|
|
|
|
|
|
|
my $tail = pop @subpath; |
4564
|
|
|
|
|
|
|
my $head = join $pathsep, @subpath; |
4565
|
|
|
|
|
|
|
return $head, $tail; |
4566
|
|
|
|
|
|
|
} |
4567
|
|
|
|
|
|
|
|
4568
|
|
|
|
|
|
|
# |
4569
|
|
|
|
|
|
|
# ShiftJIS path globbing on Mac OS |
4570
|
0
|
|
|
0
|
|
0
|
# |
4571
|
0
|
|
|
|
|
0
|
sub _do_glob_MacOS { |
4572
|
|
|
|
|
|
|
|
4573
|
|
|
|
|
|
|
my($cond,@expr) = @_; |
4574
|
0
|
|
|
|
|
0
|
my @glob = (); |
4575
|
0
|
0
|
|
|
|
0
|
|
4576
|
0
|
0
|
|
|
|
0
|
OUTER_MACOS: |
4577
|
|
|
|
|
|
|
for my $expr (@expr) { |
4578
|
0
|
|
|
|
|
0
|
next OUTER_MACOS if not defined $expr; |
4579
|
0
|
|
|
|
|
0
|
next OUTER_MACOS if $expr eq ''; |
4580
|
0
|
|
|
|
|
0
|
|
4581
|
0
|
|
|
|
|
0
|
my @matched = (); |
4582
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4583
|
0
|
|
|
|
|
0
|
my $head = ':'; |
4584
|
|
|
|
|
|
|
my $unesc_head = $head; |
4585
|
|
|
|
|
|
|
my $pathsep = ':'; |
4586
|
0
|
0
|
|
|
|
0
|
my $tail; |
4587
|
0
|
|
|
|
|
0
|
|
4588
|
|
|
|
|
|
|
# if $expr is within quotes strip em and do no globbing |
4589
|
|
|
|
|
|
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4590
|
0
|
|
|
|
|
0
|
$expr = $1; |
4591
|
|
|
|
|
|
|
|
4592
|
0
|
0
|
|
|
|
0
|
# $expr may contain escaped metachars '\*', '\?', and '\' |
4593
|
0
|
0
|
|
|
|
0
|
$expr = _unescape_MacOS($expr); |
4594
|
0
|
|
|
|
|
0
|
|
4595
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4596
|
|
|
|
|
|
|
if (Esjis::d $expr) { |
4597
|
|
|
|
|
|
|
push @glob, $expr; |
4598
|
0
|
0
|
|
|
|
0
|
} |
4599
|
0
|
|
|
|
|
0
|
} |
4600
|
|
|
|
|
|
|
else { |
4601
|
|
|
|
|
|
|
if (Esjis::e $expr) { |
4602
|
0
|
|
|
|
|
0
|
push @glob, $expr; |
4603
|
|
|
|
|
|
|
} |
4604
|
|
|
|
|
|
|
} |
4605
|
|
|
|
|
|
|
next OUTER_MACOS; |
4606
|
0
|
0
|
|
|
|
0
|
} |
4607
|
0
|
0
|
|
|
|
0
|
|
4608
|
0
|
|
|
|
|
0
|
# note: $1 is not greedy |
4609
|
0
|
|
|
|
|
0
|
if (($head,$pathsep,$tail) = $expr =~ /\A ((?:$q_char)*?) (:+) ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])*?) \z/oxms) { |
4610
|
|
|
|
|
|
|
if ($tail eq '') { |
4611
|
0
|
0
|
|
|
|
0
|
push @glob, $expr; |
4612
|
0
|
0
|
|
|
|
0
|
next OUTER_MACOS; |
4613
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4614
|
0
|
|
|
|
|
0
|
if (_hasmeta_MacOS($head)) { |
4615
|
|
|
|
|
|
|
if (@globdir = _do_glob_MacOS('d', $head)) { |
4616
|
|
|
|
|
|
|
push @glob, _do_glob_MacOS($cond, map {"$_$pathsep$tail"} @globdir); |
4617
|
0
|
|
|
|
|
0
|
next OUTER_MACOS; |
4618
|
|
|
|
|
|
|
} |
4619
|
|
|
|
|
|
|
} |
4620
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4621
|
|
|
|
|
|
|
|
4622
|
0
|
|
|
|
|
0
|
# unescape $head for file operations |
4623
|
|
|
|
|
|
|
$unesc_head = _unescape_MacOS($head); |
4624
|
|
|
|
|
|
|
|
4625
|
|
|
|
|
|
|
$expr = $tail; |
4626
|
0
|
0
|
|
|
|
0
|
} |
4627
|
0
|
0
|
|
|
|
0
|
|
4628
|
0
|
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4629
|
|
|
|
|
|
|
if (not _hasmeta_MacOS($expr)) { |
4630
|
0
|
|
|
|
|
0
|
if ($head eq ':') { |
4631
|
|
|
|
|
|
|
$unesc_head = $head = ''; |
4632
|
|
|
|
|
|
|
} |
4633
|
0
|
|
|
|
|
0
|
$head .= $expr; |
4634
|
|
|
|
|
|
|
|
4635
|
0
|
0
|
|
|
|
0
|
# unescape $head and $expr for file operations |
4636
|
0
|
0
|
|
|
|
0
|
$unesc_head .= _unescape_MacOS($expr); |
4637
|
0
|
|
|
|
|
0
|
|
4638
|
|
|
|
|
|
|
if ($cond eq 'd') { |
4639
|
|
|
|
|
|
|
if (Esjis::d $unesc_head) { |
4640
|
|
|
|
|
|
|
push @glob, $head; |
4641
|
0
|
0
|
|
|
|
0
|
} |
4642
|
0
|
|
|
|
|
0
|
} |
4643
|
|
|
|
|
|
|
else { |
4644
|
|
|
|
|
|
|
if (Esjis::e $unesc_head) { |
4645
|
0
|
|
|
|
|
0
|
push @glob, $head; |
4646
|
|
|
|
|
|
|
} |
4647
|
0
|
0
|
|
|
|
0
|
} |
4648
|
0
|
|
|
|
|
0
|
next OUTER_MACOS; |
4649
|
0
|
|
|
|
|
0
|
} |
4650
|
|
|
|
|
|
|
Esjis::opendir(*DIR, $head) or next OUTER_MACOS; |
4651
|
0
|
|
|
|
|
0
|
my @leaf = readdir DIR; |
4652
|
0
|
|
|
0
|
|
0
|
closedir DIR; |
|
0
|
|
|
|
|
0
|
|
4653
|
|
|
|
|
|
|
|
4654
|
|
|
|
|
|
|
my $pattern = _quotemeta_MacOS($expr); |
4655
|
|
|
|
|
|
|
my $matchsub = sub { Esjis::fc($_[0]) =~ /\A $pattern \z/xms }; |
4656
|
|
|
|
|
|
|
|
4657
|
|
|
|
|
|
|
# if ($@) { |
4658
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4659
|
|
|
|
|
|
|
# next OUTER_MACOS; |
4660
|
0
|
|
|
|
|
0
|
# } |
4661
|
0
|
0
|
0
|
|
|
0
|
|
4662
|
0
|
|
|
|
|
0
|
INNER_MACOS: |
4663
|
|
|
|
|
|
|
for my $leaf (@leaf) { |
4664
|
0
|
0
|
0
|
|
|
0
|
if ($leaf eq '.' or $leaf eq '..') { |
4665
|
0
|
|
|
|
|
0
|
next INNER_MACOS; |
4666
|
|
|
|
|
|
|
} |
4667
|
|
|
|
|
|
|
if ($cond eq 'd' and not Esjis::d qq{$unesc_head$leaf}) { |
4668
|
0
|
0
|
|
|
|
0
|
next INNER_MACOS; |
4669
|
0
|
0
|
0
|
|
|
0
|
} |
4670
|
|
|
|
|
|
|
|
4671
|
|
|
|
|
|
|
if (&$matchsub($leaf)) { |
4672
|
0
|
|
|
|
|
0
|
if (($unesc_head eq ':') and (Esjis::f qq{$unesc_head$leaf})) { |
4673
|
|
|
|
|
|
|
} |
4674
|
|
|
|
|
|
|
else { |
4675
|
|
|
|
|
|
|
$leaf = $unesc_head . $leaf; |
4676
|
|
|
|
|
|
|
} |
4677
|
|
|
|
|
|
|
|
4678
|
0
|
|
|
|
|
0
|
# On Mac OS, the two glob metachars '*' and '?' and the escape |
4679
|
0
|
|
|
|
|
0
|
# char '\' are valid characters for file and directory names. |
4680
|
|
|
|
|
|
|
# We have to escape and treat them specially. |
4681
|
|
|
|
|
|
|
push @matched, _escape_MacOS($leaf); |
4682
|
0
|
0
|
|
|
|
0
|
next INNER_MACOS; |
4683
|
0
|
|
|
|
|
0
|
} |
4684
|
|
|
|
|
|
|
} |
4685
|
|
|
|
|
|
|
if (@matched) { |
4686
|
0
|
|
|
|
|
0
|
push @glob, @matched; |
4687
|
|
|
|
|
|
|
} |
4688
|
|
|
|
|
|
|
} |
4689
|
|
|
|
|
|
|
return @glob; |
4690
|
|
|
|
|
|
|
} |
4691
|
|
|
|
|
|
|
|
4692
|
|
|
|
|
|
|
# |
4693
|
|
|
|
|
|
|
# _expand_volume_MacOS() will only be used on Mac OS (OS9 or older): |
4694
|
|
|
|
|
|
|
# Takes an array of original patterns as argument and returns an array of |
4695
|
|
|
|
|
|
|
# possibly modified patterns. Each original pattern is processed like |
4696
|
|
|
|
|
|
|
# that: |
4697
|
|
|
|
|
|
|
# + If there's a volume name in the pattern, we push a separate pattern |
4698
|
|
|
|
|
|
|
# for each mounted volume that matches (with '*', '?', and '\' escaped). |
4699
|
|
|
|
|
|
|
# + If there's no volume name in the original pattern, it is pushed |
4700
|
|
|
|
|
|
|
# unchanged. |
4701
|
|
|
|
|
|
|
# Note that the returned array of patterns may be empty. |
4702
|
0
|
|
|
0
|
|
0
|
# |
4703
|
0
|
0
|
|
|
|
0
|
sub _expand_volume_MacOS { |
4704
|
|
|
|
|
|
|
|
4705
|
0
|
|
|
|
|
0
|
CORE::eval q{ CORE::require MacPerl; }; |
4706
|
0
|
|
|
|
|
0
|
croak "Can't require MacPerl;" if $@; |
4707
|
0
|
|
|
|
|
0
|
|
4708
|
|
|
|
|
|
|
my @volume_glob = @_; |
4709
|
|
|
|
|
|
|
my @expand_volume = (); |
4710
|
0
|
0
|
|
|
|
0
|
for my $volume_glob (@volume_glob) { |
4711
|
0
|
|
|
|
|
0
|
|
4712
|
0
|
|
|
|
|
0
|
# volume name in pattern |
4713
|
|
|
|
|
|
|
if ($volume_glob =~ /\A ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+:) (.*) \z/oxms) { |
4714
|
0
|
|
|
|
|
0
|
my $pattern = _quotemeta_MacOS($1); |
|
0
|
|
|
|
|
0
|
|
4715
|
0
|
0
|
|
|
|
0
|
my $tail = $2; |
4716
|
|
|
|
|
|
|
|
4717
|
|
|
|
|
|
|
for my $volume (map { MacPerl::MakePath($_) } MacPerl::Volumes()) { |
4718
|
|
|
|
|
|
|
if ($volume =~ /\A $pattern \z/xmsi) { |
4719
|
|
|
|
|
|
|
|
4720
|
0
|
|
|
|
|
0
|
# On Mac OS, the two glob metachars '*' and '?' and the |
4721
|
|
|
|
|
|
|
# escape char '\' are valid characters for volume names. |
4722
|
|
|
|
|
|
|
# We have to escape and treat them specially. |
4723
|
|
|
|
|
|
|
push @expand_volume, _escape_MacOS($volume) . $tail; |
4724
|
|
|
|
|
|
|
} |
4725
|
|
|
|
|
|
|
} |
4726
|
|
|
|
|
|
|
} |
4727
|
0
|
|
|
|
|
0
|
|
4728
|
|
|
|
|
|
|
# no volume name in pattern |
4729
|
|
|
|
|
|
|
else { |
4730
|
0
|
|
|
|
|
0
|
push @expand_volume, $volume_glob; |
4731
|
|
|
|
|
|
|
} |
4732
|
|
|
|
|
|
|
} |
4733
|
|
|
|
|
|
|
return @expand_volume; |
4734
|
|
|
|
|
|
|
} |
4735
|
|
|
|
|
|
|
|
4736
|
|
|
|
|
|
|
# |
4737
|
|
|
|
|
|
|
# _canonpath_MacOS() will only be used on Mac OS (OS9 or older): |
4738
|
|
|
|
|
|
|
# Resolves any updirs in the pattern. Removes a single trailing colon |
4739
|
0
|
|
|
0
|
|
0
|
# from the pattern, unless it's a volume name pattern like "*HD:" |
4740
|
|
|
|
|
|
|
# |
4741
|
0
|
|
|
|
|
0
|
sub _canonpath_MacOS { |
4742
|
|
|
|
|
|
|
my(@expr) = @_; |
4743
|
|
|
|
|
|
|
|
4744
|
0
|
|
|
|
|
0
|
for my $expr (@expr) { |
4745
|
|
|
|
|
|
|
|
4746
|
|
|
|
|
|
|
# resolve any updirs, e.g. "*HD:t?p::a*" -> "*HD:a*" |
4747
|
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); |
4748
|
|
|
|
|
|
|
|
4749
|
0
|
|
|
|
|
0
|
# remove a single trailing colon, e.g. ":*:" -> ":*" |
4750
|
|
|
|
|
|
|
$expr =~ s/ : ((?:[^\x81-\x9F\xE0-\xFC:]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+) : \z/:$1/oxms; |
4751
|
|
|
|
|
|
|
} |
4752
|
|
|
|
|
|
|
return @expr; |
4753
|
|
|
|
|
|
|
} |
4754
|
|
|
|
|
|
|
|
4755
|
|
|
|
|
|
|
# |
4756
|
|
|
|
|
|
|
# _escape_MacOS() will only be used on Mac OS (OS9 or older): |
4757
|
0
|
|
|
0
|
|
0
|
# Escape metachars '*', '?', and '\' of arguments. |
4758
|
|
|
|
|
|
|
# |
4759
|
|
|
|
|
|
|
sub _escape_MacOS { |
4760
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4761
|
0
|
|
|
|
|
0
|
|
4762
|
0
|
|
|
|
|
0
|
# escape regex metachars but not '\' and glob chars '*', '?' |
4763
|
0
|
0
|
|
|
|
0
|
my $escape = ''; |
4764
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G ($q_char) /oxmsgc) { |
4765
|
|
|
|
|
|
|
my $char = $1; |
4766
|
|
|
|
|
|
|
if ($char =~ /\A [*?\\] \z/oxms) { |
4767
|
0
|
|
|
|
|
0
|
$escape .= '\\' . $char; |
4768
|
|
|
|
|
|
|
} |
4769
|
|
|
|
|
|
|
else { |
4770
|
0
|
|
|
|
|
0
|
$escape .= $char; |
4771
|
|
|
|
|
|
|
} |
4772
|
|
|
|
|
|
|
} |
4773
|
|
|
|
|
|
|
return $escape; |
4774
|
|
|
|
|
|
|
} |
4775
|
|
|
|
|
|
|
|
4776
|
|
|
|
|
|
|
# |
4777
|
|
|
|
|
|
|
# _unescape_MacOS() will only be used on Mac OS (OS9 or older): |
4778
|
|
|
|
|
|
|
# Unescapes a list of arguments which may contain escaped |
4779
|
0
|
|
|
0
|
|
0
|
# metachars '*', '?', and '\'. |
4780
|
|
|
|
|
|
|
# |
4781
|
0
|
|
|
|
|
0
|
sub _unescape_MacOS { |
4782
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4783
|
0
|
|
|
|
|
0
|
|
4784
|
0
|
0
|
|
|
|
0
|
my $unescape = ''; |
4785
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxmsgc) { |
4786
|
|
|
|
|
|
|
my $char = $1; |
4787
|
|
|
|
|
|
|
if ($char =~ /\A \\([*?\\]) \z/oxms) { |
4788
|
0
|
|
|
|
|
0
|
$unescape .= $1; |
4789
|
|
|
|
|
|
|
} |
4790
|
|
|
|
|
|
|
else { |
4791
|
0
|
|
|
|
|
0
|
$unescape .= $char; |
4792
|
|
|
|
|
|
|
} |
4793
|
|
|
|
|
|
|
} |
4794
|
|
|
|
|
|
|
return $unescape; |
4795
|
|
|
|
|
|
|
} |
4796
|
|
|
|
|
|
|
|
4797
|
|
|
|
|
|
|
# |
4798
|
0
|
|
|
0
|
|
0
|
# _hasmeta_MacOS() will only be used on Mac OS (OS9 or older): |
4799
|
|
|
|
|
|
|
# |
4800
|
|
|
|
|
|
|
sub _hasmeta_MacOS { |
4801
|
|
|
|
|
|
|
my($expr) = @_; |
4802
|
|
|
|
|
|
|
|
4803
|
0
|
|
|
|
|
0
|
# if a '*' or '?' is preceded by an odd count of '\', temporary delete |
4804
|
0
|
|
|
|
|
0
|
# it (and its preceding backslashes), i.e. don't treat '\*' and '\?' as |
4805
|
0
|
0
|
|
|
|
0
|
# wildcards |
|
|
0
|
|
|
|
|
|
4806
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxgc) { |
4807
|
|
|
|
|
|
|
my $char = $1; |
4808
|
|
|
|
|
|
|
if ($char eq '*') { |
4809
|
0
|
|
|
|
|
0
|
return 1; |
4810
|
|
|
|
|
|
|
} |
4811
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4812
|
0
|
|
|
|
|
0
|
return 1; |
4813
|
|
|
|
|
|
|
} |
4814
|
|
|
|
|
|
|
} |
4815
|
|
|
|
|
|
|
return 0; |
4816
|
|
|
|
|
|
|
} |
4817
|
|
|
|
|
|
|
|
4818
|
|
|
|
|
|
|
# |
4819
|
0
|
|
|
0
|
|
0
|
# _quotemeta_MacOS() will only be used on Mac OS (OS9 or older): |
4820
|
|
|
|
|
|
|
# |
4821
|
|
|
|
|
|
|
sub _quotemeta_MacOS { |
4822
|
0
|
|
|
|
|
0
|
my($expr) = @_; |
4823
|
0
|
|
|
|
|
0
|
|
4824
|
0
|
|
|
|
|
0
|
# escape regex metachars but not '\' and glob chars '*', '?' |
4825
|
0
|
0
|
|
|
|
0
|
my $quotemeta = ''; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4826
|
0
|
|
|
|
|
0
|
while ($expr =~ / \G (\\[*?\\] | $q_char) /oxgc) { |
4827
|
|
|
|
|
|
|
my $char = $1; |
4828
|
|
|
|
|
|
|
if ($char =~ /\A \\[*?\\] \z/oxms) { |
4829
|
0
|
|
|
|
|
0
|
$quotemeta .= $char; |
4830
|
|
|
|
|
|
|
} |
4831
|
|
|
|
|
|
|
elsif ($char eq '*') { |
4832
|
0
|
|
|
|
|
0
|
$quotemeta .= "(?:$your_char)*", |
4833
|
|
|
|
|
|
|
} |
4834
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4835
|
|
|
|
|
|
|
$quotemeta .= "(?:$your_char)?", # DOS style |
4836
|
0
|
|
|
|
|
0
|
# $quotemeta .= "(?:$your_char)", # UNIX style |
4837
|
|
|
|
|
|
|
} |
4838
|
|
|
|
|
|
|
elsif ((my $fc = Esjis::fc($char)) ne $char) { |
4839
|
0
|
|
|
|
|
0
|
$quotemeta .= $fc; |
4840
|
|
|
|
|
|
|
} |
4841
|
|
|
|
|
|
|
else { |
4842
|
0
|
|
|
|
|
0
|
$quotemeta .= quotemeta $char; |
4843
|
|
|
|
|
|
|
} |
4844
|
|
|
|
|
|
|
} |
4845
|
|
|
|
|
|
|
return $quotemeta; |
4846
|
|
|
|
|
|
|
} |
4847
|
|
|
|
|
|
|
|
4848
|
|
|
|
|
|
|
# |
4849
|
|
|
|
|
|
|
# via File::HomeDir::Windows 1.00 |
4850
|
|
|
|
|
|
|
# |
4851
|
|
|
|
|
|
|
sub my_home_MSWin32 { |
4852
|
|
|
|
|
|
|
|
4853
|
0
|
0
|
0
|
0
|
0
|
0
|
# A lot of unix people and unix-derived tools rely on |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
4854
|
0
|
|
|
|
|
0
|
# the ability to overload HOME. We will support it too |
4855
|
|
|
|
|
|
|
# so that they can replace raw HOME calls with File::HomeDir. |
4856
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { |
4857
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4858
|
|
|
|
|
|
|
} |
4859
|
0
|
|
|
|
|
0
|
|
4860
|
|
|
|
|
|
|
# Do we have a user profile? |
4861
|
|
|
|
|
|
|
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { |
4862
|
|
|
|
|
|
|
return $ENV{'USERPROFILE'}; |
4863
|
|
|
|
|
|
|
} |
4864
|
0
|
|
|
|
|
0
|
|
4865
|
|
|
|
|
|
|
# Some Windows use something like $ENV{'HOME'} |
4866
|
|
|
|
|
|
|
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { |
4867
|
0
|
|
|
|
|
0
|
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'}; |
4868
|
|
|
|
|
|
|
} |
4869
|
|
|
|
|
|
|
|
4870
|
|
|
|
|
|
|
return undef; |
4871
|
|
|
|
|
|
|
} |
4872
|
|
|
|
|
|
|
|
4873
|
|
|
|
|
|
|
# |
4874
|
|
|
|
|
|
|
# via File::HomeDir::MacOS9 1.00 |
4875
|
|
|
|
|
|
|
# |
4876
|
0
|
0
|
|
0
|
0
|
0
|
sub my_home_MacOS { |
4877
|
0
|
|
|
|
|
0
|
|
4878
|
|
|
|
|
|
|
# Try for $ENV{'HOME'} if we have it |
4879
|
|
|
|
|
|
|
if (defined $ENV{'HOME'}) { |
4880
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4881
|
|
|
|
|
|
|
} |
4882
|
|
|
|
|
|
|
|
4883
|
|
|
|
|
|
|
### DESPERATION SETS IN |
4884
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
4885
|
0
|
|
|
|
|
0
|
# We could use the desktop |
4886
|
|
|
|
|
|
|
SCOPE: { |
4887
|
0
|
|
|
|
|
0
|
local $@; |
4888
|
0
|
|
|
|
|
0
|
CORE::eval { |
4889
|
0
|
|
|
|
|
0
|
# Find the desktop via Mac::Files |
4890
|
|
|
|
|
|
|
local $SIG{'__DIE__'} = ''; |
4891
|
|
|
|
|
|
|
CORE::require Mac::Files; |
4892
|
|
|
|
|
|
|
my $home = Mac::Files::FindFolder( |
4893
|
0
|
0
|
0
|
|
|
0
|
Mac::Files::kOnSystemDisk(), |
4894
|
|
|
|
|
|
|
Mac::Files::kDesktopFolderType(), |
4895
|
|
|
|
|
|
|
); |
4896
|
|
|
|
|
|
|
return $home if $home and Esjis::d($home); |
4897
|
|
|
|
|
|
|
}; |
4898
|
|
|
|
|
|
|
} |
4899
|
|
|
|
|
|
|
|
4900
|
0
|
|
|
|
|
0
|
# Desperation on any platform |
|
0
|
|
|
|
|
0
|
|
4901
|
0
|
|
|
|
|
0
|
SCOPE: { |
4902
|
0
|
0
|
0
|
|
|
0
|
# On some platforms getpwuid dies if called at all |
4903
|
|
|
|
|
|
|
local $SIG{'__DIE__'} = ''; |
4904
|
|
|
|
|
|
|
my $home = CORE::eval q{ (getpwuid($<))[7] }; |
4905
|
0
|
|
|
|
|
0
|
return $home if $home and Esjis::d($home); |
4906
|
|
|
|
|
|
|
} |
4907
|
|
|
|
|
|
|
|
4908
|
|
|
|
|
|
|
croak "Could not locate current user's home directory"; |
4909
|
|
|
|
|
|
|
} |
4910
|
|
|
|
|
|
|
|
4911
|
|
|
|
|
|
|
# |
4912
|
0
|
|
|
0
|
0
|
0
|
# via File::HomeDir::Unix 1.00 |
4913
|
|
|
|
|
|
|
# |
4914
|
0
|
0
|
0
|
|
|
0
|
sub my_home { |
|
|
0
|
0
|
|
|
|
|
4915
|
0
|
|
|
|
|
0
|
my $home; |
4916
|
|
|
|
|
|
|
|
4917
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { |
4918
|
|
|
|
|
|
|
$home = $ENV{'HOME'}; |
4919
|
|
|
|
|
|
|
} |
4920
|
|
|
|
|
|
|
|
4921
|
0
|
|
|
|
|
0
|
# This is from the original code, but I'm guessing |
4922
|
|
|
|
|
|
|
# it means "login directory" and exists on some Unixes. |
4923
|
|
|
|
|
|
|
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { |
4924
|
|
|
|
|
|
|
$home = $ENV{'LOGDIR'}; |
4925
|
|
|
|
|
|
|
} |
4926
|
|
|
|
|
|
|
|
4927
|
|
|
|
|
|
|
### More-desperate methods |
4928
|
0
|
|
|
|
|
0
|
|
4929
|
|
|
|
|
|
|
# Light desperation on any (Unixish) platform |
4930
|
|
|
|
|
|
|
else { |
4931
|
|
|
|
|
|
|
$home = CORE::eval q{ (getpwuid($<))[7] }; |
4932
|
|
|
|
|
|
|
} |
4933
|
0
|
0
|
0
|
|
|
0
|
|
4934
|
0
|
|
|
|
|
0
|
# On Unix in general, a non-existant home means "no home" |
4935
|
|
|
|
|
|
|
# For example, "nobody"-like users might use /nonexistant |
4936
|
0
|
|
|
|
|
0
|
if (defined $home and ! Esjis::d($home)) { |
4937
|
|
|
|
|
|
|
$home = undef; |
4938
|
|
|
|
|
|
|
} |
4939
|
|
|
|
|
|
|
return $home; |
4940
|
|
|
|
|
|
|
} |
4941
|
|
|
|
|
|
|
|
4942
|
|
|
|
|
|
|
# |
4943
|
|
|
|
|
|
|
# ShiftJIS file lstat (with parameter) |
4944
|
0
|
0
|
|
0
|
0
|
0
|
# |
4945
|
|
|
|
|
|
|
sub Esjis::lstat(*) { |
4946
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4947
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
4948
|
|
|
|
|
|
|
|
4949
|
|
|
|
|
|
|
if (-e $_) { |
4950
|
|
|
|
|
|
|
return CORE::lstat _; |
4951
|
|
|
|
|
|
|
} |
4952
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4953
|
|
|
|
|
|
|
|
4954
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::lstat() |
4955
|
0
|
|
|
|
|
0
|
# on Windows opens the file for the path which has 5c at end. |
4956
|
0
|
0
|
|
|
|
0
|
# (and so on) |
4957
|
0
|
0
|
|
|
|
0
|
|
4958
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4959
|
0
|
0
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4960
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4961
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4962
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4963
|
0
|
|
|
|
|
0
|
return @stat; |
4964
|
0
|
0
|
|
|
|
0
|
} |
4965
|
0
|
|
|
|
|
0
|
else { |
4966
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4967
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4968
|
|
|
|
|
|
|
return $stat; |
4969
|
0
|
0
|
|
|
|
0
|
} |
4970
|
|
|
|
|
|
|
} |
4971
|
|
|
|
|
|
|
} |
4972
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4973
|
|
|
|
|
|
|
} |
4974
|
|
|
|
|
|
|
|
4975
|
|
|
|
|
|
|
# |
4976
|
|
|
|
|
|
|
# ShiftJIS file lstat (without parameter) |
4977
|
0
|
0
|
|
0
|
0
|
0
|
# |
|
|
0
|
|
|
|
|
|
4978
|
0
|
|
|
|
|
0
|
sub Esjis::lstat_() { |
4979
|
|
|
|
|
|
|
|
4980
|
|
|
|
|
|
|
if (-e $_) { |
4981
|
0
|
|
|
|
|
0
|
return CORE::lstat _; |
4982
|
0
|
0
|
|
|
|
0
|
} |
4983
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4984
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4985
|
0
|
0
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4986
|
0
|
|
|
|
|
0
|
if (wantarray) { |
4987
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4988
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4989
|
0
|
|
|
|
|
0
|
return @stat; |
4990
|
0
|
0
|
|
|
|
0
|
} |
4991
|
0
|
|
|
|
|
0
|
else { |
4992
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4993
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4994
|
|
|
|
|
|
|
return $stat; |
4995
|
0
|
0
|
|
|
|
0
|
} |
4996
|
|
|
|
|
|
|
} |
4997
|
|
|
|
|
|
|
} |
4998
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4999
|
|
|
|
|
|
|
} |
5000
|
|
|
|
|
|
|
|
5001
|
|
|
|
|
|
|
# |
5002
|
|
|
|
|
|
|
# ShiftJIS path opendir |
5003
|
0
|
|
|
0
|
0
|
0
|
# |
5004
|
0
|
0
|
|
|
|
0
|
sub Esjis::opendir(*$) { |
|
|
0
|
|
|
|
|
|
5005
|
0
|
|
|
|
|
0
|
|
5006
|
|
|
|
|
|
|
my $dh = qualify_to_ref $_[0]; |
5007
|
|
|
|
|
|
|
if (CORE::opendir $dh, $_[1]) { |
5008
|
0
|
0
|
|
|
|
0
|
return 1; |
5009
|
0
|
|
|
|
|
0
|
} |
5010
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_[1])) { |
5011
|
|
|
|
|
|
|
if (CORE::opendir $dh, "$_[1]/.") { |
5012
|
0
|
|
|
|
|
0
|
return 1; |
5013
|
|
|
|
|
|
|
} |
5014
|
|
|
|
|
|
|
} |
5015
|
|
|
|
|
|
|
return undef; |
5016
|
|
|
|
|
|
|
} |
5017
|
|
|
|
|
|
|
|
5018
|
|
|
|
|
|
|
# |
5019
|
|
|
|
|
|
|
# ShiftJIS file stat (with parameter) |
5020
|
0
|
50
|
|
385
|
0
|
0
|
# |
5021
|
|
|
|
|
|
|
sub Esjis::stat(*) { |
5022
|
385
|
|
|
|
|
2387
|
|
5023
|
385
|
50
|
|
|
|
2451
|
local $_ = shift if @_; |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5024
|
385
|
|
|
|
|
13585
|
|
5025
|
|
|
|
|
|
|
my $fh = qualify_to_ref $_; |
5026
|
|
|
|
|
|
|
if (defined fileno $fh) { |
5027
|
0
|
|
|
|
|
0
|
return CORE::stat $fh; |
5028
|
|
|
|
|
|
|
} |
5029
|
|
|
|
|
|
|
elsif (-e $_) { |
5030
|
|
|
|
|
|
|
return CORE::stat _; |
5031
|
|
|
|
|
|
|
} |
5032
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
5033
|
|
|
|
|
|
|
|
5034
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Esjis::stat() |
5035
|
385
|
|
|
|
|
3373
|
# on Windows opens the file for the path which has 5c at end. |
5036
|
0
|
0
|
|
|
|
0
|
# (and so on) |
5037
|
0
|
0
|
|
|
|
0
|
|
5038
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
5039
|
0
|
0
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
5040
|
0
|
|
|
|
|
0
|
if (wantarray) { |
5041
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5042
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
5043
|
0
|
|
|
|
|
0
|
return @stat; |
5044
|
0
|
0
|
|
|
|
0
|
} |
5045
|
0
|
|
|
|
|
0
|
else { |
5046
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5047
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
5048
|
|
|
|
|
|
|
return $stat; |
5049
|
0
|
0
|
|
|
|
0
|
} |
5050
|
|
|
|
|
|
|
} |
5051
|
|
|
|
|
|
|
} |
5052
|
|
|
|
|
|
|
return wantarray ? () : undef; |
5053
|
|
|
|
|
|
|
} |
5054
|
|
|
|
|
|
|
|
5055
|
|
|
|
|
|
|
# |
5056
|
|
|
|
|
|
|
# ShiftJIS file stat (without parameter) |
5057
|
0
|
|
|
0
|
0
|
0
|
# |
5058
|
0
|
0
|
|
|
|
0
|
sub Esjis::stat_() { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5059
|
0
|
|
|
|
|
0
|
|
5060
|
|
|
|
|
|
|
my $fh = qualify_to_ref $_; |
5061
|
|
|
|
|
|
|
if (defined fileno $fh) { |
5062
|
0
|
|
|
|
|
0
|
return CORE::stat $fh; |
5063
|
|
|
|
|
|
|
} |
5064
|
|
|
|
|
|
|
elsif (-e $_) { |
5065
|
0
|
|
|
|
|
0
|
return CORE::stat _; |
5066
|
0
|
0
|
|
|
|
0
|
} |
5067
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
5068
|
0
|
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
5069
|
0
|
0
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
5070
|
0
|
|
|
|
|
0
|
if (wantarray) { |
5071
|
|
|
|
|
|
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5072
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
5073
|
0
|
|
|
|
|
0
|
return @stat; |
5074
|
0
|
0
|
|
|
|
0
|
} |
5075
|
0
|
|
|
|
|
0
|
else { |
5076
|
|
|
|
|
|
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
5077
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
5078
|
|
|
|
|
|
|
return $stat; |
5079
|
0
|
0
|
|
|
|
0
|
} |
5080
|
|
|
|
|
|
|
} |
5081
|
|
|
|
|
|
|
} |
5082
|
|
|
|
|
|
|
return wantarray ? () : undef; |
5083
|
|
|
|
|
|
|
} |
5084
|
|
|
|
|
|
|
|
5085
|
|
|
|
|
|
|
# |
5086
|
|
|
|
|
|
|
# ShiftJIS path unlink |
5087
|
0
|
0
|
|
0
|
0
|
0
|
# |
5088
|
|
|
|
|
|
|
sub Esjis::unlink(@) { |
5089
|
0
|
|
|
|
|
0
|
|
5090
|
0
|
|
|
|
|
0
|
local @_ = ($_) unless @_; |
5091
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
5092
|
0
|
|
|
|
|
0
|
my $unlink = 0; |
5093
|
|
|
|
|
|
|
for (@_) { |
5094
|
|
|
|
|
|
|
if (CORE::unlink) { |
5095
|
|
|
|
|
|
|
$unlink++; |
5096
|
|
|
|
|
|
|
} |
5097
|
0
|
|
|
|
|
0
|
elsif (Esjis::d($_)) { |
5098
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5099
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
5100
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
5101
|
|
|
|
|
|
|
my $file = join '', map {{'/' => '\\'}->{$_} || $_} @char; |
5102
|
0
|
|
|
|
|
0
|
if ($file =~ / \A (?:$q_char)*? [ ] /oxms) { |
5103
|
0
|
0
|
|
|
|
0
|
$file = qq{"$file"}; |
5104
|
0
|
0
|
|
|
|
0
|
} |
5105
|
|
|
|
|
|
|
my $fh = gensym(); |
5106
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
5107
|
0
|
0
|
0
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
|
|
0
|
|
|
|
|
|
5108
|
0
|
|
|
|
|
0
|
|
5109
|
|
|
|
|
|
|
# cmd.exe on Windows NT, Windows 2000, Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
5110
|
|
|
|
|
|
|
if ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
5111
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
5112
|
|
|
|
|
|
|
} |
5113
|
0
|
|
|
|
|
0
|
|
5114
|
|
|
|
|
|
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
5115
|
|
|
|
|
|
|
elsif (qx{ver} =~ /\b(?:Windows 2000)\b/oms) { |
5116
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
5117
|
|
|
|
|
|
|
} |
5118
|
|
|
|
|
|
|
|
5119
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
5120
|
0
|
|
|
|
|
0
|
# command.com can not "2>NUL" |
5121
|
|
|
|
|
|
|
else { |
5122
|
|
|
|
|
|
|
CORE::system 'ATTRIB', '-R', $file; # clears Read-only file attribute |
5123
|
0
|
0
|
|
|
|
0
|
CORE::system 'DEL', $file; |
5124
|
0
|
0
|
|
|
|
0
|
} |
5125
|
|
|
|
|
|
|
|
5126
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
5127
|
0
|
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
5128
|
|
|
|
|
|
|
} |
5129
|
|
|
|
|
|
|
else { |
5130
|
|
|
|
|
|
|
$unlink++; |
5131
|
|
|
|
|
|
|
} |
5132
|
0
|
|
|
|
|
0
|
} |
5133
|
|
|
|
|
|
|
} |
5134
|
|
|
|
|
|
|
} |
5135
|
|
|
|
|
|
|
return $unlink; |
5136
|
|
|
|
|
|
|
} |
5137
|
|
|
|
|
|
|
|
5138
|
|
|
|
|
|
|
# |
5139
|
|
|
|
|
|
|
# ShiftJIS chdir |
5140
|
0
|
0
|
|
0
|
0
|
0
|
# |
5141
|
0
|
|
|
|
|
0
|
sub Esjis::chdir(;$) { |
5142
|
|
|
|
|
|
|
|
5143
|
|
|
|
|
|
|
if (@_ == 0) { |
5144
|
0
|
|
|
|
|
0
|
return CORE::chdir; |
5145
|
|
|
|
|
|
|
} |
5146
|
0
|
0
|
|
|
|
0
|
|
5147
|
0
|
0
|
|
|
|
0
|
my($dir) = @_; |
5148
|
0
|
|
|
|
|
0
|
|
5149
|
|
|
|
|
|
|
if (_MSWin32_5Cended_path($dir)) { |
5150
|
|
|
|
|
|
|
if (not Esjis::d $dir) { |
5151
|
0
|
0
|
0
|
|
|
0
|
return 0; |
|
|
0
|
|
|
|
|
|
5152
|
0
|
|
|
|
|
0
|
} |
5153
|
|
|
|
|
|
|
|
5154
|
|
|
|
|
|
|
if ($] =~ /^5\.005/oxms) { |
5155
|
0
|
|
|
|
|
0
|
return CORE::chdir $dir; |
5156
|
0
|
|
|
|
|
0
|
} |
5157
|
|
|
|
|
|
|
elsif (($] =~ /^(?:5\.006|5\.008000)/oxms) and ($^O eq 'MSWin32')) { |
5158
|
|
|
|
|
|
|
local $@; |
5159
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
5160
|
|
|
|
|
|
|
CORE::require 'jacode.pl'; |
5161
|
|
|
|
|
|
|
|
5162
|
|
|
|
|
|
|
# P.676 ${^WIDE_SYSTEM_CALLS} |
5163
|
|
|
|
|
|
|
# in Chapter 28: Special Names |
5164
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5165
|
|
|
|
|
|
|
|
5166
|
|
|
|
|
|
|
# P.790 ${^WIDE_SYSTEM_CALLS} |
5167
|
|
|
|
|
|
|
# in Chapter 25: Special Names |
5168
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5169
|
|
|
|
|
|
|
|
5170
|
0
|
0
|
|
|
|
0
|
local ${^WIDE_SYSTEM_CALLS} = 1; |
5171
|
0
|
|
|
|
|
0
|
return CORE::chdir jcode::utf8($dir,'sjis'); |
5172
|
|
|
|
|
|
|
}; |
5173
|
|
|
|
|
|
|
if (not $@) { |
5174
|
|
|
|
|
|
|
return $chdir; |
5175
|
|
|
|
|
|
|
} |
5176
|
|
|
|
|
|
|
} |
5177
|
|
|
|
|
|
|
|
5178
|
|
|
|
|
|
|
# old idea (Win32 module required) |
5179
|
|
|
|
|
|
|
elsif (0) { |
5180
|
|
|
|
|
|
|
local $@; |
5181
|
|
|
|
|
|
|
my $shortdir = ''; |
5182
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
5183
|
|
|
|
|
|
|
use Win32; |
5184
|
|
|
|
|
|
|
$shortdir = Win32::GetShortPathName($dir); |
5185
|
|
|
|
|
|
|
if ($shortdir ne $dir) { |
5186
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
5187
|
|
|
|
|
|
|
} |
5188
|
|
|
|
|
|
|
else { |
5189
|
|
|
|
|
|
|
return 0; |
5190
|
|
|
|
|
|
|
} |
5191
|
|
|
|
|
|
|
}; |
5192
|
|
|
|
|
|
|
if ($@) { |
5193
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
5194
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
5195
|
|
|
|
|
|
|
pop @char; |
5196
|
|
|
|
|
|
|
} |
5197
|
|
|
|
|
|
|
$dir = join '', @char; |
5198
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path), Win32.pm module may help you"; |
5199
|
|
|
|
|
|
|
} |
5200
|
|
|
|
|
|
|
elsif ($shortdir eq $dir) { |
5201
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
5202
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
5203
|
|
|
|
|
|
|
pop @char; |
5204
|
|
|
|
|
|
|
} |
5205
|
|
|
|
|
|
|
$dir = join '', @char; |
5206
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path)"; |
5207
|
|
|
|
|
|
|
} |
5208
|
|
|
|
|
|
|
return $chdir; |
5209
|
0
|
|
|
|
|
0
|
} |
5210
|
|
|
|
|
|
|
|
5211
|
|
|
|
|
|
|
# rejected idea ... |
5212
|
|
|
|
|
|
|
elsif (0) { |
5213
|
|
|
|
|
|
|
|
5214
|
|
|
|
|
|
|
# MSDN SetCurrentDirectory function |
5215
|
|
|
|
|
|
|
# http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365530(v=vs.85).aspx |
5216
|
|
|
|
|
|
|
# |
5217
|
|
|
|
|
|
|
# Data Execution Prevention (DEP) |
5218
|
|
|
|
|
|
|
# http://vlaurie.com/computers2/Articles/dep.htm |
5219
|
|
|
|
|
|
|
# |
5220
|
|
|
|
|
|
|
# Learning x86 assembler with Perl -- Shibuya.pm#11 |
5221
|
|
|
|
|
|
|
# http://developer.cybozu.co.jp/takesako/2009/06/perl-x86-shibuy.html |
5222
|
|
|
|
|
|
|
# |
5223
|
|
|
|
|
|
|
# Introduction to Win32::API programming in Perl |
5224
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559 |
5225
|
|
|
|
|
|
|
# |
5226
|
|
|
|
|
|
|
# DynaLoader - Dynamically load C libraries into Perl code |
5227
|
|
|
|
|
|
|
# http://perldoc.perl.org/DynaLoader.html |
5228
|
|
|
|
|
|
|
# |
5229
|
|
|
|
|
|
|
# Basic knowledge of DynaLoader |
5230
|
|
|
|
|
|
|
# http://blog.64p.org/entry/20090313/1236934042 |
5231
|
|
|
|
|
|
|
|
5232
|
|
|
|
|
|
|
if (($] =~ /^5\.006/oxms) and |
5233
|
|
|
|
|
|
|
($^O eq 'MSWin32') and |
5234
|
|
|
|
|
|
|
($ENV{'PROCESSOR_ARCHITECTURE'} eq 'x86') and |
5235
|
|
|
|
|
|
|
CORE::eval(q{CORE::require 'Dyna'.'Loader'}) |
5236
|
|
|
|
|
|
|
) { |
5237
|
|
|
|
|
|
|
my $x86 = join('', |
5238
|
|
|
|
|
|
|
|
5239
|
|
|
|
|
|
|
# PUSH Iv |
5240
|
|
|
|
|
|
|
"\x68", pack('P', "$dir\\\0"), |
5241
|
|
|
|
|
|
|
|
5242
|
|
|
|
|
|
|
# MOV eAX, Iv |
5243
|
|
|
|
|
|
|
"\xb8", pack('L', |
5244
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_find_symbol'}{'CODE'}->( |
5245
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_load_file'}{'CODE'}->("$ENV{'SystemRoot'}\\system32\\kernel32.dll"), |
5246
|
|
|
|
|
|
|
'SetCurrentDirectoryA' |
5247
|
|
|
|
|
|
|
) |
5248
|
|
|
|
|
|
|
), |
5249
|
|
|
|
|
|
|
|
5250
|
|
|
|
|
|
|
# CALL eAX |
5251
|
|
|
|
|
|
|
"\xff\xd0", |
5252
|
|
|
|
|
|
|
|
5253
|
|
|
|
|
|
|
# RETN |
5254
|
|
|
|
|
|
|
"\xc3", |
5255
|
|
|
|
|
|
|
); |
5256
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_install_xsub'}{'CODE'}->('_SetCurrentDirectoryA', unpack('L', pack 'P', $x86)); |
5257
|
|
|
|
|
|
|
_SetCurrentDirectoryA(); |
5258
|
|
|
|
|
|
|
chomp(my $chdir = qx{chdir}); |
5259
|
|
|
|
|
|
|
if (Esjis::fc($chdir) eq Esjis::fc($dir)) { |
5260
|
|
|
|
|
|
|
return 1; |
5261
|
|
|
|
|
|
|
} |
5262
|
|
|
|
|
|
|
else { |
5263
|
|
|
|
|
|
|
return 0; |
5264
|
|
|
|
|
|
|
} |
5265
|
|
|
|
|
|
|
} |
5266
|
|
|
|
|
|
|
} |
5267
|
|
|
|
|
|
|
|
5268
|
|
|
|
|
|
|
# COMMAND.COM's unhelpful tips: |
5269
|
|
|
|
|
|
|
# Displays a list of files and subdirectories in a directory. |
5270
|
|
|
|
|
|
|
# http://www.lagmonster.org/docs/DOS7/z-dir.html |
5271
|
|
|
|
|
|
|
# |
5272
|
|
|
|
|
|
|
# Syntax: |
5273
|
|
|
|
|
|
|
# |
5274
|
|
|
|
|
|
|
# DIR [drive:] [path] [filename] [/Switches] |
5275
|
|
|
|
|
|
|
# |
5276
|
|
|
|
|
|
|
# /Z Long file names are not displayed in the file listing |
5277
|
|
|
|
|
|
|
# |
5278
|
|
|
|
|
|
|
# Limitations |
5279
|
|
|
|
|
|
|
# The undocumented /Z switch (no long names) would appear to |
5280
|
|
|
|
|
|
|
# have been not fully developed and has a couple of problems: |
5281
|
|
|
|
|
|
|
# |
5282
|
|
|
|
|
|
|
# 1. It will only work if: |
5283
|
|
|
|
|
|
|
# There is no path specified (ie. for the current directory in |
5284
|
|
|
|
|
|
|
# the current drive) |
5285
|
|
|
|
|
|
|
# The path is specified as the root directory of any drive |
5286
|
|
|
|
|
|
|
# (eg. C:\, D:\, etc.) |
5287
|
|
|
|
|
|
|
# The path is specified as the current directory of any drive |
5288
|
|
|
|
|
|
|
# by using the drive letter only (eg. C:, D:, etc.) |
5289
|
|
|
|
|
|
|
# The path is specified as the parent directory using the .. |
5290
|
|
|
|
|
|
|
# notation (eg. DIR .. /Z) |
5291
|
|
|
|
|
|
|
# Any other syntax results in a "File Not Found" error message. |
5292
|
|
|
|
|
|
|
# |
5293
|
|
|
|
|
|
|
# 2. The /Z switch is compatable with the /S switch to show |
5294
|
|
|
|
|
|
|
# subdirectories (as long as the above rules are followed) and |
5295
|
|
|
|
|
|
|
# all the files are shown with short names only. The |
5296
|
|
|
|
|
|
|
# subdirectories are also shown with short names only. However, |
5297
|
|
|
|
|
|
|
# the header for each subdirectory after the first level gives |
5298
|
|
|
|
|
|
|
# the subdirectory's long name. |
5299
|
|
|
|
|
|
|
# |
5300
|
|
|
|
|
|
|
# 3. The /Z switch is also compatable with the /B switch to give |
5301
|
|
|
|
|
|
|
# a simple list of files with short names only. When used with |
5302
|
|
|
|
|
|
|
# the /S switch as well, all files are listed with their full |
5303
|
|
|
|
|
|
|
# paths. The file names themselves are all in short form, and |
5304
|
|
|
|
|
|
|
# the path of those files in the current directory are in short |
5305
|
0
|
|
|
|
|
0
|
# form, but the paths of any files in subdirectories are in |
5306
|
0
|
|
|
|
|
0
|
# long filename form. |
5307
|
0
|
|
|
|
|
0
|
|
5308
|
0
|
|
|
|
|
0
|
my $shortdir = ''; |
5309
|
0
|
|
|
|
|
0
|
my $i = 0; |
5310
|
0
|
0
|
0
|
|
|
0
|
my @subdir = (); |
5311
|
0
|
|
|
|
|
0
|
while ($dir =~ / \G ($q_char) /oxgc) { |
5312
|
0
|
|
|
|
|
0
|
my $char = $1; |
5313
|
0
|
|
|
|
|
0
|
if (($char eq '\\') or ($char eq '/')) { |
5314
|
|
|
|
|
|
|
$i++; |
5315
|
|
|
|
|
|
|
$subdir[$i] = $char; |
5316
|
0
|
|
|
|
|
0
|
$i++; |
5317
|
|
|
|
|
|
|
} |
5318
|
|
|
|
|
|
|
else { |
5319
|
0
|
0
|
0
|
|
|
0
|
$subdir[$i] .= $char; |
5320
|
0
|
|
|
|
|
0
|
} |
5321
|
|
|
|
|
|
|
} |
5322
|
|
|
|
|
|
|
if (($subdir[-1] eq '\\') or ($subdir[-1] eq '/')) { |
5323
|
|
|
|
|
|
|
pop @subdir; |
5324
|
|
|
|
|
|
|
} |
5325
|
|
|
|
|
|
|
|
5326
|
|
|
|
|
|
|
# P.504 PERL5SHELL (Microsoft ports only) |
5327
|
|
|
|
|
|
|
# in Chapter 19: The Command-Line Interface |
5328
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5329
|
|
|
|
|
|
|
|
5330
|
|
|
|
|
|
|
# P.597 PERL5SHELL (Microsoft ports only) |
5331
|
|
|
|
|
|
|
# in Chapter 17: The Command-Line Interface |
5332
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5333
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
5334
|
0
|
|
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
5335
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000 |
|
0
|
|
|
|
|
0
|
|
5336
|
0
|
0
|
|
|
|
0
|
if (qx{ver} =~ /\b(?:Windows NT|Windows 2000)\b/oms) { |
5337
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5338
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5339
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5340
|
0
|
|
|
|
|
0
|
|
5341
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5342
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 39, 8+1+3; |
5343
|
|
|
|
|
|
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5344
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5345
|
|
|
|
|
|
|
last; |
5346
|
|
|
|
|
|
|
} |
5347
|
|
|
|
|
|
|
} |
5348
|
|
|
|
|
|
|
} |
5349
|
|
|
|
|
|
|
|
5350
|
|
|
|
|
|
|
# an idea (not so portable, only Windows 2000 or later) |
5351
|
|
|
|
|
|
|
elsif (0) { |
5352
|
|
|
|
|
|
|
chomp($shortdir = qx{for %I in ("$dir") do \@echo %~sI 2>NUL}); |
5353
|
|
|
|
|
|
|
} |
5354
|
0
|
|
|
|
|
0
|
|
5355
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
|
0
|
|
|
|
|
0
|
|
5356
|
0
|
0
|
|
|
|
0
|
elsif ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
5357
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5358
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5359
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5360
|
0
|
|
|
|
|
0
|
|
5361
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5362
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 36, 8+1+3; |
5363
|
|
|
|
|
|
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5364
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5365
|
|
|
|
|
|
|
last; |
5366
|
|
|
|
|
|
|
} |
5367
|
|
|
|
|
|
|
} |
5368
|
|
|
|
|
|
|
} |
5369
|
0
|
|
|
|
|
0
|
|
5370
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
|
0
|
|
|
|
|
0
|
|
5371
|
0
|
0
|
|
|
|
0
|
else { |
5372
|
|
|
|
|
|
|
chomp(my @dirx = grep //oxms, qx{dir /ad "$dir*"}); |
5373
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5374
|
0
|
|
|
|
|
0
|
if (Esjis::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Esjis::fc($subdir[-1])) { |
5375
|
0
|
|
|
|
|
0
|
|
5376
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----v |
5377
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 0, 8+1+3; |
5378
|
0
|
|
|
|
|
0
|
CORE::substr($shortleafdir,8,1) = '.'; |
5379
|
|
|
|
|
|
|
$shortleafdir =~ s/ \. [ ]+ \z//oxms; |
5380
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5381
|
|
|
|
|
|
|
last; |
5382
|
|
|
|
|
|
|
} |
5383
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5384
|
0
|
|
|
|
|
0
|
} |
5385
|
|
|
|
|
|
|
|
5386
|
|
|
|
|
|
|
if ($shortdir eq '') { |
5387
|
0
|
|
|
|
|
0
|
return 0; |
5388
|
|
|
|
|
|
|
} |
5389
|
0
|
|
|
|
|
0
|
elsif (Esjis::fc($shortdir) eq Esjis::fc($dir)) { |
5390
|
|
|
|
|
|
|
return 0; |
5391
|
|
|
|
|
|
|
} |
5392
|
0
|
|
|
|
|
0
|
return CORE::chdir $shortdir; |
5393
|
|
|
|
|
|
|
} |
5394
|
|
|
|
|
|
|
else { |
5395
|
|
|
|
|
|
|
return CORE::chdir $dir; |
5396
|
|
|
|
|
|
|
} |
5397
|
|
|
|
|
|
|
} |
5398
|
|
|
|
|
|
|
|
5399
|
|
|
|
|
|
|
# |
5400
|
|
|
|
|
|
|
# ShiftJIS chr(0x5C) ended path on MSWin32 |
5401
|
0
|
50
|
33
|
770
|
|
0
|
# |
5402
|
770
|
50
|
|
|
|
4826
|
sub _MSWin32_5Cended_path { |
5403
|
770
|
|
|
|
|
4280
|
|
5404
|
0
|
0
|
|
|
|
0
|
if ((@_ >= 1) and ($_[0] ne '')) { |
5405
|
0
|
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
5406
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5407
|
|
|
|
|
|
|
if ($char[-1] =~ / \x5C \z/oxms) { |
5408
|
|
|
|
|
|
|
return 1; |
5409
|
0
|
|
|
|
|
0
|
} |
5410
|
|
|
|
|
|
|
} |
5411
|
|
|
|
|
|
|
} |
5412
|
|
|
|
|
|
|
return undef; |
5413
|
|
|
|
|
|
|
} |
5414
|
|
|
|
|
|
|
|
5415
|
|
|
|
|
|
|
# |
5416
|
|
|
|
|
|
|
# do ShiftJIS file |
5417
|
770
|
|
|
0
|
0
|
1942
|
# |
5418
|
|
|
|
|
|
|
sub Esjis::do($) { |
5419
|
0
|
|
|
|
|
0
|
|
5420
|
|
|
|
|
|
|
my($filename) = @_; |
5421
|
|
|
|
|
|
|
|
5422
|
|
|
|
|
|
|
my $realfilename; |
5423
|
0
|
|
|
|
|
0
|
my $result; |
|
0
|
|
|
|
|
0
|
|
5424
|
0
|
0
|
|
|
|
0
|
ITER_DO: |
5425
|
0
|
|
|
|
|
0
|
{ |
5426
|
|
|
|
|
|
|
for my $prefix (@INC) { |
5427
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5428
|
0
|
|
|
|
|
0
|
$realfilename = "$prefix$filename"; |
5429
|
|
|
|
|
|
|
} |
5430
|
|
|
|
|
|
|
else { |
5431
|
0
|
0
|
|
|
|
0
|
$realfilename = "$prefix/$filename"; |
5432
|
|
|
|
|
|
|
} |
5433
|
0
|
|
|
|
|
0
|
|
5434
|
|
|
|
|
|
|
if (Esjis::f($realfilename)) { |
5435
|
0
|
0
|
|
|
|
0
|
|
5436
|
0
|
|
|
|
|
0
|
my $script = ''; |
5437
|
0
|
|
|
|
|
0
|
|
5438
|
0
|
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
5439
|
0
|
0
|
0
|
|
|
0
|
my $e_mtime = (Esjis::stat("$realfilename.e"))[9]; |
5440
|
0
|
|
|
|
|
0
|
my $mtime = (Esjis::stat($realfilename))[9]; |
5441
|
|
|
|
|
|
|
my $module_mtime = (Esjis::stat(__FILE__))[9]; |
5442
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5443
|
|
|
|
|
|
|
Esjis::unlink "$realfilename.e"; |
5444
|
0
|
0
|
|
|
|
0
|
} |
5445
|
0
|
|
|
|
|
0
|
} |
5446
|
0
|
0
|
|
|
|
0
|
|
5447
|
0
|
0
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
|
|
0
|
|
|
|
|
|
5448
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5449
|
|
|
|
|
|
|
if (_open_r($fh, "$realfilename.e")) { |
5450
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5451
|
|
|
|
|
|
|
CORE::eval q{ |
5452
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5453
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5454
|
|
|
|
|
|
|
}; |
5455
|
|
|
|
|
|
|
} |
5456
|
|
|
|
|
|
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5457
|
|
|
|
|
|
|
|
5458
|
|
|
|
|
|
|
# P.419 File Locking |
5459
|
|
|
|
|
|
|
# in Chapter 16: Interprocess Communication |
5460
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5461
|
|
|
|
|
|
|
|
5462
|
|
|
|
|
|
|
# P.524 File Locking |
5463
|
|
|
|
|
|
|
# in Chapter 15: Interprocess Communication |
5464
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5465
|
0
|
|
|
|
|
0
|
|
5466
|
0
|
0
|
|
|
|
0
|
# (and so on) |
5467
|
0
|
|
|
|
|
0
|
|
5468
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5469
|
|
|
|
|
|
|
if ($@) { |
5470
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5471
|
0
|
|
|
|
|
0
|
} |
5472
|
|
|
|
|
|
|
} |
5473
|
0
|
|
|
|
|
0
|
else { |
5474
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5475
|
0
|
0
|
|
|
|
0
|
} |
5476
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5477
|
|
|
|
|
|
|
$script = <$fh>; |
5478
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5479
|
|
|
|
|
|
|
CORE::eval q{ |
5480
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5481
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5482
|
|
|
|
|
|
|
}; |
5483
|
|
|
|
|
|
|
} |
5484
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5485
|
0
|
|
|
|
|
0
|
} |
5486
|
0
|
0
|
|
|
|
0
|
} |
5487
|
0
|
0
|
|
|
|
0
|
else { |
|
|
0
|
|
|
|
|
|
5488
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5489
|
|
|
|
|
|
|
if (_open_r($fh, $realfilename)) { |
5490
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5491
|
|
|
|
|
|
|
CORE::eval q{ |
5492
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5493
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5494
|
0
|
|
|
|
|
0
|
}; |
5495
|
0
|
0
|
|
|
|
0
|
} |
5496
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5497
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5498
|
|
|
|
|
|
|
if ($@) { |
5499
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5500
|
0
|
|
|
|
|
0
|
} |
5501
|
|
|
|
|
|
|
} |
5502
|
0
|
|
|
|
|
0
|
else { |
5503
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5504
|
0
|
0
|
|
|
|
0
|
} |
5505
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5506
|
|
|
|
|
|
|
$script = <$fh>; |
5507
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5508
|
|
|
|
|
|
|
CORE::eval q{ |
5509
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5510
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock($realfilename); |
5511
|
|
|
|
|
|
|
}; |
5512
|
|
|
|
|
|
|
} |
5513
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5514
|
0
|
|
|
|
|
0
|
} |
5515
|
0
|
|
|
|
|
0
|
|
5516
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
5517
|
0
|
0
|
|
|
|
0
|
CORE::require Sjis; |
5518
|
0
|
0
|
|
|
|
0
|
$script = Sjis::escape_script($script); |
|
|
0
|
|
|
|
|
|
5519
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5520
|
|
|
|
|
|
|
open($fh, ">$realfilename.e") or die __FILE__, ": Can't write open file: $realfilename.e\n"; |
5521
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5522
|
|
|
|
|
|
|
CORE::eval q{ |
5523
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5524
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5525
|
0
|
|
|
|
|
0
|
}; |
5526
|
0
|
0
|
|
|
|
0
|
} |
5527
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5528
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5529
|
|
|
|
|
|
|
if ($@) { |
5530
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5531
|
0
|
|
|
|
|
0
|
} |
5532
|
|
|
|
|
|
|
} |
5533
|
0
|
|
|
|
|
0
|
else { |
5534
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5535
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5536
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
5537
|
0
|
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5538
|
|
|
|
|
|
|
print {$fh} $script; |
5539
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5540
|
|
|
|
|
|
|
CORE::eval q{ |
5541
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5542
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5543
|
|
|
|
|
|
|
}; |
5544
|
|
|
|
|
|
|
} |
5545
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5546
|
|
|
|
|
|
|
} |
5547
|
390
|
|
|
390
|
|
13389
|
} |
|
390
|
|
|
|
|
3323
|
|
|
390
|
|
|
|
|
382196
|
|
|
0
|
|
|
|
|
0
|
|
5548
|
0
|
|
|
|
|
0
|
|
5549
|
|
|
|
|
|
|
{ |
5550
|
0
|
|
|
|
|
0
|
no strict; |
5551
|
|
|
|
|
|
|
$result = scalar CORE::eval $script; |
5552
|
|
|
|
|
|
|
} |
5553
|
|
|
|
|
|
|
last ITER_DO; |
5554
|
|
|
|
|
|
|
} |
5555
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5556
|
0
|
|
|
|
|
0
|
} |
5557
|
0
|
|
|
|
|
0
|
|
5558
|
|
|
|
|
|
|
if ($@) { |
5559
|
|
|
|
|
|
|
$INC{$filename} = undef; |
5560
|
0
|
|
|
|
|
0
|
return undef; |
5561
|
|
|
|
|
|
|
} |
5562
|
|
|
|
|
|
|
elsif (not $result) { |
5563
|
0
|
|
|
|
|
0
|
return undef; |
5564
|
0
|
|
|
|
|
0
|
} |
5565
|
|
|
|
|
|
|
else { |
5566
|
|
|
|
|
|
|
$INC{$filename} = $realfilename; |
5567
|
|
|
|
|
|
|
return $result; |
5568
|
|
|
|
|
|
|
} |
5569
|
|
|
|
|
|
|
} |
5570
|
|
|
|
|
|
|
|
5571
|
|
|
|
|
|
|
# |
5572
|
|
|
|
|
|
|
# require ShiftJIS file |
5573
|
|
|
|
|
|
|
# |
5574
|
|
|
|
|
|
|
|
5575
|
|
|
|
|
|
|
# require |
5576
|
|
|
|
|
|
|
# in Chapter 3: Functions |
5577
|
|
|
|
|
|
|
# of ISBN 1-56592-149-6 Programming Perl, Second Edition. |
5578
|
|
|
|
|
|
|
# |
5579
|
|
|
|
|
|
|
# sub require { |
5580
|
|
|
|
|
|
|
# my($filename) = @_; |
5581
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5582
|
|
|
|
|
|
|
# my($realfilename, $result); |
5583
|
|
|
|
|
|
|
# ITER: { |
5584
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5585
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5586
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5587
|
|
|
|
|
|
|
# $result = CORE::eval `cat $realfilename`; |
5588
|
|
|
|
|
|
|
# last ITER; |
5589
|
|
|
|
|
|
|
# } |
5590
|
|
|
|
|
|
|
# } |
5591
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5592
|
|
|
|
|
|
|
# } |
5593
|
|
|
|
|
|
|
# die $@ if $@; |
5594
|
|
|
|
|
|
|
# die "$filename did not return true value" unless $result; |
5595
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5596
|
|
|
|
|
|
|
# return $result; |
5597
|
|
|
|
|
|
|
# } |
5598
|
|
|
|
|
|
|
|
5599
|
|
|
|
|
|
|
# require |
5600
|
|
|
|
|
|
|
# in Chapter 9: perlfunc: Perl builtin functions |
5601
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5602
|
|
|
|
|
|
|
# |
5603
|
|
|
|
|
|
|
# sub require { |
5604
|
|
|
|
|
|
|
# my($filename) = @_; |
5605
|
|
|
|
|
|
|
# if (exists $INC{$filename}) { |
5606
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5607
|
|
|
|
|
|
|
# die "Compilation failed in require"; |
5608
|
|
|
|
|
|
|
# } |
5609
|
|
|
|
|
|
|
# my($realfilename, $result); |
5610
|
|
|
|
|
|
|
# ITER: { |
5611
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5612
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5613
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5614
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5615
|
|
|
|
|
|
|
# $result = do $realfilename; |
5616
|
|
|
|
|
|
|
# last ITER; |
5617
|
|
|
|
|
|
|
# } |
5618
|
|
|
|
|
|
|
# } |
5619
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5620
|
|
|
|
|
|
|
# } |
5621
|
|
|
|
|
|
|
# if ($@) { |
5622
|
|
|
|
|
|
|
# $INC{$filename} = undef; |
5623
|
|
|
|
|
|
|
# die $@; |
5624
|
|
|
|
|
|
|
# } |
5625
|
|
|
|
|
|
|
# elsif (!$result) { |
5626
|
|
|
|
|
|
|
# delete $INC{$filename}; |
5627
|
|
|
|
|
|
|
# die "$filename did not return true value"; |
5628
|
|
|
|
|
|
|
# } |
5629
|
|
|
|
|
|
|
# else { |
5630
|
|
|
|
|
|
|
# return $result; |
5631
|
|
|
|
|
|
|
# } |
5632
|
|
|
|
|
|
|
# } |
5633
|
0
|
0
|
|
0
|
0
|
0
|
|
5634
|
|
|
|
|
|
|
sub Esjis::require(;$) { |
5635
|
0
|
0
|
|
|
|
0
|
|
5636
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5637
|
0
|
|
|
|
|
0
|
|
5638
|
|
|
|
|
|
|
if (exists $INC{$_}) { |
5639
|
|
|
|
|
|
|
return 1 if $INC{$_}; |
5640
|
|
|
|
|
|
|
croak "Compilation failed in require: $_"; |
5641
|
|
|
|
|
|
|
} |
5642
|
|
|
|
|
|
|
|
5643
|
|
|
|
|
|
|
# jcode.pl |
5644
|
|
|
|
|
|
|
# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/ |
5645
|
|
|
|
|
|
|
|
5646
|
0
|
0
|
|
|
|
0
|
# jacode.pl |
5647
|
0
|
|
|
|
|
0
|
# http://search.cpan.org/dist/jacode/ |
5648
|
|
|
|
|
|
|
|
5649
|
|
|
|
|
|
|
if (/ \b (?: jcode\.pl | jacode(?>[0-9]*)\.pl ) \z /oxms) { |
5650
|
0
|
|
|
|
|
0
|
return CORE::require($_); |
5651
|
|
|
|
|
|
|
} |
5652
|
|
|
|
|
|
|
|
5653
|
|
|
|
|
|
|
my $realfilename; |
5654
|
0
|
|
|
|
|
0
|
my $result; |
|
0
|
|
|
|
|
0
|
|
5655
|
0
|
0
|
|
|
|
0
|
ITER_REQUIRE: |
5656
|
0
|
|
|
|
|
0
|
{ |
5657
|
|
|
|
|
|
|
for my $prefix (@INC) { |
5658
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5659
|
0
|
|
|
|
|
0
|
$realfilename = "$prefix$_"; |
5660
|
|
|
|
|
|
|
} |
5661
|
|
|
|
|
|
|
else { |
5662
|
0
|
0
|
|
|
|
0
|
$realfilename = "$prefix/$_"; |
5663
|
0
|
|
|
|
|
0
|
} |
5664
|
|
|
|
|
|
|
|
5665
|
0
|
|
|
|
|
0
|
if (Esjis::f($realfilename)) { |
5666
|
|
|
|
|
|
|
$INC{$_} = $realfilename; |
5667
|
0
|
0
|
|
|
|
0
|
|
5668
|
0
|
|
|
|
|
0
|
my $script = ''; |
5669
|
0
|
|
|
|
|
0
|
|
5670
|
0
|
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
5671
|
0
|
0
|
0
|
|
|
0
|
my $e_mtime = (Esjis::stat("$realfilename.e"))[9]; |
5672
|
0
|
|
|
|
|
0
|
my $mtime = (Esjis::stat($realfilename))[9]; |
5673
|
|
|
|
|
|
|
my $module_mtime = (Esjis::stat(__FILE__))[9]; |
5674
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5675
|
|
|
|
|
|
|
Esjis::unlink "$realfilename.e"; |
5676
|
0
|
0
|
|
|
|
0
|
} |
5677
|
0
|
|
|
|
|
0
|
} |
5678
|
0
|
0
|
|
|
|
0
|
|
5679
|
0
|
0
|
|
|
|
0
|
if (Esjis::e("$realfilename.e")) { |
|
|
0
|
|
|
|
|
|
5680
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5681
|
|
|
|
|
|
|
_open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e"; |
5682
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5683
|
|
|
|
|
|
|
CORE::eval q{ |
5684
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5685
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5686
|
0
|
|
|
|
|
0
|
}; |
5687
|
0
|
0
|
|
|
|
0
|
} |
5688
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5689
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5690
|
|
|
|
|
|
|
if ($@) { |
5691
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5692
|
0
|
|
|
|
|
0
|
} |
5693
|
|
|
|
|
|
|
} |
5694
|
0
|
|
|
|
|
0
|
else { |
5695
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5696
|
0
|
0
|
|
|
|
0
|
} |
5697
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5698
|
|
|
|
|
|
|
$script = <$fh>; |
5699
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5700
|
|
|
|
|
|
|
CORE::eval q{ |
5701
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5702
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5703
|
|
|
|
|
|
|
}; |
5704
|
|
|
|
|
|
|
} |
5705
|
0
|
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5706
|
0
|
0
|
|
|
|
0
|
} |
5707
|
0
|
0
|
|
|
|
0
|
else { |
|
|
0
|
|
|
|
|
|
5708
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5709
|
|
|
|
|
|
|
_open_r($fh, $realfilename) or croak "Can't open file: $realfilename"; |
5710
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5711
|
|
|
|
|
|
|
CORE::eval q{ |
5712
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5713
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5714
|
0
|
|
|
|
|
0
|
}; |
5715
|
0
|
0
|
|
|
|
0
|
} |
5716
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5717
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5718
|
|
|
|
|
|
|
if ($@) { |
5719
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5720
|
0
|
|
|
|
|
0
|
} |
5721
|
|
|
|
|
|
|
} |
5722
|
0
|
|
|
|
|
0
|
else { |
5723
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5724
|
0
|
0
|
|
|
|
0
|
} |
5725
|
0
|
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5726
|
|
|
|
|
|
|
$script = <$fh>; |
5727
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5728
|
|
|
|
|
|
|
CORE::eval q{ |
5729
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5730
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock($realfilename); |
5731
|
|
|
|
|
|
|
}; |
5732
|
0
|
0
|
|
|
|
0
|
} |
5733
|
0
|
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5734
|
0
|
|
|
|
|
0
|
|
5735
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
5736
|
0
|
0
|
|
|
|
0
|
CORE::require Sjis; |
5737
|
0
|
0
|
|
|
|
0
|
$script = Sjis::escape_script($script); |
|
|
0
|
|
|
|
|
|
5738
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
5739
|
|
|
|
|
|
|
open($fh, ">$realfilename.e") or croak "Can't write open file: $realfilename.e"; |
5740
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5741
|
|
|
|
|
|
|
CORE::eval q{ |
5742
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5743
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5744
|
0
|
|
|
|
|
0
|
}; |
5745
|
0
|
0
|
|
|
|
0
|
} |
5746
|
0
|
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5747
|
|
|
|
|
|
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5748
|
|
|
|
|
|
|
if ($@) { |
5749
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5750
|
0
|
|
|
|
|
0
|
} |
5751
|
|
|
|
|
|
|
} |
5752
|
0
|
|
|
|
|
0
|
else { |
5753
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5754
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
5755
|
0
|
0
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
5756
|
0
|
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5757
|
|
|
|
|
|
|
print {$fh} $script; |
5758
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5759
|
|
|
|
|
|
|
CORE::eval q{ |
5760
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5761
|
0
|
0
|
|
|
|
0
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5762
|
|
|
|
|
|
|
}; |
5763
|
|
|
|
|
|
|
} |
5764
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5765
|
|
|
|
|
|
|
} |
5766
|
390
|
|
|
390
|
|
5039
|
} |
|
390
|
|
|
|
|
1057
|
|
|
390
|
|
|
|
|
420466
|
|
|
0
|
|
|
|
|
0
|
|
5767
|
0
|
|
|
|
|
0
|
|
5768
|
|
|
|
|
|
|
{ |
5769
|
0
|
|
|
|
|
0
|
no strict; |
5770
|
|
|
|
|
|
|
$result = scalar CORE::eval $script; |
5771
|
|
|
|
|
|
|
} |
5772
|
0
|
|
|
|
|
0
|
last ITER_REQUIRE; |
5773
|
|
|
|
|
|
|
} |
5774
|
|
|
|
|
|
|
} |
5775
|
0
|
0
|
|
|
|
0
|
croak "Can't find $_ in \@INC"; |
|
|
0
|
|
|
|
|
|
5776
|
0
|
|
|
|
|
0
|
} |
5777
|
0
|
|
|
|
|
0
|
|
5778
|
|
|
|
|
|
|
if ($@) { |
5779
|
|
|
|
|
|
|
$INC{$_} = undef; |
5780
|
0
|
|
|
|
|
0
|
croak $@; |
5781
|
0
|
|
|
|
|
0
|
} |
5782
|
|
|
|
|
|
|
elsif (not $result) { |
5783
|
|
|
|
|
|
|
delete $INC{$_}; |
5784
|
0
|
|
|
|
|
0
|
croak "$_ did not return true value"; |
5785
|
|
|
|
|
|
|
} |
5786
|
|
|
|
|
|
|
else { |
5787
|
|
|
|
|
|
|
return $result; |
5788
|
|
|
|
|
|
|
} |
5789
|
|
|
|
|
|
|
} |
5790
|
|
|
|
|
|
|
|
5791
|
|
|
|
|
|
|
# |
5792
|
|
|
|
|
|
|
# ShiftJIS telldir avoid warning |
5793
|
0
|
|
|
770
|
0
|
0
|
# |
5794
|
|
|
|
|
|
|
sub Esjis::telldir(*) { |
5795
|
770
|
|
|
|
|
2279
|
|
5796
|
|
|
|
|
|
|
local $^W = 0; |
5797
|
|
|
|
|
|
|
|
5798
|
|
|
|
|
|
|
return CORE::telldir $_[0]; |
5799
|
|
|
|
|
|
|
} |
5800
|
|
|
|
|
|
|
|
5801
|
|
|
|
|
|
|
# |
5802
|
770
|
0
|
|
0
|
0
|
30330
|
# ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched |
5803
|
0
|
0
|
0
|
|
|
0
|
# |
5804
|
0
|
|
|
|
|
0
|
sub Esjis::PREMATCH { |
5805
|
|
|
|
|
|
|
if (defined($&)) { |
5806
|
|
|
|
|
|
|
if (defined($1) and (CORE::substr($&,-CORE::length($1),CORE::length($1)) eq $1)) { |
5807
|
0
|
|
|
|
|
0
|
return CORE::substr($&,0,CORE::length($&)-CORE::length($1)); |
5808
|
|
|
|
|
|
|
} |
5809
|
|
|
|
|
|
|
else { |
5810
|
|
|
|
|
|
|
croak 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp'; |
5811
|
0
|
|
|
|
|
0
|
} |
5812
|
|
|
|
|
|
|
} |
5813
|
0
|
|
|
|
|
0
|
else { |
5814
|
|
|
|
|
|
|
return ''; |
5815
|
|
|
|
|
|
|
} |
5816
|
|
|
|
|
|
|
return $`; |
5817
|
|
|
|
|
|
|
} |
5818
|
|
|
|
|
|
|
|
5819
|
|
|
|
|
|
|
# |
5820
|
0
|
0
|
|
0
|
0
|
0
|
# ${^MATCH}, $MATCH, $& the string that matched |
5821
|
0
|
0
|
|
|
|
0
|
# |
5822
|
0
|
|
|
|
|
0
|
sub Esjis::MATCH { |
5823
|
|
|
|
|
|
|
if (defined($&)) { |
5824
|
|
|
|
|
|
|
if (defined($1)) { |
5825
|
0
|
|
|
|
|
0
|
return $1; |
5826
|
|
|
|
|
|
|
} |
5827
|
|
|
|
|
|
|
else { |
5828
|
|
|
|
|
|
|
croak 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp'; |
5829
|
0
|
|
|
|
|
0
|
} |
5830
|
|
|
|
|
|
|
} |
5831
|
0
|
|
|
|
|
0
|
else { |
5832
|
|
|
|
|
|
|
return ''; |
5833
|
|
|
|
|
|
|
} |
5834
|
|
|
|
|
|
|
return $&; |
5835
|
|
|
|
|
|
|
} |
5836
|
|
|
|
|
|
|
|
5837
|
|
|
|
|
|
|
# |
5838
|
0
|
|
|
0
|
0
|
0
|
# ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched |
5839
|
|
|
|
|
|
|
# |
5840
|
|
|
|
|
|
|
sub Esjis::POSTMATCH { |
5841
|
|
|
|
|
|
|
return $'; |
5842
|
|
|
|
|
|
|
} |
5843
|
|
|
|
|
|
|
|
5844
|
|
|
|
|
|
|
# |
5845
|
|
|
|
|
|
|
# ShiftJIS character to order (with parameter) |
5846
|
0
|
0
|
|
0
|
1
|
0
|
# |
5847
|
|
|
|
|
|
|
sub Sjis::ord(;$) { |
5848
|
0
|
0
|
|
|
|
0
|
|
5849
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5850
|
0
|
|
|
|
|
0
|
|
5851
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5852
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5853
|
|
|
|
|
|
|
my $ord = 0; |
5854
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
5855
|
|
|
|
|
|
|
$ord = $ord * 0x100 + $o; |
5856
|
|
|
|
|
|
|
} |
5857
|
0
|
|
|
|
|
0
|
return $ord; |
5858
|
|
|
|
|
|
|
} |
5859
|
|
|
|
|
|
|
else { |
5860
|
|
|
|
|
|
|
return CORE::ord $_; |
5861
|
|
|
|
|
|
|
} |
5862
|
|
|
|
|
|
|
} |
5863
|
|
|
|
|
|
|
|
5864
|
|
|
|
|
|
|
# |
5865
|
|
|
|
|
|
|
# ShiftJIS character to order (without parameter) |
5866
|
0
|
0
|
|
0
|
0
|
0
|
# |
5867
|
0
|
|
|
|
|
0
|
sub Sjis::ord_() { |
5868
|
0
|
|
|
|
|
0
|
|
5869
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5870
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5871
|
|
|
|
|
|
|
my $ord = 0; |
5872
|
0
|
|
|
|
|
0
|
while (my $o = shift @ord) { |
5873
|
|
|
|
|
|
|
$ord = $ord * 0x100 + $o; |
5874
|
|
|
|
|
|
|
} |
5875
|
0
|
|
|
|
|
0
|
return $ord; |
5876
|
|
|
|
|
|
|
} |
5877
|
|
|
|
|
|
|
else { |
5878
|
|
|
|
|
|
|
return CORE::ord $_; |
5879
|
|
|
|
|
|
|
} |
5880
|
|
|
|
|
|
|
} |
5881
|
|
|
|
|
|
|
|
5882
|
|
|
|
|
|
|
# |
5883
|
|
|
|
|
|
|
# ShiftJIS reverse |
5884
|
0
|
0
|
|
0
|
0
|
0
|
# |
5885
|
0
|
|
|
|
|
0
|
sub Sjis::reverse(@) { |
5886
|
|
|
|
|
|
|
|
5887
|
|
|
|
|
|
|
if (wantarray) { |
5888
|
|
|
|
|
|
|
return CORE::reverse @_; |
5889
|
|
|
|
|
|
|
} |
5890
|
|
|
|
|
|
|
else { |
5891
|
|
|
|
|
|
|
|
5892
|
|
|
|
|
|
|
# One of us once cornered Larry in an elevator and asked him what |
5893
|
|
|
|
|
|
|
# problem he was solving with this, but he looked as far off into |
5894
|
0
|
|
|
|
|
0
|
# the distance as he could in an elevator and said, "It seemed like |
5895
|
|
|
|
|
|
|
# a good idea at the time." |
5896
|
|
|
|
|
|
|
|
5897
|
|
|
|
|
|
|
return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg); |
5898
|
|
|
|
|
|
|
} |
5899
|
|
|
|
|
|
|
} |
5900
|
|
|
|
|
|
|
|
5901
|
|
|
|
|
|
|
# |
5902
|
|
|
|
|
|
|
# ShiftJIS getc (with parameter, without parameter) |
5903
|
0
|
|
|
0
|
0
|
0
|
# |
5904
|
0
|
0
|
|
|
|
0
|
sub Sjis::getc(;*@) { |
5905
|
0
|
0
|
0
|
|
|
0
|
|
5906
|
|
|
|
|
|
|
my($package) = caller; |
5907
|
0
|
|
|
|
|
0
|
my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN; |
|
0
|
|
|
|
|
0
|
|
5908
|
0
|
|
|
|
|
0
|
croak 'Too many arguments for Sjis::getc' if @_ and not wantarray; |
5909
|
0
|
|
|
|
|
0
|
|
5910
|
0
|
|
|
|
|
0
|
my @length = sort { $a <=> $b } keys %range_tr; |
5911
|
0
|
0
|
|
|
|
0
|
my $getc = ''; |
5912
|
0
|
0
|
|
|
|
0
|
for my $length ($length[0] .. $length[-1]) { |
5913
|
0
|
0
|
|
|
|
0
|
$getc .= CORE::getc($fh); |
5914
|
|
|
|
|
|
|
if (exists $range_tr{CORE::length($getc)}) { |
5915
|
|
|
|
|
|
|
if ($getc =~ /\A ${Esjis::dot_s} \z/oxms) { |
5916
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5917
|
0
|
0
|
|
|
|
0
|
} |
5918
|
|
|
|
|
|
|
} |
5919
|
|
|
|
|
|
|
} |
5920
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5921
|
|
|
|
|
|
|
} |
5922
|
|
|
|
|
|
|
|
5923
|
|
|
|
|
|
|
# |
5924
|
|
|
|
|
|
|
# ShiftJIS length by character |
5925
|
0
|
0
|
|
0
|
1
|
0
|
# |
5926
|
|
|
|
|
|
|
sub Sjis::length(;$) { |
5927
|
0
|
|
|
|
|
0
|
|
5928
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5929
|
|
|
|
|
|
|
|
5930
|
|
|
|
|
|
|
local @_ = /\G ($q_char) /oxmsg; |
5931
|
|
|
|
|
|
|
return scalar @_; |
5932
|
|
|
|
|
|
|
} |
5933
|
|
|
|
|
|
|
|
5934
|
|
|
|
|
|
|
# |
5935
|
|
|
|
|
|
|
# ShiftJIS substr by character |
5936
|
|
|
|
|
|
|
# |
5937
|
|
|
|
|
|
|
BEGIN { |
5938
|
|
|
|
|
|
|
|
5939
|
|
|
|
|
|
|
# P.232 The lvalue Attribute |
5940
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
5941
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5942
|
|
|
|
|
|
|
|
5943
|
|
|
|
|
|
|
# P.336 The lvalue Attribute |
5944
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
5945
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5946
|
|
|
|
|
|
|
|
5947
|
|
|
|
|
|
|
# P.144 8.4 Lvalue subroutines |
5948
|
390
|
50
|
0
|
390
|
1
|
262099
|
# 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
|
|
5949
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5950
|
|
|
|
|
|
|
|
5951
|
|
|
|
|
|
|
CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : ''); |
5952
|
|
|
|
|
|
|
# vv----------------------******* |
5953
|
|
|
|
|
|
|
sub Sjis::substr($$;$$) %s { |
5954
|
|
|
|
|
|
|
|
5955
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5956
|
|
|
|
|
|
|
|
5957
|
|
|
|
|
|
|
# If the substring is beyond either end of the string, substr() returns the undefined |
5958
|
|
|
|
|
|
|
# value and produces a warning. When used as an lvalue, specifying a substring that |
5959
|
|
|
|
|
|
|
# is entirely outside the string raises an exception. |
5960
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/substr.html |
5961
|
|
|
|
|
|
|
|
5962
|
|
|
|
|
|
|
# A return with no argument returns the scalar value undef in scalar context, |
5963
|
|
|
|
|
|
|
# an empty list () in list context, and (naturally) nothing at all in void |
5964
|
|
|
|
|
|
|
# context. |
5965
|
|
|
|
|
|
|
|
5966
|
|
|
|
|
|
|
my $offset = $_[1]; |
5967
|
|
|
|
|
|
|
if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) { |
5968
|
|
|
|
|
|
|
return; |
5969
|
|
|
|
|
|
|
} |
5970
|
|
|
|
|
|
|
|
5971
|
|
|
|
|
|
|
# substr($string,$offset,$length,$replacement) |
5972
|
|
|
|
|
|
|
if (@_ == 4) { |
5973
|
|
|
|
|
|
|
my(undef,undef,$length,$replacement) = @_; |
5974
|
|
|
|
|
|
|
my $substr = join '', splice(@char, $offset, $length, $replacement); |
5975
|
|
|
|
|
|
|
$_[0] = join '', @char; |
5976
|
|
|
|
|
|
|
|
5977
|
|
|
|
|
|
|
# return $substr; this doesn't work, don't say "return" |
5978
|
|
|
|
|
|
|
$substr; |
5979
|
|
|
|
|
|
|
} |
5980
|
|
|
|
|
|
|
|
5981
|
|
|
|
|
|
|
# substr($string,$offset,$length) |
5982
|
|
|
|
|
|
|
elsif (@_ == 3) { |
5983
|
|
|
|
|
|
|
my(undef,undef,$length) = @_; |
5984
|
|
|
|
|
|
|
my $octet_offset = 0; |
5985
|
|
|
|
|
|
|
my $octet_length = 0; |
5986
|
|
|
|
|
|
|
if ($offset == 0) { |
5987
|
|
|
|
|
|
|
$octet_offset = 0; |
5988
|
|
|
|
|
|
|
} |
5989
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5990
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5991
|
|
|
|
|
|
|
} |
5992
|
|
|
|
|
|
|
else { |
5993
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5994
|
|
|
|
|
|
|
} |
5995
|
|
|
|
|
|
|
if ($length == 0) { |
5996
|
|
|
|
|
|
|
$octet_length = 0; |
5997
|
|
|
|
|
|
|
} |
5998
|
|
|
|
|
|
|
elsif ($length > 0) { |
5999
|
|
|
|
|
|
|
$octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]); |
6000
|
|
|
|
|
|
|
} |
6001
|
|
|
|
|
|
|
else { |
6002
|
|
|
|
|
|
|
$octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]); |
6003
|
|
|
|
|
|
|
} |
6004
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset, $octet_length); |
6005
|
|
|
|
|
|
|
} |
6006
|
|
|
|
|
|
|
|
6007
|
|
|
|
|
|
|
# substr($string,$offset) |
6008
|
|
|
|
|
|
|
else { |
6009
|
|
|
|
|
|
|
my $octet_offset = 0; |
6010
|
|
|
|
|
|
|
if ($offset == 0) { |
6011
|
|
|
|
|
|
|
$octet_offset = 0; |
6012
|
|
|
|
|
|
|
} |
6013
|
|
|
|
|
|
|
elsif ($offset > 0) { |
6014
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
6015
|
|
|
|
|
|
|
} |
6016
|
|
|
|
|
|
|
else { |
6017
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
6018
|
|
|
|
|
|
|
} |
6019
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset); |
6020
|
|
|
|
|
|
|
} |
6021
|
|
|
|
|
|
|
} |
6022
|
|
|
|
|
|
|
END |
6023
|
|
|
|
|
|
|
} |
6024
|
|
|
|
|
|
|
|
6025
|
|
|
|
|
|
|
# |
6026
|
|
|
|
|
|
|
# ShiftJIS index by character |
6027
|
0
|
|
|
0
|
1
|
0
|
# |
6028
|
0
|
0
|
|
|
|
0
|
sub Sjis::index($$;$) { |
6029
|
0
|
|
|
|
|
0
|
|
6030
|
|
|
|
|
|
|
my $index; |
6031
|
|
|
|
|
|
|
if (@_ == 3) { |
6032
|
0
|
|
|
|
|
0
|
$index = Esjis::index($_[0], $_[1], CORE::length(Sjis::substr($_[0], 0, $_[2]))); |
6033
|
|
|
|
|
|
|
} |
6034
|
|
|
|
|
|
|
else { |
6035
|
0
|
0
|
|
|
|
0
|
$index = Esjis::index($_[0], $_[1]); |
6036
|
0
|
|
|
|
|
0
|
} |
6037
|
|
|
|
|
|
|
|
6038
|
|
|
|
|
|
|
if ($index == -1) { |
6039
|
0
|
|
|
|
|
0
|
return -1; |
6040
|
|
|
|
|
|
|
} |
6041
|
|
|
|
|
|
|
else { |
6042
|
|
|
|
|
|
|
return Sjis::length(CORE::substr $_[0], 0, $index); |
6043
|
|
|
|
|
|
|
} |
6044
|
|
|
|
|
|
|
} |
6045
|
|
|
|
|
|
|
|
6046
|
|
|
|
|
|
|
# |
6047
|
|
|
|
|
|
|
# ShiftJIS rindex by character |
6048
|
0
|
|
|
0
|
1
|
0
|
# |
6049
|
0
|
0
|
|
|
|
0
|
sub Sjis::rindex($$;$) { |
6050
|
0
|
|
|
|
|
0
|
|
6051
|
|
|
|
|
|
|
my $rindex; |
6052
|
|
|
|
|
|
|
if (@_ == 3) { |
6053
|
0
|
|
|
|
|
0
|
$rindex = Esjis::rindex($_[0], $_[1], CORE::length(Sjis::substr($_[0], 0, $_[2]))); |
6054
|
|
|
|
|
|
|
} |
6055
|
|
|
|
|
|
|
else { |
6056
|
0
|
0
|
|
|
|
0
|
$rindex = Esjis::rindex($_[0], $_[1]); |
6057
|
0
|
|
|
|
|
0
|
} |
6058
|
|
|
|
|
|
|
|
6059
|
|
|
|
|
|
|
if ($rindex == -1) { |
6060
|
0
|
|
|
|
|
0
|
return -1; |
6061
|
|
|
|
|
|
|
} |
6062
|
|
|
|
|
|
|
else { |
6063
|
|
|
|
|
|
|
return Sjis::length(CORE::substr $_[0], 0, $rindex); |
6064
|
|
|
|
|
|
|
} |
6065
|
|
|
|
|
|
|
} |
6066
|
390
|
|
|
390
|
|
2980
|
|
|
390
|
|
|
|
|
925
|
|
|
390
|
|
|
|
|
44356
|
|
6067
|
|
|
|
|
|
|
# when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??' |
6068
|
|
|
|
|
|
|
# when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else) |
6069
|
|
|
|
|
|
|
use vars qw($slash); $slash = 'm//'; |
6070
|
|
|
|
|
|
|
|
6071
|
|
|
|
|
|
|
# ord() to ord() or Sjis::ord() |
6072
|
|
|
|
|
|
|
my $function_ord = 'ord'; |
6073
|
|
|
|
|
|
|
|
6074
|
|
|
|
|
|
|
# ord to ord or Sjis::ord_ |
6075
|
|
|
|
|
|
|
my $function_ord_ = 'ord'; |
6076
|
|
|
|
|
|
|
|
6077
|
|
|
|
|
|
|
# reverse to reverse or Sjis::reverse |
6078
|
|
|
|
|
|
|
my $function_reverse = 'reverse'; |
6079
|
|
|
|
|
|
|
|
6080
|
|
|
|
|
|
|
# getc to getc or Sjis::getc |
6081
|
|
|
|
|
|
|
my $function_getc = 'getc'; |
6082
|
|
|
|
|
|
|
|
6083
|
|
|
|
|
|
|
# P.1023 Appendix W.9 Multibyte Anchoring |
6084
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
6085
|
|
|
|
|
|
|
|
6086
|
390
|
|
|
390
|
|
4240
|
my $anchor = ''; |
|
390
|
|
|
0
|
|
876
|
|
|
390
|
|
|
|
|
24471770
|
|
6087
|
|
|
|
|
|
|
$anchor = q{${Esjis::anchor}}; |
6088
|
|
|
|
|
|
|
|
6089
|
|
|
|
|
|
|
use vars qw($nest); |
6090
|
|
|
|
|
|
|
|
6091
|
|
|
|
|
|
|
# regexp of nested parens in qqXX |
6092
|
|
|
|
|
|
|
|
6093
|
|
|
|
|
|
|
# P.340 Matching Nested Constructs with Embedded Code |
6094
|
|
|
|
|
|
|
# in Chapter 7: Perl |
6095
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6096
|
|
|
|
|
|
|
|
6097
|
|
|
|
|
|
|
my $qq_paren = qr{(?{local $nest=0}) (?>(?: |
6098
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\()] | |
6099
|
|
|
|
|
|
|
\( (?{$nest++}) | |
6100
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6101
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6102
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6103
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6104
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6105
|
|
|
|
|
|
|
[\x00-\xFF] |
6106
|
|
|
|
|
|
|
}xms; |
6107
|
|
|
|
|
|
|
|
6108
|
|
|
|
|
|
|
my $qq_brace = qr{(?{local $nest=0}) (?>(?: |
6109
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\{}] | |
6110
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
6111
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6112
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6113
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6114
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6115
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6116
|
|
|
|
|
|
|
[\x00-\xFF] |
6117
|
|
|
|
|
|
|
}xms; |
6118
|
|
|
|
|
|
|
|
6119
|
|
|
|
|
|
|
my $qq_bracket = qr{(?{local $nest=0}) (?>(?: |
6120
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\]] | |
6121
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
6122
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6123
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6124
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6125
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6126
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6127
|
|
|
|
|
|
|
[\x00-\xFF] |
6128
|
|
|
|
|
|
|
}xms; |
6129
|
|
|
|
|
|
|
|
6130
|
|
|
|
|
|
|
my $qq_angle = qr{(?{local $nest=0}) (?>(?: |
6131
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\<>] | |
6132
|
|
|
|
|
|
|
\< (?{$nest++}) | |
6133
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6134
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6135
|
|
|
|
|
|
|
\\ [^\x81-\x9F\xE0-\xFCc] | |
6136
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
6137
|
|
|
|
|
|
|
\\ [\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6138
|
|
|
|
|
|
|
[\x00-\xFF] |
6139
|
|
|
|
|
|
|
}xms; |
6140
|
|
|
|
|
|
|
|
6141
|
|
|
|
|
|
|
my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} | |
6142
|
|
|
|
|
|
|
(?: ::)? (?: |
6143
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
6144
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
6145
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
6146
|
|
|
|
|
|
|
)) |
6147
|
|
|
|
|
|
|
}xms; |
6148
|
|
|
|
|
|
|
|
6149
|
|
|
|
|
|
|
my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} | |
6150
|
|
|
|
|
|
|
(?: ::)? (?: |
6151
|
|
|
|
|
|
|
(?>[0-9]+) | |
6152
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFCa-zA-Z_0-9\[\]] | |
6153
|
|
|
|
|
|
|
^[A-Z] | |
6154
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
6155
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
6156
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
6157
|
|
|
|
|
|
|
)) |
6158
|
|
|
|
|
|
|
}xms; |
6159
|
|
|
|
|
|
|
|
6160
|
|
|
|
|
|
|
my $qq_substr = qr{(?> Char::substr | Sjis::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \) |
6161
|
|
|
|
|
|
|
}xms; |
6162
|
|
|
|
|
|
|
|
6163
|
|
|
|
|
|
|
# regexp of nested parens in qXX |
6164
|
|
|
|
|
|
|
my $q_paren = qr{(?{local $nest=0}) (?>(?: |
6165
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC()] | |
6166
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6167
|
|
|
|
|
|
|
\( (?{$nest++}) | |
6168
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6169
|
|
|
|
|
|
|
[\x00-\xFF] |
6170
|
|
|
|
|
|
|
}xms; |
6171
|
|
|
|
|
|
|
|
6172
|
|
|
|
|
|
|
my $q_brace = qr{(?{local $nest=0}) (?>(?: |
6173
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\{\}] | |
6174
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6175
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
6176
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6177
|
|
|
|
|
|
|
[\x00-\xFF] |
6178
|
|
|
|
|
|
|
}xms; |
6179
|
|
|
|
|
|
|
|
6180
|
|
|
|
|
|
|
my $q_bracket = qr{(?{local $nest=0}) (?>(?: |
6181
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\[\]] | |
6182
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6183
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
6184
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6185
|
|
|
|
|
|
|
[\x00-\xFF] |
6186
|
|
|
|
|
|
|
}xms; |
6187
|
|
|
|
|
|
|
|
6188
|
|
|
|
|
|
|
my $q_angle = qr{(?{local $nest=0}) (?>(?: |
6189
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC<>] | |
6190
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
6191
|
|
|
|
|
|
|
\< (?{$nest++}) | |
6192
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
6193
|
|
|
|
|
|
|
[\x00-\xFF] |
6194
|
|
|
|
|
|
|
}xms; |
6195
|
|
|
|
|
|
|
|
6196
|
|
|
|
|
|
|
my $matched = ''; |
6197
|
|
|
|
|
|
|
my $s_matched = ''; |
6198
|
|
|
|
|
|
|
$matched = q{$Esjis::matched}; |
6199
|
|
|
|
|
|
|
$s_matched = q{ Esjis::s_matched();}; |
6200
|
|
|
|
|
|
|
|
6201
|
|
|
|
|
|
|
my $tr_variable = ''; # variable of tr/// |
6202
|
|
|
|
|
|
|
my $sub_variable = ''; # variable of s/// |
6203
|
|
|
|
|
|
|
my $bind_operator = ''; # =~ or !~ |
6204
|
|
|
|
|
|
|
|
6205
|
|
|
|
|
|
|
my @heredoc = (); # here document |
6206
|
|
|
|
|
|
|
my @heredoc_delimiter = (); |
6207
|
|
|
|
|
|
|
my $here_script = ''; # here script |
6208
|
|
|
|
|
|
|
|
6209
|
|
|
|
|
|
|
# |
6210
|
0
|
50
|
|
385
|
0
|
0
|
# escape ShiftJIS script |
6211
|
|
|
|
|
|
|
# |
6212
|
|
|
|
|
|
|
sub Sjis::escape(;$) { |
6213
|
|
|
|
|
|
|
local($_) = $_[0] if @_; |
6214
|
|
|
|
|
|
|
|
6215
|
|
|
|
|
|
|
# P.359 The Study Function |
6216
|
385
|
|
|
|
|
1330
|
# in Chapter 7: Perl |
6217
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6218
|
|
|
|
|
|
|
|
6219
|
|
|
|
|
|
|
study $_; # Yes, I studied study yesterday. |
6220
|
|
|
|
|
|
|
|
6221
|
|
|
|
|
|
|
# while all script |
6222
|
|
|
|
|
|
|
|
6223
|
|
|
|
|
|
|
# 6.14. Matching from Where the Last Pattern Left Off |
6224
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
6225
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
6226
|
|
|
|
|
|
|
# (and so on) |
6227
|
|
|
|
|
|
|
|
6228
|
|
|
|
|
|
|
# one member of Tag-team |
6229
|
|
|
|
|
|
|
# |
6230
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
6231
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
6232
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
6233
|
|
|
|
|
|
|
# P.255 Use leading anchors |
6234
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front expressions |
6235
|
|
|
|
|
|
|
# in Chapter 6: Crafting an Efficient Expression |
6236
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
6237
|
385
|
|
|
|
|
835
|
# in Chapter 7: Perl |
6238
|
385
|
|
|
|
|
882
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6239
|
385
|
|
|
|
|
1575
|
|
6240
|
|
|
|
|
|
|
my $e_script = ''; |
6241
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { # member |
6242
|
187362
|
|
|
|
|
315541
|
$e_script .= Sjis::escape_token(); |
6243
|
|
|
|
|
|
|
} |
6244
|
|
|
|
|
|
|
|
6245
|
|
|
|
|
|
|
return $e_script; |
6246
|
|
|
|
|
|
|
} |
6247
|
|
|
|
|
|
|
|
6248
|
|
|
|
|
|
|
# |
6249
|
|
|
|
|
|
|
# escape ShiftJIS token of script |
6250
|
|
|
|
|
|
|
# |
6251
|
|
|
|
|
|
|
sub Sjis::escape_token { |
6252
|
385
|
|
|
187362
|
0
|
5774
|
|
6253
|
|
|
|
|
|
|
# \n output here document |
6254
|
|
|
|
|
|
|
|
6255
|
|
|
|
|
|
|
my $ignore_modules = join('|', qw( |
6256
|
|
|
|
|
|
|
utf8 |
6257
|
|
|
|
|
|
|
bytes |
6258
|
|
|
|
|
|
|
charnames |
6259
|
|
|
|
|
|
|
I18N::Japanese |
6260
|
|
|
|
|
|
|
I18N::Collate |
6261
|
|
|
|
|
|
|
I18N::JExt |
6262
|
|
|
|
|
|
|
File::DosGlob |
6263
|
|
|
|
|
|
|
Wild |
6264
|
|
|
|
|
|
|
Wildcard |
6265
|
|
|
|
|
|
|
Japanese |
6266
|
|
|
|
|
|
|
)); |
6267
|
|
|
|
|
|
|
|
6268
|
|
|
|
|
|
|
# another member of Tag-team |
6269
|
|
|
|
|
|
|
# |
6270
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
6271
|
187362
|
100
|
100
|
|
|
225739
|
# 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
|
|
|
|
|
|
6272
|
187362
|
|
|
|
|
15086025
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
6273
|
31549
|
100
|
|
|
|
40605
|
|
6274
|
31549
|
|
|
|
|
56121
|
if (/\G ( \n ) /oxgc) { # another member (and so on) |
6275
|
|
|
|
|
|
|
my $heredoc = ''; |
6276
|
197
|
|
|
|
|
297
|
if (scalar(@heredoc_delimiter) >= 1) { |
6277
|
197
|
|
|
|
|
399
|
$slash = 'm//'; |
6278
|
|
|
|
|
|
|
|
6279
|
|
|
|
|
|
|
$heredoc = join '', @heredoc; |
6280
|
197
|
|
|
|
|
363
|
@heredoc = (); |
6281
|
197
|
|
|
|
|
364
|
|
6282
|
|
|
|
|
|
|
# skip here document |
6283
|
205
|
|
|
|
|
1352
|
for my $heredoc_delimiter (@heredoc_delimiter) { |
6284
|
|
|
|
|
|
|
/\G .*? \n $heredoc_delimiter \n/xmsgc; |
6285
|
197
|
|
|
|
|
353
|
} |
6286
|
|
|
|
|
|
|
@heredoc_delimiter = (); |
6287
|
197
|
|
|
|
|
284
|
|
6288
|
|
|
|
|
|
|
$here_script = ''; |
6289
|
|
|
|
|
|
|
} |
6290
|
|
|
|
|
|
|
return "\n" . $heredoc; |
6291
|
31549
|
|
|
|
|
95646
|
} |
6292
|
|
|
|
|
|
|
|
6293
|
|
|
|
|
|
|
# ignore space, comment |
6294
|
|
|
|
|
|
|
elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; } |
6295
|
|
|
|
|
|
|
|
6296
|
|
|
|
|
|
|
# if (, elsif (, unless (, while (, until (, given (, and when ( |
6297
|
|
|
|
|
|
|
|
6298
|
|
|
|
|
|
|
# given, when |
6299
|
|
|
|
|
|
|
|
6300
|
|
|
|
|
|
|
# P.225 The given Statement |
6301
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
6302
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6303
|
|
|
|
|
|
|
|
6304
|
|
|
|
|
|
|
# P.133 The given Statement |
6305
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
6306
|
42807
|
|
|
|
|
147535
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6307
|
3797
|
|
|
|
|
6449
|
|
6308
|
|
|
|
|
|
|
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) { |
6309
|
|
|
|
|
|
|
$slash = 'm//'; |
6310
|
|
|
|
|
|
|
return $1; |
6311
|
|
|
|
|
|
|
} |
6312
|
|
|
|
|
|
|
|
6313
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ tr///; |
6314
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ s///; |
6315
|
|
|
|
|
|
|
|
6316
|
|
|
|
|
|
|
# state |
6317
|
|
|
|
|
|
|
|
6318
|
|
|
|
|
|
|
# P.68 Persistent, Private Variables |
6319
|
|
|
|
|
|
|
# in Chapter 4: Subroutines |
6320
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6321
|
|
|
|
|
|
|
|
6322
|
|
|
|
|
|
|
# P.160 Persistent Lexically Scoped Variables: state |
6323
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
6324
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6325
|
|
|
|
|
|
|
|
6326
|
3797
|
|
|
|
|
11909
|
# (and so on) |
6327
|
|
|
|
|
|
|
|
6328
|
170
|
50
|
|
|
|
475
|
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) { |
|
|
50
|
|
|
|
|
|
6329
|
170
|
|
|
|
|
6762
|
my $e_string = e_string($1); |
6330
|
0
|
|
|
|
|
0
|
|
6331
|
0
|
|
|
|
|
0
|
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6332
|
0
|
|
|
|
|
0
|
$tr_variable = $e_string . e_string($1); |
6333
|
|
|
|
|
|
|
$bind_operator = $2; |
6334
|
|
|
|
|
|
|
$slash = 'm//'; |
6335
|
0
|
|
|
|
|
0
|
return ''; |
6336
|
0
|
|
|
|
|
0
|
} |
6337
|
0
|
|
|
|
|
0
|
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6338
|
0
|
|
|
|
|
0
|
$sub_variable = $e_string . e_string($1); |
6339
|
|
|
|
|
|
|
$bind_operator = $2; |
6340
|
|
|
|
|
|
|
$slash = 'm//'; |
6341
|
0
|
|
|
|
|
0
|
return ''; |
6342
|
170
|
|
|
|
|
380
|
} |
6343
|
|
|
|
|
|
|
else { |
6344
|
|
|
|
|
|
|
$slash = 'div'; |
6345
|
|
|
|
|
|
|
return $e_string; |
6346
|
|
|
|
|
|
|
} |
6347
|
|
|
|
|
|
|
} |
6348
|
170
|
|
|
|
|
864
|
|
6349
|
4
|
|
|
|
|
10
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
6350
|
|
|
|
|
|
|
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
6351
|
|
|
|
|
|
|
$slash = 'div'; |
6352
|
|
|
|
|
|
|
return q{Esjis::PREMATCH()}; |
6353
|
|
|
|
|
|
|
} |
6354
|
4
|
|
|
|
|
14
|
|
6355
|
28
|
|
|
|
|
58
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
6356
|
|
|
|
|
|
|
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
6357
|
|
|
|
|
|
|
$slash = 'div'; |
6358
|
|
|
|
|
|
|
return q{Esjis::MATCH()}; |
6359
|
|
|
|
|
|
|
} |
6360
|
28
|
|
|
|
|
77
|
|
6361
|
1
|
|
|
|
|
2
|
# $', ${'} --> $', ${'} |
6362
|
|
|
|
|
|
|
elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) { |
6363
|
|
|
|
|
|
|
$slash = 'div'; |
6364
|
|
|
|
|
|
|
return $1; |
6365
|
|
|
|
|
|
|
} |
6366
|
1
|
|
|
|
|
4
|
|
6367
|
3
|
|
|
|
|
8
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
6368
|
|
|
|
|
|
|
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
6369
|
|
|
|
|
|
|
$slash = 'div'; |
6370
|
|
|
|
|
|
|
return q{Esjis::POSTMATCH()}; |
6371
|
|
|
|
|
|
|
} |
6372
|
|
|
|
|
|
|
|
6373
|
|
|
|
|
|
|
# scalar variable $scalar =~ tr///; |
6374
|
|
|
|
|
|
|
# scalar variable $scalar =~ s///; |
6375
|
3
|
|
|
|
|
9
|
# substr() =~ tr///; |
6376
|
|
|
|
|
|
|
# substr() =~ s///; |
6377
|
2883
|
100
|
|
|
|
7224
|
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) { |
|
|
100
|
|
|
|
|
|
6378
|
2883
|
|
|
|
|
12509
|
my $scalar = e_string($1); |
6379
|
9
|
|
|
|
|
18
|
|
6380
|
9
|
|
|
|
|
16
|
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6381
|
9
|
|
|
|
|
12
|
$tr_variable = $scalar; |
6382
|
|
|
|
|
|
|
$bind_operator = $1; |
6383
|
|
|
|
|
|
|
$slash = 'm//'; |
6384
|
9
|
|
|
|
|
24
|
return ''; |
6385
|
254
|
|
|
|
|
472
|
} |
6386
|
254
|
|
|
|
|
466
|
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6387
|
254
|
|
|
|
|
343
|
$sub_variable = $scalar; |
6388
|
|
|
|
|
|
|
$bind_operator = $1; |
6389
|
|
|
|
|
|
|
$slash = 'm//'; |
6390
|
254
|
|
|
|
|
725
|
return ''; |
6391
|
2620
|
|
|
|
|
3863
|
} |
6392
|
|
|
|
|
|
|
else { |
6393
|
|
|
|
|
|
|
$slash = 'div'; |
6394
|
|
|
|
|
|
|
return $scalar; |
6395
|
|
|
|
|
|
|
} |
6396
|
|
|
|
|
|
|
} |
6397
|
2620
|
|
|
|
|
7117
|
|
6398
|
|
|
|
|
|
|
# end of statement |
6399
|
|
|
|
|
|
|
elsif (/\G ( [,;] ) /oxgc) { |
6400
|
12269
|
|
|
|
|
19119
|
$slash = 'm//'; |
6401
|
|
|
|
|
|
|
|
6402
|
|
|
|
|
|
|
# clear tr/// variable |
6403
|
12269
|
|
|
|
|
15078
|
$tr_variable = ''; |
6404
|
|
|
|
|
|
|
|
6405
|
12269
|
|
|
|
|
14629
|
# clear s/// variable |
6406
|
|
|
|
|
|
|
$sub_variable = ''; |
6407
|
12269
|
|
|
|
|
31035
|
|
6408
|
|
|
|
|
|
|
$bind_operator = ''; |
6409
|
|
|
|
|
|
|
|
6410
|
|
|
|
|
|
|
return $1; |
6411
|
|
|
|
|
|
|
} |
6412
|
12269
|
|
|
|
|
42729
|
|
6413
|
|
|
|
|
|
|
# bareword |
6414
|
|
|
|
|
|
|
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
6415
|
|
|
|
|
|
|
return $1; |
6416
|
|
|
|
|
|
|
} |
6417
|
0
|
|
|
|
|
0
|
|
6418
|
2
|
|
|
|
|
5
|
# $0 --> $0 |
6419
|
|
|
|
|
|
|
elsif (/\G ( \$ 0 ) /oxmsgc) { |
6420
|
|
|
|
|
|
|
$slash = 'div'; |
6421
|
2
|
|
|
|
|
7
|
return $1; |
6422
|
0
|
|
|
|
|
0
|
} |
6423
|
|
|
|
|
|
|
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
6424
|
|
|
|
|
|
|
$slash = 'div'; |
6425
|
|
|
|
|
|
|
return $1; |
6426
|
|
|
|
|
|
|
} |
6427
|
0
|
|
|
|
|
0
|
|
6428
|
1
|
|
|
|
|
2
|
# $$ --> $$ |
6429
|
|
|
|
|
|
|
elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
6430
|
|
|
|
|
|
|
$slash = 'div'; |
6431
|
|
|
|
|
|
|
return $1; |
6432
|
|
|
|
|
|
|
} |
6433
|
|
|
|
|
|
|
|
6434
|
1
|
|
|
|
|
4
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6435
|
219
|
|
|
|
|
376
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6436
|
|
|
|
|
|
|
elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
6437
|
|
|
|
|
|
|
$slash = 'div'; |
6438
|
219
|
|
|
|
|
504
|
return e_capture($1); |
6439
|
0
|
|
|
|
|
0
|
} |
6440
|
|
|
|
|
|
|
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
6441
|
|
|
|
|
|
|
$slash = 'div'; |
6442
|
|
|
|
|
|
|
return e_capture($1); |
6443
|
|
|
|
|
|
|
} |
6444
|
0
|
|
|
|
|
0
|
|
6445
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6446
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
6447
|
|
|
|
|
|
|
$slash = 'div'; |
6448
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6449
|
|
|
|
|
|
|
} |
6450
|
0
|
|
|
|
|
0
|
|
6451
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
6452
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
6453
|
|
|
|
|
|
|
$slash = 'div'; |
6454
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6455
|
|
|
|
|
|
|
} |
6456
|
0
|
|
|
|
|
0
|
|
6457
|
0
|
|
|
|
|
0
|
# $$foo |
6458
|
|
|
|
|
|
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
6459
|
|
|
|
|
|
|
$slash = 'div'; |
6460
|
|
|
|
|
|
|
return e_capture($1); |
6461
|
|
|
|
|
|
|
} |
6462
|
0
|
|
|
|
|
0
|
|
6463
|
0
|
|
|
|
|
0
|
# ${ foo } |
6464
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) { |
6465
|
|
|
|
|
|
|
$slash = 'div'; |
6466
|
|
|
|
|
|
|
return '${' . $1 . '}'; |
6467
|
|
|
|
|
|
|
} |
6468
|
0
|
|
|
|
|
0
|
|
6469
|
0
|
|
|
|
|
0
|
# ${ ... } |
6470
|
|
|
|
|
|
|
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
6471
|
|
|
|
|
|
|
$slash = 'div'; |
6472
|
|
|
|
|
|
|
return e_capture($1); |
6473
|
|
|
|
|
|
|
} |
6474
|
|
|
|
|
|
|
|
6475
|
0
|
|
|
|
|
0
|
# variable or function |
6476
|
605
|
|
|
|
|
958
|
# $ @ % & * $ # |
6477
|
|
|
|
|
|
|
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) { |
6478
|
|
|
|
|
|
|
$slash = 'div'; |
6479
|
|
|
|
|
|
|
return $1; |
6480
|
|
|
|
|
|
|
} |
6481
|
605
|
|
|
|
|
1973
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
6482
|
103
|
|
|
|
|
212
|
# $ @ # \ ' " / ? ( ) [ ] < > |
6483
|
|
|
|
|
|
|
elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
6484
|
|
|
|
|
|
|
$slash = 'div'; |
6485
|
|
|
|
|
|
|
return $1; |
6486
|
|
|
|
|
|
|
} |
6487
|
103
|
|
|
|
|
641
|
|
6488
|
|
|
|
|
|
|
# while () |
6489
|
|
|
|
|
|
|
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) { |
6490
|
|
|
|
|
|
|
return $1; |
6491
|
|
|
|
|
|
|
} |
6492
|
|
|
|
|
|
|
|
6493
|
|
|
|
|
|
|
# while () --- glob |
6494
|
|
|
|
|
|
|
|
6495
|
0
|
|
|
|
|
0
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6496
|
|
|
|
|
|
|
|
6497
|
|
|
|
|
|
|
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) { |
6498
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob("' . $1 . '"))'; |
6499
|
|
|
|
|
|
|
} |
6500
|
0
|
|
|
|
|
0
|
|
6501
|
|
|
|
|
|
|
# while (glob) |
6502
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) { |
6503
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob_)'; |
6504
|
|
|
|
|
|
|
} |
6505
|
0
|
|
|
|
|
0
|
|
6506
|
|
|
|
|
|
|
# while (glob(WILDCARD)) |
6507
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) { |
6508
|
|
|
|
|
|
|
return 'while ($_ = Esjis::glob'; |
6509
|
0
|
|
|
|
|
0
|
} |
|
484
|
|
|
|
|
1212
|
|
6510
|
|
|
|
|
|
|
|
6511
|
|
|
|
|
|
|
# doit if, doit unless, doit while, doit until, doit for, doit when |
6512
|
484
|
|
|
|
|
1919
|
elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; } |
|
19
|
|
|
|
|
85
|
|
6513
|
19
|
|
|
|
|
70
|
|
|
0
|
|
|
|
|
0
|
|
6514
|
0
|
|
|
|
|
0
|
# subroutines of package Esjis |
|
13
|
|
|
|
|
23
|
|
6515
|
13
|
|
|
|
|
41
|
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
6516
|
0
|
|
|
|
|
0
|
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
114
|
|
|
|
|
196
|
|
6517
|
114
|
|
|
|
|
328
|
elsif (/\G \b Sjis::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
2
|
|
|
|
|
4
|
|
6518
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; } |
|
2
|
|
|
|
|
5
|
|
6519
|
2
|
|
|
|
|
6
|
elsif (/\G \b Sjis::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Sjis::escape'; } |
|
2
|
|
|
|
|
6
|
|
6520
|
2
|
|
|
|
|
5
|
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; } |
|
0
|
|
|
|
|
0
|
|
6521
|
0
|
|
|
|
|
0
|
elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::chop'; } |
|
2
|
|
|
|
|
5
|
|
6522
|
2
|
|
|
|
|
12
|
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; } |
|
2
|
|
|
|
|
4
|
|
6523
|
2
|
|
|
|
|
5
|
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; } |
|
2
|
|
|
|
|
5
|
|
6524
|
2
|
|
|
|
|
6
|
elsif (/\G \b Sjis::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Sjis::index'; } |
|
0
|
|
|
|
|
0
|
|
6525
|
0
|
|
|
|
|
0
|
elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::index'; } |
|
2
|
|
|
|
|
6
|
|
6526
|
2
|
|
|
|
|
5
|
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; } |
|
2
|
|
|
|
|
3
|
|
6527
|
2
|
|
|
|
|
93
|
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; } |
|
1
|
|
|
|
|
2
|
|
6528
|
1
|
|
|
|
|
4
|
elsif (/\G \b Sjis::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Sjis::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6529
|
0
|
|
|
|
|
0
|
elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6530
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lc'; } |
|
0
|
|
|
|
|
0
|
|
6531
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lcfirst'; } |
|
3
|
|
|
|
|
5
|
|
6532
|
|
|
|
|
|
|
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::uc'; } |
6533
|
|
|
|
|
|
|
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::ucfirst'; } |
6534
|
|
|
|
|
|
|
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::fc'; } |
6535
|
|
|
|
|
|
|
|
6536
|
|
|
|
|
|
|
# stacked file test operators |
6537
|
|
|
|
|
|
|
|
6538
|
|
|
|
|
|
|
# P.179 File Test Operators |
6539
|
|
|
|
|
|
|
# in Chapter 12: File Tests |
6540
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6541
|
|
|
|
|
|
|
|
6542
|
|
|
|
|
|
|
# P.106 Named Unary and File Test Operators |
6543
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
6544
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6545
|
|
|
|
|
|
|
|
6546
|
3
|
|
|
|
|
10
|
# (and so on) |
|
0
|
|
|
|
|
0
|
|
6547
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6548
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6549
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6550
|
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
|
|
6551
|
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
|
|
6552
|
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
|
|
6553
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6554
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6555
|
1
|
|
|
|
|
7
|
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
|
|
6556
|
5
|
|
|
|
|
21
|
|
|
0
|
|
|
|
|
0
|
|
6557
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6558
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6559
|
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
|
|
6560
|
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
|
|
6561
|
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
|
|
6562
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6563
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6564
|
1
|
|
|
|
|
5
|
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
|
|
6565
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6566
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6567
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6568
|
|
|
|
|
|
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
6569
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $slash = 'm//'; return "Esjis::filetest qw($1),"; } |
|
0
|
|
|
|
|
0
|
|
6570
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Esjis::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6571
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6572
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6573
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6574
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6575
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
5
|
|
6576
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
6577
|
2
|
|
|
|
|
9
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
103
|
|
|
|
|
210
|
|
6578
|
103
|
|
|
|
|
303
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6579
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6580
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6581
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6582
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6583
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
6
|
|
6584
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6585
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6586
|
2
|
|
|
|
|
23
|
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
|
|
6587
|
6
|
|
|
|
|
34
|
|
|
0
|
|
|
|
|
0
|
|
6588
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6589
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Esjis::$1($2)"; } |
|
50
|
|
|
|
|
88
|
|
6590
|
50
|
|
|
|
|
223
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Esjis::$1($2)"; } |
|
2
|
|
|
|
|
4
|
|
6591
|
2
|
|
|
|
|
9
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return "Esjis::$1"; } |
|
1
|
|
|
|
|
3
|
|
6592
|
1
|
|
|
|
|
3
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Esjis::$1(::"."$2)"; } |
|
3
|
|
|
|
|
13
|
|
6593
|
|
|
|
|
|
|
elsif (/\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-t $2"; } |
6594
|
|
|
|
|
|
|
elsif (/\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::lstat'; } |
6595
|
3
|
|
|
|
|
13
|
elsif (/\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::stat'; } |
|
0
|
|
|
|
|
0
|
|
6596
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6597
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
6598
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6599
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6600
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6601
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6602
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
6603
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6604
|
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
|
|
6605
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6606
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6607
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6608
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6609
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6610
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6611
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6612
|
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
|
|
6613
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6614
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6615
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
6616
|
|
|
|
|
|
|
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; } |
6617
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; } |
|
2
|
|
|
|
|
5
|
|
6618
|
2
|
|
|
|
|
7
|
elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; } |
|
2
|
|
|
|
|
5
|
|
6619
|
2
|
|
|
|
|
8
|
|
|
36
|
|
|
|
|
80
|
|
6620
|
36
|
|
|
|
|
198
|
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; } |
|
2
|
|
|
|
|
5
|
|
6621
|
2
|
|
|
|
|
9
|
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
7
|
|
6622
|
2
|
|
|
|
|
8
|
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::chr'; } |
|
8
|
|
|
|
|
26
|
|
6623
|
8
|
|
|
|
|
34
|
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; } |
|
0
|
|
|
|
|
0
|
|
6624
|
0
|
|
|
|
|
0
|
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; } |
|
0
|
|
|
|
|
0
|
|
6625
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Esjis::glob'; } |
|
0
|
|
|
|
|
0
|
|
6626
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lc_'; } |
|
0
|
|
|
|
|
0
|
|
6627
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lcfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6628
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::uc_'; } |
|
0
|
|
|
|
|
0
|
|
6629
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::ucfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6630
|
|
|
|
|
|
|
elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::fc_'; } |
6631
|
0
|
|
|
|
|
0
|
elsif (/\G \b lstat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::lstat_'; } |
|
0
|
|
|
|
|
0
|
|
6632
|
|
|
|
|
|
|
elsif (/\G \b stat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::stat_'; } |
6633
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6634
|
|
|
|
|
|
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Esjis::filetest_(qw($1))"; } |
6635
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) |
|
0
|
|
|
|
|
0
|
|
6636
|
|
|
|
|
|
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Esjis::${1}_"; } |
6637
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6638
|
0
|
|
|
|
|
0
|
elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; } |
|
0
|
|
|
|
|
0
|
|
6639
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6640
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; } |
|
0
|
|
|
|
|
0
|
|
6641
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
7
|
|
6642
|
2
|
|
|
|
|
9
|
elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::chr_'; } |
|
0
|
|
|
|
|
0
|
|
6643
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; } |
|
4
|
|
|
|
|
12
|
|
6644
|
4
|
|
|
|
|
8170
|
elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; } |
|
8
|
|
|
|
|
22
|
|
6645
|
8
|
|
|
|
|
31
|
elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::glob_'; } |
|
2
|
|
|
|
|
6
|
|
6646
|
2
|
|
|
|
|
14
|
elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; } |
|
0
|
|
|
|
|
0
|
|
6647
|
0
|
|
|
|
|
0
|
elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; } |
|
87
|
|
|
|
|
240
|
|
6648
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Esjis::opendir$1*"; } |
6649
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Esjis::opendir$1*"; } |
6650
|
|
|
|
|
|
|
elsif (/\G \b unlink \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Esjis::unlink'; } |
6651
|
87
|
|
|
|
|
508
|
|
6652
|
|
|
|
|
|
|
# chdir |
6653
|
3
|
|
|
|
|
8
|
elsif (/\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
6654
|
|
|
|
|
|
|
$slash = 'm//'; |
6655
|
3
|
|
|
|
|
6
|
|
6656
|
3
|
|
|
|
|
12
|
my $e = 'Esjis::chdir'; |
6657
|
|
|
|
|
|
|
|
6658
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6659
|
|
|
|
|
|
|
$e .= $1; |
6660
|
3
|
50
|
|
|
|
15
|
} |
|
3
|
100
|
|
|
|
254
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6661
|
|
|
|
|
|
|
|
6662
|
|
|
|
|
|
|
# end of chdir |
6663
|
0
|
|
|
|
|
0
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return $e; } |
6664
|
|
|
|
|
|
|
|
6665
|
|
|
|
|
|
|
# chdir scalar value |
6666
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return $e . e_string($1); } |
6667
|
1
|
0
|
|
|
|
5
|
|
|
0
|
|
|
|
|
0
|
|
6668
|
|
|
|
|
|
|
# chdir qq// |
6669
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qq) \b /oxgc) { |
6670
|
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
|
|
|
|
|
|
6671
|
0
|
|
|
|
|
0
|
else { |
6672
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6673
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6674
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq ( ) --> qr ( ) |
6675
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq { } --> qr { } |
6676
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq [ ] --> qr [ ] |
6677
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq < > --> qr < > |
6678
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq','{','}',$2); } # qq | | --> qr { } |
6679
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq * * --> qr * * |
6680
|
|
|
|
|
|
|
} |
6681
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6682
|
|
|
|
|
|
|
} |
6683
|
|
|
|
|
|
|
} |
6684
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6685
|
|
|
|
|
|
|
# chdir q// |
6686
|
0
|
|
|
|
|
0
|
elsif (/\G \b (q) \b /oxgc) { |
6687
|
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
|
|
|
|
|
|
6688
|
0
|
|
|
|
|
0
|
else { |
6689
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6690
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6691
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q ( ) --> qr ( ) |
6692
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q { } --> qr { } |
6693
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q [ ] --> qr [ ] |
6694
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q < > --> qr < > |
6695
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q','{','}',$2); } # q | | --> qr { } |
6696
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q * * --> qr * * |
6697
|
|
|
|
|
|
|
} |
6698
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6699
|
|
|
|
|
|
|
} |
6700
|
|
|
|
|
|
|
} |
6701
|
0
|
|
|
|
|
0
|
|
6702
|
2
|
|
|
|
|
4
|
# chdir '' |
6703
|
2
|
50
|
|
|
|
8
|
elsif (/\G (\') /oxgc) { |
|
13
|
50
|
|
|
|
69
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6704
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6705
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6706
|
2
|
|
|
|
|
8
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6707
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
6708
|
11
|
|
|
|
|
28
|
elsif (/\G \' /oxgc) { return $e . e_chdir_q('',"'","'",$q_string); } |
6709
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6710
|
|
|
|
|
|
|
} |
6711
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6712
|
|
|
|
|
|
|
} |
6713
|
0
|
|
|
|
|
0
|
|
6714
|
0
|
|
|
|
|
0
|
# chdir "" |
6715
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6716
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6717
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6718
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6719
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
6720
|
0
|
|
|
|
|
0
|
elsif (/\G \" /oxgc) { return $e . e_chdir('','"','"',$qq_string); } |
6721
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6722
|
|
|
|
|
|
|
} |
6723
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6724
|
|
|
|
|
|
|
} |
6725
|
|
|
|
|
|
|
} |
6726
|
0
|
|
|
|
|
0
|
|
6727
|
|
|
|
|
|
|
# split |
6728
|
404
|
|
|
|
|
969
|
elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
6729
|
404
|
|
|
|
|
716
|
$slash = 'm//'; |
6730
|
404
|
|
|
|
|
1418
|
|
6731
|
|
|
|
|
|
|
my $e = ''; |
6732
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6733
|
|
|
|
|
|
|
$e .= $1; |
6734
|
401
|
100
|
|
|
|
1541
|
} |
|
404
|
100
|
|
|
|
18811
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6735
|
|
|
|
|
|
|
|
6736
|
|
|
|
|
|
|
# end of split |
6737
|
3
|
|
|
|
|
16
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Esjis::split' . $e; } |
6738
|
|
|
|
|
|
|
|
6739
|
|
|
|
|
|
|
# split scalar value |
6740
|
1
|
|
|
|
|
6
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Esjis::split' . $e . e_string($1); } |
6741
|
0
|
|
|
|
|
0
|
|
6742
|
0
|
|
|
|
|
0
|
# split literal space |
6743
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Esjis::split' . $e . qq {qq$1 $2}; } |
6744
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6745
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6746
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6747
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6748
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Esjis::split' . $e . qq{$1qq$2 $3}; } |
6749
|
0
|
|
|
|
|
0
|
elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Esjis::split' . $e . qq {q$1 $2}; } |
6750
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6751
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6752
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6753
|
13
|
|
|
|
|
84
|
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6754
|
|
|
|
|
|
|
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Esjis::split' . $e . qq {$1q$2 $3}; } |
6755
|
|
|
|
|
|
|
elsif (/\G ' [ ] ' /oxgc) { return 'Esjis::split' . $e . qq {' '}; } |
6756
|
|
|
|
|
|
|
elsif (/\G " [ ] " /oxgc) { return 'Esjis::split' . $e . qq {" "}; } |
6757
|
2
|
0
|
|
|
|
11
|
|
|
0
|
|
|
|
|
0
|
|
6758
|
|
|
|
|
|
|
# split qq// |
6759
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qq) \b /oxgc) { |
6760
|
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
|
|
|
|
|
|
6761
|
0
|
|
|
|
|
0
|
else { |
6762
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6763
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6764
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( ) |
6765
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { } |
6766
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ] |
6767
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < > |
6768
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { } |
6769
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * * |
6770
|
|
|
|
|
|
|
} |
6771
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6772
|
|
|
|
|
|
|
} |
6773
|
|
|
|
|
|
|
} |
6774
|
0
|
50
|
|
|
|
0
|
|
|
124
|
|
|
|
|
865
|
|
6775
|
|
|
|
|
|
|
# split qr// |
6776
|
0
|
|
|
|
|
0
|
elsif (/\G \b (qr) \b /oxgc) { |
6777
|
124
|
50
|
|
|
|
311
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# # |
|
124
|
50
|
|
|
|
5595
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6778
|
0
|
|
|
|
|
0
|
else { |
6779
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6780
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6781
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( ) |
6782
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { } |
6783
|
56
|
|
|
|
|
195
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ] |
6784
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < > |
6785
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' ' |
6786
|
68
|
|
|
|
|
339
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { } |
6787
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * * |
6788
|
|
|
|
|
|
|
} |
6789
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6790
|
|
|
|
|
|
|
} |
6791
|
|
|
|
|
|
|
} |
6792
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6793
|
|
|
|
|
|
|
# split q// |
6794
|
0
|
|
|
|
|
0
|
elsif (/\G \b (q) \b /oxgc) { |
6795
|
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
|
|
|
|
|
|
6796
|
0
|
|
|
|
|
0
|
else { |
6797
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6798
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6799
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( ) |
6800
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { } |
6801
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ] |
6802
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < > |
6803
|
0
|
|
|
|
|
0
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { } |
6804
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * * |
6805
|
|
|
|
|
|
|
} |
6806
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6807
|
|
|
|
|
|
|
} |
6808
|
|
|
|
|
|
|
} |
6809
|
0
|
50
|
|
|
|
0
|
|
|
136
|
|
|
|
|
979
|
|
6810
|
|
|
|
|
|
|
# split m// |
6811
|
0
|
|
|
|
|
0
|
elsif (/\G \b (m) \b /oxgc) { |
6812
|
136
|
50
|
|
|
|
373
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # # |
|
136
|
50
|
|
|
|
6586
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6813
|
0
|
|
|
|
|
0
|
else { |
6814
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6815
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6816
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( ) |
6817
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { } |
6818
|
56
|
|
|
|
|
258
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ] |
6819
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < > |
6820
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' ' |
6821
|
80
|
|
|
|
|
393
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { } |
6822
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * * |
6823
|
|
|
|
|
|
|
} |
6824
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6825
|
|
|
|
|
|
|
} |
6826
|
|
|
|
|
|
|
} |
6827
|
0
|
|
|
|
|
0
|
|
6828
|
0
|
|
|
|
|
0
|
# split '' |
6829
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6830
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6831
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6832
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6833
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
6834
|
0
|
|
|
|
|
0
|
elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' ' |
6835
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6836
|
|
|
|
|
|
|
} |
6837
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6838
|
|
|
|
|
|
|
} |
6839
|
0
|
|
|
|
|
0
|
|
6840
|
0
|
|
|
|
|
0
|
# split "" |
6841
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6842
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6843
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6844
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6845
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
6846
|
0
|
|
|
|
|
0
|
elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " " |
6847
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6848
|
|
|
|
|
|
|
} |
6849
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6850
|
|
|
|
|
|
|
} |
6851
|
0
|
|
|
|
|
0
|
|
6852
|
125
|
|
|
|
|
263
|
# split // |
6853
|
125
|
50
|
|
|
|
320
|
elsif (/\G (\/) /oxgc) { |
|
558
|
50
|
|
|
|
2664
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6854
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
6855
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6856
|
125
|
|
|
|
|
448
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
6857
|
|
|
|
|
|
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
6858
|
433
|
|
|
|
|
1002
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / / |
6859
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
6860
|
|
|
|
|
|
|
} |
6861
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6862
|
|
|
|
|
|
|
} |
6863
|
|
|
|
|
|
|
} |
6864
|
|
|
|
|
|
|
|
6865
|
|
|
|
|
|
|
# tr/// or y/// |
6866
|
|
|
|
|
|
|
|
6867
|
|
|
|
|
|
|
# about [cdsrbB]* (/B modifier) |
6868
|
|
|
|
|
|
|
# |
6869
|
|
|
|
|
|
|
# P.559 appendix C |
6870
|
|
|
|
|
|
|
# of ISBN 4-89052-384-7 Programming perl |
6871
|
0
|
|
|
|
|
0
|
# (Japanese title is: Perl puroguramingu) |
6872
|
|
|
|
|
|
|
|
6873
|
|
|
|
|
|
|
elsif (/\G \b ( tr | y ) \b /oxgc) { |
6874
|
11
|
50
|
|
|
|
32
|
my $ope = $1; |
6875
|
11
|
|
|
|
|
160
|
|
6876
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
6877
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # # |
6878
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6879
|
0
|
|
|
|
|
0
|
return e_tr(@tr,'',$4,$6); |
6880
|
11
|
|
|
|
|
20
|
} |
6881
|
11
|
50
|
|
|
|
32
|
else { |
|
11
|
50
|
|
|
|
757
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6882
|
|
|
|
|
|
|
my $e = ''; |
6883
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6884
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6885
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6886
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6887
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6888
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6889
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( ) |
6890
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { } |
6891
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ] |
6892
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < > |
6893
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * * |
6894
|
|
|
|
|
|
|
} |
6895
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6896
|
0
|
|
|
|
|
0
|
} |
6897
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6898
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6899
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6900
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6901
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( ) |
6902
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { } |
6903
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ] |
6904
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < > |
6905
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * * |
6906
|
|
|
|
|
|
|
} |
6907
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6908
|
0
|
|
|
|
|
0
|
} |
6909
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6910
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6911
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6912
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6913
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( ) |
6914
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { } |
6915
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ] |
6916
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < > |
6917
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * * |
6918
|
|
|
|
|
|
|
} |
6919
|
0
|
|
|
|
|
0
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6920
|
0
|
|
|
|
|
0
|
} |
6921
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6922
|
0
|
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
6923
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6924
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6925
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( ) |
6926
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { } |
6927
|
|
|
|
|
|
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ] |
6928
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < > |
6929
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * * |
6930
|
|
|
|
|
|
|
} |
6931
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6932
|
0
|
|
|
|
|
0
|
} |
6933
|
11
|
|
|
|
|
40
|
# $1 $2 $3 $4 $5 $6 |
6934
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * * |
6935
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6936
|
11
|
|
|
|
|
35
|
return e_tr(@tr,'',$4,$6); |
6937
|
|
|
|
|
|
|
} |
6938
|
|
|
|
|
|
|
} |
6939
|
|
|
|
|
|
|
die __FILE__, ": Transliteration pattern not terminated\n"; |
6940
|
|
|
|
|
|
|
} |
6941
|
|
|
|
|
|
|
} |
6942
|
0
|
|
|
|
|
0
|
|
6943
|
|
|
|
|
|
|
# qq// |
6944
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6945
|
5900
|
100
|
|
|
|
17380
|
my $ope = $1; |
6946
|
5900
|
|
|
|
|
12110
|
|
6947
|
40
|
|
|
|
|
55
|
# if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# # |
6948
|
40
|
100
|
|
|
|
91
|
if (/\G (\#) /oxgc) { # qq# # |
|
1948
|
50
|
|
|
|
5870
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6949
|
80
|
|
|
|
|
150
|
my $qq_string = ''; |
6950
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6951
|
40
|
|
|
|
|
169
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6952
|
|
|
|
|
|
|
elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; } |
6953
|
1828
|
|
|
|
|
3882
|
elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); } |
6954
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6955
|
|
|
|
|
|
|
} |
6956
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6957
|
0
|
|
|
|
|
0
|
} |
6958
|
5860
|
|
|
|
|
8182
|
|
6959
|
5860
|
50
|
|
|
|
14660
|
else { |
|
5860
|
50
|
|
|
|
23238
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6960
|
|
|
|
|
|
|
my $e = ''; |
6961
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6962
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6963
|
0
|
|
|
|
|
0
|
|
6964
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( ) |
6965
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { # qq ( ) |
6966
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6967
|
0
|
|
|
|
|
0
|
local $nest = 1; |
6968
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
6969
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6970
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6971
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; } |
6972
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
6973
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); } |
6974
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
6975
|
0
|
|
|
|
|
0
|
} |
6976
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6977
|
|
|
|
|
|
|
} |
6978
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6979
|
|
|
|
|
|
|
} |
6980
|
0
|
|
|
|
|
0
|
|
6981
|
5778
|
|
|
|
|
9232
|
# elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { } |
6982
|
5778
|
|
|
|
|
8819
|
elsif (/\G (\{) /oxgc) { # qq { } |
6983
|
5778
|
100
|
|
|
|
12575
|
my $qq_string = ''; |
|
246074
|
50
|
|
|
|
794571
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6984
|
720
|
|
|
|
|
1567
|
local $nest = 1; |
6985
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
1384
|
|
|
|
|
1949
|
|
6986
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6987
|
1384
|
100
|
|
|
|
2484
|
elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; } |
|
7162
|
|
|
|
|
11738
|
|
6988
|
5778
|
|
|
|
|
13256
|
elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; } |
6989
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
6990
|
1384
|
|
|
|
|
2788
|
if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); } |
6991
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
6992
|
236808
|
|
|
|
|
472215
|
} |
6993
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6994
|
|
|
|
|
|
|
} |
6995
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6996
|
|
|
|
|
|
|
} |
6997
|
0
|
|
|
|
|
0
|
|
6998
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ] |
6999
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # qq [ ] |
7000
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7001
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7002
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7003
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7004
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7005
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; } |
7006
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
7007
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); } |
7008
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
7009
|
0
|
|
|
|
|
0
|
} |
7010
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7011
|
|
|
|
|
|
|
} |
7012
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7013
|
|
|
|
|
|
|
} |
7014
|
0
|
|
|
|
|
0
|
|
7015
|
62
|
|
|
|
|
174
|
# elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < > |
7016
|
62
|
|
|
|
|
117
|
elsif (/\G (\<) /oxgc) { # qq < > |
7017
|
62
|
100
|
|
|
|
183
|
my $qq_string = ''; |
|
2040
|
50
|
|
|
|
7267
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7018
|
22
|
|
|
|
|
53
|
local $nest = 1; |
7019
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
|
2
|
|
|
|
|
4
|
|
7020
|
|
|
|
|
|
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7021
|
2
|
100
|
|
|
|
3
|
elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; } |
|
64
|
|
|
|
|
148
|
|
7022
|
62
|
|
|
|
|
156
|
elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; } |
7023
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
7024
|
2
|
|
|
|
|
5
|
if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); } |
7025
|
|
|
|
|
|
|
else { $qq_string .= $1; } |
7026
|
1952
|
|
|
|
|
4288
|
} |
7027
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7028
|
|
|
|
|
|
|
} |
7029
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7030
|
|
|
|
|
|
|
} |
7031
|
0
|
|
|
|
|
0
|
|
7032
|
20
|
|
|
|
|
36
|
# elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * * |
7033
|
20
|
|
|
|
|
24
|
elsif (/\G (\S) /oxgc) { # qq * * |
7034
|
20
|
50
|
|
|
|
37
|
my $delimiter = $1; |
|
840
|
50
|
|
|
|
2438
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7035
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
7036
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7037
|
20
|
|
|
|
|
39
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7038
|
|
|
|
|
|
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; } |
7039
|
820
|
|
|
|
|
1510
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); } |
7040
|
|
|
|
|
|
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
7041
|
|
|
|
|
|
|
} |
7042
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7043
|
|
|
|
|
|
|
} |
7044
|
|
|
|
|
|
|
} |
7045
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7046
|
|
|
|
|
|
|
} |
7047
|
|
|
|
|
|
|
} |
7048
|
0
|
|
|
|
|
0
|
|
7049
|
184
|
50
|
|
|
|
512
|
# qr// |
7050
|
184
|
|
|
|
|
831
|
elsif (/\G \b (qr) \b /oxgc) { |
7051
|
|
|
|
|
|
|
my $ope = $1; |
7052
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # # |
7053
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
7054
|
184
|
|
|
|
|
294
|
} |
7055
|
184
|
50
|
|
|
|
465
|
else { |
|
184
|
50
|
|
|
|
5072
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7056
|
0
|
|
|
|
|
0
|
my $e = ''; |
7057
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7058
|
1
|
|
|
|
|
6
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7059
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( ) |
7060
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { } |
7061
|
76
|
|
|
|
|
220
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ] |
7062
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < > |
7063
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' ' |
7064
|
107
|
|
|
|
|
370
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { } |
7065
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * * |
7066
|
|
|
|
|
|
|
} |
7067
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7068
|
|
|
|
|
|
|
} |
7069
|
|
|
|
|
|
|
} |
7070
|
0
|
|
|
|
|
0
|
|
7071
|
34
|
50
|
|
|
|
114
|
# qw// |
7072
|
34
|
|
|
|
|
112
|
elsif (/\G \b (qw) \b /oxgc) { |
7073
|
|
|
|
|
|
|
my $ope = $1; |
7074
|
|
|
|
|
|
|
if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# # |
7075
|
0
|
|
|
|
|
0
|
return e_qw($ope,$1,$3,$2); |
7076
|
34
|
|
|
|
|
80
|
} |
7077
|
34
|
50
|
|
|
|
128
|
else { |
|
34
|
50
|
|
|
|
228
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7078
|
|
|
|
|
|
|
my $e = ''; |
7079
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7080
|
34
|
|
|
|
|
132
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7081
|
|
|
|
|
|
|
|
7082
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
7083
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
7084
|
|
|
|
|
|
|
|
7085
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
7086
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
7087
|
|
|
|
|
|
|
|
7088
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
7089
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
7090
|
|
|
|
|
|
|
|
7091
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
7092
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
7093
|
|
|
|
|
|
|
|
7094
|
0
|
|
|
|
|
0
|
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
7095
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
7096
|
|
|
|
|
|
|
} |
7097
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7098
|
|
|
|
|
|
|
} |
7099
|
|
|
|
|
|
|
} |
7100
|
0
|
|
|
|
|
0
|
|
7101
|
3
|
50
|
|
|
|
9
|
# qx// |
7102
|
3
|
|
|
|
|
77
|
elsif (/\G \b (qx) \b /oxgc) { |
7103
|
|
|
|
|
|
|
my $ope = $1; |
7104
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
7105
|
0
|
|
|
|
|
0
|
return e_qq($ope,$1,$3,$2); |
7106
|
3
|
|
|
|
|
7
|
} |
7107
|
3
|
50
|
|
|
|
12
|
else { |
|
3
|
50
|
|
|
|
415
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7108
|
0
|
|
|
|
|
0
|
my $e = ''; |
7109
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7110
|
2
|
|
|
|
|
8
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7111
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( ) |
7112
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { } |
7113
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ] |
7114
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < > |
7115
|
1
|
|
|
|
|
5
|
elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' ' |
7116
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * * |
7117
|
|
|
|
|
|
|
} |
7118
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7119
|
|
|
|
|
|
|
} |
7120
|
|
|
|
|
|
|
} |
7121
|
0
|
|
|
|
|
0
|
|
7122
|
|
|
|
|
|
|
# q// |
7123
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
7124
|
|
|
|
|
|
|
my $ope = $1; |
7125
|
|
|
|
|
|
|
|
7126
|
|
|
|
|
|
|
# if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# # |
7127
|
|
|
|
|
|
|
|
7128
|
607
|
50
|
|
|
|
2059
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7129
|
607
|
|
|
|
|
1922
|
# (and so on) |
7130
|
0
|
|
|
|
|
0
|
|
7131
|
0
|
0
|
|
|
|
0
|
if (/\G (\#) /oxgc) { # q# # |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7132
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
7133
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7134
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7135
|
|
|
|
|
|
|
elsif (/\G (\\\#) /oxgc) { $q_string .= $1; } |
7136
|
0
|
|
|
|
|
0
|
elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); } |
7137
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7138
|
|
|
|
|
|
|
} |
7139
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7140
|
0
|
|
|
|
|
0
|
} |
7141
|
607
|
|
|
|
|
1166
|
|
7142
|
607
|
50
|
|
|
|
3248
|
else { |
|
607
|
100
|
|
|
|
4001
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7143
|
|
|
|
|
|
|
my $e = ''; |
7144
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
7145
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7146
|
0
|
|
|
|
|
0
|
|
7147
|
1
|
|
|
|
|
2
|
# elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( ) |
7148
|
1
|
|
|
|
|
2
|
elsif (/\G (\() /oxgc) { # q ( ) |
7149
|
1
|
50
|
|
|
|
4
|
my $q_string = ''; |
|
7
|
50
|
|
|
|
55
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7150
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7151
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7152
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7153
|
|
|
|
|
|
|
elsif (/\G (\\\)) /oxgc) { $q_string .= $1; } |
7154
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\\\() /oxgc) { $q_string .= $1; } |
|
1
|
|
|
|
|
3
|
|
7155
|
1
|
|
|
|
|
3
|
elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; } |
7156
|
|
|
|
|
|
|
elsif (/\G (\)) /oxgc) { |
7157
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); } |
7158
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7159
|
6
|
|
|
|
|
16
|
} |
7160
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7161
|
|
|
|
|
|
|
} |
7162
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7163
|
|
|
|
|
|
|
} |
7164
|
0
|
|
|
|
|
0
|
|
7165
|
600
|
|
|
|
|
1140
|
# elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { } |
7166
|
600
|
|
|
|
|
1207
|
elsif (/\G (\{) /oxgc) { # q { } |
7167
|
600
|
50
|
|
|
|
1780
|
my $q_string = ''; |
|
8204
|
50
|
|
|
|
38164
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7168
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7169
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7170
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
114
|
|
|
|
|
194
|
|
7171
|
|
|
|
|
|
|
elsif (/\G (\\\}) /oxgc) { $q_string .= $1; } |
7172
|
114
|
100
|
|
|
|
224
|
elsif (/\G (\\\{) /oxgc) { $q_string .= $1; } |
|
714
|
|
|
|
|
1718
|
|
7173
|
600
|
|
|
|
|
2243
|
elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; } |
7174
|
|
|
|
|
|
|
elsif (/\G (\}) /oxgc) { |
7175
|
114
|
|
|
|
|
254
|
if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); } |
7176
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7177
|
7376
|
|
|
|
|
15349
|
} |
7178
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7179
|
|
|
|
|
|
|
} |
7180
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7181
|
|
|
|
|
|
|
} |
7182
|
0
|
|
|
|
|
0
|
|
7183
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ] |
7184
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # q [ ] |
7185
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7186
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7187
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7188
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7189
|
|
|
|
|
|
|
elsif (/\G (\\\]) /oxgc) { $q_string .= $1; } |
7190
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\\\[) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7191
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; } |
7192
|
|
|
|
|
|
|
elsif (/\G (\]) /oxgc) { |
7193
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); } |
7194
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7195
|
0
|
|
|
|
|
0
|
} |
7196
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7197
|
|
|
|
|
|
|
} |
7198
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7199
|
|
|
|
|
|
|
} |
7200
|
0
|
|
|
|
|
0
|
|
7201
|
5
|
|
|
|
|
14
|
# elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < > |
7202
|
5
|
|
|
|
|
11
|
elsif (/\G (\<) /oxgc) { # q < > |
7203
|
5
|
50
|
|
|
|
22
|
my $q_string = ''; |
|
82
|
50
|
|
|
|
770
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7204
|
0
|
|
|
|
|
0
|
local $nest = 1; |
7205
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7206
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7207
|
|
|
|
|
|
|
elsif (/\G (\\\>) /oxgc) { $q_string .= $1; } |
7208
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\\\<) /oxgc) { $q_string .= $1; } |
|
5
|
|
|
|
|
26
|
|
7209
|
5
|
|
|
|
|
34
|
elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; } |
7210
|
|
|
|
|
|
|
elsif (/\G (\>) /oxgc) { |
7211
|
0
|
|
|
|
|
0
|
if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); } |
7212
|
|
|
|
|
|
|
else { $q_string .= $1; } |
7213
|
77
|
|
|
|
|
525
|
} |
7214
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7215
|
|
|
|
|
|
|
} |
7216
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7217
|
|
|
|
|
|
|
} |
7218
|
0
|
|
|
|
|
0
|
|
7219
|
1
|
|
|
|
|
2
|
# elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * * |
7220
|
1
|
|
|
|
|
2
|
elsif (/\G (\S) /oxgc) { # q * * |
7221
|
1
|
50
|
|
|
|
3
|
my $delimiter = $1; |
|
14
|
50
|
|
|
|
73
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7222
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
7223
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7224
|
1
|
|
|
|
|
3
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7225
|
|
|
|
|
|
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; } |
7226
|
13
|
|
|
|
|
29
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); } |
7227
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7228
|
|
|
|
|
|
|
} |
7229
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7230
|
|
|
|
|
|
|
} |
7231
|
|
|
|
|
|
|
} |
7232
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7233
|
|
|
|
|
|
|
} |
7234
|
|
|
|
|
|
|
} |
7235
|
0
|
|
|
|
|
0
|
|
7236
|
491
|
50
|
|
|
|
1468
|
# m// |
7237
|
491
|
|
|
|
|
3078
|
elsif (/\G \b (m) \b /oxgc) { |
7238
|
|
|
|
|
|
|
my $ope = $1; |
7239
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# # |
7240
|
0
|
|
|
|
|
0
|
return e_qr($ope,$1,$3,$2,$4); |
7241
|
491
|
|
|
|
|
824
|
} |
7242
|
491
|
50
|
|
|
|
1298
|
else { |
|
491
|
50
|
|
|
|
20002
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7243
|
0
|
|
|
|
|
0
|
my $e = ''; |
7244
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7245
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7246
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( ) |
7247
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { } |
7248
|
92
|
|
|
|
|
297
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ] |
7249
|
87
|
|
|
|
|
310
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < > |
7250
|
0
|
|
|
|
|
0
|
elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ? |
7251
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' ' |
7252
|
312
|
|
|
|
|
1116
|
elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { } |
7253
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * * |
7254
|
|
|
|
|
|
|
} |
7255
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7256
|
|
|
|
|
|
|
} |
7257
|
|
|
|
|
|
|
} |
7258
|
|
|
|
|
|
|
|
7259
|
|
|
|
|
|
|
# s/// |
7260
|
|
|
|
|
|
|
|
7261
|
|
|
|
|
|
|
# about [cegimosxpradlunbB]* (/cg modifier) |
7262
|
|
|
|
|
|
|
# |
7263
|
|
|
|
|
|
|
# P.67 Pattern-Matching Operators |
7264
|
0
|
|
|
|
|
0
|
# of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition. |
7265
|
|
|
|
|
|
|
|
7266
|
|
|
|
|
|
|
elsif (/\G \b (s) \b /oxgc) { |
7267
|
291
|
100
|
|
|
|
847
|
my $ope = $1; |
7268
|
291
|
|
|
|
|
20286
|
|
7269
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7270
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # # |
7271
|
1
|
|
|
|
|
5
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7272
|
290
|
|
|
|
|
521
|
} |
7273
|
290
|
50
|
|
|
|
833
|
else { |
|
290
|
50
|
|
|
|
53815
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7274
|
|
|
|
|
|
|
my $e = ''; |
7275
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7276
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7277
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7278
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7279
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7280
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7281
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7282
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7283
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7284
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7285
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7286
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7287
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7288
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7289
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7290
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7291
|
|
|
|
|
|
|
} |
7292
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7293
|
0
|
|
|
|
|
0
|
} |
7294
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7295
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7296
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7297
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7298
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7299
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7300
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7301
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7302
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7303
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7304
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7305
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7306
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7307
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7308
|
|
|
|
|
|
|
} |
7309
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7310
|
0
|
|
|
|
|
0
|
} |
7311
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7312
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7313
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7314
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7315
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7316
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7317
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7318
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7319
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7320
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7321
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7322
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7323
|
|
|
|
|
|
|
} |
7324
|
0
|
|
|
|
|
0
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7325
|
0
|
|
|
|
|
0
|
} |
7326
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7327
|
|
|
|
|
|
|
my @s = ($1,$2,$3); |
7328
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7329
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
7330
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
7331
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7332
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7333
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7334
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7335
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7336
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7337
|
|
|
|
|
|
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7338
|
0
|
|
|
|
|
0
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7339
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7340
|
|
|
|
|
|
|
} |
7341
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7342
|
0
|
|
|
|
|
0
|
} |
7343
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7344
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { |
7345
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7346
|
96
|
|
|
|
|
263
|
} |
7347
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7348
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7349
|
|
|
|
|
|
|
return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { } |
7350
|
2
|
|
|
|
|
24
|
} |
7351
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7352
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7353
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7354
|
0
|
|
|
|
|
0
|
} |
7355
|
|
|
|
|
|
|
# $1 $2 $3 $4 $5 $6 |
7356
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7357
|
192
|
|
|
|
|
831
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7358
|
|
|
|
|
|
|
} |
7359
|
|
|
|
|
|
|
} |
7360
|
|
|
|
|
|
|
die __FILE__, ": Substitution pattern not terminated\n"; |
7361
|
|
|
|
|
|
|
} |
7362
|
0
|
|
|
|
|
0
|
} |
7363
|
1
|
|
|
|
|
5
|
|
7364
|
0
|
|
|
|
|
0
|
# do |
7365
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s*) \{ ) /oxmsgc) { return 'do'; } |
7366
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?: q | qq | qx ) \b) /oxmsgc) { return 'Esjis::do'; } |
7367
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s+) (?>\w+)) /oxmsgc) { return 'do'; } |
7368
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s*) \$ (?> \w+ (?: ::\w+)* ) \( ) /oxmsgc) { return 'do'; } |
7369
|
2
|
|
|
|
|
10
|
elsif (/\G \b do \b /oxmsgc) { return 'Esjis::do'; } |
7370
|
0
|
|
|
|
|
0
|
|
7371
|
0
|
|
|
|
|
0
|
# require ignore module |
7372
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; } |
7373
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# require$1\n$2"; } |
7374
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; } |
7375
|
0
|
|
|
|
|
0
|
|
7376
|
0
|
|
|
|
|
0
|
# require version number |
7377
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7378
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7379
|
0
|
|
|
|
|
0
|
elsif (/\G \b require (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7380
|
|
|
|
|
|
|
|
7381
|
|
|
|
|
|
|
# require bare package name |
7382
|
18
|
|
|
|
|
133
|
elsif (/\G \b require (?>\s+) ((?>[A-Za-z_]\w* (?: :: [A-Za-z_]\w*)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7383
|
0
|
|
|
|
|
0
|
|
7384
|
|
|
|
|
|
|
# require else |
7385
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s*) ; /oxmsgc) { return 'Esjis::require;'; } |
7386
|
1
|
|
|
|
|
5
|
elsif (/\G \b require \b /oxmsgc) { return 'Esjis::require'; } |
7387
|
70
|
|
|
|
|
792
|
|
7388
|
0
|
|
|
|
|
0
|
# use strict; --> use strict; no strict qw(refs); |
7389
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; } |
7390
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; } |
7391
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; } |
7392
|
0
|
50
|
33
|
|
|
0
|
|
|
|
|
33
|
|
|
|
|
7393
|
3
|
|
|
|
|
71
|
# use 5.12.0; --> use 5.12.0; no strict qw(refs); |
7394
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7395
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) { |
7396
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
7397
|
|
|
|
|
|
|
} |
7398
|
|
|
|
|
|
|
else { |
7399
|
|
|
|
|
|
|
return "use $1;"; |
7400
|
3
|
0
|
0
|
|
|
20
|
} |
|
|
|
0
|
|
|
|
|
7401
|
0
|
|
|
|
|
0
|
} |
7402
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7403
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) { |
7404
|
0
|
|
|
|
|
0
|
return "use $1; no strict qw(refs);"; |
7405
|
|
|
|
|
|
|
} |
7406
|
|
|
|
|
|
|
else { |
7407
|
|
|
|
|
|
|
return "use $1;"; |
7408
|
|
|
|
|
|
|
} |
7409
|
0
|
|
|
|
|
0
|
} |
7410
|
2
|
|
|
|
|
19
|
|
7411
|
0
|
|
|
|
|
0
|
# ignore use module |
7412
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; } |
7413
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# use$1\n$2"; } |
7414
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; } |
7415
|
0
|
|
|
|
|
0
|
|
7416
|
0
|
|
|
|
|
0
|
# ignore no module |
7417
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; } |
7418
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x81-\x9F\xE0-\xFC#]) /oxmsgc) { return "# no$1\n$2"; } |
7419
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; } |
7420
|
0
|
|
|
|
|
0
|
|
7421
|
0
|
|
|
|
|
0
|
# use without import |
7422
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7423
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7424
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7425
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7426
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7427
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7428
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7429
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7430
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7431
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7432
|
|
|
|
|
|
|
|
7433
|
|
|
|
|
|
|
# use with import no parameter |
7434
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_use_noparam($1); } |
7435
|
0
|
|
|
|
|
0
|
|
7436
|
0
|
|
|
|
|
0
|
# use with import parameters |
7437
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7438
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\x9F\xE0-\xFC']* \') (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7439
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\x9F\xE0-\xFC"]* \") (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7440
|
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); } |
7441
|
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); } |
7442
|
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); } |
7443
|
|
|
|
|
|
|
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); } |
7444
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7445
|
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); } |
7446
|
0
|
|
|
|
|
0
|
|
7447
|
0
|
|
|
|
|
0
|
# no without unimport |
7448
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7449
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7450
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7451
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7452
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7453
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7454
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7455
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7456
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7457
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7458
|
|
|
|
|
|
|
|
7459
|
|
|
|
|
|
|
# no with unimport no parameter |
7460
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_no_noparam($1); } |
7461
|
0
|
|
|
|
|
0
|
|
7462
|
0
|
|
|
|
|
0
|
# no with unimport parameters |
7463
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x81-\x9F\xE0-\xFC)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7464
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x81-\x9F\xE0-\xFC']* \') (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7465
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x81-\x9F\xE0-\xFC"]* \") (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7466
|
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); } |
7467
|
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); } |
7468
|
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); } |
7469
|
|
|
|
|
|
|
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); } |
7470
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7471
|
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); } |
7472
|
|
|
|
|
|
|
|
7473
|
|
|
|
|
|
|
# use else |
7474
|
0
|
|
|
|
|
0
|
elsif (/\G \b use \b /oxmsgc) { return "use"; } |
7475
|
|
|
|
|
|
|
|
7476
|
|
|
|
|
|
|
# use else |
7477
|
|
|
|
|
|
|
elsif (/\G \b no \b /oxmsgc) { return "no"; } |
7478
|
2
|
|
|
|
|
10
|
|
7479
|
3199
|
|
|
|
|
7856
|
# '' |
7480
|
3199
|
100
|
|
|
|
9258
|
elsif (/\G (?
|
|
15823
|
100
|
|
|
|
65108
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7481
|
8
|
|
|
|
|
21
|
my $q_string = ''; |
7482
|
48
|
|
|
|
|
94
|
while (not /\G \z/oxgc) { |
7483
|
3199
|
|
|
|
|
8690
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7484
|
|
|
|
|
|
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
7485
|
12568
|
|
|
|
|
28879
|
elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); } |
7486
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7487
|
|
|
|
|
|
|
} |
7488
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7489
|
|
|
|
|
|
|
} |
7490
|
0
|
|
|
|
|
0
|
|
7491
|
3440
|
|
|
|
|
9826
|
# "" |
7492
|
3440
|
100
|
|
|
|
11538
|
elsif (/\G (\") /oxgc) { |
|
72112
|
100
|
|
|
|
259772
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7493
|
109
|
|
|
|
|
317
|
my $qq_string = ''; |
7494
|
14
|
|
|
|
|
30
|
while (not /\G \z/oxgc) { |
7495
|
3440
|
|
|
|
|
8478
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7496
|
|
|
|
|
|
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
7497
|
68549
|
|
|
|
|
160612
|
elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); } |
7498
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
7499
|
|
|
|
|
|
|
} |
7500
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7501
|
|
|
|
|
|
|
} |
7502
|
0
|
|
|
|
|
0
|
|
7503
|
37
|
|
|
|
|
118
|
# `` |
7504
|
37
|
50
|
|
|
|
150
|
elsif (/\G (\`) /oxgc) { |
|
313
|
50
|
|
|
|
1832
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7505
|
0
|
|
|
|
|
0
|
my $qx_string = ''; |
7506
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7507
|
37
|
|
|
|
|
152
|
if (/\G (\\\\) /oxgc) { $qx_string .= $1; } |
7508
|
|
|
|
|
|
|
elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; } |
7509
|
276
|
|
|
|
|
697
|
elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); } |
7510
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; } |
7511
|
|
|
|
|
|
|
} |
7512
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7513
|
|
|
|
|
|
|
} |
7514
|
0
|
|
|
|
|
0
|
|
7515
|
1231
|
|
|
|
|
3384
|
# // --- not divide operator (num / num), not defined-or |
7516
|
1231
|
100
|
|
|
|
3955
|
elsif (($slash eq 'm//') and /\G (\/) /oxgc) { |
|
12525
|
50
|
|
|
|
43359
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7517
|
11
|
|
|
|
|
31
|
my $regexp = ''; |
7518
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7519
|
1231
|
|
|
|
|
3900
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7520
|
|
|
|
|
|
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } |
7521
|
11283
|
|
|
|
|
23069
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); } |
7522
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7523
|
|
|
|
|
|
|
} |
7524
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7525
|
|
|
|
|
|
|
} |
7526
|
0
|
|
|
|
|
0
|
|
7527
|
92
|
|
|
|
|
210
|
# ?? --- not conditional operator (condition ? then : else) |
7528
|
92
|
50
|
|
|
|
432
|
elsif (($slash eq 'm//') and /\G (\?) /oxgc) { |
|
266
|
50
|
|
|
|
1055
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7529
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
7530
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7531
|
92
|
|
|
|
|
221
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7532
|
|
|
|
|
|
|
elsif (/\G (\\\?) /oxgc) { $regexp .= $1; } |
7533
|
174
|
|
|
|
|
405
|
elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); } |
7534
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7535
|
|
|
|
|
|
|
} |
7536
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7537
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
7538
|
|
|
|
|
|
|
|
7539
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
7540
|
0
|
|
|
|
|
0
|
elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; } |
|
0
|
|
|
|
|
0
|
|
7541
|
|
|
|
|
|
|
|
7542
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
7543
|
|
|
|
|
|
|
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; } |
7544
|
0
|
|
|
|
|
0
|
|
7545
|
6
|
|
|
|
|
12
|
# <<~'HEREDOC' |
7546
|
6
|
|
|
|
|
9
|
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
7547
|
|
|
|
|
|
|
$slash = 'm//'; |
7548
|
|
|
|
|
|
|
my $here_quote = $1; |
7549
|
6
|
50
|
|
|
|
12
|
my $delimiter = $2; |
7550
|
6
|
|
|
|
|
12
|
|
7551
|
6
|
|
|
|
|
22
|
# get here document |
7552
|
|
|
|
|
|
|
if ($here_script eq '') { |
7553
|
6
|
50
|
|
|
|
30
|
$here_script = CORE::substr $_, pos $_; |
7554
|
6
|
|
|
|
|
52
|
$here_script =~ s/.*?\n//oxm; |
7555
|
6
|
|
|
|
|
13
|
} |
7556
|
6
|
|
|
|
|
7
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7557
|
6
|
|
|
|
|
47
|
my $heredoc = $1; |
7558
|
6
|
|
|
|
|
20
|
my $indent = $2; |
7559
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7560
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7561
|
6
|
|
|
|
|
11
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7562
|
|
|
|
|
|
|
} |
7563
|
0
|
|
|
|
|
0
|
else { |
7564
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7565
|
|
|
|
|
|
|
} |
7566
|
|
|
|
|
|
|
return qq{<<'$delimiter'}; |
7567
|
|
|
|
|
|
|
} |
7568
|
|
|
|
|
|
|
|
7569
|
|
|
|
|
|
|
# <<~\HEREDOC |
7570
|
|
|
|
|
|
|
|
7571
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7572
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7573
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7574
|
|
|
|
|
|
|
|
7575
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7576
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7577
|
6
|
|
|
|
|
25
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7578
|
3
|
|
|
|
|
8
|
|
7579
|
3
|
|
|
|
|
8
|
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
7580
|
|
|
|
|
|
|
$slash = 'm//'; |
7581
|
|
|
|
|
|
|
my $here_quote = $1; |
7582
|
3
|
50
|
|
|
|
7
|
my $delimiter = $2; |
7583
|
3
|
|
|
|
|
7
|
|
7584
|
3
|
|
|
|
|
14
|
# get here document |
7585
|
|
|
|
|
|
|
if ($here_script eq '') { |
7586
|
3
|
50
|
|
|
|
17
|
$here_script = CORE::substr $_, pos $_; |
7587
|
3
|
|
|
|
|
37
|
$here_script =~ s/.*?\n//oxm; |
7588
|
3
|
|
|
|
|
7
|
} |
7589
|
3
|
|
|
|
|
5
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7590
|
3
|
|
|
|
|
33
|
my $heredoc = $1; |
7591
|
3
|
|
|
|
|
13
|
my $indent = $2; |
7592
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7593
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7594
|
3
|
|
|
|
|
7
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7595
|
|
|
|
|
|
|
} |
7596
|
0
|
|
|
|
|
0
|
else { |
7597
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7598
|
|
|
|
|
|
|
} |
7599
|
|
|
|
|
|
|
return qq{<<\\$delimiter}; |
7600
|
|
|
|
|
|
|
} |
7601
|
3
|
|
|
|
|
12
|
|
7602
|
6
|
|
|
|
|
11
|
# <<~"HEREDOC" |
7603
|
6
|
|
|
|
|
11
|
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
7604
|
|
|
|
|
|
|
$slash = 'm//'; |
7605
|
|
|
|
|
|
|
my $here_quote = $1; |
7606
|
6
|
50
|
|
|
|
9
|
my $delimiter = $2; |
7607
|
6
|
|
|
|
|
13
|
|
7608
|
6
|
|
|
|
|
26
|
# get here document |
7609
|
|
|
|
|
|
|
if ($here_script eq '') { |
7610
|
6
|
50
|
|
|
|
31
|
$here_script = CORE::substr $_, pos $_; |
7611
|
6
|
|
|
|
|
62
|
$here_script =~ s/.*?\n//oxm; |
7612
|
6
|
|
|
|
|
15
|
} |
7613
|
6
|
|
|
|
|
8
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7614
|
6
|
|
|
|
|
45
|
my $heredoc = $1; |
7615
|
6
|
|
|
|
|
17
|
my $indent = $2; |
7616
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7617
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7618
|
6
|
|
|
|
|
14
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7619
|
|
|
|
|
|
|
} |
7620
|
0
|
|
|
|
|
0
|
else { |
7621
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7622
|
|
|
|
|
|
|
} |
7623
|
|
|
|
|
|
|
return qq{<<"$delimiter"}; |
7624
|
|
|
|
|
|
|
} |
7625
|
6
|
|
|
|
|
23
|
|
7626
|
3
|
|
|
|
|
7
|
# <<~HEREDOC |
7627
|
3
|
|
|
|
|
6
|
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
7628
|
|
|
|
|
|
|
$slash = 'm//'; |
7629
|
|
|
|
|
|
|
my $here_quote = $1; |
7630
|
3
|
50
|
|
|
|
7
|
my $delimiter = $2; |
7631
|
3
|
|
|
|
|
7
|
|
7632
|
3
|
|
|
|
|
12
|
# get here document |
7633
|
|
|
|
|
|
|
if ($here_script eq '') { |
7634
|
3
|
50
|
|
|
|
14
|
$here_script = CORE::substr $_, pos $_; |
7635
|
3
|
|
|
|
|
36
|
$here_script =~ s/.*?\n//oxm; |
7636
|
3
|
|
|
|
|
7
|
} |
7637
|
3
|
|
|
|
|
4
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7638
|
3
|
|
|
|
|
35
|
my $heredoc = $1; |
7639
|
3
|
|
|
|
|
8
|
my $indent = $2; |
7640
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7641
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7642
|
3
|
|
|
|
|
7
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7643
|
|
|
|
|
|
|
} |
7644
|
0
|
|
|
|
|
0
|
else { |
7645
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7646
|
|
|
|
|
|
|
} |
7647
|
|
|
|
|
|
|
return qq{<<$delimiter}; |
7648
|
|
|
|
|
|
|
} |
7649
|
3
|
|
|
|
|
13
|
|
7650
|
6
|
|
|
|
|
16
|
# <<~`HEREDOC` |
7651
|
6
|
|
|
|
|
12
|
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
7652
|
|
|
|
|
|
|
$slash = 'm//'; |
7653
|
|
|
|
|
|
|
my $here_quote = $1; |
7654
|
6
|
50
|
|
|
|
8
|
my $delimiter = $2; |
7655
|
6
|
|
|
|
|
13
|
|
7656
|
6
|
|
|
|
|
15
|
# get here document |
7657
|
|
|
|
|
|
|
if ($here_script eq '') { |
7658
|
6
|
50
|
|
|
|
29
|
$here_script = CORE::substr $_, pos $_; |
7659
|
6
|
|
|
|
|
59
|
$here_script =~ s/.*?\n//oxm; |
7660
|
6
|
|
|
|
|
13
|
} |
7661
|
6
|
|
|
|
|
8
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7662
|
6
|
|
|
|
|
48
|
my $heredoc = $1; |
7663
|
6
|
|
|
|
|
17
|
my $indent = $2; |
7664
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7665
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7666
|
6
|
|
|
|
|
15
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7667
|
|
|
|
|
|
|
} |
7668
|
0
|
|
|
|
|
0
|
else { |
7669
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7670
|
|
|
|
|
|
|
} |
7671
|
|
|
|
|
|
|
return qq{<<`$delimiter`}; |
7672
|
|
|
|
|
|
|
} |
7673
|
6
|
|
|
|
|
23
|
|
7674
|
86
|
|
|
|
|
231
|
# <<'HEREDOC' |
7675
|
86
|
|
|
|
|
209
|
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
7676
|
|
|
|
|
|
|
$slash = 'm//'; |
7677
|
|
|
|
|
|
|
my $here_quote = $1; |
7678
|
86
|
100
|
|
|
|
147
|
my $delimiter = $2; |
7679
|
86
|
|
|
|
|
187
|
|
7680
|
83
|
|
|
|
|
456
|
# get here document |
7681
|
|
|
|
|
|
|
if ($here_script eq '') { |
7682
|
83
|
50
|
|
|
|
473
|
$here_script = CORE::substr $_, pos $_; |
7683
|
86
|
|
|
|
|
766
|
$here_script =~ s/.*?\n//oxm; |
7684
|
86
|
|
|
|
|
323
|
} |
7685
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7686
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7687
|
86
|
|
|
|
|
170
|
push @heredoc_delimiter, $delimiter; |
7688
|
|
|
|
|
|
|
} |
7689
|
0
|
|
|
|
|
0
|
else { |
7690
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7691
|
|
|
|
|
|
|
} |
7692
|
|
|
|
|
|
|
return $here_quote; |
7693
|
|
|
|
|
|
|
} |
7694
|
|
|
|
|
|
|
|
7695
|
|
|
|
|
|
|
# <<\HEREDOC |
7696
|
|
|
|
|
|
|
|
7697
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7698
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7699
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7700
|
|
|
|
|
|
|
|
7701
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7702
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7703
|
86
|
|
|
|
|
361
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7704
|
2
|
|
|
|
|
5
|
|
7705
|
2
|
|
|
|
|
5
|
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
7706
|
|
|
|
|
|
|
$slash = 'm//'; |
7707
|
|
|
|
|
|
|
my $here_quote = $1; |
7708
|
2
|
100
|
|
|
|
8
|
my $delimiter = $2; |
7709
|
2
|
|
|
|
|
6
|
|
7710
|
1
|
|
|
|
|
4
|
# get here document |
7711
|
|
|
|
|
|
|
if ($here_script eq '') { |
7712
|
1
|
50
|
|
|
|
6
|
$here_script = CORE::substr $_, pos $_; |
7713
|
2
|
|
|
|
|
28
|
$here_script =~ s/.*?\n//oxm; |
7714
|
2
|
|
|
|
|
9
|
} |
7715
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7716
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7717
|
2
|
|
|
|
|
4
|
push @heredoc_delimiter, $delimiter; |
7718
|
|
|
|
|
|
|
} |
7719
|
0
|
|
|
|
|
0
|
else { |
7720
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7721
|
|
|
|
|
|
|
} |
7722
|
|
|
|
|
|
|
return $here_quote; |
7723
|
|
|
|
|
|
|
} |
7724
|
2
|
|
|
|
|
8
|
|
7725
|
39
|
|
|
|
|
103
|
# <<"HEREDOC" |
7726
|
39
|
|
|
|
|
93
|
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
7727
|
|
|
|
|
|
|
$slash = 'm//'; |
7728
|
|
|
|
|
|
|
my $here_quote = $1; |
7729
|
39
|
100
|
|
|
|
70
|
my $delimiter = $2; |
7730
|
39
|
|
|
|
|
116
|
|
7731
|
38
|
|
|
|
|
222
|
# get here document |
7732
|
|
|
|
|
|
|
if ($here_script eq '') { |
7733
|
38
|
50
|
|
|
|
204
|
$here_script = CORE::substr $_, pos $_; |
7734
|
39
|
|
|
|
|
509
|
$here_script =~ s/.*?\n//oxm; |
7735
|
39
|
|
|
|
|
123
|
} |
7736
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7737
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7738
|
39
|
|
|
|
|
84
|
push @heredoc_delimiter, $delimiter; |
7739
|
|
|
|
|
|
|
} |
7740
|
0
|
|
|
|
|
0
|
else { |
7741
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7742
|
|
|
|
|
|
|
} |
7743
|
|
|
|
|
|
|
return $here_quote; |
7744
|
|
|
|
|
|
|
} |
7745
|
39
|
|
|
|
|
158
|
|
7746
|
54
|
|
|
|
|
142
|
# <
|
7747
|
54
|
|
|
|
|
134
|
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
7748
|
|
|
|
|
|
|
$slash = 'm//'; |
7749
|
|
|
|
|
|
|
my $here_quote = $1; |
7750
|
54
|
100
|
|
|
|
99
|
my $delimiter = $2; |
7751
|
54
|
|
|
|
|
244
|
|
7752
|
51
|
|
|
|
|
325
|
# get here document |
7753
|
|
|
|
|
|
|
if ($here_script eq '') { |
7754
|
51
|
50
|
|
|
|
423
|
$here_script = CORE::substr $_, pos $_; |
7755
|
54
|
|
|
|
|
753
|
$here_script =~ s/.*?\n//oxm; |
7756
|
54
|
|
|
|
|
202
|
} |
7757
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7758
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7759
|
54
|
|
|
|
|
158
|
push @heredoc_delimiter, $delimiter; |
7760
|
|
|
|
|
|
|
} |
7761
|
0
|
|
|
|
|
0
|
else { |
7762
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7763
|
|
|
|
|
|
|
} |
7764
|
|
|
|
|
|
|
return $here_quote; |
7765
|
|
|
|
|
|
|
} |
7766
|
54
|
|
|
|
|
290
|
|
7767
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
7768
|
0
|
|
|
|
|
0
|
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
7769
|
|
|
|
|
|
|
$slash = 'm//'; |
7770
|
|
|
|
|
|
|
my $here_quote = $1; |
7771
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
7772
|
0
|
|
|
|
|
0
|
|
7773
|
0
|
|
|
|
|
0
|
# get here document |
7774
|
|
|
|
|
|
|
if ($here_script eq '') { |
7775
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
7776
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
7777
|
0
|
|
|
|
|
0
|
} |
7778
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7779
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7780
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
7781
|
|
|
|
|
|
|
} |
7782
|
0
|
|
|
|
|
0
|
else { |
7783
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7784
|
|
|
|
|
|
|
} |
7785
|
|
|
|
|
|
|
return $here_quote; |
7786
|
|
|
|
|
|
|
} |
7787
|
0
|
|
|
|
|
0
|
|
7788
|
|
|
|
|
|
|
# <<= <=> <= < operator |
7789
|
|
|
|
|
|
|
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { |
7790
|
|
|
|
|
|
|
return $1; |
7791
|
|
|
|
|
|
|
} |
7792
|
13
|
|
|
|
|
74
|
|
7793
|
|
|
|
|
|
|
# |
7794
|
|
|
|
|
|
|
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { |
7795
|
|
|
|
|
|
|
return $1; |
7796
|
|
|
|
|
|
|
} |
7797
|
|
|
|
|
|
|
|
7798
|
|
|
|
|
|
|
# --- glob |
7799
|
|
|
|
|
|
|
|
7800
|
0
|
|
|
|
|
0
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7801
|
|
|
|
|
|
|
|
7802
|
|
|
|
|
|
|
elsif (/\G < ((?:[^\x81-\x9F\xE0-\xFC>\0\a\e\f\n\r\t]|[\x81-\x9F\xE0-\xFC][\x00-\xFF])+?) > /oxgc) { |
7803
|
|
|
|
|
|
|
return 'Esjis::glob("' . $1 . '")'; |
7804
|
0
|
|
|
|
|
0
|
} |
7805
|
|
|
|
|
|
|
|
7806
|
|
|
|
|
|
|
# __DATA__ |
7807
|
0
|
|
|
|
|
0
|
elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; } |
7808
|
|
|
|
|
|
|
|
7809
|
|
|
|
|
|
|
# __END__ |
7810
|
|
|
|
|
|
|
elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; } |
7811
|
|
|
|
|
|
|
|
7812
|
|
|
|
|
|
|
# \cD Control-D |
7813
|
|
|
|
|
|
|
|
7814
|
|
|
|
|
|
|
# P.68 2.6.8. Other Literal Tokens |
7815
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7816
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7817
|
|
|
|
|
|
|
|
7818
|
|
|
|
|
|
|
# P.76 Other Literal Tokens |
7819
|
385
|
|
|
|
|
3316
|
# in Chapter 2: Bits and Pieces |
7820
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7821
|
|
|
|
|
|
|
|
7822
|
0
|
|
|
|
|
0
|
elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; } |
7823
|
|
|
|
|
|
|
|
7824
|
|
|
|
|
|
|
# \cZ Control-Z |
7825
|
|
|
|
|
|
|
elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; } |
7826
|
|
|
|
|
|
|
|
7827
|
|
|
|
|
|
|
# any operator before div |
7828
|
|
|
|
|
|
|
elsif (/\G ( |
7829
|
0
|
|
|
|
|
0
|
-- | \+\+ | |
|
14213
|
|
|
|
|
33521
|
|
7830
|
|
|
|
|
|
|
[\)\}\]] |
7831
|
|
|
|
|
|
|
|
7832
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; return $1; } |
7833
|
|
|
|
|
|
|
|
7834
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
7835
|
14213
|
|
|
|
|
69771
|
elsif (/\G ( |
|
7
|
|
|
|
|
13
|
|
7836
|
|
|
|
|
|
|
\.\.\. |
7837
|
|
|
|
|
|
|
|
7838
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; } |
7839
|
|
|
|
|
|
|
|
7840
|
|
|
|
|
|
|
# any operator before m// |
7841
|
|
|
|
|
|
|
|
7842
|
|
|
|
|
|
|
# //, //= (defined-or) |
7843
|
|
|
|
|
|
|
|
7844
|
|
|
|
|
|
|
# P.164 Logical Operators |
7845
|
|
|
|
|
|
|
# in Chapter 10: More Control Structures |
7846
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7847
|
|
|
|
|
|
|
|
7848
|
|
|
|
|
|
|
# P.119 C-Style Logical (Short-Circuit) Operators |
7849
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7850
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7851
|
|
|
|
|
|
|
|
7852
|
|
|
|
|
|
|
# (and so on) |
7853
|
|
|
|
|
|
|
|
7854
|
|
|
|
|
|
|
# ~~ |
7855
|
|
|
|
|
|
|
|
7856
|
|
|
|
|
|
|
# P.221 The Smart Match Operator |
7857
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
7858
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7859
|
|
|
|
|
|
|
|
7860
|
|
|
|
|
|
|
# P.112 Smartmatch Operator |
7861
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7862
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7863
|
|
|
|
|
|
|
|
7864
|
|
|
|
|
|
|
# (and so on) |
7865
|
|
|
|
|
|
|
|
7866
|
|
|
|
|
|
|
elsif (/\G ((?> |
7867
|
|
|
|
|
|
|
|
7868
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
7869
|
|
|
|
|
|
|
%= | % | |
7870
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
7871
|
|
|
|
|
|
|
-= | -> | - | |
7872
|
|
|
|
|
|
|
:(?>\s*)= | |
7873
|
|
|
|
|
|
|
: | |
7874
|
|
|
|
|
|
|
<<>> | |
7875
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
7876
|
|
|
|
|
|
|
== | => | =~ | = | |
7877
|
|
|
|
|
|
|
>>= | >> | >= | > | |
7878
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
7879
|
|
|
|
|
|
|
\+= | \+ | |
7880
|
|
|
|
|
|
|
\.\. | \.= | \. | |
7881
|
|
|
|
|
|
|
\/\/= | \/\/ | |
7882
|
|
|
|
|
|
|
\/= | \/ | |
7883
|
|
|
|
|
|
|
\? | |
7884
|
|
|
|
|
|
|
\\ | |
7885
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
7886
|
|
|
|
|
|
|
\b x= | |
7887
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
7888
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
7889
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
7890
|
|
|
|
|
|
|
\b(?: print )\b | |
7891
|
7
|
|
|
|
|
29
|
|
|
23904
|
|
|
|
|
56828
|
|
7892
|
|
|
|
|
|
|
[,;\(\{\[] |
7893
|
|
|
|
|
|
|
|
7894
|
23904
|
|
|
|
|
131059
|
)) /oxgc) { $slash = 'm//'; return $1; } |
|
37187
|
|
|
|
|
88963
|
|
7895
|
|
|
|
|
|
|
|
7896
|
|
|
|
|
|
|
# other any character |
7897
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; } |
7898
|
37187
|
|
|
|
|
208881
|
|
7899
|
|
|
|
|
|
|
# system error |
7900
|
|
|
|
|
|
|
else { |
7901
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
7902
|
|
|
|
|
|
|
} |
7903
|
|
|
|
|
|
|
} |
7904
|
0
|
|
|
3102
|
0
|
0
|
|
7905
|
3102
|
|
|
|
|
7767
|
# escape ShiftJIS string |
7906
|
|
|
|
|
|
|
sub e_string { |
7907
|
3102
|
|
|
|
|
4566
|
my($string) = @_; |
7908
|
|
|
|
|
|
|
my $e_string = ''; |
7909
|
|
|
|
|
|
|
|
7910
|
|
|
|
|
|
|
local $slash = 'm//'; |
7911
|
|
|
|
|
|
|
|
7912
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
7913
|
3102
|
|
|
|
|
4818
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
7914
|
|
|
|
|
|
|
# (and so on) |
7915
|
|
|
|
|
|
|
|
7916
|
3102
|
100
|
66
|
|
|
30657
|
my @char = $string =~ / \G (?>[^\x81-\x9F\xE0-\xFC\\]|\\$q_char|$q_char) /oxmsg; |
7917
|
3102
|
50
|
|
|
|
14797
|
|
7918
|
3023
|
|
|
|
|
6991
|
# without { ... } |
7919
|
|
|
|
|
|
|
if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) { |
7920
|
|
|
|
|
|
|
if ($string !~ /<
|
7921
|
|
|
|
|
|
|
return $string; |
7922
|
|
|
|
|
|
|
} |
7923
|
3023
|
|
|
|
|
8009
|
} |
7924
|
79
|
50
|
|
|
|
291
|
|
|
|
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
|
|
|
|
|
|
7925
|
|
|
|
|
|
|
E_STRING_LOOP: |
7926
|
|
|
|
|
|
|
while ($string !~ /\G \z/oxgc) { |
7927
|
|
|
|
|
|
|
if (0) { |
7928
|
606
|
|
|
|
|
84790
|
} |
7929
|
0
|
|
|
|
|
0
|
|
7930
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Esjis::PREMATCH()]} |
7931
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
7932
|
|
|
|
|
|
|
$e_string .= q{Esjis::PREMATCH()}; |
7933
|
|
|
|
|
|
|
$slash = 'div'; |
7934
|
|
|
|
|
|
|
} |
7935
|
0
|
|
|
|
|
0
|
|
7936
|
0
|
|
|
|
|
0
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Esjis::MATCH()]} |
7937
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
7938
|
|
|
|
|
|
|
$e_string .= q{Esjis::MATCH()}; |
7939
|
|
|
|
|
|
|
$slash = 'div'; |
7940
|
|
|
|
|
|
|
} |
7941
|
0
|
|
|
|
|
0
|
|
7942
|
0
|
|
|
|
|
0
|
# $', ${'} --> $', ${'} |
7943
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) { |
7944
|
|
|
|
|
|
|
$e_string .= $1; |
7945
|
|
|
|
|
|
|
$slash = 'div'; |
7946
|
|
|
|
|
|
|
} |
7947
|
0
|
|
|
|
|
0
|
|
7948
|
0
|
|
|
|
|
0
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Esjis::POSTMATCH()]} |
7949
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
7950
|
|
|
|
|
|
|
$e_string .= q{Esjis::POSTMATCH()}; |
7951
|
|
|
|
|
|
|
$slash = 'div'; |
7952
|
|
|
|
|
|
|
} |
7953
|
0
|
|
|
|
|
0
|
|
7954
|
0
|
|
|
|
|
0
|
# bareword |
7955
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
7956
|
|
|
|
|
|
|
$e_string .= $1; |
7957
|
|
|
|
|
|
|
$slash = 'div'; |
7958
|
|
|
|
|
|
|
} |
7959
|
0
|
|
|
|
|
0
|
|
7960
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
7961
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) { |
7962
|
|
|
|
|
|
|
$e_string .= $1; |
7963
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
7964
|
0
|
|
|
|
|
0
|
} |
7965
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
7966
|
|
|
|
|
|
|
$e_string .= $1; |
7967
|
|
|
|
|
|
|
$slash = 'div'; |
7968
|
|
|
|
|
|
|
} |
7969
|
0
|
|
|
|
|
0
|
|
7970
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
7971
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
7972
|
|
|
|
|
|
|
$e_string .= $1; |
7973
|
|
|
|
|
|
|
$slash = 'div'; |
7974
|
|
|
|
|
|
|
} |
7975
|
|
|
|
|
|
|
|
7976
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
7977
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
7978
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
7979
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7980
|
0
|
|
|
|
|
0
|
$slash = 'div'; |
7981
|
0
|
|
|
|
|
0
|
} |
7982
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
7983
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7984
|
|
|
|
|
|
|
$slash = 'div'; |
7985
|
|
|
|
|
|
|
} |
7986
|
0
|
|
|
|
|
0
|
|
7987
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
7988
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
7989
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7990
|
|
|
|
|
|
|
$slash = 'div'; |
7991
|
|
|
|
|
|
|
} |
7992
|
0
|
|
|
|
|
0
|
|
7993
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
7994
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
7995
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7996
|
|
|
|
|
|
|
$slash = 'div'; |
7997
|
|
|
|
|
|
|
} |
7998
|
0
|
|
|
|
|
0
|
|
7999
|
0
|
|
|
|
|
0
|
# $$foo |
8000
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
8001
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
8002
|
|
|
|
|
|
|
$slash = 'div'; |
8003
|
|
|
|
|
|
|
} |
8004
|
0
|
|
|
|
|
0
|
|
8005
|
0
|
|
|
|
|
0
|
# ${ foo } |
8006
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) { |
8007
|
|
|
|
|
|
|
$e_string .= '${' . $1 . '}'; |
8008
|
|
|
|
|
|
|
$slash = 'div'; |
8009
|
|
|
|
|
|
|
} |
8010
|
0
|
|
|
|
|
0
|
|
8011
|
3
|
|
|
|
|
10
|
# ${ ... } |
8012
|
|
|
|
|
|
|
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
8013
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
8014
|
|
|
|
|
|
|
$slash = 'div'; |
8015
|
|
|
|
|
|
|
} |
8016
|
|
|
|
|
|
|
|
8017
|
3
|
|
|
|
|
15
|
# variable or function |
8018
|
0
|
|
|
|
|
0
|
# $ @ % & * $ # |
8019
|
|
|
|
|
|
|
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) { |
8020
|
|
|
|
|
|
|
$e_string .= $1; |
8021
|
|
|
|
|
|
|
$slash = 'div'; |
8022
|
|
|
|
|
|
|
} |
8023
|
0
|
|
|
|
|
0
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
8024
|
0
|
|
|
|
|
0
|
# $ @ # \ ' " / ? ( ) [ ] < > |
8025
|
|
|
|
|
|
|
elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
8026
|
|
|
|
|
|
|
$e_string .= $1; |
8027
|
|
|
|
|
|
|
$slash = 'div'; |
8028
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
8029
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8030
|
0
|
|
|
|
|
0
|
# subroutines of package Esjis |
|
0
|
|
|
|
|
0
|
|
8031
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8032
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8033
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8034
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8035
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::eval \b /oxgc) { $e_string .= 'eval Sjis::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8036
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8037
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Esjis::chop'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8038
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8039
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8040
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::index \b /oxgc) { $e_string .= 'Sjis::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8041
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Esjis::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8042
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8043
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8044
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Sjis::rindex \b /oxgc) { $e_string .= 'Sjis::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8045
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Esjis::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8046
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8047
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lcfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8048
|
|
|
|
|
|
|
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::uc'; $slash = 'm//'; } |
8049
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::ucfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8050
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::fc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8051
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8052
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8053
|
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
|
|
8054
|
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
|
|
8055
|
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
|
|
8056
|
|
|
|
|
|
|
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//'; } |
8057
|
|
|
|
|
|
|
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//'; } |
8058
|
1
|
|
|
|
|
6
|
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
|
|
8059
|
1
|
|
|
|
|
4
|
|
|
0
|
|
|
|
|
0
|
|
8060
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8061
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Esjis::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8062
|
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
|
|
8063
|
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
|
|
8064
|
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
|
|
|
|
|
9
|
|
8065
|
|
|
|
|
|
|
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//'; } |
8066
|
|
|
|
|
|
|
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//'; } |
8067
|
1
|
|
|
|
|
4
|
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
|
|
8068
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8069
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8070
|
0
|
|
|
|
|
0
|
{ $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8071
|
|
|
|
|
|
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
8072
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $e_string .= "Esjis::filetest qw($1),"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8073
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $e_string .= "Esjis::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8074
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8075
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Esjis::$1(" . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8076
|
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
|
|
8077
|
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
|
|
8078
|
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
|
|
|
|
|
9
|
|
8079
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
8080
|
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
|
|
|
|
|
13
|
|
8081
|
1
|
|
|
|
|
3
|
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
|
|
8082
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8083
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Esjis::$1(" . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8084
|
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
|
|
8085
|
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
|
|
8086
|
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
|
|
8087
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8088
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Esjis::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
8089
|
2
|
|
|
|
|
7
|
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
|
|
8090
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8091
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8092
|
0
|
|
|
|
|
0
|
{ $e_string .= "Esjis::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8093
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Esjis::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8094
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= "Esjis::$1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8095
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "Esjis::$1(::"."$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8096
|
|
|
|
|
|
|
elsif ($string =~ /\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-t $2"; $slash = 'm//'; } |
8097
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::lstat'; $slash = 'm//'; } |
8098
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::stat'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8099
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8100
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
8101
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8102
|
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
|
|
8103
|
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
|
|
8104
|
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
|
|
8105
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
8106
|
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
|
|
8107
|
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
|
|
8108
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8109
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8110
|
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
|
|
8111
|
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
|
|
8112
|
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
|
|
8113
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
8114
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
8115
|
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
|
|
8116
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8117
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
8118
|
0
|
|
|
|
|
0
|
{ $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8119
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; } |
8120
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8121
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8122
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8123
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8124
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8125
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8126
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8127
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8128
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Esjis::glob'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8129
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Esjis::lc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8130
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Esjis::lcfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8131
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Esjis::uc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8132
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Esjis::ucfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8133
|
|
|
|
|
|
|
elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Esjis::fc_'; $slash = 'm//'; } |
8134
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lstat \b /oxgc) { $e_string .= 'Esjis::lstat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8135
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat \b /oxgc) { $e_string .= 'Esjis::stat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8136
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
8137
|
|
|
|
|
|
|
\b /oxgc) { $e_string .= "Esjis::filetest_(qw($1))"; $slash = 'm//'; } |
8138
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) \b /oxgc) { $e_string .= "Esjis::${1}_"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8139
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8140
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8141
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8142
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8143
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Esjis::chr_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8144
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8145
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
8146
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Esjis::glob_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8147
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8148
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
8149
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Esjis::opendir$1*"; $slash = 'm//'; } |
8150
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Esjis::opendir$1*"; $slash = 'm//'; } |
8151
|
|
|
|
|
|
|
elsif ($string =~ /\G \b unlink \b /oxgc) { $e_string .= 'Esjis::unlink'; $slash = 'm//'; } |
8152
|
0
|
|
|
|
|
0
|
|
8153
|
|
|
|
|
|
|
# chdir |
8154
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
8155
|
|
|
|
|
|
|
$slash = 'm//'; |
8156
|
0
|
|
|
|
|
0
|
|
8157
|
0
|
|
|
|
|
0
|
$e_string .= 'Esjis::chdir'; |
8158
|
|
|
|
|
|
|
|
8159
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
8160
|
|
|
|
|
|
|
$e_string .= $1; |
8161
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8162
|
|
|
|
|
|
|
|
8163
|
|
|
|
|
|
|
# end of chdir |
8164
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return $e_string; } |
|
0
|
|
|
|
|
0
|
|
8165
|
|
|
|
|
|
|
|
8166
|
|
|
|
|
|
|
# chdir scalar value |
8167
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= e_string($1); next E_STRING_LOOP; } |
8168
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8169
|
|
|
|
|
|
|
# chdir qq// |
8170
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8171
|
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
|
|
|
|
|
|
8172
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8173
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8174
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8175
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
8176
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
8177
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
8178
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq < > --> qr < > |
8179
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq','{','}',$2); next E_STRING_LOOP; } # qq | | --> qr { } |
8180
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq * * --> qr * * |
8181
|
|
|
|
|
|
|
} |
8182
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8183
|
|
|
|
|
|
|
} |
8184
|
|
|
|
|
|
|
} |
8185
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8186
|
|
|
|
|
|
|
# chdir q// |
8187
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8188
|
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
|
|
|
|
|
|
8189
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8190
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8191
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8192
|
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
|
|
8193
|
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
|
|
8194
|
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
|
|
8195
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q < > --> qr < > |
8196
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q','{','}',$2); next E_STRING_LOOP; } # q | | --> qr { } |
8197
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q * * --> qr * * |
8198
|
|
|
|
|
|
|
} |
8199
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8200
|
|
|
|
|
|
|
} |
8201
|
|
|
|
|
|
|
} |
8202
|
0
|
|
|
|
|
0
|
|
8203
|
0
|
|
|
|
|
0
|
# chdir '' |
8204
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8205
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
8206
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8207
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
8208
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } |
8209
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_chdir_q('',"'","'",$q_string); next E_STRING_LOOP; } |
8210
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
8211
|
|
|
|
|
|
|
} |
8212
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8213
|
|
|
|
|
|
|
} |
8214
|
0
|
|
|
|
|
0
|
|
8215
|
0
|
|
|
|
|
0
|
# chdir "" |
8216
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8217
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
8218
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8219
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
8220
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } |
8221
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_chdir('','"','"',$qq_string); next E_STRING_LOOP; } |
8222
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8223
|
|
|
|
|
|
|
} |
8224
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8225
|
|
|
|
|
|
|
} |
8226
|
|
|
|
|
|
|
} |
8227
|
0
|
|
|
|
|
0
|
|
8228
|
|
|
|
|
|
|
# split |
8229
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
8230
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8231
|
0
|
|
|
|
|
0
|
|
8232
|
|
|
|
|
|
|
my $e = ''; |
8233
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
8234
|
|
|
|
|
|
|
$e .= $1; |
8235
|
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
|
|
|
|
|
|
8236
|
|
|
|
|
|
|
|
8237
|
|
|
|
|
|
|
# end of split |
8238
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Esjis::split' . $e; } |
|
0
|
|
|
|
|
0
|
|
8239
|
|
|
|
|
|
|
|
8240
|
|
|
|
|
|
|
# split scalar value |
8241
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Esjis::split' . $e . e_string($1); next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8242
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8243
|
0
|
|
|
|
|
0
|
# split literal space |
|
0
|
|
|
|
|
0
|
|
8244
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8245
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8246
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8247
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8248
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Esjis::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8249
|
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
|
|
8250
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8251
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8252
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8253
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8254
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
8255
|
|
|
|
|
|
|
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Esjis::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
8256
|
|
|
|
|
|
|
elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Esjis::split' . $e . qq {' '}; next E_STRING_LOOP; } |
8257
|
|
|
|
|
|
|
elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Esjis::split' . $e . qq {" "}; next E_STRING_LOOP; } |
8258
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8259
|
|
|
|
|
|
|
# split qq// |
8260
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8261
|
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
|
|
|
|
|
|
8262
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8263
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8264
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8265
|
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
|
|
8266
|
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
|
|
8267
|
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
|
|
8268
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < > |
8269
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { } |
8270
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * * |
8271
|
|
|
|
|
|
|
} |
8272
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8273
|
|
|
|
|
|
|
} |
8274
|
|
|
|
|
|
|
} |
8275
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8276
|
|
|
|
|
|
|
# split qr// |
8277
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qr) \b /oxgc) { |
8278
|
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
|
|
|
|
|
|
8279
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8280
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8281
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8282
|
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
|
|
8283
|
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
|
|
8284
|
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
|
|
8285
|
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
|
|
8286
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' ' |
8287
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { } |
8288
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr * * |
8289
|
|
|
|
|
|
|
} |
8290
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8291
|
|
|
|
|
|
|
} |
8292
|
|
|
|
|
|
|
} |
8293
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8294
|
|
|
|
|
|
|
# split q// |
8295
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8296
|
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
|
|
|
|
|
|
8297
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8298
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8299
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8300
|
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
|
|
8301
|
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
|
|
8302
|
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
|
|
8303
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < > |
8304
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { } |
8305
|
|
|
|
|
|
|
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 * * |
8306
|
|
|
|
|
|
|
} |
8307
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8308
|
|
|
|
|
|
|
} |
8309
|
|
|
|
|
|
|
} |
8310
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
8311
|
|
|
|
|
|
|
# split m// |
8312
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (m) \b /oxgc) { |
8313
|
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
|
|
|
|
|
|
8314
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
8315
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8316
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
8317
|
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
|
|
8318
|
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
|
|
8319
|
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
|
|
8320
|
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
|
|
8321
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ' ' --> qr ' ' |
8322
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { } |
8323
|
|
|
|
|
|
|
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 * * |
8324
|
|
|
|
|
|
|
} |
8325
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8326
|
|
|
|
|
|
|
} |
8327
|
|
|
|
|
|
|
} |
8328
|
0
|
|
|
|
|
0
|
|
8329
|
0
|
|
|
|
|
0
|
# split '' |
8330
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8331
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
8332
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8333
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
8334
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
8335
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' ' |
8336
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
8337
|
|
|
|
|
|
|
} |
8338
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8339
|
|
|
|
|
|
|
} |
8340
|
0
|
|
|
|
|
0
|
|
8341
|
0
|
|
|
|
|
0
|
# split "" |
8342
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8343
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
8344
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8345
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
8346
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
8347
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " " |
8348
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8349
|
|
|
|
|
|
|
} |
8350
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8351
|
|
|
|
|
|
|
} |
8352
|
0
|
|
|
|
|
0
|
|
8353
|
0
|
|
|
|
|
0
|
# split // |
8354
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G (\/) /oxgc) { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8355
|
0
|
|
|
|
|
0
|
my $regexp = ''; |
8356
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8357
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; } |
8358
|
|
|
|
|
|
|
elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
8359
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / / |
8360
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; } |
8361
|
|
|
|
|
|
|
} |
8362
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8363
|
|
|
|
|
|
|
} |
8364
|
|
|
|
|
|
|
} |
8365
|
0
|
|
|
|
|
0
|
|
8366
|
0
|
0
|
|
|
|
0
|
# qq// |
8367
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8368
|
|
|
|
|
|
|
my $ope = $1; |
8369
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# # |
8370
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
8371
|
0
|
|
|
|
|
0
|
} |
8372
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8373
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8374
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8375
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8376
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( ) |
|
0
|
|
|
|
|
0
|
|
8377
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { } |
|
0
|
|
|
|
|
0
|
|
8378
|
|
|
|
|
|
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ] |
8379
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < > |
8380
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * * |
8381
|
|
|
|
|
|
|
} |
8382
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8383
|
|
|
|
|
|
|
} |
8384
|
|
|
|
|
|
|
} |
8385
|
0
|
|
|
|
|
0
|
|
8386
|
0
|
0
|
|
|
|
0
|
# qx// |
8387
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (qx) \b /oxgc) { |
8388
|
|
|
|
|
|
|
my $ope = $1; |
8389
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
8390
|
0
|
|
|
|
|
0
|
$e_string .= e_qq($ope,$1,$3,$2); |
8391
|
0
|
|
|
|
|
0
|
} |
8392
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8393
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8394
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8395
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8396
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( ) |
|
0
|
|
|
|
|
0
|
|
8397
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { } |
|
0
|
|
|
|
|
0
|
|
8398
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ] |
|
0
|
|
|
|
|
0
|
|
8399
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < > |
8400
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' ' |
8401
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * * |
8402
|
|
|
|
|
|
|
} |
8403
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8404
|
|
|
|
|
|
|
} |
8405
|
|
|
|
|
|
|
} |
8406
|
0
|
|
|
|
|
0
|
|
8407
|
0
|
0
|
|
|
|
0
|
# q// |
8408
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8409
|
|
|
|
|
|
|
my $ope = $1; |
8410
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# # |
8411
|
0
|
|
|
|
|
0
|
$e_string .= e_q($ope,$1,$3,$2); |
8412
|
0
|
|
|
|
|
0
|
} |
8413
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8414
|
0
|
|
|
|
|
0
|
my $e = ''; |
|
0
|
|
|
|
|
0
|
|
8415
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8416
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8417
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( ) |
|
0
|
|
|
|
|
0
|
|
8418
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { } |
|
0
|
|
|
|
|
0
|
|
8419
|
|
|
|
|
|
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ] |
8420
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < > |
8421
|
|
|
|
|
|
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * * |
8422
|
|
|
|
|
|
|
} |
8423
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8424
|
|
|
|
|
|
|
} |
8425
|
0
|
|
|
|
|
0
|
} |
8426
|
|
|
|
|
|
|
|
8427
|
|
|
|
|
|
|
# '' |
8428
|
44
|
|
|
|
|
190
|
elsif ($string =~ /\G (?
|
8429
|
|
|
|
|
|
|
|
8430
|
|
|
|
|
|
|
# "" |
8431
|
6
|
|
|
|
|
74
|
elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8432
|
|
|
|
|
|
|
|
8433
|
|
|
|
|
|
|
# `` |
8434
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8435
|
|
|
|
|
|
|
|
8436
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
8437
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; } |
8438
|
|
|
|
|
|
|
|
8439
|
|
|
|
|
|
|
# <<= <=> <= < operator |
8440
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; } |
8441
|
|
|
|
|
|
|
|
8442
|
|
|
|
|
|
|
# |
8443
|
|
|
|
|
|
|
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; } |
8444
|
0
|
|
|
|
|
0
|
|
8445
|
|
|
|
|
|
|
# --- glob |
8446
|
|
|
|
|
|
|
elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) { |
8447
|
|
|
|
|
|
|
$e_string .= 'Esjis::glob("' . $1 . '")'; |
8448
|
|
|
|
|
|
|
} |
8449
|
0
|
|
|
|
|
0
|
|
8450
|
0
|
|
|
|
|
0
|
# << (bit shift) --- not here document |
8451
|
|
|
|
|
|
|
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { |
8452
|
|
|
|
|
|
|
$slash = 'm//'; |
8453
|
|
|
|
|
|
|
$e_string .= $1; |
8454
|
|
|
|
|
|
|
} |
8455
|
0
|
|
|
|
|
0
|
|
8456
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
8457
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
8458
|
|
|
|
|
|
|
$slash = 'm//'; |
8459
|
|
|
|
|
|
|
my $here_quote = $1; |
8460
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8461
|
0
|
|
|
|
|
0
|
|
8462
|
0
|
|
|
|
|
0
|
# get here document |
8463
|
|
|
|
|
|
|
if ($here_script eq '') { |
8464
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8465
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8466
|
0
|
|
|
|
|
0
|
} |
8467
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8468
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8469
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8470
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8471
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8472
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8473
|
|
|
|
|
|
|
} |
8474
|
0
|
|
|
|
|
0
|
else { |
8475
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8476
|
|
|
|
|
|
|
} |
8477
|
|
|
|
|
|
|
$e_string .= qq{<<'$delimiter'}; |
8478
|
|
|
|
|
|
|
} |
8479
|
0
|
|
|
|
|
0
|
|
8480
|
0
|
|
|
|
|
0
|
# <<~\HEREDOC |
8481
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
8482
|
|
|
|
|
|
|
$slash = 'm//'; |
8483
|
|
|
|
|
|
|
my $here_quote = $1; |
8484
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8485
|
0
|
|
|
|
|
0
|
|
8486
|
0
|
|
|
|
|
0
|
# get here document |
8487
|
|
|
|
|
|
|
if ($here_script eq '') { |
8488
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8489
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8490
|
0
|
|
|
|
|
0
|
} |
8491
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8492
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8493
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8494
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8495
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8496
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8497
|
|
|
|
|
|
|
} |
8498
|
0
|
|
|
|
|
0
|
else { |
8499
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8500
|
|
|
|
|
|
|
} |
8501
|
|
|
|
|
|
|
$e_string .= qq{<<\\$delimiter}; |
8502
|
|
|
|
|
|
|
} |
8503
|
0
|
|
|
|
|
0
|
|
8504
|
0
|
|
|
|
|
0
|
# <<~"HEREDOC" |
8505
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
8506
|
|
|
|
|
|
|
$slash = 'm//'; |
8507
|
|
|
|
|
|
|
my $here_quote = $1; |
8508
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8509
|
0
|
|
|
|
|
0
|
|
8510
|
0
|
|
|
|
|
0
|
# get here document |
8511
|
|
|
|
|
|
|
if ($here_script eq '') { |
8512
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8513
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8514
|
0
|
|
|
|
|
0
|
} |
8515
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8516
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8517
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8518
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8519
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8520
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8521
|
|
|
|
|
|
|
} |
8522
|
0
|
|
|
|
|
0
|
else { |
8523
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8524
|
|
|
|
|
|
|
} |
8525
|
|
|
|
|
|
|
$e_string .= qq{<<"$delimiter"}; |
8526
|
|
|
|
|
|
|
} |
8527
|
0
|
|
|
|
|
0
|
|
8528
|
0
|
|
|
|
|
0
|
# <<~HEREDOC |
8529
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
8530
|
|
|
|
|
|
|
$slash = 'm//'; |
8531
|
|
|
|
|
|
|
my $here_quote = $1; |
8532
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8533
|
0
|
|
|
|
|
0
|
|
8534
|
0
|
|
|
|
|
0
|
# get here document |
8535
|
|
|
|
|
|
|
if ($here_script eq '') { |
8536
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8537
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8538
|
0
|
|
|
|
|
0
|
} |
8539
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8540
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8541
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8542
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8543
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8544
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8545
|
|
|
|
|
|
|
} |
8546
|
0
|
|
|
|
|
0
|
else { |
8547
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8548
|
|
|
|
|
|
|
} |
8549
|
|
|
|
|
|
|
$e_string .= qq{<<$delimiter}; |
8550
|
|
|
|
|
|
|
} |
8551
|
0
|
|
|
|
|
0
|
|
8552
|
0
|
|
|
|
|
0
|
# <<~`HEREDOC` |
8553
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
8554
|
|
|
|
|
|
|
$slash = 'm//'; |
8555
|
|
|
|
|
|
|
my $here_quote = $1; |
8556
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8557
|
0
|
|
|
|
|
0
|
|
8558
|
0
|
|
|
|
|
0
|
# get here document |
8559
|
|
|
|
|
|
|
if ($here_script eq '') { |
8560
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8561
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8562
|
0
|
|
|
|
|
0
|
} |
8563
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8564
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8565
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8566
|
|
|
|
|
|
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8567
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8568
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8569
|
|
|
|
|
|
|
} |
8570
|
0
|
|
|
|
|
0
|
else { |
8571
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8572
|
|
|
|
|
|
|
} |
8573
|
|
|
|
|
|
|
$e_string .= qq{<<`$delimiter`}; |
8574
|
|
|
|
|
|
|
} |
8575
|
0
|
|
|
|
|
0
|
|
8576
|
0
|
|
|
|
|
0
|
# <<'HEREDOC' |
8577
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
8578
|
|
|
|
|
|
|
$slash = 'm//'; |
8579
|
|
|
|
|
|
|
my $here_quote = $1; |
8580
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8581
|
0
|
|
|
|
|
0
|
|
8582
|
0
|
|
|
|
|
0
|
# get here document |
8583
|
|
|
|
|
|
|
if ($here_script eq '') { |
8584
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8585
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8586
|
0
|
|
|
|
|
0
|
} |
8587
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8588
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8589
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8590
|
|
|
|
|
|
|
} |
8591
|
0
|
|
|
|
|
0
|
else { |
8592
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8593
|
|
|
|
|
|
|
} |
8594
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8595
|
|
|
|
|
|
|
} |
8596
|
0
|
|
|
|
|
0
|
|
8597
|
0
|
|
|
|
|
0
|
# <<\HEREDOC |
8598
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
8599
|
|
|
|
|
|
|
$slash = 'm//'; |
8600
|
|
|
|
|
|
|
my $here_quote = $1; |
8601
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8602
|
0
|
|
|
|
|
0
|
|
8603
|
0
|
|
|
|
|
0
|
# get here document |
8604
|
|
|
|
|
|
|
if ($here_script eq '') { |
8605
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8606
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8607
|
0
|
|
|
|
|
0
|
} |
8608
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8609
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8610
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8611
|
|
|
|
|
|
|
} |
8612
|
0
|
|
|
|
|
0
|
else { |
8613
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8614
|
|
|
|
|
|
|
} |
8615
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8616
|
|
|
|
|
|
|
} |
8617
|
0
|
|
|
|
|
0
|
|
8618
|
0
|
|
|
|
|
0
|
# <<"HEREDOC" |
8619
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
8620
|
|
|
|
|
|
|
$slash = 'm//'; |
8621
|
|
|
|
|
|
|
my $here_quote = $1; |
8622
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8623
|
0
|
|
|
|
|
0
|
|
8624
|
0
|
|
|
|
|
0
|
# get here document |
8625
|
|
|
|
|
|
|
if ($here_script eq '') { |
8626
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8627
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8628
|
0
|
|
|
|
|
0
|
} |
8629
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8630
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8631
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8632
|
|
|
|
|
|
|
} |
8633
|
0
|
|
|
|
|
0
|
else { |
8634
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8635
|
|
|
|
|
|
|
} |
8636
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8637
|
|
|
|
|
|
|
} |
8638
|
0
|
|
|
|
|
0
|
|
8639
|
0
|
|
|
|
|
0
|
# <
|
8640
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
8641
|
|
|
|
|
|
|
$slash = 'm//'; |
8642
|
|
|
|
|
|
|
my $here_quote = $1; |
8643
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8644
|
0
|
|
|
|
|
0
|
|
8645
|
0
|
|
|
|
|
0
|
# get here document |
8646
|
|
|
|
|
|
|
if ($here_script eq '') { |
8647
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8648
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8649
|
0
|
|
|
|
|
0
|
} |
8650
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8651
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8652
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8653
|
|
|
|
|
|
|
} |
8654
|
0
|
|
|
|
|
0
|
else { |
8655
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8656
|
|
|
|
|
|
|
} |
8657
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8658
|
|
|
|
|
|
|
} |
8659
|
0
|
|
|
|
|
0
|
|
8660
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
8661
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
8662
|
|
|
|
|
|
|
$slash = 'm//'; |
8663
|
|
|
|
|
|
|
my $here_quote = $1; |
8664
|
0
|
0
|
|
|
|
0
|
my $delimiter = $2; |
8665
|
0
|
|
|
|
|
0
|
|
8666
|
0
|
|
|
|
|
0
|
# get here document |
8667
|
|
|
|
|
|
|
if ($here_script eq '') { |
8668
|
0
|
0
|
|
|
|
0
|
$here_script = CORE::substr $_, pos $_; |
8669
|
0
|
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8670
|
0
|
|
|
|
|
0
|
} |
8671
|
|
|
|
|
|
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8672
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8673
|
0
|
|
|
|
|
0
|
push @heredoc_delimiter, $delimiter; |
8674
|
|
|
|
|
|
|
} |
8675
|
0
|
|
|
|
|
0
|
else { |
8676
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8677
|
|
|
|
|
|
|
} |
8678
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8679
|
|
|
|
|
|
|
} |
8680
|
|
|
|
|
|
|
|
8681
|
|
|
|
|
|
|
# any operator before div |
8682
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8683
|
0
|
|
|
|
|
0
|
-- | \+\+ | |
|
80
|
|
|
|
|
158
|
|
8684
|
|
|
|
|
|
|
[\)\}\]] |
8685
|
|
|
|
|
|
|
|
8686
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; $e_string .= $1; } |
8687
|
|
|
|
|
|
|
|
8688
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
8689
|
80
|
|
|
|
|
282
|
elsif ($string =~ /\G ( |
|
0
|
|
|
|
|
0
|
|
8690
|
|
|
|
|
|
|
\.\.\. |
8691
|
|
|
|
|
|
|
|
8692
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; } |
8693
|
|
|
|
|
|
|
|
8694
|
|
|
|
|
|
|
# any operator before m// |
8695
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?> |
8696
|
|
|
|
|
|
|
|
8697
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
8698
|
|
|
|
|
|
|
%= | % | |
8699
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
8700
|
|
|
|
|
|
|
-= | -> | - | |
8701
|
|
|
|
|
|
|
:(?>\s*)= | |
8702
|
|
|
|
|
|
|
: | |
8703
|
|
|
|
|
|
|
<<>> | |
8704
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
8705
|
|
|
|
|
|
|
== | => | =~ | = | |
8706
|
|
|
|
|
|
|
>>= | >> | >= | > | |
8707
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
8708
|
|
|
|
|
|
|
\+= | \+ | |
8709
|
|
|
|
|
|
|
\.\. | \.= | \. | |
8710
|
|
|
|
|
|
|
\/\/= | \/\/ | |
8711
|
|
|
|
|
|
|
\/= | \/ | |
8712
|
|
|
|
|
|
|
\? | |
8713
|
|
|
|
|
|
|
\\ | |
8714
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
8715
|
|
|
|
|
|
|
\b x= | |
8716
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
8717
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
8718
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
8719
|
|
|
|
|
|
|
\b(?: print )\b | |
8720
|
0
|
|
|
|
|
0
|
|
|
112
|
|
|
|
|
251
|
|
8721
|
|
|
|
|
|
|
[,;\(\{\[] |
8722
|
|
|
|
|
|
|
|
8723
|
112
|
|
|
|
|
666
|
)) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
8724
|
|
|
|
|
|
|
|
8725
|
|
|
|
|
|
|
# other any character |
8726
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; } |
8727
|
353
|
|
|
|
|
1505
|
|
8728
|
|
|
|
|
|
|
# system error |
8729
|
|
|
|
|
|
|
else { |
8730
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
8731
|
0
|
|
|
|
|
0
|
} |
8732
|
|
|
|
|
|
|
} |
8733
|
|
|
|
|
|
|
|
8734
|
|
|
|
|
|
|
return $e_string; |
8735
|
|
|
|
|
|
|
} |
8736
|
|
|
|
|
|
|
|
8737
|
|
|
|
|
|
|
# |
8738
|
79
|
|
|
5358
|
0
|
342
|
# character class |
8739
|
|
|
|
|
|
|
# |
8740
|
5358
|
100
|
|
|
|
10927
|
sub character_class { |
8741
|
5358
|
100
|
|
|
|
16443
|
my($char,$modifier) = @_; |
8742
|
115
|
|
|
|
|
276
|
|
8743
|
|
|
|
|
|
|
if ($char eq '.') { |
8744
|
|
|
|
|
|
|
if ($modifier =~ /s/) { |
8745
|
23
|
|
|
|
|
64
|
return '${Esjis::dot_s}'; |
8746
|
|
|
|
|
|
|
} |
8747
|
|
|
|
|
|
|
else { |
8748
|
|
|
|
|
|
|
return '${Esjis::dot}'; |
8749
|
92
|
|
|
|
|
212
|
} |
8750
|
|
|
|
|
|
|
} |
8751
|
|
|
|
|
|
|
else { |
8752
|
|
|
|
|
|
|
return Esjis::classic_character_class($char); |
8753
|
|
|
|
|
|
|
} |
8754
|
|
|
|
|
|
|
} |
8755
|
|
|
|
|
|
|
|
8756
|
|
|
|
|
|
|
# |
8757
|
|
|
|
|
|
|
# escape capture ($1, $2, $3, ...) |
8758
|
5243
|
|
|
637
|
0
|
10109
|
# |
8759
|
637
|
|
|
|
|
2869
|
sub e_capture { |
8760
|
|
|
|
|
|
|
|
8761
|
|
|
|
|
|
|
return join '', '${Esjis::capture(', $_[0], ')}'; |
8762
|
|
|
|
|
|
|
return join '', '${', $_[0], '}'; |
8763
|
|
|
|
|
|
|
} |
8764
|
|
|
|
|
|
|
|
8765
|
|
|
|
|
|
|
# |
8766
|
0
|
|
|
11
|
0
|
0
|
# escape transliteration (tr/// or y///) |
8767
|
11
|
|
|
|
|
54
|
# |
8768
|
11
|
|
100
|
|
|
21
|
sub e_tr { |
8769
|
|
|
|
|
|
|
my($variable,$charclass,$e,$charclass2,$modifier) = @_; |
8770
|
11
|
|
|
|
|
32
|
my $e_tr = ''; |
8771
|
|
|
|
|
|
|
$modifier ||= ''; |
8772
|
|
|
|
|
|
|
|
8773
|
11
|
|
|
|
|
15
|
$slash = 'div'; |
8774
|
|
|
|
|
|
|
|
8775
|
|
|
|
|
|
|
# quote character class 1 |
8776
|
11
|
|
|
|
|
23
|
$charclass = q_tr($charclass); |
8777
|
|
|
|
|
|
|
|
8778
|
|
|
|
|
|
|
# quote character class 2 |
8779
|
11
|
50
|
|
|
|
23
|
$charclass2 = q_tr($charclass2); |
8780
|
11
|
0
|
|
|
|
31
|
|
8781
|
0
|
|
|
|
|
0
|
# /b /B modifier |
8782
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
8783
|
|
|
|
|
|
|
if ($variable eq '') { |
8784
|
0
|
|
|
|
|
0
|
$e_tr = qq{tr$charclass$e$charclass2$modifier}; |
8785
|
|
|
|
|
|
|
} |
8786
|
|
|
|
|
|
|
else { |
8787
|
|
|
|
|
|
|
$e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier}; |
8788
|
0
|
100
|
|
|
|
0
|
} |
8789
|
11
|
|
|
|
|
22
|
} |
8790
|
|
|
|
|
|
|
else { |
8791
|
|
|
|
|
|
|
if ($variable eq '') { |
8792
|
2
|
|
|
|
|
9
|
$e_tr = qq{Esjis::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}; |
8793
|
|
|
|
|
|
|
} |
8794
|
|
|
|
|
|
|
else { |
8795
|
|
|
|
|
|
|
$e_tr = qq{Esjis::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}; |
8796
|
|
|
|
|
|
|
} |
8797
|
9
|
|
|
|
|
27
|
} |
8798
|
11
|
|
|
|
|
14
|
|
8799
|
|
|
|
|
|
|
# clear tr/// variable |
8800
|
11
|
|
|
|
|
15
|
$tr_variable = ''; |
8801
|
|
|
|
|
|
|
$bind_operator = ''; |
8802
|
|
|
|
|
|
|
|
8803
|
|
|
|
|
|
|
return $e_tr; |
8804
|
|
|
|
|
|
|
} |
8805
|
|
|
|
|
|
|
|
8806
|
|
|
|
|
|
|
# |
8807
|
11
|
|
|
22
|
0
|
57
|
# quote for escape transliteration (tr/// or y///) |
8808
|
|
|
|
|
|
|
# |
8809
|
|
|
|
|
|
|
sub q_tr { |
8810
|
22
|
50
|
|
|
|
36
|
my($charclass) = @_; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8811
|
22
|
|
|
|
|
46
|
|
8812
|
|
|
|
|
|
|
# quote character class |
8813
|
|
|
|
|
|
|
if ($charclass !~ /'/oxms) { |
8814
|
22
|
|
|
|
|
37
|
return e_q('', "'", "'", $charclass); # --> q' ' |
8815
|
|
|
|
|
|
|
} |
8816
|
|
|
|
|
|
|
elsif ($charclass !~ /\//oxms) { |
8817
|
0
|
|
|
|
|
0
|
return e_q('q', '/', '/', $charclass); # --> q/ / |
8818
|
|
|
|
|
|
|
} |
8819
|
|
|
|
|
|
|
elsif ($charclass !~ /\#/oxms) { |
8820
|
0
|
|
|
|
|
0
|
return e_q('q', '#', '#', $charclass); # --> q# # |
8821
|
|
|
|
|
|
|
} |
8822
|
|
|
|
|
|
|
elsif ($charclass !~ /[\<\>]/oxms) { |
8823
|
0
|
|
|
|
|
0
|
return e_q('q', '<', '>', $charclass); # --> q< > |
8824
|
|
|
|
|
|
|
} |
8825
|
|
|
|
|
|
|
elsif ($charclass !~ /[\(\)]/oxms) { |
8826
|
0
|
|
|
|
|
0
|
return e_q('q', '(', ')', $charclass); # --> q( ) |
8827
|
|
|
|
|
|
|
} |
8828
|
|
|
|
|
|
|
elsif ($charclass !~ /[\{\}]/oxms) { |
8829
|
0
|
|
|
|
|
0
|
return e_q('q', '{', '}', $charclass); # --> q{ } |
8830
|
0
|
0
|
|
|
|
0
|
} |
8831
|
0
|
|
|
|
|
0
|
else { |
8832
|
|
|
|
|
|
|
for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8833
|
|
|
|
|
|
|
if ($charclass !~ /\Q$char\E/xms) { |
8834
|
|
|
|
|
|
|
return e_q('q', $char, $char, $charclass); |
8835
|
|
|
|
|
|
|
} |
8836
|
0
|
|
|
|
|
0
|
} |
8837
|
|
|
|
|
|
|
} |
8838
|
|
|
|
|
|
|
|
8839
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); |
8840
|
|
|
|
|
|
|
} |
8841
|
|
|
|
|
|
|
|
8842
|
|
|
|
|
|
|
# |
8843
|
0
|
|
|
3990
|
0
|
0
|
# escape q string (q//, '') |
8844
|
|
|
|
|
|
|
# |
8845
|
3990
|
|
|
|
|
11174
|
sub e_q { |
8846
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8847
|
3990
|
|
|
|
|
6200
|
|
8848
|
3990
|
|
|
|
|
26607
|
$slash = 'div'; |
8849
|
|
|
|
|
|
|
|
8850
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>$q_char) /oxmsg; |
8851
|
3990
|
100
|
100
|
|
|
11790
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
100
|
100
|
|
|
|
|
8852
|
21330
|
|
|
|
|
131330
|
|
8853
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
8854
|
|
|
|
|
|
|
if ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
8855
|
1
|
|
|
|
|
5
|
$char[$i] = $1 . '\\' . $2; |
8856
|
|
|
|
|
|
|
} |
8857
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8858
|
22
|
100
|
100
|
|
|
103
|
$char[$i] = $1 . '\\' . $2; |
8859
|
3990
|
|
|
|
|
16666
|
} |
8860
|
|
|
|
|
|
|
} |
8861
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8862
|
204
|
|
|
|
|
674
|
$char[-1] = $1 . '\\' . $2; |
8863
|
3990
|
|
|
|
|
25222
|
} |
8864
|
|
|
|
|
|
|
|
8865
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8866
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8867
|
|
|
|
|
|
|
} |
8868
|
|
|
|
|
|
|
|
8869
|
|
|
|
|
|
|
# |
8870
|
0
|
|
|
9592
|
0
|
0
|
# escape qq string (qq//, "", qx//, ``) |
8871
|
|
|
|
|
|
|
# |
8872
|
9592
|
|
|
|
|
24172
|
sub e_qq { |
8873
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8874
|
9592
|
|
|
|
|
15298
|
|
8875
|
9592
|
|
|
|
|
11939
|
$slash = 'div'; |
8876
|
|
|
|
|
|
|
|
8877
|
|
|
|
|
|
|
my $left_e = 0; |
8878
|
9592
|
|
|
|
|
11300
|
my $right_e = 0; |
8879
|
|
|
|
|
|
|
|
8880
|
|
|
|
|
|
|
# split regexp |
8881
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8882
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
8883
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8884
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8885
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
8886
|
|
|
|
|
|
|
\\ $q_char | |
8887
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8888
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8889
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8890
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8891
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8892
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8893
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8894
|
9592
|
|
|
|
|
398577
|
$q_char |
8895
|
|
|
|
|
|
|
))/oxmsg; |
8896
|
|
|
|
|
|
|
|
8897
|
9592
|
50
|
66
|
|
|
32094
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8898
|
309941
|
|
|
|
|
1038247
|
|
8899
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
8900
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8901
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8902
|
|
|
|
|
|
|
} |
8903
|
0
|
|
|
|
|
0
|
|
8904
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
8905
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8906
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8907
|
|
|
|
|
|
|
} |
8908
|
0
|
|
|
|
|
0
|
|
8909
|
|
|
|
|
|
|
# octal escape sequence |
8910
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8911
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
8912
|
|
|
|
|
|
|
} |
8913
|
1
|
|
|
|
|
6
|
|
8914
|
|
|
|
|
|
|
# hexadecimal escape sequence |
8915
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8916
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
8917
|
|
|
|
|
|
|
} |
8918
|
1
|
|
|
|
|
132
|
|
8919
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
8920
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
8921
|
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
|
|
|
|
|
|
8922
|
|
|
|
|
|
|
} |
8923
|
|
|
|
|
|
|
|
8924
|
|
|
|
|
|
|
if (0) { |
8925
|
|
|
|
|
|
|
} |
8926
|
|
|
|
|
|
|
|
8927
|
309941
|
|
|
|
|
3089146
|
# escape last octet of multiple-octet |
8928
|
0
|
|
|
|
|
0
|
# my $metachar = qr/[\@\\\|]/oxms; # '|' is for qx//, ``, open(), and system() |
8929
|
|
|
|
|
|
|
# variable $delimiter and $end_delimiter can be '' |
8930
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\@\\\|$delimiter$end_delimiter]) \z/xms) { |
8931
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8932
|
|
|
|
|
|
|
} |
8933
|
|
|
|
|
|
|
|
8934
|
|
|
|
|
|
|
# \F |
8935
|
|
|
|
|
|
|
# |
8936
|
|
|
|
|
|
|
# P.69 Table 2-6. Translation escapes |
8937
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
8938
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8939
|
|
|
|
|
|
|
# (and so on) |
8940
|
1342
|
50
|
|
|
|
5697
|
|
8941
|
650
|
|
|
|
|
1656
|
# \u \l \U \L \F \Q \E |
8942
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8943
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8944
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8945
|
|
|
|
|
|
|
} |
8946
|
|
|
|
|
|
|
} |
8947
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
8948
|
|
|
|
|
|
|
|
8949
|
|
|
|
|
|
|
# "STRING @{[ LIST EXPR ]} MORE STRING" |
8950
|
|
|
|
|
|
|
|
8951
|
|
|
|
|
|
|
# P.257 Other Tricks You Can Do with Hard References |
8952
|
|
|
|
|
|
|
# in Chapter 8: References |
8953
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
8954
|
|
|
|
|
|
|
|
8955
|
|
|
|
|
|
|
# P.353 Other Tricks You Can Do with Hard References |
8956
|
|
|
|
|
|
|
# in Chapter 8: References |
8957
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8958
|
0
|
|
|
|
|
0
|
|
8959
|
0
|
|
|
|
|
0
|
# (and so on) |
8960
|
|
|
|
|
|
|
|
8961
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
8962
|
0
|
|
|
|
|
0
|
$left_e++; |
8963
|
0
|
|
|
|
|
0
|
} |
8964
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
8965
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
8966
|
0
|
|
|
|
|
0
|
$left_e++; |
8967
|
0
|
|
|
|
|
0
|
} |
8968
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
8969
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
8970
|
0
|
|
|
|
|
0
|
$left_e++; |
8971
|
6
|
|
|
|
|
10
|
} |
8972
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
8973
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
8974
|
6
|
|
|
|
|
13
|
$left_e++; |
8975
|
9
|
|
|
|
|
19
|
} |
8976
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
8977
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
8978
|
9
|
|
|
|
|
23
|
$left_e++; |
8979
|
0
|
|
|
|
|
0
|
} |
8980
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
8981
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8982
|
0
|
50
|
|
|
|
0
|
$left_e++; |
8983
|
12
|
|
|
|
|
24
|
} |
8984
|
12
|
|
|
|
|
15
|
elsif ($char[$i] eq '\E') { |
8985
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8986
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8987
|
12
|
|
|
|
|
25
|
$right_e++; |
8988
|
|
|
|
|
|
|
} |
8989
|
|
|
|
|
|
|
else { |
8990
|
|
|
|
|
|
|
$char[$i] = ''; |
8991
|
0
|
|
|
|
|
0
|
} |
8992
|
0
|
0
|
|
|
|
0
|
} |
8993
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8994
|
|
|
|
|
|
|
while (1) { |
8995
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
8996
|
0
|
|
|
|
|
0
|
last; |
8997
|
|
|
|
|
|
|
} |
8998
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8999
|
|
|
|
|
|
|
last; |
9000
|
|
|
|
|
|
|
} |
9001
|
|
|
|
|
|
|
} |
9002
|
|
|
|
|
|
|
} |
9003
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9004
|
|
|
|
|
|
|
} |
9005
|
|
|
|
|
|
|
|
9006
|
|
|
|
|
|
|
# $0 --> $0 |
9007
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9008
|
|
|
|
|
|
|
} |
9009
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9010
|
|
|
|
|
|
|
} |
9011
|
|
|
|
|
|
|
|
9012
|
|
|
|
|
|
|
# $$ --> $$ |
9013
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9014
|
|
|
|
|
|
|
} |
9015
|
|
|
|
|
|
|
|
9016
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9017
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9018
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9019
|
415
|
|
|
|
|
1187
|
$char[$i] = e_capture($1); |
9020
|
|
|
|
|
|
|
} |
9021
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9022
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
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_bracket)*? \] ) \z/oxms) { |
9027
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9028
|
|
|
|
|
|
|
} |
9029
|
0
|
|
|
|
|
0
|
|
9030
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
9031
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9032
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9033
|
|
|
|
|
|
|
} |
9034
|
0
|
|
|
|
|
0
|
|
9035
|
|
|
|
|
|
|
# $$foo |
9036
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9037
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9038
|
|
|
|
|
|
|
} |
9039
|
0
|
|
|
|
|
0
|
|
9040
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9041
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9042
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9043
|
|
|
|
|
|
|
} |
9044
|
44
|
|
|
|
|
138
|
|
9045
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9046
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9047
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9048
|
|
|
|
|
|
|
} |
9049
|
45
|
|
|
|
|
138
|
|
9050
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9051
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9052
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9053
|
|
|
|
|
|
|
} |
9054
|
|
|
|
|
|
|
|
9055
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
9056
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
9057
|
|
|
|
|
|
|
} |
9058
|
33
|
|
|
|
|
117
|
|
9059
|
|
|
|
|
|
|
# ${ ... } |
9060
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9061
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9062
|
|
|
|
|
|
|
} |
9063
|
0
|
100
|
|
|
|
0
|
} |
9064
|
9592
|
|
|
|
|
20664
|
|
9065
|
|
|
|
|
|
|
# return string |
9066
|
3
|
|
|
|
|
20
|
if ($left_e > $right_e) { |
9067
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter; |
9068
|
|
|
|
|
|
|
} |
9069
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
9070
|
|
|
|
|
|
|
} |
9071
|
|
|
|
|
|
|
|
9072
|
|
|
|
|
|
|
# |
9073
|
9589
|
|
|
34
|
0
|
82699
|
# escape qw string (qw//) |
9074
|
|
|
|
|
|
|
# |
9075
|
34
|
|
|
|
|
180
|
sub e_qw { |
9076
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
9077
|
|
|
|
|
|
|
|
9078
|
34
|
|
|
|
|
71
|
$slash = 'div'; |
|
34
|
|
|
|
|
340
|
|
9079
|
621
|
50
|
|
|
|
991
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9080
|
34
|
|
|
|
|
179
|
# choice again delimiter |
9081
|
|
|
|
|
|
|
my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg); |
9082
|
|
|
|
|
|
|
if (not $octet{$end_delimiter}) { |
9083
|
34
|
|
|
|
|
303
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
9084
|
|
|
|
|
|
|
} |
9085
|
|
|
|
|
|
|
elsif (not $octet{')'}) { |
9086
|
0
|
|
|
|
|
0
|
return join '', $ope, '(', $string, ')'; |
9087
|
|
|
|
|
|
|
} |
9088
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9089
|
0
|
|
|
|
|
0
|
return join '', $ope, '{', $string, '}'; |
9090
|
|
|
|
|
|
|
} |
9091
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9092
|
0
|
|
|
|
|
0
|
return join '', $ope, '[', $string, ']'; |
9093
|
|
|
|
|
|
|
} |
9094
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9095
|
0
|
|
|
|
|
0
|
return join '', $ope, '<', $string, '>'; |
9096
|
0
|
0
|
|
|
|
0
|
} |
9097
|
0
|
|
|
|
|
0
|
else { |
9098
|
|
|
|
|
|
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9099
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9100
|
|
|
|
|
|
|
return join '', $ope, $char, $string, $char; |
9101
|
|
|
|
|
|
|
} |
9102
|
|
|
|
|
|
|
} |
9103
|
0
|
|
|
|
|
0
|
} |
9104
|
0
|
|
|
|
|
0
|
|
9105
|
0
|
|
|
|
|
0
|
# qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC') |
9106
|
0
|
|
|
|
|
0
|
my @string = CORE::split(/\s+/, $string); |
9107
|
0
|
0
|
|
|
|
0
|
for my $string (@string) { |
9108
|
0
|
|
|
|
|
0
|
my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
9109
|
|
|
|
|
|
|
for my $octet (@octet) { |
9110
|
|
|
|
|
|
|
if ($octet =~ /\A (['\\]) \z/oxms) { |
9111
|
0
|
|
|
|
|
0
|
$octet = '\\' . $1; |
9112
|
|
|
|
|
|
|
} |
9113
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
9114
|
|
|
|
|
|
|
$string = join '', @octet; |
9115
|
|
|
|
|
|
|
} |
9116
|
|
|
|
|
|
|
return join '', '(', (join ', ', map { "'$_'" } @string), ')'; |
9117
|
|
|
|
|
|
|
} |
9118
|
|
|
|
|
|
|
|
9119
|
|
|
|
|
|
|
# |
9120
|
0
|
|
|
108
|
0
|
0
|
# escape here document (<<"HEREDOC", <
|
9121
|
|
|
|
|
|
|
# |
9122
|
108
|
|
|
|
|
291
|
sub e_heredoc { |
9123
|
|
|
|
|
|
|
my($string) = @_; |
9124
|
108
|
|
|
|
|
222
|
|
9125
|
|
|
|
|
|
|
$slash = 'm//'; |
9126
|
108
|
|
|
|
|
383
|
|
9127
|
108
|
|
|
|
|
163
|
my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC` |
9128
|
|
|
|
|
|
|
|
9129
|
|
|
|
|
|
|
my $left_e = 0; |
9130
|
108
|
|
|
|
|
139
|
my $right_e = 0; |
9131
|
|
|
|
|
|
|
|
9132
|
|
|
|
|
|
|
# split regexp |
9133
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9134
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9135
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9136
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9137
|
|
|
|
|
|
|
\\N\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
9138
|
|
|
|
|
|
|
\\ $q_char | |
9139
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9140
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9141
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9142
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9143
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9144
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9145
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9146
|
108
|
|
|
|
|
10673
|
$q_char |
9147
|
|
|
|
|
|
|
))/oxmsg; |
9148
|
|
|
|
|
|
|
|
9149
|
108
|
50
|
66
|
|
|
544
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9150
|
3225
|
|
|
|
|
10042
|
|
9151
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
9152
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9153
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9154
|
|
|
|
|
|
|
} |
9155
|
0
|
|
|
|
|
0
|
|
9156
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
9157
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9158
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9159
|
|
|
|
|
|
|
} |
9160
|
0
|
|
|
|
|
0
|
|
9161
|
|
|
|
|
|
|
# octal escape sequence |
9162
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9163
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
9164
|
|
|
|
|
|
|
} |
9165
|
1
|
|
|
|
|
5
|
|
9166
|
|
|
|
|
|
|
# hexadecimal escape sequence |
9167
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9168
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
9169
|
|
|
|
|
|
|
} |
9170
|
1
|
|
|
|
|
5
|
|
9171
|
|
|
|
|
|
|
# \N{CHARNAME} --> N{CHARNAME} |
9172
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
9173
|
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
|
|
|
|
|
|
9174
|
|
|
|
|
|
|
} |
9175
|
|
|
|
|
|
|
|
9176
|
|
|
|
|
|
|
if (0) { |
9177
|
3225
|
|
|
|
|
28915
|
} |
9178
|
0
|
|
|
|
|
0
|
|
9179
|
|
|
|
|
|
|
# escape character |
9180
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
9181
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9182
|
|
|
|
|
|
|
} |
9183
|
57
|
50
|
|
|
|
225
|
|
9184
|
72
|
|
|
|
|
132
|
# \u \l \U \L \F \Q \E |
9185
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
9186
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9187
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9188
|
0
|
|
|
|
|
0
|
} |
9189
|
0
|
|
|
|
|
0
|
} |
9190
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
9191
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
9192
|
0
|
|
|
|
|
0
|
$left_e++; |
9193
|
0
|
|
|
|
|
0
|
} |
9194
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
9195
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
9196
|
0
|
|
|
|
|
0
|
$left_e++; |
9197
|
0
|
|
|
|
|
0
|
} |
9198
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
9199
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
9200
|
0
|
|
|
|
|
0
|
$left_e++; |
9201
|
6
|
|
|
|
|
8
|
} |
9202
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
9203
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
9204
|
6
|
|
|
|
|
12
|
$left_e++; |
9205
|
0
|
|
|
|
|
0
|
} |
9206
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
9207
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
9208
|
0
|
|
|
|
|
0
|
$left_e++; |
9209
|
0
|
|
|
|
|
0
|
} |
9210
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
9211
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9212
|
0
|
50
|
|
|
|
0
|
$left_e++; |
9213
|
3
|
|
|
|
|
7
|
} |
9214
|
3
|
|
|
|
|
7
|
elsif ($char[$i] eq '\E') { |
9215
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9216
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9217
|
3
|
|
|
|
|
6
|
$right_e++; |
9218
|
|
|
|
|
|
|
} |
9219
|
|
|
|
|
|
|
else { |
9220
|
|
|
|
|
|
|
$char[$i] = ''; |
9221
|
0
|
|
|
|
|
0
|
} |
9222
|
0
|
0
|
|
|
|
0
|
} |
9223
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9224
|
|
|
|
|
|
|
while (1) { |
9225
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9226
|
0
|
|
|
|
|
0
|
last; |
9227
|
|
|
|
|
|
|
} |
9228
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9229
|
|
|
|
|
|
|
last; |
9230
|
|
|
|
|
|
|
} |
9231
|
|
|
|
|
|
|
} |
9232
|
|
|
|
|
|
|
} |
9233
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9234
|
|
|
|
|
|
|
} |
9235
|
|
|
|
|
|
|
|
9236
|
|
|
|
|
|
|
# $0 --> $0 |
9237
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9238
|
|
|
|
|
|
|
} |
9239
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9240
|
|
|
|
|
|
|
} |
9241
|
|
|
|
|
|
|
|
9242
|
|
|
|
|
|
|
# $$ --> $$ |
9243
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9244
|
|
|
|
|
|
|
} |
9245
|
|
|
|
|
|
|
|
9246
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9247
|
|
|
|
|
|
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9248
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9249
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9250
|
|
|
|
|
|
|
} |
9251
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9252
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
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_bracket)*? \] ) \z/oxms) { |
9257
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9258
|
|
|
|
|
|
|
} |
9259
|
0
|
|
|
|
|
0
|
|
9260
|
|
|
|
|
|
|
# $$foo{ ... } --> $ $foo->{ ... } |
9261
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9262
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9263
|
|
|
|
|
|
|
} |
9264
|
0
|
|
|
|
|
0
|
|
9265
|
|
|
|
|
|
|
# $$foo |
9266
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9267
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9268
|
|
|
|
|
|
|
} |
9269
|
0
|
|
|
|
|
0
|
|
9270
|
|
|
|
|
|
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9271
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9272
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9273
|
|
|
|
|
|
|
} |
9274
|
8
|
|
|
|
|
50
|
|
9275
|
|
|
|
|
|
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9276
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9277
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9278
|
|
|
|
|
|
|
} |
9279
|
8
|
|
|
|
|
46
|
|
9280
|
|
|
|
|
|
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9281
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9282
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9283
|
|
|
|
|
|
|
} |
9284
|
|
|
|
|
|
|
|
9285
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
9286
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
9287
|
|
|
|
|
|
|
} |
9288
|
6
|
|
|
|
|
34
|
|
9289
|
|
|
|
|
|
|
# ${ ... } |
9290
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9291
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9292
|
|
|
|
|
|
|
} |
9293
|
0
|
100
|
|
|
|
0
|
} |
9294
|
108
|
|
|
|
|
271
|
|
9295
|
|
|
|
|
|
|
# return string |
9296
|
3
|
|
|
|
|
24
|
if ($left_e > $right_e) { |
9297
|
|
|
|
|
|
|
return join '', @char, '>]}' x ($left_e - $right_e); |
9298
|
|
|
|
|
|
|
} |
9299
|
|
|
|
|
|
|
return join '', @char; |
9300
|
|
|
|
|
|
|
} |
9301
|
|
|
|
|
|
|
|
9302
|
|
|
|
|
|
|
# |
9303
|
105
|
|
|
1835
|
0
|
842
|
# escape regexp (m//, qr//) |
9304
|
1835
|
|
100
|
|
|
9045
|
# |
9305
|
|
|
|
|
|
|
sub e_qr { |
9306
|
1835
|
|
|
|
|
7658
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9307
|
1835
|
50
|
|
|
|
4243
|
$modifier ||= ''; |
9308
|
1835
|
|
|
|
|
5397
|
|
9309
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9310
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9311
|
0
|
|
|
|
|
0
|
my $line = 0; |
9312
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9313
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9314
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9315
|
0
|
|
|
|
|
0
|
last; |
9316
|
|
|
|
|
|
|
} |
9317
|
|
|
|
|
|
|
} |
9318
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9319
|
|
|
|
|
|
|
} |
9320
|
|
|
|
|
|
|
|
9321
|
1835
|
100
|
|
|
|
3194
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9322
|
1835
|
|
|
|
|
6327
|
|
9323
|
8
|
|
|
|
|
14
|
# literal null string pattern |
9324
|
8
|
|
|
|
|
10
|
if ($string eq '') { |
9325
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9326
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9327
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9328
|
|
|
|
|
|
|
} |
9329
|
|
|
|
|
|
|
|
9330
|
|
|
|
|
|
|
# /b /B modifier |
9331
|
8
|
50
|
|
|
|
38
|
elsif ($modifier =~ tr/bB//d) { |
9332
|
240
|
|
|
|
|
681
|
|
9333
|
0
|
|
|
|
|
0
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9334
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9335
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
9336
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9337
|
|
|
|
|
|
|
if (not $octet{')'}) { |
9338
|
|
|
|
|
|
|
$delimiter = '('; |
9339
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
9340
|
0
|
|
|
|
|
0
|
} |
9341
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9342
|
|
|
|
|
|
|
$delimiter = '{'; |
9343
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
9344
|
0
|
|
|
|
|
0
|
} |
9345
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9346
|
|
|
|
|
|
|
$delimiter = '['; |
9347
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
9348
|
0
|
|
|
|
|
0
|
} |
9349
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9350
|
|
|
|
|
|
|
$delimiter = '<'; |
9351
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
9352
|
0
|
0
|
|
|
|
0
|
} |
9353
|
0
|
|
|
|
|
0
|
else { |
9354
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9355
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9356
|
|
|
|
|
|
|
$delimiter = $char; |
9357
|
|
|
|
|
|
|
$end_delimiter = $char; |
9358
|
|
|
|
|
|
|
last; |
9359
|
|
|
|
|
|
|
} |
9360
|
|
|
|
|
|
|
} |
9361
|
0
|
100
|
100
|
|
|
0
|
} |
9362
|
240
|
|
|
|
|
1097
|
} |
9363
|
|
|
|
|
|
|
|
9364
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9365
|
90
|
|
|
|
|
514
|
return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier; |
9366
|
|
|
|
|
|
|
} |
9367
|
|
|
|
|
|
|
else { |
9368
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9369
|
150
|
100
|
|
|
|
881
|
} |
9370
|
1587
|
|
|
|
|
4120
|
} |
9371
|
|
|
|
|
|
|
|
9372
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9373
|
1587
|
|
|
|
|
6103
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9374
|
|
|
|
|
|
|
|
9375
|
|
|
|
|
|
|
# split regexp |
9376
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9377
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9378
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9379
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9380
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9381
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9382
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9383
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
9384
|
|
|
|
|
|
|
\\ $q_char | |
9385
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9386
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9387
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9388
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9389
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9390
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9391
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9392
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9393
|
|
|
|
|
|
|
\[\^ | |
9394
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9395
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9396
|
|
|
|
|
|
|
\(\? | |
9397
|
|
|
|
|
|
|
$q_char |
9398
|
1587
|
50
|
|
|
|
167943
|
))/oxmsg; |
9399
|
1587
|
|
|
|
|
8747
|
|
|
0
|
|
|
|
|
0
|
|
9400
|
0
|
0
|
|
|
|
0
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9401
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
9402
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9403
|
|
|
|
|
|
|
if (not $octet{')'}) { |
9404
|
|
|
|
|
|
|
$delimiter = '('; |
9405
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
9406
|
0
|
|
|
|
|
0
|
} |
9407
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
9408
|
|
|
|
|
|
|
$delimiter = '{'; |
9409
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
9410
|
0
|
|
|
|
|
0
|
} |
9411
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
9412
|
|
|
|
|
|
|
$delimiter = '['; |
9413
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
9414
|
0
|
|
|
|
|
0
|
} |
9415
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
9416
|
|
|
|
|
|
|
$delimiter = '<'; |
9417
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
9418
|
0
|
0
|
|
|
|
0
|
} |
9419
|
0
|
|
|
|
|
0
|
else { |
9420
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9421
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9422
|
|
|
|
|
|
|
$delimiter = $char; |
9423
|
|
|
|
|
|
|
$end_delimiter = $char; |
9424
|
|
|
|
|
|
|
last; |
9425
|
|
|
|
|
|
|
} |
9426
|
|
|
|
|
|
|
} |
9427
|
0
|
|
|
|
|
0
|
} |
9428
|
1587
|
|
|
|
|
3032
|
} |
9429
|
1587
|
|
|
|
|
2361
|
|
9430
|
|
|
|
|
|
|
my $left_e = 0; |
9431
|
|
|
|
|
|
|
my $right_e = 0; |
9432
|
1587
|
50
|
66
|
|
|
4855
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9433
|
5437
|
|
|
|
|
33287
|
|
9434
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
9435
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9436
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9437
|
|
|
|
|
|
|
} |
9438
|
0
|
|
|
|
|
0
|
|
9439
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
9440
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9441
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9442
|
|
|
|
|
|
|
} |
9443
|
0
|
|
|
|
|
0
|
|
9444
|
|
|
|
|
|
|
# octal escape sequence |
9445
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9446
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
9447
|
|
|
|
|
|
|
} |
9448
|
1
|
|
|
|
|
5
|
|
9449
|
|
|
|
|
|
|
# hexadecimal escape sequence |
9450
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9451
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
9452
|
|
|
|
|
|
|
} |
9453
|
|
|
|
|
|
|
|
9454
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9455
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9456
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9457
|
1
|
|
|
|
|
4
|
# \p{PROPERTY} --> p\{PROPERTY} |
9458
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
9459
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
9460
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9461
|
|
|
|
|
|
|
} |
9462
|
6
|
|
|
|
|
20
|
|
9463
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
9464
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9465
|
4
|
100
|
100
|
|
|
10
|
$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
|
|
|
|
|
|
9466
|
|
|
|
|
|
|
} |
9467
|
|
|
|
|
|
|
|
9468
|
|
|
|
|
|
|
if (0) { |
9469
|
5437
|
|
|
|
|
39795
|
} |
9470
|
0
|
|
|
|
|
0
|
|
9471
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
9472
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9473
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9474
|
|
|
|
|
|
|
} |
9475
|
77
|
50
|
33
|
|
|
422
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
9476
|
6
|
|
|
|
|
115
|
# join separated multiple-octet |
9477
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9478
|
|
|
|
|
|
|
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)) { |
9479
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9480
|
|
|
|
|
|
|
} |
9481
|
|
|
|
|
|
|
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)) { |
9482
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9483
|
|
|
|
|
|
|
} |
9484
|
|
|
|
|
|
|
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)) { |
9485
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9486
|
|
|
|
|
|
|
} |
9487
|
|
|
|
|
|
|
} |
9488
|
0
|
|
|
|
|
0
|
|
9489
|
|
|
|
|
|
|
# open character class [...] |
9490
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
9491
|
|
|
|
|
|
|
my $left = $i; |
9492
|
|
|
|
|
|
|
|
9493
|
586
|
100
|
|
|
|
939
|
# [] make die "Unmatched [] in regexp ...\n" |
9494
|
586
|
|
|
|
|
1527
|
# (and so on) |
9495
|
|
|
|
|
|
|
|
9496
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9497
|
3
|
|
|
|
|
7
|
$i++; |
9498
|
586
|
50
|
|
|
|
757
|
} |
9499
|
2583
|
|
|
|
|
3789
|
|
9500
|
|
|
|
|
|
|
while (1) { |
9501
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
9502
|
2583
|
|
|
|
|
4396
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9503
|
|
|
|
|
|
|
} |
9504
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9505
|
586
|
100
|
|
|
|
924
|
my $right = $i; |
9506
|
586
|
|
|
|
|
4054
|
|
|
90
|
|
|
|
|
220
|
|
9507
|
|
|
|
|
|
|
# [...] |
9508
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9509
|
270
|
|
|
|
|
465
|
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); |
9510
|
|
|
|
|
|
|
} |
9511
|
|
|
|
|
|
|
else { |
9512
|
496
|
|
|
|
|
2668
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
9513
|
586
|
|
|
|
|
1641
|
} |
9514
|
|
|
|
|
|
|
|
9515
|
|
|
|
|
|
|
$i = $left; |
9516
|
|
|
|
|
|
|
last; |
9517
|
|
|
|
|
|
|
} |
9518
|
|
|
|
|
|
|
} |
9519
|
|
|
|
|
|
|
} |
9520
|
586
|
|
|
|
|
1936
|
|
9521
|
|
|
|
|
|
|
# open character class [^...] |
9522
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
9523
|
|
|
|
|
|
|
my $left = $i; |
9524
|
|
|
|
|
|
|
|
9525
|
328
|
100
|
|
|
|
537
|
# [^] make die "Unmatched [] in regexp ...\n" |
9526
|
328
|
|
|
|
|
955
|
# (and so on) |
9527
|
|
|
|
|
|
|
|
9528
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9529
|
5
|
|
|
|
|
8
|
$i++; |
9530
|
328
|
50
|
|
|
|
435
|
} |
9531
|
1447
|
|
|
|
|
2041
|
|
9532
|
|
|
|
|
|
|
while (1) { |
9533
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
9534
|
1447
|
|
|
|
|
2159
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9535
|
|
|
|
|
|
|
} |
9536
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9537
|
328
|
100
|
|
|
|
400
|
my $right = $i; |
9538
|
328
|
|
|
|
|
1930
|
|
|
90
|
|
|
|
|
219
|
|
9539
|
|
|
|
|
|
|
# [^...] |
9540
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9541
|
270
|
|
|
|
|
433
|
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); |
9542
|
|
|
|
|
|
|
} |
9543
|
|
|
|
|
|
|
else { |
9544
|
238
|
|
|
|
|
1229
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9545
|
328
|
|
|
|
|
638
|
} |
9546
|
|
|
|
|
|
|
|
9547
|
|
|
|
|
|
|
$i = $left; |
9548
|
|
|
|
|
|
|
last; |
9549
|
|
|
|
|
|
|
} |
9550
|
|
|
|
|
|
|
} |
9551
|
|
|
|
|
|
|
} |
9552
|
328
|
|
|
|
|
971
|
|
9553
|
|
|
|
|
|
|
# rewrite character class or escape character |
9554
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9555
|
|
|
|
|
|
|
$char[$i] = $char; |
9556
|
|
|
|
|
|
|
} |
9557
|
215
|
50
|
|
|
|
638
|
|
9558
|
238
|
|
|
|
|
484
|
# /i modifier |
9559
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
9560
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
9561
|
238
|
|
|
|
|
506
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
9562
|
|
|
|
|
|
|
} |
9563
|
|
|
|
|
|
|
else { |
9564
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
9565
|
|
|
|
|
|
|
} |
9566
|
|
|
|
|
|
|
} |
9567
|
0
|
50
|
|
|
|
0
|
|
9568
|
1
|
|
|
|
|
5
|
# \u \l \U \L \F \Q \E |
9569
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9570
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9571
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9572
|
0
|
|
|
|
|
0
|
} |
9573
|
0
|
|
|
|
|
0
|
} |
9574
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
9575
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
9576
|
0
|
|
|
|
|
0
|
$left_e++; |
9577
|
0
|
|
|
|
|
0
|
} |
9578
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
9579
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
9580
|
0
|
|
|
|
|
0
|
$left_e++; |
9581
|
1
|
|
|
|
|
3
|
} |
9582
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
9583
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
9584
|
1
|
|
|
|
|
4
|
$left_e++; |
9585
|
1
|
|
|
|
|
2
|
} |
9586
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
9587
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
9588
|
1
|
|
|
|
|
3
|
$left_e++; |
9589
|
9
|
|
|
|
|
16
|
} |
9590
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
9591
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
9592
|
9
|
|
|
|
|
19
|
$left_e++; |
9593
|
22
|
|
|
|
|
47
|
} |
9594
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
9595
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9596
|
22
|
50
|
|
|
|
59
|
$left_e++; |
9597
|
33
|
|
|
|
|
81
|
} |
9598
|
33
|
|
|
|
|
100
|
elsif ($char[$i] eq '\E') { |
9599
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9600
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9601
|
33
|
|
|
|
|
78
|
$right_e++; |
9602
|
|
|
|
|
|
|
} |
9603
|
|
|
|
|
|
|
else { |
9604
|
|
|
|
|
|
|
$char[$i] = ''; |
9605
|
0
|
|
|
|
|
0
|
} |
9606
|
0
|
0
|
|
|
|
0
|
} |
9607
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9608
|
|
|
|
|
|
|
while (1) { |
9609
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9610
|
0
|
|
|
|
|
0
|
last; |
9611
|
|
|
|
|
|
|
} |
9612
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9613
|
|
|
|
|
|
|
last; |
9614
|
|
|
|
|
|
|
} |
9615
|
|
|
|
|
|
|
} |
9616
|
|
|
|
|
|
|
} |
9617
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9618
|
|
|
|
|
|
|
} |
9619
|
0
|
0
|
|
|
|
0
|
|
9620
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
9621
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9622
|
|
|
|
|
|
|
if ($ignorecase) { |
9623
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9624
|
0
|
0
|
|
|
|
0
|
} |
9625
|
0
|
|
|
|
|
0
|
} |
9626
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9627
|
|
|
|
|
|
|
if ($ignorecase) { |
9628
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9629
|
|
|
|
|
|
|
} |
9630
|
|
|
|
|
|
|
} |
9631
|
|
|
|
|
|
|
|
9632
|
|
|
|
|
|
|
# $$ --> $$ |
9633
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9634
|
|
|
|
|
|
|
} |
9635
|
|
|
|
|
|
|
|
9636
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9637
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9638
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9639
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9640
|
|
|
|
|
|
|
if ($ignorecase) { |
9641
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9642
|
0
|
|
|
|
|
0
|
} |
9643
|
0
|
0
|
|
|
|
0
|
} |
9644
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9645
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9646
|
|
|
|
|
|
|
if ($ignorecase) { |
9647
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9648
|
|
|
|
|
|
|
} |
9649
|
|
|
|
|
|
|
} |
9650
|
0
|
|
|
|
|
0
|
|
9651
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9652
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9653
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9654
|
|
|
|
|
|
|
if ($ignorecase) { |
9655
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9656
|
|
|
|
|
|
|
} |
9657
|
|
|
|
|
|
|
} |
9658
|
0
|
|
|
|
|
0
|
|
9659
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
9660
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9661
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
9662
|
|
|
|
|
|
|
if ($ignorecase) { |
9663
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9664
|
|
|
|
|
|
|
} |
9665
|
|
|
|
|
|
|
} |
9666
|
0
|
|
|
|
|
0
|
|
9667
|
0
|
0
|
|
|
|
0
|
# $$foo |
9668
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9669
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9670
|
|
|
|
|
|
|
if ($ignorecase) { |
9671
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9672
|
|
|
|
|
|
|
} |
9673
|
|
|
|
|
|
|
} |
9674
|
0
|
50
|
|
|
|
0
|
|
9675
|
8
|
|
|
|
|
24
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
9676
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9677
|
|
|
|
|
|
|
if ($ignorecase) { |
9678
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
9679
|
|
|
|
|
|
|
} |
9680
|
|
|
|
|
|
|
else { |
9681
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
9682
|
|
|
|
|
|
|
} |
9683
|
|
|
|
|
|
|
} |
9684
|
8
|
50
|
|
|
|
25
|
|
9685
|
8
|
|
|
|
|
22
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
9686
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9687
|
|
|
|
|
|
|
if ($ignorecase) { |
9688
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
9689
|
|
|
|
|
|
|
} |
9690
|
|
|
|
|
|
|
else { |
9691
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
9692
|
|
|
|
|
|
|
} |
9693
|
|
|
|
|
|
|
} |
9694
|
8
|
50
|
|
|
|
27
|
|
9695
|
6
|
|
|
|
|
17
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
9696
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9697
|
|
|
|
|
|
|
if ($ignorecase) { |
9698
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
9699
|
|
|
|
|
|
|
} |
9700
|
|
|
|
|
|
|
else { |
9701
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
9702
|
|
|
|
|
|
|
} |
9703
|
|
|
|
|
|
|
} |
9704
|
6
|
0
|
|
|
|
18
|
|
9705
|
0
|
|
|
|
|
0
|
# ${ foo } |
9706
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
9707
|
|
|
|
|
|
|
if ($ignorecase) { |
9708
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9709
|
|
|
|
|
|
|
} |
9710
|
|
|
|
|
|
|
} |
9711
|
0
|
|
|
|
|
0
|
|
9712
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
9713
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9714
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
9715
|
|
|
|
|
|
|
if ($ignorecase) { |
9716
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9717
|
|
|
|
|
|
|
} |
9718
|
|
|
|
|
|
|
} |
9719
|
0
|
|
|
|
|
0
|
|
9720
|
31
|
100
|
|
|
|
144
|
# $scalar or @array |
9721
|
31
|
|
|
|
|
113
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
9722
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
9723
|
|
|
|
|
|
|
if ($ignorecase) { |
9724
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
9725
|
|
|
|
|
|
|
} |
9726
|
|
|
|
|
|
|
} |
9727
|
4
|
100
|
66
|
|
|
15
|
|
|
|
50
|
|
|
|
|
|
9728
|
|
|
|
|
|
|
# quote character before ? + * { |
9729
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9730
|
188
|
|
|
|
|
1463
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
9731
|
0
|
0
|
|
|
|
0
|
} |
9732
|
0
|
|
|
|
|
0
|
elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9733
|
|
|
|
|
|
|
my $char = $char[$i-1]; |
9734
|
|
|
|
|
|
|
if ($char[$i] eq '{') { |
9735
|
0
|
|
|
|
|
0
|
die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n}; |
9736
|
|
|
|
|
|
|
} |
9737
|
|
|
|
|
|
|
else { |
9738
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n}; |
9739
|
0
|
|
|
|
|
0
|
} |
9740
|
|
|
|
|
|
|
} |
9741
|
|
|
|
|
|
|
else { |
9742
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9743
|
|
|
|
|
|
|
} |
9744
|
|
|
|
|
|
|
} |
9745
|
187
|
|
|
|
|
979
|
} |
9746
|
1587
|
50
|
|
|
|
3178
|
|
9747
|
1587
|
0
|
0
|
|
|
3955
|
# make regexp string |
9748
|
0
|
|
|
|
|
0
|
$modifier =~ tr/i//d; |
9749
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
9750
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9751
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier; |
9752
|
|
|
|
|
|
|
} |
9753
|
|
|
|
|
|
|
else { |
9754
|
0
|
100
|
100
|
|
|
0
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
9755
|
1587
|
|
|
|
|
9536
|
} |
9756
|
|
|
|
|
|
|
} |
9757
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9758
|
94
|
|
|
|
|
821
|
return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier; |
9759
|
|
|
|
|
|
|
} |
9760
|
|
|
|
|
|
|
else { |
9761
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9762
|
|
|
|
|
|
|
} |
9763
|
|
|
|
|
|
|
} |
9764
|
|
|
|
|
|
|
|
9765
|
|
|
|
|
|
|
# |
9766
|
1493
|
|
|
540
|
0
|
15718
|
# double quote stuff |
9767
|
|
|
|
|
|
|
# |
9768
|
|
|
|
|
|
|
sub qq_stuff { |
9769
|
540
|
100
|
|
|
|
922
|
my($delimiter,$end_delimiter,$stuff) = @_; |
9770
|
540
|
|
|
|
|
1241
|
|
9771
|
|
|
|
|
|
|
# scalar variable or array variable |
9772
|
|
|
|
|
|
|
if ($stuff =~ /\A [\$\@] /oxms) { |
9773
|
|
|
|
|
|
|
return $stuff; |
9774
|
300
|
|
|
|
|
1006
|
} |
|
240
|
|
|
|
|
628
|
|
9775
|
280
|
|
|
|
|
761
|
|
9776
|
240
|
50
|
|
|
|
576
|
# quote by delimiter |
9777
|
240
|
50
|
|
|
|
402
|
my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg); |
9778
|
240
|
50
|
|
|
|
341
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9779
|
240
|
|
|
|
|
459
|
next if $char eq $delimiter; |
9780
|
|
|
|
|
|
|
next if $char eq $end_delimiter; |
9781
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9782
|
240
|
|
|
|
|
927
|
return join '', 'qq', $char, $stuff, $char; |
9783
|
|
|
|
|
|
|
} |
9784
|
|
|
|
|
|
|
} |
9785
|
|
|
|
|
|
|
return join '', 'qq', '<', $stuff, '>'; |
9786
|
|
|
|
|
|
|
} |
9787
|
|
|
|
|
|
|
|
9788
|
|
|
|
|
|
|
# |
9789
|
0
|
|
|
163
|
0
|
0
|
# escape regexp (m'', qr'', and m''b, qr''b) |
9790
|
163
|
|
100
|
|
|
719
|
# |
9791
|
|
|
|
|
|
|
sub e_qr_q { |
9792
|
163
|
|
|
|
|
466
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9793
|
163
|
50
|
|
|
|
280
|
$modifier ||= ''; |
9794
|
163
|
|
|
|
|
461
|
|
9795
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9796
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9797
|
0
|
|
|
|
|
0
|
my $line = 0; |
9798
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9799
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9800
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9801
|
0
|
|
|
|
|
0
|
last; |
9802
|
|
|
|
|
|
|
} |
9803
|
|
|
|
|
|
|
} |
9804
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9805
|
|
|
|
|
|
|
} |
9806
|
|
|
|
|
|
|
|
9807
|
163
|
100
|
|
|
|
219
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9808
|
163
|
|
|
|
|
372
|
|
9809
|
8
|
|
|
|
|
9
|
# literal null string pattern |
9810
|
8
|
|
|
|
|
10
|
if ($string eq '') { |
9811
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9812
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9813
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9814
|
|
|
|
|
|
|
} |
9815
|
8
|
|
|
|
|
40
|
|
9816
|
|
|
|
|
|
|
# with /b /B modifier |
9817
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9818
|
|
|
|
|
|
|
return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
9819
|
|
|
|
|
|
|
} |
9820
|
89
|
|
|
|
|
213
|
|
9821
|
|
|
|
|
|
|
# without /b /B modifier |
9822
|
|
|
|
|
|
|
else { |
9823
|
|
|
|
|
|
|
return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
9824
|
|
|
|
|
|
|
} |
9825
|
|
|
|
|
|
|
} |
9826
|
|
|
|
|
|
|
|
9827
|
|
|
|
|
|
|
# |
9828
|
66
|
|
|
66
|
0
|
141
|
# escape regexp (m'', qr'') |
9829
|
|
|
|
|
|
|
# |
9830
|
66
|
100
|
|
|
|
168
|
sub e_qr_qt { |
9831
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9832
|
|
|
|
|
|
|
|
9833
|
66
|
|
|
|
|
160
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9834
|
|
|
|
|
|
|
|
9835
|
|
|
|
|
|
|
# split regexp |
9836
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9837
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\$\@\/] | |
9838
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
9839
|
|
|
|
|
|
|
\[\^ | |
9840
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
9841
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
9842
|
|
|
|
|
|
|
[\$\@\/] | |
9843
|
|
|
|
|
|
|
\\ (?:$q_char) | |
9844
|
|
|
|
|
|
|
(?:$q_char) |
9845
|
66
|
|
|
|
|
676
|
))/oxmsg; |
9846
|
66
|
100
|
100
|
|
|
182
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9847
|
|
|
|
|
|
|
# unescape character |
9848
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9849
|
|
|
|
|
|
|
if (0) { |
9850
|
79
|
|
|
|
|
734
|
} |
9851
|
0
|
|
|
|
|
0
|
|
9852
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
9853
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9854
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9855
|
|
|
|
|
|
|
} |
9856
|
2
|
|
|
|
|
22
|
|
9857
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
9858
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
9859
|
|
|
|
|
|
|
my $left = $i; |
9860
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
9861
|
0
|
0
|
|
|
|
0
|
$i++; |
9862
|
0
|
|
|
|
|
0
|
} |
9863
|
|
|
|
|
|
|
while (1) { |
9864
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9865
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9866
|
|
|
|
|
|
|
} |
9867
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9868
|
0
|
|
|
|
|
0
|
my $right = $i; |
9869
|
|
|
|
|
|
|
|
9870
|
0
|
|
|
|
|
0
|
# [...] |
9871
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
9872
|
|
|
|
|
|
|
|
9873
|
|
|
|
|
|
|
$i = $left; |
9874
|
|
|
|
|
|
|
last; |
9875
|
|
|
|
|
|
|
} |
9876
|
|
|
|
|
|
|
} |
9877
|
|
|
|
|
|
|
} |
9878
|
0
|
|
|
|
|
0
|
|
9879
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
9880
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9881
|
|
|
|
|
|
|
my $left = $i; |
9882
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
9883
|
0
|
0
|
|
|
|
0
|
$i++; |
9884
|
0
|
|
|
|
|
0
|
} |
9885
|
|
|
|
|
|
|
while (1) { |
9886
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
9887
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9888
|
|
|
|
|
|
|
} |
9889
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9890
|
0
|
|
|
|
|
0
|
my $right = $i; |
9891
|
|
|
|
|
|
|
|
9892
|
0
|
|
|
|
|
0
|
# [^...] |
9893
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9894
|
|
|
|
|
|
|
|
9895
|
|
|
|
|
|
|
$i = $left; |
9896
|
|
|
|
|
|
|
last; |
9897
|
|
|
|
|
|
|
} |
9898
|
|
|
|
|
|
|
} |
9899
|
|
|
|
|
|
|
} |
9900
|
0
|
|
|
|
|
0
|
|
9901
|
|
|
|
|
|
|
# escape $ @ / and \ |
9902
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9903
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9904
|
|
|
|
|
|
|
} |
9905
|
0
|
|
|
|
|
0
|
|
9906
|
|
|
|
|
|
|
# rewrite character class or escape character |
9907
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9908
|
|
|
|
|
|
|
$char[$i] = $char; |
9909
|
|
|
|
|
|
|
} |
9910
|
0
|
50
|
|
|
|
0
|
|
9911
|
16
|
|
|
|
|
41
|
# /i modifier |
9912
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
9913
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
9914
|
16
|
|
|
|
|
35
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
9915
|
|
|
|
|
|
|
} |
9916
|
|
|
|
|
|
|
else { |
9917
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
9918
|
|
|
|
|
|
|
} |
9919
|
|
|
|
|
|
|
} |
9920
|
0
|
0
|
|
|
|
0
|
|
9921
|
|
|
|
|
|
|
# quote character before ? + * { |
9922
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9923
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
9924
|
|
|
|
|
|
|
} |
9925
|
|
|
|
|
|
|
else { |
9926
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9927
|
|
|
|
|
|
|
} |
9928
|
0
|
|
|
|
|
0
|
} |
9929
|
66
|
|
|
|
|
132
|
} |
9930
|
|
|
|
|
|
|
|
9931
|
66
|
|
|
|
|
86
|
$delimiter = '/'; |
9932
|
66
|
|
|
|
|
103
|
$end_delimiter = '/'; |
9933
|
|
|
|
|
|
|
|
9934
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9935
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9936
|
|
|
|
|
|
|
} |
9937
|
|
|
|
|
|
|
|
9938
|
|
|
|
|
|
|
# |
9939
|
66
|
|
|
89
|
0
|
436
|
# escape regexp (m''b, qr''b) |
9940
|
|
|
|
|
|
|
# |
9941
|
|
|
|
|
|
|
sub e_qr_qb { |
9942
|
89
|
|
|
|
|
184
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9943
|
|
|
|
|
|
|
|
9944
|
|
|
|
|
|
|
# split regexp |
9945
|
89
|
|
|
|
|
334
|
my @char = $string =~ /\G ((?>[^\\]|\\\\|[\x00-\xFF])) /oxmsg; |
9946
|
89
|
50
|
|
|
|
226
|
|
|
|
50
|
|
|
|
|
|
9947
|
|
|
|
|
|
|
# unescape character |
9948
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9949
|
|
|
|
|
|
|
if (0) { |
9950
|
199
|
|
|
|
|
572
|
} |
9951
|
|
|
|
|
|
|
|
9952
|
|
|
|
|
|
|
# remain \\ |
9953
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
9954
|
|
|
|
|
|
|
} |
9955
|
0
|
|
|
|
|
0
|
|
9956
|
|
|
|
|
|
|
# escape $ @ / and \ |
9957
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9958
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9959
|
0
|
|
|
|
|
0
|
} |
9960
|
89
|
|
|
|
|
133
|
} |
9961
|
89
|
|
|
|
|
101
|
|
9962
|
|
|
|
|
|
|
$delimiter = '/'; |
9963
|
|
|
|
|
|
|
$end_delimiter = '/'; |
9964
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9965
|
|
|
|
|
|
|
} |
9966
|
|
|
|
|
|
|
|
9967
|
|
|
|
|
|
|
# |
9968
|
89
|
|
|
195
|
0
|
506
|
# escape regexp (s/here//) |
9969
|
195
|
|
100
|
|
|
730
|
# |
9970
|
|
|
|
|
|
|
sub e_s1 { |
9971
|
195
|
|
|
|
|
720
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9972
|
195
|
50
|
|
|
|
375
|
$modifier ||= ''; |
9973
|
195
|
|
|
|
|
657
|
|
9974
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
9975
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9976
|
0
|
|
|
|
|
0
|
my $line = 0; |
9977
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9978
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
9979
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9980
|
0
|
|
|
|
|
0
|
last; |
9981
|
|
|
|
|
|
|
} |
9982
|
|
|
|
|
|
|
} |
9983
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9984
|
|
|
|
|
|
|
} |
9985
|
|
|
|
|
|
|
|
9986
|
195
|
100
|
|
|
|
498
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
9987
|
195
|
|
|
|
|
965
|
|
9988
|
8
|
|
|
|
|
11
|
# literal null string pattern |
9989
|
8
|
|
|
|
|
11
|
if ($string eq '') { |
9990
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
9991
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9992
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9993
|
|
|
|
|
|
|
} |
9994
|
|
|
|
|
|
|
|
9995
|
|
|
|
|
|
|
# /b /B modifier |
9996
|
8
|
50
|
|
|
|
54
|
elsif ($modifier =~ tr/bB//d) { |
9997
|
44
|
|
|
|
|
95
|
|
9998
|
0
|
|
|
|
|
0
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9999
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
10000
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
10001
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
10002
|
|
|
|
|
|
|
if (not $octet{')'}) { |
10003
|
|
|
|
|
|
|
$delimiter = '('; |
10004
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
10005
|
0
|
|
|
|
|
0
|
} |
10006
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
10007
|
|
|
|
|
|
|
$delimiter = '{'; |
10008
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
10009
|
0
|
|
|
|
|
0
|
} |
10010
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
10011
|
|
|
|
|
|
|
$delimiter = '['; |
10012
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
10013
|
0
|
|
|
|
|
0
|
} |
10014
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
10015
|
|
|
|
|
|
|
$delimiter = '<'; |
10016
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
10017
|
0
|
0
|
|
|
|
0
|
} |
10018
|
0
|
|
|
|
|
0
|
else { |
10019
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
10020
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
10021
|
|
|
|
|
|
|
$delimiter = $char; |
10022
|
|
|
|
|
|
|
$end_delimiter = $char; |
10023
|
|
|
|
|
|
|
last; |
10024
|
|
|
|
|
|
|
} |
10025
|
|
|
|
|
|
|
} |
10026
|
0
|
|
|
|
|
0
|
} |
10027
|
44
|
|
|
|
|
61
|
} |
10028
|
44
|
|
|
|
|
52
|
|
10029
|
|
|
|
|
|
|
my $prematch = ''; |
10030
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10031
|
44
|
100
|
|
|
|
271
|
return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
10032
|
143
|
|
|
|
|
526
|
} |
10033
|
|
|
|
|
|
|
|
10034
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10035
|
143
|
|
|
|
|
652
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10036
|
|
|
|
|
|
|
|
10037
|
|
|
|
|
|
|
# split regexp |
10038
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10039
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10040
|
|
|
|
|
|
|
\\ (?>[1-9][0-9]*) | |
10041
|
|
|
|
|
|
|
\\g (?>\s*) (?>[1-9][0-9]*) | |
10042
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
10043
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
10044
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10045
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10046
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10047
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10048
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10049
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
10050
|
|
|
|
|
|
|
\\ $q_char | |
10051
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10052
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10053
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10054
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10055
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10056
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10057
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10058
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10059
|
|
|
|
|
|
|
\[\^ | |
10060
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10061
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10062
|
|
|
|
|
|
|
\(\? | |
10063
|
|
|
|
|
|
|
$q_char |
10064
|
143
|
50
|
|
|
|
39562
|
))/oxmsg; |
10065
|
143
|
|
|
|
|
1380
|
|
|
0
|
|
|
|
|
0
|
|
10066
|
0
|
0
|
|
|
|
0
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
10067
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
10068
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
10069
|
|
|
|
|
|
|
if (not $octet{')'}) { |
10070
|
|
|
|
|
|
|
$delimiter = '('; |
10071
|
0
|
|
|
|
|
0
|
$end_delimiter = ')'; |
10072
|
0
|
|
|
|
|
0
|
} |
10073
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
10074
|
|
|
|
|
|
|
$delimiter = '{'; |
10075
|
0
|
|
|
|
|
0
|
$end_delimiter = '}'; |
10076
|
0
|
|
|
|
|
0
|
} |
10077
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
10078
|
|
|
|
|
|
|
$delimiter = '['; |
10079
|
0
|
|
|
|
|
0
|
$end_delimiter = ']'; |
10080
|
0
|
|
|
|
|
0
|
} |
10081
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
10082
|
|
|
|
|
|
|
$delimiter = '<'; |
10083
|
0
|
|
|
|
|
0
|
$end_delimiter = '>'; |
10084
|
0
|
0
|
|
|
|
0
|
} |
10085
|
0
|
|
|
|
|
0
|
else { |
10086
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
10087
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
10088
|
|
|
|
|
|
|
$delimiter = $char; |
10089
|
|
|
|
|
|
|
$end_delimiter = $char; |
10090
|
|
|
|
|
|
|
last; |
10091
|
|
|
|
|
|
|
} |
10092
|
|
|
|
|
|
|
} |
10093
|
|
|
|
|
|
|
} |
10094
|
0
|
|
|
|
|
0
|
} |
|
143
|
|
|
|
|
307
|
|
10095
|
|
|
|
|
|
|
|
10096
|
477
|
|
|
|
|
888
|
# count '(' |
10097
|
143
|
|
|
|
|
247
|
my $parens = grep { $_ eq '(' } @char; |
10098
|
143
|
|
|
|
|
215
|
|
10099
|
|
|
|
|
|
|
my $left_e = 0; |
10100
|
|
|
|
|
|
|
my $right_e = 0; |
10101
|
143
|
50
|
33
|
|
|
475
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10102
|
398
|
|
|
|
|
3318
|
|
10103
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
10104
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10105
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10106
|
|
|
|
|
|
|
} |
10107
|
0
|
|
|
|
|
0
|
|
10108
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
10109
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
10110
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10111
|
|
|
|
|
|
|
} |
10112
|
0
|
|
|
|
|
0
|
|
10113
|
|
|
|
|
|
|
# octal escape sequence |
10114
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
10115
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
10116
|
|
|
|
|
|
|
} |
10117
|
1
|
|
|
|
|
4
|
|
10118
|
|
|
|
|
|
|
# hexadecimal escape sequence |
10119
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
10120
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
10121
|
|
|
|
|
|
|
} |
10122
|
|
|
|
|
|
|
|
10123
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
10124
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
10125
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
10126
|
1
|
|
|
|
|
3
|
# \p{PROPERTY} --> p\{PROPERTY} |
10127
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
10128
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
10129
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10130
|
|
|
|
|
|
|
} |
10131
|
0
|
|
|
|
|
0
|
|
10132
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
10133
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
10134
|
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
|
|
|
|
|
|
10135
|
|
|
|
|
|
|
} |
10136
|
|
|
|
|
|
|
|
10137
|
|
|
|
|
|
|
if (0) { |
10138
|
398
|
|
|
|
|
5083
|
} |
10139
|
0
|
|
|
|
|
0
|
|
10140
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10141
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10142
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10143
|
|
|
|
|
|
|
} |
10144
|
23
|
0
|
0
|
|
|
121
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
10145
|
0
|
|
|
|
|
0
|
# join separated multiple-octet |
10146
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
10147
|
|
|
|
|
|
|
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)) { |
10148
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
10149
|
|
|
|
|
|
|
} |
10150
|
|
|
|
|
|
|
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)) { |
10151
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
10152
|
|
|
|
|
|
|
} |
10153
|
|
|
|
|
|
|
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)) { |
10154
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
10155
|
|
|
|
|
|
|
} |
10156
|
|
|
|
|
|
|
} |
10157
|
0
|
|
|
|
|
0
|
|
10158
|
20
|
50
|
|
|
|
513
|
# open character class [...] |
10159
|
20
|
|
|
|
|
79
|
elsif ($char[$i] eq '[') { |
10160
|
|
|
|
|
|
|
my $left = $i; |
10161
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10162
|
20
|
50
|
|
|
|
38
|
$i++; |
10163
|
79
|
|
|
|
|
242
|
} |
10164
|
|
|
|
|
|
|
while (1) { |
10165
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
10166
|
79
|
|
|
|
|
201
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10167
|
|
|
|
|
|
|
} |
10168
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10169
|
20
|
50
|
|
|
|
40
|
my $right = $i; |
10170
|
20
|
|
|
|
|
152
|
|
|
0
|
|
|
|
|
0
|
|
10171
|
|
|
|
|
|
|
# [...] |
10172
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10173
|
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); |
10174
|
|
|
|
|
|
|
} |
10175
|
|
|
|
|
|
|
else { |
10176
|
20
|
|
|
|
|
114
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
10177
|
20
|
|
|
|
|
35
|
} |
10178
|
|
|
|
|
|
|
|
10179
|
|
|
|
|
|
|
$i = $left; |
10180
|
|
|
|
|
|
|
last; |
10181
|
|
|
|
|
|
|
} |
10182
|
|
|
|
|
|
|
} |
10183
|
|
|
|
|
|
|
} |
10184
|
20
|
|
|
|
|
89
|
|
10185
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
10186
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10187
|
|
|
|
|
|
|
my $left = $i; |
10188
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10189
|
0
|
0
|
|
|
|
0
|
$i++; |
10190
|
0
|
|
|
|
|
0
|
} |
10191
|
|
|
|
|
|
|
while (1) { |
10192
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10193
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10194
|
|
|
|
|
|
|
} |
10195
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10196
|
0
|
0
|
|
|
|
0
|
my $right = $i; |
10197
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
10198
|
|
|
|
|
|
|
# [^...] |
10199
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10200
|
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); |
10201
|
|
|
|
|
|
|
} |
10202
|
|
|
|
|
|
|
else { |
10203
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10204
|
0
|
|
|
|
|
0
|
} |
10205
|
|
|
|
|
|
|
|
10206
|
|
|
|
|
|
|
$i = $left; |
10207
|
|
|
|
|
|
|
last; |
10208
|
|
|
|
|
|
|
} |
10209
|
|
|
|
|
|
|
} |
10210
|
|
|
|
|
|
|
} |
10211
|
0
|
|
|
|
|
0
|
|
10212
|
|
|
|
|
|
|
# rewrite character class or escape character |
10213
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10214
|
|
|
|
|
|
|
$char[$i] = $char; |
10215
|
|
|
|
|
|
|
} |
10216
|
11
|
50
|
|
|
|
27
|
|
10217
|
11
|
|
|
|
|
25
|
# /i modifier |
10218
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
10219
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
10220
|
11
|
|
|
|
|
27
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
10221
|
|
|
|
|
|
|
} |
10222
|
|
|
|
|
|
|
else { |
10223
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
10224
|
|
|
|
|
|
|
} |
10225
|
|
|
|
|
|
|
} |
10226
|
0
|
50
|
|
|
|
0
|
|
10227
|
8
|
|
|
|
|
27
|
# \u \l \U \L \F \Q \E |
10228
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
10229
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10230
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10231
|
0
|
|
|
|
|
0
|
} |
10232
|
0
|
|
|
|
|
0
|
} |
10233
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
10234
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
10235
|
0
|
|
|
|
|
0
|
$left_e++; |
10236
|
0
|
|
|
|
|
0
|
} |
10237
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
10238
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
10239
|
0
|
|
|
|
|
0
|
$left_e++; |
10240
|
0
|
|
|
|
|
0
|
} |
10241
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
10242
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
10243
|
0
|
|
|
|
|
0
|
$left_e++; |
10244
|
0
|
|
|
|
|
0
|
} |
10245
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
10246
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
10247
|
0
|
|
|
|
|
0
|
$left_e++; |
10248
|
0
|
|
|
|
|
0
|
} |
10249
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
10250
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
10251
|
0
|
|
|
|
|
0
|
$left_e++; |
10252
|
7
|
|
|
|
|
13
|
} |
10253
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
10254
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
10255
|
7
|
50
|
|
|
|
18
|
$left_e++; |
10256
|
7
|
|
|
|
|
20
|
} |
10257
|
7
|
|
|
|
|
13
|
elsif ($char[$i] eq '\E') { |
10258
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10259
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
10260
|
7
|
|
|
|
|
16
|
$right_e++; |
10261
|
|
|
|
|
|
|
} |
10262
|
|
|
|
|
|
|
else { |
10263
|
|
|
|
|
|
|
$char[$i] = ''; |
10264
|
0
|
|
|
|
|
0
|
} |
10265
|
0
|
0
|
|
|
|
0
|
} |
10266
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10267
|
|
|
|
|
|
|
while (1) { |
10268
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10269
|
0
|
|
|
|
|
0
|
last; |
10270
|
|
|
|
|
|
|
} |
10271
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
10272
|
|
|
|
|
|
|
last; |
10273
|
|
|
|
|
|
|
} |
10274
|
|
|
|
|
|
|
} |
10275
|
|
|
|
|
|
|
} |
10276
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
10277
|
|
|
|
|
|
|
} |
10278
|
|
|
|
|
|
|
|
10279
|
|
|
|
|
|
|
# \0 --> \0 |
10280
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) { |
10281
|
|
|
|
|
|
|
} |
10282
|
|
|
|
|
|
|
|
10283
|
|
|
|
|
|
|
# \g{N}, \g{-N} |
10284
|
|
|
|
|
|
|
|
10285
|
|
|
|
|
|
|
# P.108 Using Simple Patterns |
10286
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
10287
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
10288
|
|
|
|
|
|
|
|
10289
|
|
|
|
|
|
|
# P.221 Capturing |
10290
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10291
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10292
|
|
|
|
|
|
|
|
10293
|
|
|
|
|
|
|
# \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3} |
10294
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10295
|
|
|
|
|
|
|
} |
10296
|
0
|
0
|
|
|
|
0
|
|
10297
|
0
|
|
|
|
|
0
|
# \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable) |
10298
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10299
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10300
|
|
|
|
|
|
|
$char[$i] = '\\g{' . ($1 + 1) . '}'; |
10301
|
|
|
|
|
|
|
} |
10302
|
|
|
|
|
|
|
} |
10303
|
0
|
0
|
|
|
|
0
|
|
10304
|
0
|
|
|
|
|
0
|
# \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable) |
10305
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
10306
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10307
|
|
|
|
|
|
|
$char[$i] = '\\g' . ($1 + 1); |
10308
|
|
|
|
|
|
|
} |
10309
|
|
|
|
|
|
|
} |
10310
|
0
|
0
|
|
|
|
0
|
|
10311
|
0
|
|
|
|
|
0
|
# \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable) |
10312
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
10313
|
|
|
|
|
|
|
if ($1 <= $parens) { |
10314
|
|
|
|
|
|
|
$char[$i] = '\\' . ($1 + 1); |
10315
|
|
|
|
|
|
|
} |
10316
|
|
|
|
|
|
|
} |
10317
|
0
|
0
|
|
|
|
0
|
|
10318
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
10319
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
10320
|
|
|
|
|
|
|
if ($ignorecase) { |
10321
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10322
|
0
|
0
|
|
|
|
0
|
} |
10323
|
0
|
|
|
|
|
0
|
} |
10324
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
10325
|
|
|
|
|
|
|
if ($ignorecase) { |
10326
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10327
|
|
|
|
|
|
|
} |
10328
|
|
|
|
|
|
|
} |
10329
|
|
|
|
|
|
|
|
10330
|
|
|
|
|
|
|
# $$ --> $$ |
10331
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
10332
|
|
|
|
|
|
|
} |
10333
|
|
|
|
|
|
|
|
10334
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
10335
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
10336
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
10337
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10338
|
|
|
|
|
|
|
if ($ignorecase) { |
10339
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10340
|
0
|
|
|
|
|
0
|
} |
10341
|
0
|
0
|
|
|
|
0
|
} |
10342
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10343
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10344
|
|
|
|
|
|
|
if ($ignorecase) { |
10345
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10346
|
|
|
|
|
|
|
} |
10347
|
|
|
|
|
|
|
} |
10348
|
0
|
|
|
|
|
0
|
|
10349
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10350
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10351
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
10352
|
|
|
|
|
|
|
if ($ignorecase) { |
10353
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10354
|
|
|
|
|
|
|
} |
10355
|
|
|
|
|
|
|
} |
10356
|
0
|
|
|
|
|
0
|
|
10357
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10358
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10359
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
10360
|
|
|
|
|
|
|
if ($ignorecase) { |
10361
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10362
|
|
|
|
|
|
|
} |
10363
|
|
|
|
|
|
|
} |
10364
|
0
|
|
|
|
|
0
|
|
10365
|
0
|
0
|
|
|
|
0
|
# $$foo |
10366
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10367
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10368
|
|
|
|
|
|
|
if ($ignorecase) { |
10369
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10370
|
|
|
|
|
|
|
} |
10371
|
|
|
|
|
|
|
} |
10372
|
0
|
50
|
|
|
|
0
|
|
10373
|
4
|
|
|
|
|
17
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
10374
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10375
|
|
|
|
|
|
|
if ($ignorecase) { |
10376
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
10377
|
|
|
|
|
|
|
} |
10378
|
|
|
|
|
|
|
else { |
10379
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
10380
|
|
|
|
|
|
|
} |
10381
|
|
|
|
|
|
|
} |
10382
|
4
|
50
|
|
|
|
16
|
|
10383
|
4
|
|
|
|
|
16
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
10384
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10385
|
|
|
|
|
|
|
if ($ignorecase) { |
10386
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
10387
|
|
|
|
|
|
|
} |
10388
|
|
|
|
|
|
|
else { |
10389
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
10390
|
|
|
|
|
|
|
} |
10391
|
|
|
|
|
|
|
} |
10392
|
4
|
50
|
|
|
|
15
|
|
10393
|
3
|
|
|
|
|
12
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
10394
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10395
|
|
|
|
|
|
|
if ($ignorecase) { |
10396
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
10397
|
|
|
|
|
|
|
} |
10398
|
|
|
|
|
|
|
else { |
10399
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
10400
|
|
|
|
|
|
|
} |
10401
|
|
|
|
|
|
|
} |
10402
|
3
|
0
|
|
|
|
12
|
|
10403
|
0
|
|
|
|
|
0
|
# ${ foo } |
10404
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10405
|
|
|
|
|
|
|
if ($ignorecase) { |
10406
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10407
|
|
|
|
|
|
|
} |
10408
|
|
|
|
|
|
|
} |
10409
|
0
|
|
|
|
|
0
|
|
10410
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
10411
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10412
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
10413
|
|
|
|
|
|
|
if ($ignorecase) { |
10414
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10415
|
|
|
|
|
|
|
} |
10416
|
|
|
|
|
|
|
} |
10417
|
0
|
|
|
|
|
0
|
|
10418
|
13
|
50
|
|
|
|
47
|
# $scalar or @array |
10419
|
13
|
|
|
|
|
57
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10420
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
10421
|
|
|
|
|
|
|
if ($ignorecase) { |
10422
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
10423
|
|
|
|
|
|
|
} |
10424
|
|
|
|
|
|
|
} |
10425
|
0
|
50
|
|
|
|
0
|
|
10426
|
|
|
|
|
|
|
# quote character before ? + * { |
10427
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10428
|
23
|
|
|
|
|
137
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10429
|
|
|
|
|
|
|
} |
10430
|
|
|
|
|
|
|
else { |
10431
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10432
|
|
|
|
|
|
|
} |
10433
|
|
|
|
|
|
|
} |
10434
|
23
|
|
|
|
|
230
|
} |
10435
|
143
|
|
|
|
|
333
|
|
10436
|
143
|
|
|
|
|
347
|
# make regexp string |
10437
|
143
|
50
|
|
|
|
252
|
my $prematch = ''; |
10438
|
143
|
|
|
|
|
431
|
$prematch = "($anchor)"; |
10439
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10440
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
10441
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
10442
|
|
|
|
|
|
|
} |
10443
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10444
|
|
|
|
|
|
|
} |
10445
|
|
|
|
|
|
|
|
10446
|
|
|
|
|
|
|
# |
10447
|
143
|
|
|
96
|
0
|
1773
|
# escape regexp (s'here'' or s'here''b) |
10448
|
96
|
|
100
|
|
|
193
|
# |
10449
|
|
|
|
|
|
|
sub e_s1_q { |
10450
|
96
|
|
|
|
|
225
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10451
|
96
|
50
|
|
|
|
126
|
$modifier ||= ''; |
10452
|
96
|
|
|
|
|
276
|
|
10453
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10454
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10455
|
0
|
|
|
|
|
0
|
my $line = 0; |
10456
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10457
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10458
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10459
|
0
|
|
|
|
|
0
|
last; |
10460
|
|
|
|
|
|
|
} |
10461
|
|
|
|
|
|
|
} |
10462
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10463
|
|
|
|
|
|
|
} |
10464
|
|
|
|
|
|
|
|
10465
|
96
|
100
|
|
|
|
129
|
$slash = 'div'; |
|
|
100
|
|
|
|
|
|
10466
|
96
|
|
|
|
|
250
|
|
10467
|
8
|
|
|
|
|
11
|
# literal null string pattern |
10468
|
8
|
|
|
|
|
11
|
if ($string eq '') { |
10469
|
|
|
|
|
|
|
$modifier =~ tr/bB//d; |
10470
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10471
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
10472
|
|
|
|
|
|
|
} |
10473
|
8
|
|
|
|
|
51
|
|
10474
|
|
|
|
|
|
|
# with /b /B modifier |
10475
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
10476
|
|
|
|
|
|
|
return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
10477
|
|
|
|
|
|
|
} |
10478
|
44
|
|
|
|
|
84
|
|
10479
|
|
|
|
|
|
|
# without /b /B modifier |
10480
|
|
|
|
|
|
|
else { |
10481
|
|
|
|
|
|
|
return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
10482
|
|
|
|
|
|
|
} |
10483
|
|
|
|
|
|
|
} |
10484
|
|
|
|
|
|
|
|
10485
|
|
|
|
|
|
|
# |
10486
|
44
|
|
|
44
|
0
|
202
|
# escape regexp (s'here'') |
10487
|
|
|
|
|
|
|
# |
10488
|
44
|
100
|
|
|
|
99
|
sub e_s1_qt { |
10489
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10490
|
|
|
|
|
|
|
|
10491
|
44
|
|
|
|
|
91
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10492
|
|
|
|
|
|
|
|
10493
|
|
|
|
|
|
|
# split regexp |
10494
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10495
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[\$\@\/] | |
10496
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10497
|
|
|
|
|
|
|
\[\^ | |
10498
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
10499
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
10500
|
|
|
|
|
|
|
[\$\@\/] | |
10501
|
|
|
|
|
|
|
\\ (?:$q_char) | |
10502
|
|
|
|
|
|
|
(?:$q_char) |
10503
|
44
|
|
|
|
|
479
|
))/oxmsg; |
10504
|
44
|
50
|
100
|
|
|
118
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10505
|
|
|
|
|
|
|
# unescape character |
10506
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10507
|
|
|
|
|
|
|
if (0) { |
10508
|
62
|
|
|
|
|
565
|
} |
10509
|
0
|
|
|
|
|
0
|
|
10510
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10511
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10512
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10513
|
|
|
|
|
|
|
} |
10514
|
0
|
|
|
|
|
0
|
|
10515
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
10516
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
10517
|
|
|
|
|
|
|
my $left = $i; |
10518
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10519
|
0
|
0
|
|
|
|
0
|
$i++; |
10520
|
0
|
|
|
|
|
0
|
} |
10521
|
|
|
|
|
|
|
while (1) { |
10522
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10523
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10524
|
|
|
|
|
|
|
} |
10525
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10526
|
0
|
|
|
|
|
0
|
my $right = $i; |
10527
|
|
|
|
|
|
|
|
10528
|
0
|
|
|
|
|
0
|
# [...] |
10529
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
10530
|
|
|
|
|
|
|
|
10531
|
|
|
|
|
|
|
$i = $left; |
10532
|
|
|
|
|
|
|
last; |
10533
|
|
|
|
|
|
|
} |
10534
|
|
|
|
|
|
|
} |
10535
|
|
|
|
|
|
|
} |
10536
|
0
|
|
|
|
|
0
|
|
10537
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
10538
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10539
|
|
|
|
|
|
|
my $left = $i; |
10540
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
10541
|
0
|
0
|
|
|
|
0
|
$i++; |
10542
|
0
|
|
|
|
|
0
|
} |
10543
|
|
|
|
|
|
|
while (1) { |
10544
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
10545
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10546
|
|
|
|
|
|
|
} |
10547
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10548
|
0
|
|
|
|
|
0
|
my $right = $i; |
10549
|
|
|
|
|
|
|
|
10550
|
0
|
|
|
|
|
0
|
# [^...] |
10551
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10552
|
|
|
|
|
|
|
|
10553
|
|
|
|
|
|
|
$i = $left; |
10554
|
|
|
|
|
|
|
last; |
10555
|
|
|
|
|
|
|
} |
10556
|
|
|
|
|
|
|
} |
10557
|
|
|
|
|
|
|
} |
10558
|
0
|
|
|
|
|
0
|
|
10559
|
|
|
|
|
|
|
# escape $ @ / and \ |
10560
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10561
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10562
|
|
|
|
|
|
|
} |
10563
|
0
|
|
|
|
|
0
|
|
10564
|
|
|
|
|
|
|
# rewrite character class or escape character |
10565
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10566
|
|
|
|
|
|
|
$char[$i] = $char; |
10567
|
|
|
|
|
|
|
} |
10568
|
6
|
50
|
|
|
|
13
|
|
10569
|
8
|
|
|
|
|
15
|
# /i modifier |
10570
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
10571
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
10572
|
8
|
|
|
|
|
21
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
10573
|
|
|
|
|
|
|
} |
10574
|
|
|
|
|
|
|
else { |
10575
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
10576
|
|
|
|
|
|
|
} |
10577
|
|
|
|
|
|
|
} |
10578
|
0
|
0
|
|
|
|
0
|
|
10579
|
|
|
|
|
|
|
# quote character before ? + * { |
10580
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10581
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
10582
|
|
|
|
|
|
|
} |
10583
|
|
|
|
|
|
|
else { |
10584
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10585
|
|
|
|
|
|
|
} |
10586
|
0
|
|
|
|
|
0
|
} |
10587
|
44
|
|
|
|
|
150
|
} |
10588
|
44
|
|
|
|
|
59
|
|
10589
|
44
|
|
|
|
|
57
|
$modifier =~ tr/i//d; |
10590
|
44
|
|
|
|
|
49
|
$delimiter = '/'; |
10591
|
44
|
|
|
|
|
81
|
$end_delimiter = '/'; |
10592
|
|
|
|
|
|
|
my $prematch = ''; |
10593
|
|
|
|
|
|
|
$prematch = "($anchor)"; |
10594
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10595
|
|
|
|
|
|
|
} |
10596
|
|
|
|
|
|
|
|
10597
|
|
|
|
|
|
|
# |
10598
|
44
|
|
|
44
|
0
|
316
|
# escape regexp (s'here''b) |
10599
|
|
|
|
|
|
|
# |
10600
|
|
|
|
|
|
|
sub e_s1_qb { |
10601
|
44
|
|
|
|
|
93
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10602
|
|
|
|
|
|
|
|
10603
|
|
|
|
|
|
|
# split regexp |
10604
|
44
|
|
|
|
|
154
|
my @char = $string =~ /\G (?>[^\\]|\\\\|[\x00-\xFF]) /oxmsg; |
10605
|
44
|
50
|
|
|
|
98
|
|
|
|
50
|
|
|
|
|
|
10606
|
|
|
|
|
|
|
# unescape character |
10607
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10608
|
|
|
|
|
|
|
if (0) { |
10609
|
98
|
|
|
|
|
314
|
} |
10610
|
|
|
|
|
|
|
|
10611
|
|
|
|
|
|
|
# remain \\ |
10612
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
10613
|
|
|
|
|
|
|
} |
10614
|
0
|
|
|
|
|
0
|
|
10615
|
|
|
|
|
|
|
# escape $ @ / and \ |
10616
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10617
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10618
|
0
|
|
|
|
|
0
|
} |
10619
|
44
|
|
|
|
|
65
|
} |
10620
|
44
|
|
|
|
|
48
|
|
10621
|
44
|
|
|
|
|
52
|
$delimiter = '/'; |
10622
|
44
|
|
|
|
|
49
|
$end_delimiter = '/'; |
10623
|
|
|
|
|
|
|
my $prematch = ''; |
10624
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10625
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10626
|
|
|
|
|
|
|
} |
10627
|
|
|
|
|
|
|
|
10628
|
|
|
|
|
|
|
# |
10629
|
44
|
|
|
91
|
0
|
299
|
# escape regexp (s''here') |
10630
|
|
|
|
|
|
|
# |
10631
|
91
|
|
|
|
|
180
|
sub e_s2_q { |
10632
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10633
|
91
|
|
|
|
|
105
|
|
10634
|
91
|
|
|
|
|
334
|
$slash = 'div'; |
10635
|
91
|
50
|
66
|
|
|
220
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
10636
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>[^\x81-\x9F\xE0-\xFC\\]|\\\\|$q_char) /oxmsg; |
10637
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10638
|
|
|
|
|
|
|
if (0) { |
10639
|
9
|
|
|
|
|
187
|
} |
10640
|
0
|
|
|
|
|
0
|
|
10641
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
10642
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10643
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
10644
|
|
|
|
|
|
|
} |
10645
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10646
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10647
|
|
|
|
|
|
|
} |
10648
|
|
|
|
|
|
|
|
10649
|
|
|
|
|
|
|
# not escape \\ |
10650
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\\\ \z/oxms) { |
10651
|
|
|
|
|
|
|
} |
10652
|
0
|
|
|
|
|
0
|
|
10653
|
|
|
|
|
|
|
# escape $ @ / and \ |
10654
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10655
|
5
|
50
|
66
|
|
|
20
|
$char[$i] = '\\' . $char[$i]; |
10656
|
91
|
|
|
|
|
215
|
} |
10657
|
|
|
|
|
|
|
} |
10658
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10659
|
0
|
|
|
|
|
0
|
$char[-1] = $1 . '\\' . $2; |
10660
|
|
|
|
|
|
|
} |
10661
|
|
|
|
|
|
|
|
10662
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
10663
|
|
|
|
|
|
|
} |
10664
|
|
|
|
|
|
|
|
10665
|
|
|
|
|
|
|
# |
10666
|
91
|
|
|
291
|
0
|
303
|
# escape regexp (s/here/and here/modifier) |
10667
|
291
|
|
100
|
|
|
2456
|
# |
10668
|
|
|
|
|
|
|
sub e_sub { |
10669
|
291
|
|
|
|
|
1194
|
my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_; |
10670
|
291
|
50
|
|
|
|
561
|
$modifier ||= ''; |
10671
|
291
|
|
|
|
|
1046
|
|
10672
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10673
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10674
|
0
|
|
|
|
|
0
|
my $line = 0; |
10675
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10676
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10677
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10678
|
0
|
|
|
|
|
0
|
last; |
10679
|
|
|
|
|
|
|
} |
10680
|
|
|
|
|
|
|
} |
10681
|
0
|
100
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10682
|
291
|
|
|
|
|
665
|
} |
10683
|
37
|
|
|
|
|
119
|
|
10684
|
|
|
|
|
|
|
if ($variable eq '') { |
10685
|
|
|
|
|
|
|
$variable = '$_'; |
10686
|
37
|
|
|
|
|
55
|
$bind_operator = ' =~ '; |
10687
|
|
|
|
|
|
|
} |
10688
|
|
|
|
|
|
|
|
10689
|
|
|
|
|
|
|
$slash = 'div'; |
10690
|
|
|
|
|
|
|
|
10691
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
10692
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
10693
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
10694
|
|
|
|
|
|
|
# P.312 Iterative Matching: Scalar Context, with /g |
10695
|
|
|
|
|
|
|
# in Chapter 7: Perl |
10696
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
10697
|
|
|
|
|
|
|
|
10698
|
|
|
|
|
|
|
# P.181 Where You Left Off: The \G Assertion |
10699
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10700
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10701
|
|
|
|
|
|
|
|
10702
|
|
|
|
|
|
|
# P.220 Where You Left Off: The \G Assertion |
10703
|
291
|
|
|
|
|
417
|
# in Chapter 5: Pattern Matching |
10704
|
291
|
|
|
|
|
431
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10705
|
|
|
|
|
|
|
|
10706
|
291
|
|
|
|
|
457
|
my $e_modifier = $modifier =~ tr/e//d; |
10707
|
291
|
50
|
|
|
|
411
|
my $r_modifier = $modifier =~ tr/r//d; |
10708
|
291
|
|
|
|
|
783
|
|
10709
|
0
|
|
|
|
|
0
|
my $my = ''; |
10710
|
0
|
|
|
|
|
0
|
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) { |
10711
|
|
|
|
|
|
|
$my = $variable; |
10712
|
|
|
|
|
|
|
$variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms; |
10713
|
0
|
|
|
|
|
0
|
$variable =~ s/ = .+ \z//oxms; |
10714
|
291
|
|
|
|
|
709
|
} |
10715
|
|
|
|
|
|
|
|
10716
|
|
|
|
|
|
|
(my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms; |
10717
|
291
|
|
|
|
|
504
|
$variable_basename =~ s/ \s+ \z//oxms; |
10718
|
291
|
100
|
|
|
|
391
|
|
10719
|
291
|
|
|
|
|
670
|
# quote replacement string |
10720
|
17
|
|
|
|
|
39
|
my $e_replacement = ''; |
10721
|
|
|
|
|
|
|
if ($e_modifier >= 1) { |
10722
|
|
|
|
|
|
|
$e_replacement = e_qq('', '', '', $replacement); |
10723
|
17
|
100
|
|
|
|
23
|
$e_modifier--; |
10724
|
274
|
|
|
|
|
538
|
} |
10725
|
|
|
|
|
|
|
else { |
10726
|
|
|
|
|
|
|
if ($delimiter2 eq "'") { |
10727
|
91
|
|
|
|
|
172
|
$e_replacement = e_s2_q('qq', '/', '/', $replacement); |
10728
|
|
|
|
|
|
|
} |
10729
|
|
|
|
|
|
|
else { |
10730
|
|
|
|
|
|
|
$e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement); |
10731
|
183
|
|
|
|
|
415
|
} |
10732
|
|
|
|
|
|
|
} |
10733
|
|
|
|
|
|
|
|
10734
|
291
|
100
|
|
|
|
474
|
my $sub = ''; |
10735
|
291
|
100
|
|
|
|
583
|
|
|
|
50
|
|
|
|
|
|
10736
|
|
|
|
|
|
|
# with /r |
10737
|
|
|
|
|
|
|
if ($r_modifier) { |
10738
|
|
|
|
|
|
|
if (0) { |
10739
|
8
|
|
|
|
|
108
|
} |
10740
|
0
|
50
|
|
|
|
0
|
|
10741
|
|
|
|
|
|
|
# s///gr with multibyte anchoring |
10742
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10743
|
|
|
|
|
|
|
$sub = sprintf( |
10744
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10745
|
|
|
|
|
|
|
q, |
10746
|
|
|
|
|
|
|
|
10747
|
|
|
|
|
|
|
$variable, # 1 |
10748
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10749
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10750
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10751
|
|
|
|
|
|
|
$s_matched, # 3 |
10752
|
|
|
|
|
|
|
$e_replacement, # 4 |
10753
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10754
|
|
|
|
|
|
|
); |
10755
|
|
|
|
|
|
|
} |
10756
|
4
|
0
|
|
|
|
26
|
|
10757
|
|
|
|
|
|
|
# s///gr without multibyte anchoring |
10758
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10759
|
|
|
|
|
|
|
$sub = sprintf( |
10760
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10761
|
|
|
|
|
|
|
q, |
10762
|
|
|
|
|
|
|
|
10763
|
|
|
|
|
|
|
$variable, # 1 |
10764
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10765
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10766
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10767
|
|
|
|
|
|
|
$s_matched, # 3 |
10768
|
|
|
|
|
|
|
$e_replacement, # 4 |
10769
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10770
|
|
|
|
|
|
|
); |
10771
|
|
|
|
|
|
|
} |
10772
|
|
|
|
|
|
|
|
10773
|
0
|
|
|
|
|
0
|
# s///r |
10774
|
4
|
|
|
|
|
8
|
else { |
10775
|
|
|
|
|
|
|
|
10776
|
4
|
50
|
|
|
|
6
|
my $prematch = q{$`}; |
10777
|
|
|
|
|
|
|
$prematch = q{${1}}; |
10778
|
|
|
|
|
|
|
|
10779
|
|
|
|
|
|
|
$sub = sprintf( |
10780
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 |
10781
|
|
|
|
|
|
|
q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s"%s$Esjis::re_r$'" } : %s>, |
10782
|
|
|
|
|
|
|
|
10783
|
|
|
|
|
|
|
$variable, # 1 |
10784
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10785
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10786
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10787
|
|
|
|
|
|
|
$s_matched, # 3 |
10788
|
|
|
|
|
|
|
$e_replacement, # 4 |
10789
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10790
|
|
|
|
|
|
|
$prematch, # 6 |
10791
|
|
|
|
|
|
|
$variable, # 7 |
10792
|
|
|
|
|
|
|
); |
10793
|
4
|
50
|
|
|
|
26
|
} |
10794
|
8
|
|
|
|
|
29
|
|
10795
|
|
|
|
|
|
|
# $var !~ s///r doesn't make sense |
10796
|
|
|
|
|
|
|
if ($bind_operator =~ / !~ /oxms) { |
10797
|
|
|
|
|
|
|
$sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub; |
10798
|
|
|
|
|
|
|
} |
10799
|
|
|
|
|
|
|
} |
10800
|
0
|
100
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
10801
|
|
|
|
|
|
|
# without /r |
10802
|
|
|
|
|
|
|
else { |
10803
|
|
|
|
|
|
|
if (0) { |
10804
|
283
|
|
|
|
|
802
|
} |
10805
|
0
|
100
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
10806
|
|
|
|
|
|
|
# s///g with multibyte anchoring |
10807
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10808
|
|
|
|
|
|
|
$sub = sprintf( |
10809
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 |
10810
|
|
|
|
|
|
|
q, |
10811
|
|
|
|
|
|
|
|
10812
|
|
|
|
|
|
|
$variable, # 1 |
10813
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10814
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10815
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10816
|
|
|
|
|
|
|
$s_matched, # 3 |
10817
|
|
|
|
|
|
|
$e_replacement, # 4 |
10818
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10819
|
|
|
|
|
|
|
$variable, # 6 |
10820
|
|
|
|
|
|
|
$variable, # 7 |
10821
|
|
|
|
|
|
|
$variable, # 8 |
10822
|
|
|
|
|
|
|
$variable, # 9 |
10823
|
|
|
|
|
|
|
|
10824
|
|
|
|
|
|
|
# Binary "!~" is just like "=~" except the return value is negated in the logical sense. |
10825
|
|
|
|
|
|
|
# It returns false if the match succeeds, and true if it fails. |
10826
|
|
|
|
|
|
|
# (and so on) |
10827
|
|
|
|
|
|
|
|
10828
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 10 |
10829
|
|
|
|
|
|
|
); |
10830
|
|
|
|
|
|
|
} |
10831
|
36
|
0
|
|
|
|
160
|
|
|
|
0
|
|
|
|
|
|
10832
|
|
|
|
|
|
|
# s///g without multibyte anchoring |
10833
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10834
|
|
|
|
|
|
|
$sub = sprintf( |
10835
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10836
|
|
|
|
|
|
|
q, |
10837
|
|
|
|
|
|
|
|
10838
|
|
|
|
|
|
|
$variable, # 1 |
10839
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10840
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10841
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10842
|
|
|
|
|
|
|
$s_matched, # 3 |
10843
|
|
|
|
|
|
|
$e_replacement, # 4 |
10844
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 5 |
10845
|
|
|
|
|
|
|
$variable, # 6 |
10846
|
|
|
|
|
|
|
$variable, # 7 |
10847
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 8 |
10848
|
|
|
|
|
|
|
); |
10849
|
|
|
|
|
|
|
} |
10850
|
|
|
|
|
|
|
|
10851
|
0
|
|
|
|
|
0
|
# s/// |
10852
|
247
|
|
|
|
|
569
|
else { |
10853
|
|
|
|
|
|
|
|
10854
|
247
|
100
|
|
|
|
314
|
my $prematch = q{$`}; |
|
|
100
|
|
|
|
|
|
10855
|
|
|
|
|
|
|
$prematch = q{${1}}; |
10856
|
|
|
|
|
|
|
|
10857
|
|
|
|
|
|
|
$sub = sprintf( |
10858
|
|
|
|
|
|
|
|
10859
|
|
|
|
|
|
|
($bind_operator =~ / =~ /oxms) ? |
10860
|
|
|
|
|
|
|
|
10861
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10862
|
|
|
|
|
|
|
q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s%s="%s$Esjis::re_r$'"; 1 } : undef> : |
10863
|
|
|
|
|
|
|
|
10864
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10865
|
|
|
|
|
|
|
q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Esjis::re_r=%s; %s%s="%s$Esjis::re_r$'"; undef }>, |
10866
|
|
|
|
|
|
|
|
10867
|
|
|
|
|
|
|
$variable, # 1 |
10868
|
|
|
|
|
|
|
$bind_operator, # 2 |
10869
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 3 |
10870
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10871
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10872
|
|
|
|
|
|
|
$s_matched, # 4 |
10873
|
|
|
|
|
|
|
$e_replacement, # 5 |
10874
|
|
|
|
|
|
|
'$Esjis::re_r=CORE::eval $Esjis::re_r; ' x $e_modifier, # 6 |
10875
|
|
|
|
|
|
|
$variable, # 7 |
10876
|
|
|
|
|
|
|
$prematch, # 8 |
10877
|
|
|
|
|
|
|
); |
10878
|
|
|
|
|
|
|
} |
10879
|
247
|
50
|
|
|
|
1378
|
} |
10880
|
291
|
|
|
|
|
733
|
|
10881
|
|
|
|
|
|
|
# (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1] |
10882
|
|
|
|
|
|
|
if ($my ne '') { |
10883
|
|
|
|
|
|
|
$sub = "($my, $sub)[1]"; |
10884
|
0
|
|
|
|
|
0
|
} |
10885
|
291
|
|
|
|
|
414
|
|
10886
|
|
|
|
|
|
|
# clear s/// variable |
10887
|
291
|
|
|
|
|
379
|
$sub_variable = ''; |
10888
|
|
|
|
|
|
|
$bind_operator = ''; |
10889
|
|
|
|
|
|
|
|
10890
|
|
|
|
|
|
|
return $sub; |
10891
|
|
|
|
|
|
|
} |
10892
|
|
|
|
|
|
|
|
10893
|
|
|
|
|
|
|
# |
10894
|
291
|
|
|
0
|
0
|
2051
|
# escape chdir (qq//, "") |
10895
|
|
|
|
|
|
|
# |
10896
|
0
|
0
|
|
|
|
0
|
sub e_chdir { |
10897
|
0
|
0
|
|
|
|
0
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10898
|
0
|
0
|
|
|
|
0
|
|
10899
|
0
|
|
|
|
|
0
|
if ($^W) { |
10900
|
0
|
|
|
|
|
0
|
if (Esjis::_MSWin32_5Cended_path($string)) { |
10901
|
|
|
|
|
|
|
if ($] !~ /^5\.005/oxms) { |
10902
|
|
|
|
|
|
|
warn <
|
10903
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10904
|
|
|
|
|
|
|
|
10905
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10906
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10907
|
|
|
|
|
|
|
END |
10908
|
|
|
|
|
|
|
} |
10909
|
0
|
|
|
|
|
0
|
} |
10910
|
|
|
|
|
|
|
} |
10911
|
|
|
|
|
|
|
|
10912
|
|
|
|
|
|
|
return e_qq($ope,$delimiter,$end_delimiter,$string); |
10913
|
|
|
|
|
|
|
} |
10914
|
|
|
|
|
|
|
|
10915
|
|
|
|
|
|
|
# |
10916
|
0
|
|
|
2
|
0
|
0
|
# escape chdir (q//, '') |
10917
|
|
|
|
|
|
|
# |
10918
|
2
|
50
|
|
|
|
8
|
sub e_chdir_q { |
10919
|
2
|
0
|
|
|
|
8
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10920
|
0
|
0
|
|
|
|
0
|
|
10921
|
0
|
|
|
|
|
0
|
if ($^W) { |
10922
|
0
|
|
|
|
|
0
|
if (Esjis::_MSWin32_5Cended_path($string)) { |
10923
|
|
|
|
|
|
|
if ($] !~ /^5\.005/oxms) { |
10924
|
|
|
|
|
|
|
warn <
|
10925
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10926
|
|
|
|
|
|
|
|
10927
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10928
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10929
|
|
|
|
|
|
|
END |
10930
|
|
|
|
|
|
|
} |
10931
|
0
|
|
|
|
|
0
|
} |
10932
|
|
|
|
|
|
|
} |
10933
|
|
|
|
|
|
|
|
10934
|
|
|
|
|
|
|
return e_q($ope,$delimiter,$end_delimiter,$string); |
10935
|
|
|
|
|
|
|
} |
10936
|
|
|
|
|
|
|
|
10937
|
|
|
|
|
|
|
# |
10938
|
2
|
|
|
273
|
0
|
16
|
# escape regexp of split qr// |
10939
|
273
|
|
100
|
|
|
1193
|
# |
10940
|
|
|
|
|
|
|
sub e_split { |
10941
|
273
|
|
|
|
|
1142
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10942
|
273
|
50
|
|
|
|
480
|
$modifier ||= ''; |
10943
|
273
|
|
|
|
|
711
|
|
10944
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
10945
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10946
|
0
|
|
|
|
|
0
|
my $line = 0; |
10947
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10948
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
10949
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10950
|
0
|
|
|
|
|
0
|
last; |
10951
|
|
|
|
|
|
|
} |
10952
|
|
|
|
|
|
|
} |
10953
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10954
|
|
|
|
|
|
|
} |
10955
|
|
|
|
|
|
|
|
10956
|
273
|
100
|
|
|
|
418
|
$slash = 'div'; |
10957
|
273
|
|
|
|
|
646
|
|
10958
|
|
|
|
|
|
|
# /b /B modifier |
10959
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
10960
|
84
|
100
|
|
|
|
388
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
10961
|
189
|
|
|
|
|
630
|
} |
10962
|
|
|
|
|
|
|
|
10963
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10964
|
189
|
|
|
|
|
641
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10965
|
|
|
|
|
|
|
|
10966
|
|
|
|
|
|
|
# split regexp |
10967
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10968
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\$\@\[\(]|[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
10969
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10970
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10971
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10972
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10973
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10974
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} | |
10975
|
|
|
|
|
|
|
\\ $q_char | |
10976
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10977
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10978
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10979
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10980
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10981
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10982
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10983
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10984
|
|
|
|
|
|
|
\[\^ | |
10985
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10986
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10987
|
|
|
|
|
|
|
\(\? | |
10988
|
189
|
|
|
|
|
17126
|
$q_char |
10989
|
189
|
|
|
|
|
572
|
))/oxmsg; |
10990
|
189
|
|
|
|
|
277
|
|
10991
|
|
|
|
|
|
|
my $left_e = 0; |
10992
|
|
|
|
|
|
|
my $right_e = 0; |
10993
|
189
|
50
|
33
|
|
|
510
|
for (my $i=0; $i <= $#char; $i++) { |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10994
|
372
|
|
|
|
|
2164
|
|
10995
|
|
|
|
|
|
|
# "\L\u" --> "\u\L" |
10996
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10997
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10998
|
|
|
|
|
|
|
} |
10999
|
0
|
|
|
|
|
0
|
|
11000
|
|
|
|
|
|
|
# "\U\l" --> "\l\U" |
11001
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
11002
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
11003
|
|
|
|
|
|
|
} |
11004
|
0
|
|
|
|
|
0
|
|
11005
|
|
|
|
|
|
|
# octal escape sequence |
11006
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
11007
|
|
|
|
|
|
|
$char[$i] = Esjis::octchr($1); |
11008
|
|
|
|
|
|
|
} |
11009
|
1
|
|
|
|
|
6
|
|
11010
|
|
|
|
|
|
|
# hexadecimal escape sequence |
11011
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
11012
|
|
|
|
|
|
|
$char[$i] = Esjis::hexchr($1); |
11013
|
|
|
|
|
|
|
} |
11014
|
|
|
|
|
|
|
|
11015
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
11016
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
11017
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
11018
|
1
|
|
|
|
|
5
|
# \p{PROPERTY} --> p\{PROPERTY} |
11019
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
11020
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x81-\x9F\xE0-\xFC0-9\}][^\x81-\x9F\xE0-\xFC\}]*) \} ) \z/oxms) { |
11021
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11022
|
|
|
|
|
|
|
} |
11023
|
0
|
|
|
|
|
0
|
|
11024
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
11025
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
11026
|
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
|
|
|
|
|
|
11027
|
|
|
|
|
|
|
} |
11028
|
|
|
|
|
|
|
|
11029
|
|
|
|
|
|
|
if (0) { |
11030
|
372
|
|
|
|
|
3349
|
} |
11031
|
0
|
|
|
|
|
0
|
|
11032
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
11033
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11034
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11035
|
|
|
|
|
|
|
} |
11036
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
11037
|
0
|
|
|
|
|
0
|
# join separated multiple-octet |
11038
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
11039
|
|
|
|
|
|
|
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)) { |
11040
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 3; |
11041
|
|
|
|
|
|
|
} |
11042
|
|
|
|
|
|
|
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)) { |
11043
|
0
|
|
|
|
|
0
|
$char[$i] .= join '', splice @char, $i+1, 2; |
11044
|
|
|
|
|
|
|
} |
11045
|
|
|
|
|
|
|
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)) { |
11046
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
11047
|
|
|
|
|
|
|
} |
11048
|
|
|
|
|
|
|
} |
11049
|
0
|
|
|
|
|
0
|
|
11050
|
3
|
50
|
|
|
|
7
|
# open character class [...] |
11051
|
3
|
|
|
|
|
10
|
elsif ($char[$i] eq '[') { |
11052
|
|
|
|
|
|
|
my $left = $i; |
11053
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11054
|
3
|
50
|
|
|
|
4
|
$i++; |
11055
|
7
|
|
|
|
|
13
|
} |
11056
|
|
|
|
|
|
|
while (1) { |
11057
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
11058
|
7
|
|
|
|
|
12
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11059
|
|
|
|
|
|
|
} |
11060
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11061
|
3
|
50
|
|
|
|
4
|
my $right = $i; |
11062
|
3
|
|
|
|
|
18
|
|
|
0
|
|
|
|
|
0
|
|
11063
|
|
|
|
|
|
|
# [...] |
11064
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
11065
|
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); |
11066
|
|
|
|
|
|
|
} |
11067
|
|
|
|
|
|
|
else { |
11068
|
3
|
|
|
|
|
13
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
11069
|
3
|
|
|
|
|
5
|
} |
11070
|
|
|
|
|
|
|
|
11071
|
|
|
|
|
|
|
$i = $left; |
11072
|
|
|
|
|
|
|
last; |
11073
|
|
|
|
|
|
|
} |
11074
|
|
|
|
|
|
|
} |
11075
|
|
|
|
|
|
|
} |
11076
|
3
|
|
|
|
|
8
|
|
11077
|
1
|
50
|
|
|
|
2
|
# open character class [^...] |
11078
|
1
|
|
|
|
|
5
|
elsif ($char[$i] eq '[^') { |
11079
|
|
|
|
|
|
|
my $left = $i; |
11080
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11081
|
1
|
50
|
|
|
|
2
|
$i++; |
11082
|
2
|
|
|
|
|
5
|
} |
11083
|
|
|
|
|
|
|
while (1) { |
11084
|
0
|
100
|
|
|
|
0
|
if (++$i > $#char) { |
11085
|
2
|
|
|
|
|
4
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11086
|
|
|
|
|
|
|
} |
11087
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11088
|
1
|
50
|
|
|
|
2
|
my $right = $i; |
11089
|
1
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
11090
|
|
|
|
|
|
|
# [^...] |
11091
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
11092
|
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); |
11093
|
|
|
|
|
|
|
} |
11094
|
|
|
|
|
|
|
else { |
11095
|
1
|
|
|
|
|
26
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11096
|
1
|
|
|
|
|
2
|
} |
11097
|
|
|
|
|
|
|
|
11098
|
|
|
|
|
|
|
$i = $left; |
11099
|
|
|
|
|
|
|
last; |
11100
|
|
|
|
|
|
|
} |
11101
|
|
|
|
|
|
|
} |
11102
|
|
|
|
|
|
|
} |
11103
|
1
|
|
|
|
|
3
|
|
11104
|
|
|
|
|
|
|
# rewrite character class or escape character |
11105
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11106
|
|
|
|
|
|
|
$char[$i] = $char; |
11107
|
|
|
|
|
|
|
} |
11108
|
|
|
|
|
|
|
|
11109
|
|
|
|
|
|
|
# P.794 29.2.161. split |
11110
|
|
|
|
|
|
|
# in Chapter 29: Functions |
11111
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11112
|
|
|
|
|
|
|
|
11113
|
|
|
|
|
|
|
# P.951 split |
11114
|
|
|
|
|
|
|
# in Chapter 27: Functions |
11115
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11116
|
|
|
|
|
|
|
|
11117
|
|
|
|
|
|
|
# said "The //m modifier is assumed when you split on the pattern /^/", |
11118
|
|
|
|
|
|
|
# but perl5.008 is not so. Therefore, this software adds //m. |
11119
|
|
|
|
|
|
|
# (and so on) |
11120
|
5
|
|
|
|
|
20
|
|
11121
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
11122
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11123
|
|
|
|
|
|
|
$modifier .= 'm'; |
11124
|
|
|
|
|
|
|
} |
11125
|
11
|
50
|
|
|
|
42
|
|
11126
|
18
|
|
|
|
|
38
|
# /i modifier |
11127
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
11128
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
11129
|
18
|
|
|
|
|
43
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
11130
|
|
|
|
|
|
|
} |
11131
|
|
|
|
|
|
|
else { |
11132
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
11133
|
|
|
|
|
|
|
} |
11134
|
|
|
|
|
|
|
} |
11135
|
0
|
50
|
|
|
|
0
|
|
11136
|
2
|
|
|
|
|
9
|
# \u \l \U \L \F \Q \E |
11137
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
11138
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
11139
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
11140
|
0
|
|
|
|
|
0
|
} |
11141
|
0
|
|
|
|
|
0
|
} |
11142
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
11143
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ucfirst qq<'; |
11144
|
0
|
|
|
|
|
0
|
$left_e++; |
11145
|
0
|
|
|
|
|
0
|
} |
11146
|
|
|
|
|
|
|
elsif ($char[$i] eq '\l') { |
11147
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lcfirst qq<'; |
11148
|
0
|
|
|
|
|
0
|
$left_e++; |
11149
|
0
|
|
|
|
|
0
|
} |
11150
|
|
|
|
|
|
|
elsif ($char[$i] eq '\U') { |
11151
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::uc qq<'; |
11152
|
0
|
|
|
|
|
0
|
$left_e++; |
11153
|
0
|
|
|
|
|
0
|
} |
11154
|
|
|
|
|
|
|
elsif ($char[$i] eq '\L') { |
11155
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::lc qq<'; |
11156
|
0
|
|
|
|
|
0
|
$left_e++; |
11157
|
0
|
|
|
|
|
0
|
} |
11158
|
|
|
|
|
|
|
elsif ($char[$i] eq '\F') { |
11159
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::fc qq<'; |
11160
|
0
|
|
|
|
|
0
|
$left_e++; |
11161
|
0
|
|
|
|
|
0
|
} |
11162
|
|
|
|
|
|
|
elsif ($char[$i] eq '\Q') { |
11163
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
11164
|
0
|
0
|
|
|
|
0
|
$left_e++; |
11165
|
0
|
|
|
|
|
0
|
} |
11166
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\E') { |
11167
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
11168
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
11169
|
0
|
|
|
|
|
0
|
$right_e++; |
11170
|
|
|
|
|
|
|
} |
11171
|
|
|
|
|
|
|
else { |
11172
|
|
|
|
|
|
|
$char[$i] = ''; |
11173
|
0
|
|
|
|
|
0
|
} |
11174
|
0
|
0
|
|
|
|
0
|
} |
11175
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
11176
|
|
|
|
|
|
|
while (1) { |
11177
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11178
|
0
|
|
|
|
|
0
|
last; |
11179
|
|
|
|
|
|
|
} |
11180
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
11181
|
|
|
|
|
|
|
last; |
11182
|
|
|
|
|
|
|
} |
11183
|
|
|
|
|
|
|
} |
11184
|
|
|
|
|
|
|
} |
11185
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
11186
|
|
|
|
|
|
|
} |
11187
|
0
|
0
|
|
|
|
0
|
|
11188
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
11189
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
11190
|
|
|
|
|
|
|
if ($ignorecase) { |
11191
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11192
|
0
|
0
|
|
|
|
0
|
} |
11193
|
0
|
|
|
|
|
0
|
} |
11194
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
11195
|
|
|
|
|
|
|
if ($ignorecase) { |
11196
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11197
|
|
|
|
|
|
|
} |
11198
|
|
|
|
|
|
|
} |
11199
|
|
|
|
|
|
|
|
11200
|
|
|
|
|
|
|
# $$ --> $$ |
11201
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
11202
|
|
|
|
|
|
|
} |
11203
|
|
|
|
|
|
|
|
11204
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
11205
|
0
|
0
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
11206
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
11207
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11208
|
|
|
|
|
|
|
if ($ignorecase) { |
11209
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11210
|
0
|
|
|
|
|
0
|
} |
11211
|
0
|
0
|
|
|
|
0
|
} |
11212
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
11213
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11214
|
|
|
|
|
|
|
if ($ignorecase) { |
11215
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11216
|
|
|
|
|
|
|
} |
11217
|
|
|
|
|
|
|
} |
11218
|
0
|
|
|
|
|
0
|
|
11219
|
0
|
0
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
11220
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
11221
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
11222
|
|
|
|
|
|
|
if ($ignorecase) { |
11223
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11224
|
|
|
|
|
|
|
} |
11225
|
|
|
|
|
|
|
} |
11226
|
0
|
|
|
|
|
0
|
|
11227
|
0
|
0
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
11228
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
11229
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
11230
|
|
|
|
|
|
|
if ($ignorecase) { |
11231
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11232
|
|
|
|
|
|
|
} |
11233
|
|
|
|
|
|
|
} |
11234
|
0
|
|
|
|
|
0
|
|
11235
|
0
|
0
|
|
|
|
0
|
# $$foo |
11236
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
11237
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11238
|
|
|
|
|
|
|
if ($ignorecase) { |
11239
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11240
|
|
|
|
|
|
|
} |
11241
|
|
|
|
|
|
|
} |
11242
|
0
|
50
|
|
|
|
0
|
|
11243
|
12
|
|
|
|
|
34
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Esjis::PREMATCH() |
11244
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
11245
|
|
|
|
|
|
|
if ($ignorecase) { |
11246
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::PREMATCH())]}'; |
11247
|
|
|
|
|
|
|
} |
11248
|
|
|
|
|
|
|
else { |
11249
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::PREMATCH()]}'; |
11250
|
|
|
|
|
|
|
} |
11251
|
|
|
|
|
|
|
} |
11252
|
12
|
50
|
|
|
|
58
|
|
11253
|
12
|
|
|
|
|
51
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Esjis::MATCH() |
11254
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
11255
|
|
|
|
|
|
|
if ($ignorecase) { |
11256
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::MATCH())]}'; |
11257
|
|
|
|
|
|
|
} |
11258
|
|
|
|
|
|
|
else { |
11259
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::MATCH()]}'; |
11260
|
|
|
|
|
|
|
} |
11261
|
|
|
|
|
|
|
} |
11262
|
12
|
50
|
|
|
|
60
|
|
11263
|
9
|
|
|
|
|
21
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Esjis::POSTMATCH() |
11264
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
11265
|
|
|
|
|
|
|
if ($ignorecase) { |
11266
|
0
|
|
|
|
|
0
|
$char[$i] = '@{[Esjis::ignorecase(Esjis::POSTMATCH())]}'; |
11267
|
|
|
|
|
|
|
} |
11268
|
|
|
|
|
|
|
else { |
11269
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::POSTMATCH()]}'; |
11270
|
|
|
|
|
|
|
} |
11271
|
|
|
|
|
|
|
} |
11272
|
9
|
0
|
|
|
|
49
|
|
11273
|
0
|
|
|
|
|
0
|
# ${ foo } |
11274
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
11275
|
|
|
|
|
|
|
if ($ignorecase) { |
11276
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $1 . ')]}'; |
11277
|
|
|
|
|
|
|
} |
11278
|
|
|
|
|
|
|
} |
11279
|
0
|
|
|
|
|
0
|
|
11280
|
0
|
0
|
|
|
|
0
|
# ${ ... } |
11281
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
11282
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
11283
|
|
|
|
|
|
|
if ($ignorecase) { |
11284
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11285
|
|
|
|
|
|
|
} |
11286
|
|
|
|
|
|
|
} |
11287
|
0
|
|
|
|
|
0
|
|
11288
|
3
|
50
|
|
|
|
10
|
# $scalar or @array |
11289
|
3
|
|
|
|
|
16
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
11290
|
|
|
|
|
|
|
$char[$i] = e_string($char[$i]); |
11291
|
|
|
|
|
|
|
if ($ignorecase) { |
11292
|
|
|
|
|
|
|
$char[$i] = '@{[Esjis::ignorecase(' . $char[$i] . ')]}'; |
11293
|
|
|
|
|
|
|
} |
11294
|
|
|
|
|
|
|
} |
11295
|
0
|
100
|
|
|
|
0
|
|
11296
|
|
|
|
|
|
|
# quote character before ? + * { |
11297
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11298
|
7
|
|
|
|
|
39
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
11299
|
|
|
|
|
|
|
} |
11300
|
|
|
|
|
|
|
else { |
11301
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11302
|
|
|
|
|
|
|
} |
11303
|
|
|
|
|
|
|
} |
11304
|
4
|
|
|
|
|
22
|
} |
11305
|
189
|
50
|
|
|
|
403
|
|
11306
|
189
|
|
|
|
|
423
|
# make regexp string |
11307
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11308
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
11309
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier; |
11310
|
|
|
|
|
|
|
} |
11311
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11312
|
|
|
|
|
|
|
} |
11313
|
|
|
|
|
|
|
|
11314
|
|
|
|
|
|
|
# |
11315
|
189
|
|
|
112
|
0
|
1594
|
# escape regexp of split qr'' |
11316
|
112
|
|
100
|
|
|
527
|
# |
11317
|
|
|
|
|
|
|
sub e_split_q { |
11318
|
112
|
|
|
|
|
341
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
11319
|
112
|
50
|
|
|
|
202
|
$modifier ||= ''; |
11320
|
112
|
|
|
|
|
312
|
|
11321
|
0
|
|
|
|
|
0
|
$modifier =~ tr/p//d; |
11322
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
11323
|
0
|
|
|
|
|
0
|
my $line = 0; |
11324
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
11325
|
|
|
|
|
|
|
if ($filename ne __FILE__) { |
11326
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
11327
|
0
|
|
|
|
|
0
|
last; |
11328
|
|
|
|
|
|
|
} |
11329
|
|
|
|
|
|
|
} |
11330
|
0
|
|
|
|
|
0
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
11331
|
|
|
|
|
|
|
} |
11332
|
|
|
|
|
|
|
|
11333
|
112
|
100
|
|
|
|
172
|
$slash = 'div'; |
11334
|
112
|
|
|
|
|
243
|
|
11335
|
|
|
|
|
|
|
# /b /B modifier |
11336
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
11337
|
56
|
100
|
|
|
|
295
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
11338
|
|
|
|
|
|
|
} |
11339
|
|
|
|
|
|
|
|
11340
|
56
|
|
|
|
|
150
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
11341
|
|
|
|
|
|
|
|
11342
|
|
|
|
|
|
|
# split regexp |
11343
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
11344
|
|
|
|
|
|
|
[^\x81-\x9F\xE0-\xFC\\\[] | |
11345
|
|
|
|
|
|
|
[\x81-\x9F\xE0-\xFC][\x00-\xFF] | |
11346
|
|
|
|
|
|
|
\[\^ | |
11347
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
11348
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
11349
|
|
|
|
|
|
|
\\ (?:$q_char) | |
11350
|
|
|
|
|
|
|
(?:$q_char) |
11351
|
56
|
|
|
|
|
305
|
))/oxmsg; |
11352
|
56
|
50
|
33
|
|
|
173
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
11353
|
|
|
|
|
|
|
# unescape character |
11354
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
11355
|
|
|
|
|
|
|
if (0) { |
11356
|
56
|
|
|
|
|
514
|
} |
11357
|
0
|
|
|
|
|
0
|
|
11358
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
11359
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11360
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11361
|
|
|
|
|
|
|
} |
11362
|
0
|
|
|
|
|
0
|
|
11363
|
0
|
0
|
|
|
|
0
|
# open character class [...] |
11364
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
11365
|
|
|
|
|
|
|
my $left = $i; |
11366
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11367
|
0
|
0
|
|
|
|
0
|
$i++; |
11368
|
0
|
|
|
|
|
0
|
} |
11369
|
|
|
|
|
|
|
while (1) { |
11370
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11371
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11372
|
|
|
|
|
|
|
} |
11373
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11374
|
0
|
|
|
|
|
0
|
my $right = $i; |
11375
|
|
|
|
|
|
|
|
11376
|
0
|
|
|
|
|
0
|
# [...] |
11377
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_qr(@char[$left+1..$right-1], $modifier); |
11378
|
|
|
|
|
|
|
|
11379
|
|
|
|
|
|
|
$i = $left; |
11380
|
|
|
|
|
|
|
last; |
11381
|
|
|
|
|
|
|
} |
11382
|
|
|
|
|
|
|
} |
11383
|
|
|
|
|
|
|
} |
11384
|
0
|
|
|
|
|
0
|
|
11385
|
0
|
0
|
|
|
|
0
|
# open character class [^...] |
11386
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
11387
|
|
|
|
|
|
|
my $left = $i; |
11388
|
0
|
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
11389
|
0
|
0
|
|
|
|
0
|
$i++; |
11390
|
0
|
|
|
|
|
0
|
} |
11391
|
|
|
|
|
|
|
while (1) { |
11392
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
11393
|
0
|
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11394
|
|
|
|
|
|
|
} |
11395
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11396
|
0
|
|
|
|
|
0
|
my $right = $i; |
11397
|
|
|
|
|
|
|
|
11398
|
0
|
|
|
|
|
0
|
# [^...] |
11399
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Esjis::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11400
|
|
|
|
|
|
|
|
11401
|
|
|
|
|
|
|
$i = $left; |
11402
|
|
|
|
|
|
|
last; |
11403
|
|
|
|
|
|
|
} |
11404
|
|
|
|
|
|
|
} |
11405
|
|
|
|
|
|
|
} |
11406
|
0
|
|
|
|
|
0
|
|
11407
|
|
|
|
|
|
|
# rewrite character class or escape character |
11408
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11409
|
|
|
|
|
|
|
$char[$i] = $char; |
11410
|
|
|
|
|
|
|
} |
11411
|
0
|
|
|
|
|
0
|
|
11412
|
|
|
|
|
|
|
# split(m/^/) --> split(m/^/m) |
11413
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11414
|
|
|
|
|
|
|
$modifier .= 'm'; |
11415
|
|
|
|
|
|
|
} |
11416
|
0
|
50
|
|
|
|
0
|
|
11417
|
12
|
|
|
|
|
29
|
# /i modifier |
11418
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Esjis::uc($char[$i]) ne Esjis::fc($char[$i]))) { |
11419
|
|
|
|
|
|
|
if (CORE::length(Esjis::fc($char[$i])) == 1) { |
11420
|
12
|
|
|
|
|
30
|
$char[$i] = '[' . Esjis::uc($char[$i]) . Esjis::fc($char[$i]) . ']'; |
11421
|
|
|
|
|
|
|
} |
11422
|
|
|
|
|
|
|
else { |
11423
|
|
|
|
|
|
|
$char[$i] = '(?:' . Esjis::uc($char[$i]) . '|' . Esjis::fc($char[$i]) . ')'; |
11424
|
|
|
|
|
|
|
} |
11425
|
|
|
|
|
|
|
} |
11426
|
0
|
0
|
|
|
|
0
|
|
11427
|
|
|
|
|
|
|
# quote character before ? + * { |
11428
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11429
|
0
|
|
|
|
|
0
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
11430
|
|
|
|
|
|
|
} |
11431
|
|
|
|
|
|
|
else { |
11432
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11433
|
|
|
|
|
|
|
} |
11434
|
0
|
|
|
|
|
0
|
} |
11435
|
56
|
|
|
|
|
122
|
} |
11436
|
|
|
|
|
|
|
|
11437
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11438
|
|
|
|
|
|
|
return join '', 'Esjis::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11439
|
|
|
|
|
|
|
} |
11440
|
|
|
|
|
|
|
|
11441
|
|
|
|
|
|
|
# |
11442
|
56
|
|
|
0
|
0
|
319
|
# escape use without import |
11443
|
|
|
|
|
|
|
# |
11444
|
0
|
|
|
|
|
|
sub e_use_noimport { |
11445
|
|
|
|
|
|
|
my($module) = @_; |
11446
|
0
|
|
|
|
|
|
|
11447
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11448
|
|
|
|
|
|
|
|
11449
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11450
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11451
|
0
|
|
|
|
|
|
|
11452
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11453
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11454
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11455
|
0
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11456
|
|
|
|
|
|
|
|
11457
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11458
|
|
|
|
|
|
|
return qq; |
11459
|
|
|
|
|
|
|
} |
11460
|
|
|
|
|
|
|
last; |
11461
|
0
|
|
|
|
|
|
} |
11462
|
|
|
|
|
|
|
} |
11463
|
|
|
|
|
|
|
|
11464
|
|
|
|
|
|
|
return qq |
11465
|
|
|
|
|
|
|
} |
11466
|
|
|
|
|
|
|
|
11467
|
|
|
|
|
|
|
# |
11468
|
0
|
|
|
0
|
0
|
|
# escape no without unimport |
11469
|
|
|
|
|
|
|
# |
11470
|
0
|
|
|
|
|
|
sub e_no_nounimport { |
11471
|
|
|
|
|
|
|
my($module) = @_; |
11472
|
0
|
|
|
|
|
|
|
11473
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11474
|
|
|
|
|
|
|
|
11475
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11476
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11477
|
0
|
|
|
|
|
|
|
11478
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11479
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11480
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11481
|
0
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11482
|
|
|
|
|
|
|
|
11483
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11484
|
|
|
|
|
|
|
return qq; |
11485
|
|
|
|
|
|
|
} |
11486
|
|
|
|
|
|
|
last; |
11487
|
0
|
|
|
|
|
|
} |
11488
|
|
|
|
|
|
|
} |
11489
|
|
|
|
|
|
|
|
11490
|
|
|
|
|
|
|
return qq; |
11491
|
|
|
|
|
|
|
} |
11492
|
|
|
|
|
|
|
|
11493
|
|
|
|
|
|
|
# |
11494
|
0
|
|
|
0
|
0
|
|
# escape use with import no parameter |
11495
|
|
|
|
|
|
|
# |
11496
|
0
|
|
|
|
|
|
sub e_use_noparam { |
11497
|
|
|
|
|
|
|
my($module) = @_; |
11498
|
0
|
|
|
|
|
|
|
11499
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11500
|
|
|
|
|
|
|
|
11501
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11502
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11503
|
0
|
|
|
|
|
|
|
11504
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11505
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11506
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11507
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11508
|
|
|
|
|
|
|
|
11509
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11510
|
|
|
|
|
|
|
|
11511
|
|
|
|
|
|
|
# P.326 UNIVERSAL: The Ultimate Ancestor Class |
11512
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11513
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11514
|
|
|
|
|
|
|
|
11515
|
|
|
|
|
|
|
# P.435 UNIVERSAL: The Ultimate Ancestor Class |
11516
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11517
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11518
|
0
|
|
|
|
|
|
|
11519
|
|
|
|
|
|
|
# (and so on) |
11520
|
0
|
|
|
|
|
|
|
11521
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->import() if $module->can('import'); }]; |
11522
|
|
|
|
|
|
|
} |
11523
|
|
|
|
|
|
|
last; |
11524
|
0
|
|
|
|
|
|
} |
11525
|
|
|
|
|
|
|
} |
11526
|
|
|
|
|
|
|
|
11527
|
|
|
|
|
|
|
return qq |
11528
|
|
|
|
|
|
|
} |
11529
|
|
|
|
|
|
|
|
11530
|
|
|
|
|
|
|
# |
11531
|
0
|
|
|
0
|
0
|
|
# escape no with unimport no parameter |
11532
|
|
|
|
|
|
|
# |
11533
|
0
|
|
|
|
|
|
sub e_no_noparam { |
11534
|
|
|
|
|
|
|
my($module) = @_; |
11535
|
0
|
|
|
|
|
|
|
11536
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11537
|
|
|
|
|
|
|
|
11538
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11539
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11540
|
0
|
|
|
|
|
|
|
11541
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11542
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11543
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11544
|
0
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11545
|
|
|
|
|
|
|
|
11546
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11547
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->unimport() if $module->can('unimport'); }]; |
11548
|
|
|
|
|
|
|
} |
11549
|
|
|
|
|
|
|
last; |
11550
|
0
|
|
|
|
|
|
} |
11551
|
|
|
|
|
|
|
} |
11552
|
|
|
|
|
|
|
|
11553
|
|
|
|
|
|
|
return qq; |
11554
|
|
|
|
|
|
|
} |
11555
|
|
|
|
|
|
|
|
11556
|
|
|
|
|
|
|
# |
11557
|
0
|
|
|
0
|
0
|
|
# escape use with import parameters |
11558
|
|
|
|
|
|
|
# |
11559
|
0
|
|
|
|
|
|
sub e_use { |
11560
|
|
|
|
|
|
|
my($module,$list) = @_; |
11561
|
0
|
|
|
|
|
|
|
11562
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11563
|
|
|
|
|
|
|
|
11564
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11565
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11566
|
0
|
|
|
|
|
|
|
11567
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11568
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11569
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11570
|
0
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11571
|
|
|
|
|
|
|
|
11572
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11573
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->import($list) if $module->can('import'); }]; |
11574
|
|
|
|
|
|
|
} |
11575
|
|
|
|
|
|
|
last; |
11576
|
0
|
|
|
|
|
|
} |
11577
|
|
|
|
|
|
|
} |
11578
|
|
|
|
|
|
|
|
11579
|
|
|
|
|
|
|
return qq |
11580
|
|
|
|
|
|
|
} |
11581
|
|
|
|
|
|
|
|
11582
|
|
|
|
|
|
|
# |
11583
|
0
|
|
|
0
|
0
|
|
# escape no with unimport parameters |
11584
|
|
|
|
|
|
|
# |
11585
|
0
|
|
|
|
|
|
sub e_no { |
11586
|
|
|
|
|
|
|
my($module,$list) = @_; |
11587
|
0
|
|
|
|
|
|
|
11588
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11589
|
|
|
|
|
|
|
|
11590
|
0
|
0
|
|
|
|
|
my $fh = gensym(); |
11591
|
0
|
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11592
|
0
|
|
|
|
|
|
|
11593
|
0
|
0
|
|
|
|
|
if (Esjis::_open_r($fh, $realfilename)) { |
11594
|
|
|
|
|
|
|
local $/ = undef; # slurp mode |
11595
|
0
|
0
|
|
|
|
|
my $script = <$fh>; |
11596
|
0
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11597
|
|
|
|
|
|
|
|
11598
|
0
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) Sjis (?>\s*) ([^\x81-\x9F\xE0-\xFC;]*) ; (?>\s*) \n? $/oxms) { |
11599
|
|
|
|
|
|
|
return qq[BEGIN { Esjis::require '$expr'; $module->unimport($list) if $module->can('unimport'); }]; |
11600
|
|
|
|
|
|
|
} |
11601
|
|
|
|
|
|
|
last; |
11602
|
0
|
|
|
|
|
|
} |
11603
|
|
|
|
|
|
|
} |
11604
|
|
|
|
|
|
|
|
11605
|
|
|
|
|
|
|
return qq; |
11606
|
|
|
|
|
|
|
} |
11607
|
|
|
|
|
|
|
|
11608
|
|
|
|
|
|
|
# |
11609
|
0
|
|
|
0
|
|
|
# file path of module |
11610
|
|
|
|
|
|
|
# |
11611
|
0
|
0
|
|
|
|
|
sub _pathof { |
11612
|
0
|
|
|
|
|
|
my($expr) = @_; |
11613
|
|
|
|
|
|
|
|
11614
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11615
|
0
|
|
|
|
|
|
$expr =~ s#::#:#g; |
11616
|
|
|
|
|
|
|
} |
11617
|
0
|
0
|
|
|
|
|
else { |
11618
|
|
|
|
|
|
|
$expr =~ s#::#/#g; |
11619
|
0
|
|
|
|
|
|
} |
11620
|
|
|
|
|
|
|
$expr .= '.pm' if $expr !~ / \.pm \z/oxmsi; |
11621
|
|
|
|
|
|
|
|
11622
|
|
|
|
|
|
|
return $expr; |
11623
|
|
|
|
|
|
|
} |
11624
|
|
|
|
|
|
|
|
11625
|
|
|
|
|
|
|
# |
11626
|
0
|
|
|
0
|
|
|
# real file name of module |
11627
|
|
|
|
|
|
|
# |
11628
|
0
|
0
|
|
|
|
|
sub _realfilename { |
11629
|
0
|
|
|
|
|
|
my($expr) = @_; |
|
0
|
|
|
|
|
|
|
11630
|
|
|
|
|
|
|
|
11631
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11632
|
0
|
|
|
|
|
|
return map {"$_$expr"} @INC; |
|
0
|
|
|
|
|
|
|
11633
|
|
|
|
|
|
|
} |
11634
|
|
|
|
|
|
|
else { |
11635
|
|
|
|
|
|
|
return map {"$_/$expr"} @INC; |
11636
|
|
|
|
|
|
|
} |
11637
|
|
|
|
|
|
|
} |
11638
|
|
|
|
|
|
|
|
11639
|
|
|
|
|
|
|
# |
11640
|
0
|
|
|
0
|
0
|
|
# instead of Carp::carp |
11641
|
0
|
|
|
|
|
|
# |
11642
|
|
|
|
|
|
|
sub carp { |
11643
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11644
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11645
|
|
|
|
|
|
|
} |
11646
|
|
|
|
|
|
|
|
11647
|
|
|
|
|
|
|
# |
11648
|
0
|
|
|
0
|
0
|
|
# instead of Carp::croak |
11649
|
0
|
|
|
|
|
|
# |
11650
|
0
|
|
|
|
|
|
sub croak { |
11651
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11652
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11653
|
|
|
|
|
|
|
die "\n"; |
11654
|
|
|
|
|
|
|
} |
11655
|
|
|
|
|
|
|
|
11656
|
|
|
|
|
|
|
# |
11657
|
0
|
|
|
0
|
0
|
|
# instead of Carp::cluck |
11658
|
0
|
|
|
|
|
|
# |
11659
|
0
|
|
|
|
|
|
sub cluck { |
11660
|
0
|
|
|
|
|
|
my $i = 0; |
11661
|
0
|
|
|
|
|
|
my @cluck = (); |
11662
|
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11663
|
0
|
|
|
|
|
|
push @cluck, "[$i] $filename($line) $package::$subroutine\n"; |
11664
|
0
|
|
|
|
|
|
$i++; |
11665
|
0
|
|
|
|
|
|
} |
11666
|
|
|
|
|
|
|
print STDERR CORE::reverse @cluck; |
11667
|
|
|
|
|
|
|
print STDERR "\n"; |
11668
|
|
|
|
|
|
|
print STDERR @_; |
11669
|
|
|
|
|
|
|
} |
11670
|
|
|
|
|
|
|
|
11671
|
|
|
|
|
|
|
# |
11672
|
0
|
|
|
0
|
0
|
|
# instead of Carp::confess |
11673
|
0
|
|
|
|
|
|
# |
11674
|
0
|
|
|
|
|
|
sub confess { |
11675
|
0
|
|
|
|
|
|
my $i = 0; |
11676
|
0
|
|
|
|
|
|
my @confess = (); |
11677
|
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11678
|
0
|
|
|
|
|
|
push @confess, "[$i] $filename($line) $package::$subroutine\n"; |
11679
|
0
|
|
|
|
|
|
$i++; |
11680
|
0
|
|
|
|
|
|
} |
11681
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @confess; |
11682
|
|
|
|
|
|
|
print STDERR "\n"; |
11683
|
|
|
|
|
|
|
print STDERR @_; |
11684
|
|
|
|
|
|
|
die "\n"; |
11685
|
|
|
|
|
|
|
} |
11686
|
|
|
|
|
|
|
|
11687
|
|
|
|
|
|
|
1; |
11688
|
|
|
|
|
|
|
|
11689
|
|
|
|
|
|
|
__END__ |