use
5.00503;
BEGIN {
if
($^X =~ / jperl /oxmsi) {
die
__FILE__,
": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)"
;
}
if
(CORE::
ord
(
'A'
) == 193) {
die
__FILE__,
": is not US-ASCII script (may be EBCDIC or EBCDIK script)."
;
}
if
(CORE::
ord
(
'A'
) != 0x41) {
die
__FILE__,
": is not US-ASCII script (must be US-ASCII script)."
;
}
}
BEGIN {
eval
q{ use vars qw($VERSION) }
}
$VERSION
=
sprintf
'%d.%02d'
,
q$Revision: 0.84 $
=~ /(\d+)/oxmsg;
BEGIN {
my
$genpkg
=
"Symbol::"
;
my
$genseq
= 0;
sub
gensym () {
my
$name
=
"GEN"
.
$genseq
++;
my
$ref
= \*{
$genpkg
.
$name
};
delete
$$genpkg
{
$name
};
$ref
;
}
}
BEGIN {
if
(
eval
{CORE::
require
strict}) {
strict::->
import
;
}
}
sub
LOCK_SH() {1}
sub
LOCK_EX() {2}
sub
LOCK_UN() {8}
sub
LOCK_NB() {4}
sub
import
() {}
sub
unimport() {}
sub
EUCJP::escape_script;
my
$your_char
=
q{\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF]|[\x00-\xFF]}
;
my
$qq_char
=
qr/\\c[\x40-\x5F]|\\?(?:$your_char)/
oxms;
my
$q_char
=
qr/$your_char/
oxms;
my
$anchor
=
''
;
$anchor
=
q{${Eeucjp::anchor}
};
BEGIN {
eval
q{ use vars qw($nest) }
}
my
$qq_paren
=
qr{(?{local $nest=0}
) (?>(?:
\\c[\x40-\x5F] |
\\? \x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
\\ [\x00-\xFF] |
[^()] |
\( (?{
$nest
++}) |
\) (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$qq_brace
=
qr{(?{local $nest=0}
) (?>(?:
\\c[\x40-\x5F] |
\\? \x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
\\ [\x00-\xFF] |
[^{}] |
\{ (?{
$nest
++}) |
\} (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$qq_bracket
=
qr{(?{local $nest=0}
) (?>(?:
\\c[\x40-\x5F] |
\\? \x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
\\ [\x00-\xFF] |
[^[\]] |
\[ (?{
$nest
++}) |
\] (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$qq_angle
=
qr{(?{local $nest=0}
) (?>(?:
\\c[\x40-\x5F] |
\\? \x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
\\ [\x00-\xFF] |
[^<>] |
\< (?{
$nest
++}) |
\> (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$qq_scalar
=
qr{(?: \{ (?:$qq_brace)*? \}
|
(?: ::)? (?:
[a-zA-Z_][a-zA-Z_0-9]*
(?: ::[a-zA-Z_][a-zA-Z_0-9]* )* (?: \[ (?: \$\[ | \$\] |
$qq_char
)*? \] | \{ (?:
$qq_brace
)*? \} )*
(?: (?: -> )? (?: \[ (?: \$\[ | \$\] |
$qq_char
)*? \] | \{ (?:
$qq_brace
)*? \} ) )*
))
}xms;
my
$qq_variable
=
qr{(?: \{ (?:$qq_brace)*? \}
|
(?: ::)? (?:
[0-9]+ |
[^\x8E\x8F\xA1-\xFEa-zA-Z_0-9\[\]] |
^[A-Z] |
[a-zA-Z_][a-zA-Z_0-9]*
(?: ::[a-zA-Z_][a-zA-Z_0-9]* )* (?: \[ (?: \$\[ | \$\] |
$qq_char
)*? \] | \{ (?:
$qq_brace
)*? \} )*
(?: (?: -> )? (?: \[ (?: \$\[ | \$\] |
$qq_char
)*? \] | \{ (?:
$qq_brace
)*? \} ) )*
))
}xms;
my
$q_paren
=
qr{(?{local $nest=0}
) (?>(?:
\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
[^()] |
\( (?{
$nest
++}) |
\) (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$q_brace
=
qr{(?{local $nest=0}
) (?>(?:
\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
[^{}] |
\{ (?{
$nest
++}) |
\} (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$q_bracket
=
qr{(?{local $nest=0}
) (?>(?:
\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
[^[\]] |
\[ (?{
$nest
++}) |
\] (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$q_angle
=
qr{(?{local $nest=0}
) (?>(?:
\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF] |
[^<>] |
\< (?{
$nest
++}) |
\> (?(?{
$nest
>0})(?{
$nest
--})|(?!)))*) (?(?{
$nest
!=0})(?!))
}xms;
my
$matched
=
''
;
my
$s_matched
=
''
;
$matched
=
q{$Eeucjp::matched}
;
$s_matched
=
q{ Eeucjp::s_matched();}
;
my
$tr_variable
=
''
;
my
$sub_variable
=
''
;
my
$bind_operator
=
''
;
BEGIN {
eval
q{ use vars qw($slash) }
}
my
@heredoc
= ();
my
@heredoc_delimiter
= ();
my
$here_script
=
''
;
my
$function_ord
;
my
$function_ord_
;
my
$function_reverse
;
my
$ignore_modules
=
join
(
'|'
,
qw(
utf8
bytes
charnames
I18N::Japanese
I18N::Collate
I18N::JExt
File::DosGlob
Wild
Wildcard
Japanese
)
);
if
($0 eq __FILE__) {
unless
(
@ARGV
) {
die
<<END;
$0: usage
perl $0 EUC-JP_script.pl > Escaped_script.pl.e
END
}
print
EUCJP::escape_script(
$ARGV
[0]);
exit
0;
}
my
(
$package
,
$filename
,
$line
,
$subroutine
,
$hasargs
,
$wantarray
,
$evaltext
,
$is_require
,
$hints
,
$bitmask
) =
caller
0;
if
(
$package
ne
'main'
) {
die
<<END;
@{[__FILE__]}: escape by manually command '$^X @{[__FILE__]} "$filename" > "@{[__PACKAGE__]}::$filename"'
and rewrite "use $package;" to "use @{[__PACKAGE__]}::$package;" of script "$0".
END
}
if
(-e(
"$filename.e"
)) {
if
(
exists
$ENV
{
'SJIS_DEBUG'
}) {
unlink
"$filename.e"
;
}
elsif
(-z(
"$filename.e"
)) {
unlink
"$filename.e"
;
}
else
{
my
$e_mtime
= (
stat
(
"$filename.e"
))[9];
my
$mtime
= (
stat
(
$filename
))[9];
my
$__mtime__
= (
stat
(__FILE__))[9];
if
((
$e_mtime
<
$mtime
) or (
$mtime
<
$__mtime__
)) {
unlink
"$filename.e"
;
}
}
}
if
(not -e(
"$filename.e"
)) {
my
$fh
= gensym();
if
(
eval
q{ use Fcntl qw(O_WRONLY O_APPEND O_CREAT); 1 }
and CORE::
sysopen
(
$fh
,
"$filename.e"
,
&O_WRONLY
|
&O_APPEND
|
&O_CREAT
)) {
}
else
{
Eeucjp::_open_a(
$fh
,
"$filename.e"
) or
die
__FILE__,
": Can't write open file: $filename.e"
;
}
if
(0) {
}
elsif
(
exists
$ENV
{
'SJIS_NONBLOCK'
}) {
eval
q{
unless (flock($fh, LOCK_EX | LOCK_NB)) {
warn __FILE__, ": Can't immediately write-lock the file: $filename.e";
exit;
}
};
}
else
{
eval
q{ flock($fh, LOCK_EX) }
;
}
truncate
(
$fh
, 0) or
die
__FILE__,
": Can't truncate file: $filename.e"
;
seek
(
$fh
, 0, 0) or
die
__FILE__,
": Can't seek file: $filename.e"
;
my
$e_script
= EUCJP::escape_script(
$filename
);
print
{
$fh
}
$e_script
;
my
$mode
= (
stat
(
$filename
))[2] & 0777;
chmod
$mode
,
"$filename.e"
;
close
(
$fh
) or
die
__FILE__,
": Can't close file: $filename.e"
;
}
my
$fh
= gensym();
Eeucjp::_open_r(
$fh
,
"$filename.e"
) or
die
__FILE__,
": Can't read open file: $filename.e"
;
if
(0) {
}
elsif
(
exists
$ENV
{
'SJIS_NONBLOCK'
}) {
eval
q{
unless (flock($fh, LOCK_SH | LOCK_NB)) {
warn __FILE__, ": Can't immediately read-lock the file: $filename.e";
exit;
}
};
}
else
{
eval
q{ flock($fh, LOCK_SH) }
;
}
my
@switch
= ();
if
($^W) {
push
@switch
,
'-w'
;
}
if
($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
exit
Eeucjp::_systemx
_escapeshellcmd_MSWin32($^X),
(
map
{
'-I'
.
$_
}
@INC
),
@switch
,
'--'
,
map
{ _escapeshellcmd_MSWin32(
$_
) }
"$filename.e"
,
@ARGV
;
}
else
{
exit
Eeucjp::_systemx
_escapeshellcmd($^X),
(
map
{
'-I'
. _escapeshellcmd(
$_
) }
@INC
),
@switch
,
'--'
,
map
{ _escapeshellcmd(
$_
) }
"$filename.e"
,
@ARGV
;
}
sub
_escapeshellcmd_MSWin32 {
my
(
$word
) =
@_
;
if
(
$word
=~ / [ ] /oxms) {
return
qq{"$word"}
;
}
else
{
return
$word
;
}
}
sub
_escapeshellcmd {
my
(
$word
) =
@_
;
return
$word
;
}
sub
EUCJP::escape_script {
my
(
$script
) =
@_
;
my
$e_script
=
''
;
my
$fh
= gensym();
Eeucjp::_open_r(
$fh
,
$script
) or
die
__FILE__,
": Can't open file: $script"
;
local
$/ =
undef
;
$_
= <
$fh
>;
close
(
$fh
) or
die
__FILE__,
": Can't close file: $script"
;
if
(/^
use
Eeucjp(?:\s+[0-9\.]*)?\s*; $/oxms) {
return
$_
;
}
else
{
if
(s/\A(
my
$head
= $1;
$head
=~ s/\bjperl\b/perl/gi;
$e_script
.=
$head
;
}
if
(s/\A(\
@rem
\s*=\s*
'.*?'
\s*;\s*\n)//oms) {
my
$head
= $1;
$head
=~ s/\bjperl\b/perl/gi;
$e_script
.=
$head
;
}
if
(s/(.*^
my
$head
= $1;
$head
=~ s/\bjperl\b/perl/gi;
$e_script
.=
$head
;
}
$e_script
.=
sprintf
(
"use Eeucjp %s;\n"
,
$EUCJP::VERSION
);
$function_ord
=
'ord'
;
$function_ord_
=
'ord'
;
$function_reverse
=
'reverse'
;
if
(s/^ \s*
use
\s+ EUCJP \s* ([^\x8E\x8F\xA1-\xFE;]*) ; \s* \n? $//oxms) {
my
$list
= $1;
if
(
$list
=~ s/\A ([0-9]+\.[0-9]+) \.0 \s* //oxms) {
my
$version
= $1;
if
(
$version
ne
$EUCJP::VERSION
) {
my
@file
=
grep
-e,
map
{
qq{$_/EUCJP.pm}
}
@INC
;
my
%file
=
map
{
$_
=> 1 }
@file
;
if
(
scalar
(
keys
%file
) >= 2) {
my
$file
=
join
"\n"
,
sort
keys
%file
;
warn
<<END;
****************************************************
C A U T I O N
CONFLICT EUCJP.pm FILE
$file
****************************************************
END
}
die
"Script $0 expects EUCJP.pm $version, but @{[__FILE__]} is version $EUCJP::VERSION\n"
;
}
$e_script
.=
qq{die "Script \$0 expects Eeucjp.pm $version, but \\\$Eeucjp::VERSION is \$Eeucjp::VERSION" if \$Eeucjp::VERSION ne '$version';\n}
;
}
elsif
(
$list
=~ s/\A ([0-9]+(?:\.[0-9]*)) \s* //oxms) {
my
$version
= $1;
if
(
$version
>
$EUCJP::VERSION
) {
die
"Script $0 required EUCJP.pm $version, but @{[__FILE__]} is only version $EUCJP::VERSION\n"
;
}
}
if
(
$list
!~ /\A \s* \z/oxms) {
local
$@;
my
@list
=
eval
$list
;
for
(
@list
) {
$function_ord
=
'EUCJP::ord'
if
/\A
ord
\z/oxms;
$function_ord_
=
'EUCJP::ord_'
if
/\A
ord
\z/oxms;
$function_reverse
=
'EUCJP::reverse'
if
/\A
reverse
\z/oxms;
}
}
}
}
$slash
=
'm//'
;
study
$_
;
while
(not /\G \z/oxgc) {
$e_script
.= escape();
}
return
$e_script
;
}
sub
escape {
if
(/\G ( \n ) /oxgc) {
my
$heredoc
=
''
;
if
(
scalar
(
@heredoc_delimiter
) >= 1) {
$slash
=
'm//'
;
$heredoc
=
join
''
,
@heredoc
;
@heredoc
= ();
for
my
$heredoc_delimiter
(
@heredoc_delimiter
) {
/\G .*? \n
$heredoc_delimiter
\n/xmsgc;
}
@heredoc_delimiter
= ();
$here_script
=
''
;
}
return
"\n"
.
$heredoc
;
}
elsif
(/\G (\s+|\
elsif
(/\G ( (?:
if
|
elsif
|
unless
|
while
|
until
|
given
|
when
) \s* \( ) /oxgc) {
$slash
=
'm//'
;
return
$1;
}
elsif
(/\G ( \( \s* (?:
local
\b |
my
\b |
our
\b | state \b )? \s* \$
$qq_scalar
) /oxgc) {
my
$e_string
= e_string($1);
if
(/\G ( \s* =
$qq_paren
\) ) ( \s* (?: =~ | !~ ) \s* ) (?= (?:
tr
|y) \b ) /oxgc) {
$tr_variable
=
$e_string
. e_string($1);
$bind_operator
= $2;
$slash
=
'm//'
;
return
''
;
}
elsif
(/\G ( \s* =
$qq_paren
\) ) ( \s* (?: =~ | !~ ) \s* ) (?= s \b ) /oxgc) {
$sub_variable
=
$e_string
. e_string($1);
$bind_operator
= $2;
$slash
=
'm//'
;
return
''
;
}
else
{
$slash
=
'div'
;
return
$e_string
;
}
}
elsif
(/\G ( \$` | \$\{`\} | \$ \s* PREMATCH \b | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) /oxmsgc) {
$slash
=
'div'
;
return
q{Eeucjp::PREMATCH()}
;
}
elsif
(/\G ( \$& | \$\{&\} | \$ \s* MATCH \b | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) /oxmsgc) {
$slash
=
'div'
;
return
q{Eeucjp::MATCH()}
;
}
elsif
(/\G ( \$ \s* POSTMATCH \b | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) /oxmsgc) {
$slash
=
'div'
;
return
q{Eeucjp::POSTMATCH()}
;
}
elsif
(/\G ( \$
$qq_scalar
) /oxgc) {
my
$scalar
= e_string($1);
if
(/\G ( \s* (?: =~ | !~ ) \s* ) (?= (?:
tr
|y) \b ) /oxgc) {
$tr_variable
=
$scalar
;
$bind_operator
= $1;
$slash
=
'm//'
;
return
''
;
}
elsif
(/\G ( \s* (?: =~ | !~ ) \s* ) (?= s \b ) /oxgc) {
$sub_variable
=
$scalar
;
$bind_operator
= $1;
$slash
=
'm//'
;
return
''
;
}
else
{
$slash
=
'div'
;
return
$scalar
;
}
}
elsif
(/\G ( [,;] ) /oxgc) {
$slash
=
'm//'
;
$tr_variable
=
''
;
$sub_variable
=
''
;
$bind_operator
=
''
;
return
$1;
}
elsif
(/\G ( \{ \s* (?:
tr
|
index
|
rindex
|
reverse
) \s* \} ) /oxmsgc) {
return
$1;
}
elsif
(/\G ( \$ 0 ) /oxmsgc) {
$slash
=
'div'
;
return
$1;
}
elsif
(/\G ( \$ \{ \s* 0 \s* \} ) /oxmsgc) {
$slash
=
'div'
;
return
$1;
}
elsif
(/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
$slash
=
'div'
;
return
$1;
}
elsif
(/\G \$ ([1-9][0-9]*) /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1);
}
elsif
(/\G \$ \{ \s* ([1-9][0-9]*) \s* \} /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1);
}
elsif
(/\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ .+? \] ) /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1.
'->'
.$2);
}
elsif
(/\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ .+? \} ) /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1.
'->'
.$2);
}
elsif
(/\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1);
}
elsif
(/\G \$ \s* \{ ( \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} /oxmsgc) {
$slash
=
'div'
;
return
'${'
. $1 .
'}'
;
}
elsif
(/\G \$ \s* \{ \s* (
$qq_brace
) \s* \} /oxmsgc) {
$slash
=
'div'
;
return
e_capture($1);
}
elsif
(/\G ( (?: [\$\@\%\&\*] | \$\
$slash
=
'div'
;
return
$1;
}
elsif
(/\G ( \$[\$\@\
$slash
=
'div'
;
return
$1;
}
elsif
(/\G \b (
while
\s* \( \s* <[\$]?[A-Za-z_][A-Za-z_0-9]*> \s* \)) \b /oxgc) {
return
$1;
}
elsif
(/\G \b
while
\s* \( \s* < ((?:\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF]|[^\x8E\x8F\xA1-\xFE>\0\a\e\f\n\r\t])+?) > \s* \) \b /oxgc) {
return
'while ($_ = Eeucjp::glob("'
. $1 .
'"))'
;
}
elsif
(/\G \b
while
\s* \( \s*
glob
\s* \) /oxgc) {
return
'while ($_ = Eeucjp::glob_)'
;
}
elsif
(/\G \b
while
\s* \( \s*
glob
\b /oxgc) {
return
'while ($_ = Eeucjp::glob'
;
}
elsif
(/\G \b (
if
|
unless
|
while
|
until
|
for
|
when
) \b /oxgc) {
$slash
=
'm//'
;
return
$1; }
elsif
(/\G \b (CORE:: | ->[ ]* (?:
atan2
| [a-z]{2,})) \b /oxgc) {
$slash
=
'm//'
;
return
$1; }
elsif
(/\G \b bytes::
substr
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'substr'
; }
elsif
(/\G \b
chop
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::chop'
; }
elsif
(/\G \b bytes::
index
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'index'
; }
elsif
(/\G \b EUCJP::
index
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'EUCJP::index'
; }
elsif
(/\G \b
index
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::index'
; }
elsif
(/\G \b bytes::
rindex
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'rindex'
; }
elsif
(/\G \b EUCJP::
rindex
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'EUCJP::rindex'
; }
elsif
(/\G \b
rindex
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::rindex'
; }
elsif
(/\G \b
lc
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
lc
'; }
elsif
(/\G \b
lcfirst
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
lcfirst
'; }
elsif
(/\G \b
uc
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
uc
'; }
elsif
(/\G \b
ucfirst
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
ucfirst
'; }
elsif
(/\G \b fc (?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::fc'; }
elsif
(/\G -s \s+ \s* (\") ((?:
$qq_char
)+?) (\") /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
''
, $1,$3,$2); }
elsif
(/\G -s \s+
qq \s*
(\
elsif
(/\G -s \s+ qq \s* (\() ((?:
$qq_paren
)+?) (\)) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
'qq'
,$1,$3,$2); }
elsif
(/\G -s \s+ qq \s* (\{) ((?:
$qq_brace
)+?) (\}) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
'qq'
,$1,$3,$2); }
elsif
(/\G -s \s+ qq \s* (\[) ((?:
$qq_bracket
)+?) (\]) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
'qq'
,$1,$3,$2); }
elsif
(/\G -s \s+ qq \s* (\<) ((?:
$qq_angle
)+?) (\>) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
'qq'
,$1,$3,$2); }
elsif
(/\G -s \s+ qq \s* (\S) ((?:
$qq_char
)+?) (\3) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_qq(
'qq'
,$1,$3,$2); }
elsif
(/\G -s \s+ \s* (\
') ((?:\\\1|\\\\|$q_char)+?) (\') /oxgc) { $slash = '
m//
'; return '
-s
' . e_q ('
', $1,$3,$2); }
elsif
(/\G -s \s+
q
\s* (\
elsif
(/\G -s \s+ q \s* (\() ((?:\\\)|\\\\|
$q_paren
)+?) (\)) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_q (
'q'
, $1,$3,$2); }
elsif
(/\G -s \s+ q \s* (\{) ((?:\\\}|\\\\|
$q_brace
)+?) (\}) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_q (
'q'
, $1,$3,$2); }
elsif
(/\G -s \s+ q \s* (\[) ((?:\\\]|\\\\|
$q_bracket
)+?) (\]) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_q (
'q'
, $1,$3,$2); }
elsif
(/\G -s \s+ q \s* (\<) ((?:\\\>|\\\\|
$q_angle
)+?) (\>) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_q (
'q'
, $1,$3,$2); }
elsif
(/\G -s \s+ q \s* (\S) ((?:\\\1|\\\\|
$q_char
)+?) (\3) /oxgc) {
$slash
=
'm//'
;
return
'-s '
. e_q (
'q'
, $1,$3,$2); }
elsif
(/\G -s \s* (\$ \w+(?: ::\w+)* (?: (?: ->)? (?: \( (?:
$qq_paren
)*? \) | \{ (?:
$qq_brace
)+? \} | \[ (?:
$qq_bracket
)+? \] ) )*) /oxgc)
{
$slash
=
'm//'
;
return
"-s $1"
; }
elsif
(/\G -s \s* \( ((?:
$qq_paren
)*?) \) /oxgc) {
$slash
=
'm//'
;
return
"-s ($1)"
; }
elsif
(/\G -s (?= \s+ [a-z]+) /oxgc) {
$slash
=
'm//'
;
return
'-s'
; }
elsif
(/\G -s \s+ (\w+) /oxgc) {
$slash
=
'm//'
;
return
"-s $1"
; }
elsif
(/\G \b bytes::
length
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
length
'; }
elsif
(/\G \b bytes::
chr
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
chr
'; }
elsif
(/\G \b
chr
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
chr
'; }
elsif
(/\G \b bytes::
ord
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
div
'; return '
ord
'; }
elsif
(/\G \b
ord
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
div';
return
$function_ord
; }
elsif
(/\G \b
glob
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $slash = '
m//
'; return '
Eeucjp::
glob
'; }
elsif
(/\G \b
lc
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::lc_'
; }
elsif
(/\G \b
lcfirst
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::lcfirst_'
; }
elsif
(/\G \b
uc
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::uc_'
; }
elsif
(/\G \b
ucfirst
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::ucfirst_'
; }
elsif
(/\G \b fc \b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::fc_'
; }
elsif
(/\G -s \b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'-s '
; }
elsif
(/\G \b bytes::
length
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'length'
; }
elsif
(/\G \b bytes::
chr
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'chr'
; }
elsif
(/\G \b
chr
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::chr_'
; }
elsif
(/\G \b bytes::
ord
\b (?! \s* => ) /oxgc) {
$slash
=
'div'
;
return
'ord'
; }
elsif
(/\G \b
ord
\b (?! \s* => ) /oxgc) {
$slash
=
'div'
;
return
$function_ord_
; }
elsif
(/\G \b
glob
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
'Eeucjp::glob_'
; }
elsif
(/\G \b
reverse
\b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
return
$function_reverse
; }
elsif
(/\G \b (
split
) \b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
my
$e
=
''
;
while
(/\G ( \s+ | \( | \
$e
.= $1;
}
if
(/\G (?= [,;\)\}\]] ) /oxgc) {
return
'Eeucjp::split'
.
$e
; }
elsif
(/\G ( [\$\@\&\*]
$qq_scalar
) /oxgc) {
return
'Eeucjp::split'
.
$e
. e_string($1); }
elsif
(/\G \b
qq
(\
elsif
(/\G \b
qq (\s*)
(\() [ ] (\)) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
; }
elsif
(/\G \b
qq (\s*)
(\{) [ ] (\}) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
; }
elsif
(/\G \b
qq (\s*)
(\[) [ ] (\]) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
; }
elsif
(/\G \b
qq (\s*)
(\<) [ ] (\>) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
; }
elsif
(/\G \b
qq (\s*)
(\S) [ ] (\2) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
; }
elsif
(/\G \b
q
(\
elsif
(/\G \b
q
(\s*) (\() [ ] (\)) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3}; }
elsif
(/\G \b
q
(\s*) (\{) [ ] (\}) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3}; }
elsif
(/\G \b
q
(\s*) (\[) [ ] (\]) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3}; }
elsif
(/\G \b
q
(\s*) (\<) [ ] (\>) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3}; }
elsif
(/\G \b
q
(\s*) (\S) [ ] (\2) /oxgc) {
return
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3}; }
elsif
(/\G
' [ ] '
/oxgc) {
return
'Eeucjp::split'
.
$e
.
qq
{
' '
}; }
elsif
(/\G
" [ ] "
/oxgc) {
return
'Eeucjp::split'
.
$e
.
qq
{
" "
}; }
elsif
(/\G \b (
qq) \b /oxgc)
{
if
(/\G (\
else
{
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
return
e_split(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
return
e_split(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
return
e_split(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
return
e_split(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) /oxgc) {
return
e_split(
$e
.
'qr'
,
'{'
,
'}'
,$2,
''
); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) /oxgc) {
return
e_split(
$e
.
'qr'
,$1,$3,$2,
''
); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
qr) \b /oxgc)
{
if
(/\G (\
else
{
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\
') ((?:$qq_char)*?) (\') ([imosxpadlubB]*) /oxgc) { return e_split_q($e.'
qr',$1, $3, $2,$4); } # qr '
'
elsif
(/\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,
'{'
,
'}'
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
q) \b /oxgc)
{
if
(/\G (\
else
{
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:\\\\|\\\)|\\\(|
$q_paren
)*?) (\)) /oxgc) {
return
e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\{) ((?:\\\\|\\\}|\\\{|
$q_brace
)*?) (\}) /oxgc) {
return
e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\[) ((?:\\\\|\\\]|\\\[|
$q_bracket
)*?) (\]) /oxgc) {
return
e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G (\<) ((?:\\\\|\\\>|\\\<|
$q_angle
)*?) (\>) /oxgc) {
return
e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
); }
elsif
(/\G ([*\-:?\\^|]) ((?:
$q_char
)*?) (\1) /oxgc) {
return
e_split_q(
$e
.
'qr'
,
'{'
,
'}'
,$2,
''
); }
elsif
(/\G (\S) ((?:\\\\|\\\1|
$q_char
)*?) (\1) /oxgc) {
return
e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (m) \b /oxgc) {
if
(/\G (\
else
{
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
elsif
(/\G (\
') ((?:$qq_char)*?) (\') ([cgimosxpadlubB]*) /oxgc) { return e_split_q($e.'
qr',$1, $3, $2,$4); } # m '
' --> qr '
'
elsif
(/\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,
'{'
,
'}'
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
return
e_split (
$e
.
'qr'
,$1, $3, $2,$4); }
}
die
__FILE__,
": Search pattern not terminated"
;
}
}
elsif
(/\G (\') /oxgc) {
my
$q_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\
') /oxgc) { $q_string .= $1; } # splitqr'
' --> split qr'
'
elsif
(/\G \
' /oxgc) { return e_split_q($e.q{ qr},"'
",
"'"
,
$q_string
,'
'); } # '
' --> qr '
'
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\") /oxgc) {
my
$qq_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\
") /oxgc) { $qq_string .= $1; } # splitqr"
" --> split qr"
"
elsif
(/\G \
" /oxgc) { return e_split($e.q{ qr},'"
',
'"'
,
$qq_string
,
''
); }
elsif
(/\G (
$q_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\/) /oxgc) {
my
$regexp
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$regexp
.= $1; }
elsif
(/\G (\\\/) /oxgc) {
$regexp
.= $1; }
elsif
(/\G \/ ([cgimosxpadlubB]*) /oxgc) {
return
e_split(
$e
.
q{ qr}
,
'/'
,
'/'
,
$regexp
,$1); }
elsif
(/\G (
$q_char
) /oxgc) {
$regexp
.= $1; }
}
die
__FILE__,
": Search pattern not terminated"
;
}
}
elsif
(/\G \b (
tr
|y) \b /oxgc) {
my
$ope
= $1;
if
(/\G (\
my
@tr
= (
$tr_variable
,$2);
return
e_tr(
@tr
,
''
,$4,$6);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
my
@tr
= (
$tr_variable
,$2);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
}
die
__FILE__,
": Transliteration replacement not terminated"
;
}
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
my
@tr
= (
$tr_variable
,$2);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
}
die
__FILE__,
": Transliteration replacement not terminated"
;
}
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
my
@tr
= (
$tr_variable
,$2);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
}
die
__FILE__,
": Transliteration replacement not terminated"
;
}
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
my
@tr
= (
$tr_variable
,$2);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cdsrbB]*) /oxgc) {
return
e_tr(
@tr
,
$e
,$2,$4); }
}
die
__FILE__,
": Transliteration replacement not terminated"
;
}
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ((?:
$qq_char
)*?) (\1) ([cdsrbB]*) /oxgc) {
my
@tr
= (
$tr_variable
,$2);
return
e_tr(
@tr
,
''
,$4,$6);
}
}
die
__FILE__,
": Transliteration pattern not terminated"
;
}
}
elsif
(/\G \b (
qq) \b /oxgc)
{
my
$ope
= $1;
if
(/\G (\
my
$qq_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\
elsif
(/\G (\
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() /oxgc) {
my
$qq_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\)) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\() /oxgc) {
$qq_string
.= $1;
$nest
++; }
elsif
(/\G (\)) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_qq(
$ope
,
'('
,
')'
,
$qq_string
); }
else
{
$qq_string
.= $1; }
}
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\{) /oxgc) {
my
$qq_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\}) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\{) /oxgc) {
$qq_string
.= $1;
$nest
++; }
elsif
(/\G (\}) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_qq(
$ope
,
'{'
,
'}'
,
$qq_string
); }
else
{
$qq_string
.= $1; }
}
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\[) /oxgc) {
my
$qq_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\]) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\[) /oxgc) {
$qq_string
.= $1;
$nest
++; }
elsif
(/\G (\]) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_qq(
$ope
,
'['
,
']'
,
$qq_string
); }
else
{
$qq_string
.= $1; }
}
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\<) /oxgc) {
my
$qq_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\>) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\<) /oxgc) {
$qq_string
.= $1;
$nest
++; }
elsif
(/\G (\>) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_qq(
$ope
,
'<'
,
'>'
,
$qq_string
); }
else
{
$qq_string
.= $1; }
}
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\S) /oxgc) {
my
$delimiter
= $1;
my
$qq_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\Q
$delimiter
\E) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\Q
$delimiter
\E) /oxgc) {
return
$e
. e_qq(
$ope
,
$delimiter
,
$delimiter
,
$qq_string
); }
elsif
(/\G (
$qq_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
qr) \b /oxgc)
{
my
$ope
= $1;
if
(/\G (\
return
e_qr(
$ope
,$1,$3,$2,$4);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\
') ((?:$qq_char)*?) (\') ([imosxpadlubB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr '
'
elsif
(/\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,
'{'
,
'}'
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
qw) \b /oxgc)
{
my
$ope
= $1;
if
(/\G (\
return
e_qw(
$ope
,$1,$3,$2);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ([^(]*?) (\)) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\() ((?:
$q_paren
)*?) (\)) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\{) ([^{]*?) (\}) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\{) ((?:
$q_brace
)*?) (\}) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\[) ([^[]*?) (\]) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\[) ((?:
$q_bracket
)*?) (\]) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\<) ([^<]*?) (\>) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\<) ((?:
$q_angle
)*?) (\>) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
elsif
(/\G (\S) ((?:
$q_char
)*?) (\1) /oxmsgc) {
return
$e
. e_qw(
$ope
,$1,$3,$2); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
qx) \b /oxgc)
{
my
$ope
= $1;
if
(/\G (\
return
e_qq(
$ope
,$1,$3,$2);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
return
$e
. e_qq(
$ope
,$1,$3,$2); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
return
$e
. e_qq(
$ope
,$1,$3,$2); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
return
$e
. e_qq(
$ope
,$1,$3,$2); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
return
$e
. e_qq(
$ope
,$1,$3,$2); }
elsif
(/\G (\
') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx '
'
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) /oxgc) {
return
$e
. e_qq(
$ope
,$1,$3,$2); }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (
q) \b /oxgc)
{
my
$ope
= $1;
if
(/\G (\
my
$q_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\
elsif
(/\G (\
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() /oxgc) {
my
$q_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\)) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\() /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\() /oxgc) {
$q_string
.= $1;
$nest
++; }
elsif
(/\G (\)) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_q(
$ope
,
'('
,
')'
,
$q_string
); }
else
{
$q_string
.= $1; }
}
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\{) /oxgc) {
my
$q_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\}) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\{) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\{) /oxgc) {
$q_string
.= $1;
$nest
++; }
elsif
(/\G (\}) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_q(
$ope
,
'{'
,
'}'
,
$q_string
); }
else
{
$q_string
.= $1; }
}
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\[) /oxgc) {
my
$q_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\]) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\[) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\[) /oxgc) {
$q_string
.= $1;
$nest
++; }
elsif
(/\G (\]) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_q(
$ope
,
'['
,
']'
,
$q_string
); }
else
{
$q_string
.= $1; }
}
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\<) /oxgc) {
my
$q_string
=
''
;
local
$nest
= 1;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\>) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\<) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\<) /oxgc) {
$q_string
.= $1;
$nest
++; }
elsif
(/\G (\>) /oxgc) {
if
(--
$nest
== 0) {
return
$e
. e_q(
$ope
,
'<'
,
'>'
,
$q_string
); }
else
{
$q_string
.= $1; }
}
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\S) /oxgc) {
my
$delimiter
= $1;
my
$q_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\Q
$delimiter
\E) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\Q
$delimiter
\E) /oxgc) {
return
$e
. e_q(
$ope
,
$delimiter
,
$delimiter
,
$q_string
); }
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(/\G \b (m) \b /oxgc) {
my
$ope
= $1;
if
(/\G (\
return
e_qr(
$ope
,$1,$3,$2,$4);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\?) ((?:
$qq_char
)*?) (\?) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
elsif
(/\G (\
') ((?:$qq_char)*?) (\') ([cgimosxpadlubB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m '
'
elsif
(/\G ([*\-:\\^|]) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,
'{'
,
'}'
,$2,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
return
$e
. e_qr (
$ope
,$1, $3, $2,$4); }
}
die
__FILE__,
": Search pattern not terminated"
;
}
}
elsif
(/\G \b (s) \b /oxgc) {
my
$ope
= $1;
if
(/\G (\
return
e_sub(
$sub_variable
,$1,$2,$3,$3,$4,$5,$6);
}
else
{
my
$e
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
my
@s
= ($1,$2,$3);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\') ((?:
$qq_char
)*?) (\') ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\$) ((?:
$qq_char
)*?) (\$) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\:) ((?:
$qq_char
)*?) (\:) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\@) ((?:
$qq_char
)*?) (\@) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
}
die
__FILE__,
": Substitution replacement not terminated"
;
}
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
my
@s
= ($1,$2,$3);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\') ((?:
$qq_char
)*?) (\') ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\$) ((?:
$qq_char
)*?) (\$) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\:) ((?:
$qq_char
)*?) (\:) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\@) ((?:
$qq_char
)*?) (\@) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
}
die
__FILE__,
": Substitution replacement not terminated"
;
}
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
my
@s
= ($1,$2,$3);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\') ((?:
$qq_char
)*?) (\') ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\$) ((?:
$qq_char
)*?) (\$) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
}
die
__FILE__,
": Substitution replacement not terminated"
;
}
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
my
@s
= ($1,$2,$3);
while
(not /\G \z/oxgc) {
if
(/\G (\s+|\
elsif
(/\G (\() ((?:
$qq_paren
)*?) (\)) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\{) ((?:
$qq_brace
)*?) (\}) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\<) ((?:
$qq_angle
)*?) (\>) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\') ((?:
$qq_char
)*?) (\') ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\$) ((?:
$qq_char
)*?) (\$) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\:) ((?:
$qq_char
)*?) (\:) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\@) ((?:
$qq_char
)*?) (\@) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
@s
,$1,$2,$3,$4); }
}
die
__FILE__,
": Substitution replacement not terminated"
;
}
elsif
(/\G (\') ((?:
$qq_char
)*?) (\') ((?:
$qq_char
)*?) (\') ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,$1,$2,$3,$3,$4,$5,$6);
}
elsif
(/\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,
'{'
,$2,
'}'
,
'{'
,$4,
'}'
,$6);
}
elsif
(/\G (\$) ((?:
$qq_char
)*?) (\1) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,$1,$2,$3,$3,$4,$5,$6);
}
elsif
(/\G (\S) ((?:
$qq_char
)*?) (\1) ((?:
$qq_char
)*?) (\1) ([cegimosxpradlubB]*) /oxgc) {
return
e_sub(
$sub_variable
,$1,$2,$3,$3,$4,$5,$6);
}
}
die
__FILE__,
": Substitution pattern not terminated"
;
}
}
elsif
(/\G \b
require
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [
elsif
(/\G \b
require
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [^\x8E\x8F\xA1-\xFE
elsif
(/\G \b
require
(\s+ (?:
$ignore_modules
)) \b /oxmsgc) {
return
"# require$1"
; }
elsif
(/\G \b
use
(\s+ strict .*? ;) ([ \t]* [
elsif
(/\G \b
use
(\s+ strict .*? ;) ([ \t]* [^\x8E\x8F\xA1-\xFE
elsif
(/\G \b
use
(\s+ strict) \b /oxmsgc) {
return
"use$1; no strict qw(refs)"
; }
elsif
(/\G \b
use
\s+ (([1-9][0-9_]*)(?:\.([0-9_]+))*) \s* ; /oxmsgc) {
if
(($2 >= 6) or (($2 == 5) and ($3 >= 12))) {
return
"use$1 no strict qw(refs);"
;
}
else
{
return
"use$1"
;
}
}
elsif
(/\G \b
use
\s+ (v([0-9][0-9_]*)(?:\.([0-9_]+))*) \s* ; /oxmsgc) {
if
(($2 >= 6) or (($2 == 5) and ($3 >= 12))) {
return
"use$1 no strict qw(refs);"
;
}
else
{
return
"use$1"
;
}
}
elsif
(/\G \b
use
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [
elsif
(/\G \b
use
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [^\x8E\x8F\xA1-\xFE
elsif
(/\G \b
use
(\s+ (?:
$ignore_modules
)) \b /oxmsgc) {
return
"# use$1"
; }
elsif
(/\G \b
no
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [
elsif
(/\G \b
no
(\s+ (?:
$ignore_modules
) .*? ;) ([ \t]* [^\x8E\x8F\xA1-\xFE
elsif
(/\G \b
no
(\s+ (?:
$ignore_modules
)) \b /oxmsgc) {
return
"# no$1"
; }
elsif
(/\G \b
use
\b /oxmsgc) {
return
"use"
; }
elsif
(/\G \b
no
\b /oxmsgc) {
return
"no"
; }
elsif
(/\G (?<![\w\$\@\%\&\*]) (\') /oxgc) {
my
$q_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(/\G (\\\') /oxgc) {
$q_string
.= $1; }
elsif
(/\G \
' /oxgc) { return e_q('
', "'
",
"'"
,
$q_string
); }
elsif
(/\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\") /oxgc) {
my
$qq_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(/\G (\\\") /oxgc) {
$qq_string
.= $1; }
elsif
(/\G \
" /oxgc) { return e_qq('', '"
',
'"'
,
$qq_string
); }
elsif
(/\G (
$q_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(/\G (\`) /oxgc) {
my
$qx_string
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$qx_string
.= $1; }
elsif
(/\G (\\\`) /oxgc) {
$qx_string
.= $1; }
elsif
(/\G \` /oxgc) {
return
e_qq(
''
,
'`'
,
'`'
,
$qx_string
); }
elsif
(/\G (
$q_char
) /oxgc) {
$qx_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
((
$slash
eq
'm//'
) and /\G (\/) /oxgc) {
my
$regexp
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$regexp
.= $1; }
elsif
(/\G (\\\/) /oxgc) {
$regexp
.= $1; }
elsif
(/\G \/ ([cgimosxpadlubB]*) /oxgc) {
return
e_qr(
''
,
'/'
,
'/'
,
$regexp
,$1); }
elsif
(/\G (
$q_char
) /oxgc) {
$regexp
.= $1; }
}
die
__FILE__,
": Search pattern not terminated"
;
}
elsif
((
$slash
eq
'm//'
) and /\G (\?) /oxgc) {
my
$regexp
=
''
;
while
(not /\G \z/oxgc) {
if
(/\G (\\\\) /oxgc) {
$regexp
.= $1; }
elsif
(/\G (\\\?) /oxgc) {
$regexp
.= $1; }
elsif
(/\G \? ([cgimosxpadlubB]*) /oxgc) {
return
e_qr(
'm'
,
'?'
,
'?'
,
$regexp
,$1); }
elsif
(/\G (
$q_char
) /oxgc) {
$regexp
.= $1; }
}
die
__FILE__,
": Search pattern not terminated"
;
}
elsif
(/\G ( << \s* ) (?= [0-9\$\@\&] ) /oxgc) {
$slash
=
'm//'
;
return
$1; }
elsif
(/\G ( <<
'([a-zA-Z_0-9]*)'
) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, $1 .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
return
$here_quote
;
}
elsif
(/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, $1 .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
return
$here_quote
;
}
elsif
(/\G ( <<
"([a-zA-Z_0-9]*)"
) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
return
$here_quote
;
}
elsif
(/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
return
$here_quote
;
}
elsif
(/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
return
$here_quote
;
}
elsif
(/\G (<<=|<=>|<=|<) (?= \s* [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
return
$1;
}
elsif
(/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
return
$1;
}
elsif
(/\G < ((?:\x8F[\xA1-\xFE][\xA1-\xFE]|[\x8E\xA1-\xFE][\x00-\xFF]|[^\x8E\x8F\xA1-\xFE>\0\a\e\f\n\r\t])+?) > /oxgc) {
return
'Eeucjp::glob("'
. $1 .
'")'
;
}
elsif
(/\G ^ ( __DATA__ \n .*) \z /oxmsgc) {
return
$1; }
elsif
(/\G ^ ( __END__ \n .*) \z /oxmsgc) {
return
$1; }
elsif
(/\G ( \cD .*) \z /oxmsgc) {
return
$1; }
elsif
(/\G ( \cZ .*) \z /oxmsgc) {
return
$1; }
elsif
(/\G (
-- | \+\+ |
[\)\}\]]
) /oxgc) {
$slash
=
'div'
;
return
$1; }
elsif
(/\G (
!~~ | !~ | != | ! |
%= | % |
&&= | && | &= | & |
-= | -> | - |
:\s*= |
: |
<<= | <=> | <= | < |
== | => | =~ | = |
>>= | >> | >= | > |
\*\*= | \*\* | \*= | \* |
\+= | \+ |
\.\.\. | \.\. | \.= | \. |
\/\/= | \/\/ |
\/= | \/ |
\? |
\\ |
\^= | \^ |
\b x= |
\|\|= | \|\| | \|= | \| |
~~ | ~ |
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
\b(?:
print
)\b |
[,;\(\{\[]
) /oxgc) {
$slash
=
'm//'
;
return
$1; }
elsif
(/\G (
$q_char
) /oxgc) {
$slash
=
'div'
;
return
$1; }
else
{
die
__FILE__,
": Oops, this shouldn't happen!"
;
}
}
sub
e_string {
my
(
$string
) =
@_
;
my
$e_string
=
''
;
local
$slash
=
'm//'
;
my
@char
=
$string
=~ / \G (\\?(?:
$q_char
)) /oxmsg;
if
(not (
grep
(/\A \{ \z/xms,
@char
) and
grep
(/\A \} \z/xms,
@char
))) {
if
(
$string
!~ /<</oxms) {
return
$string
;
}
}
E_STRING_LOOP:
while
(
$string
!~ /\G \z/oxgc) {
if
(0) {
}
elsif
(
$string
=~ /\G ( \$` | \$\{`\} | \$ \s* PREMATCH \b | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) /oxmsgc) {
$e_string
.=
q{Eeucjp::PREMATCH()}
;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$& | \$\{&\} | \$ \s* MATCH \b | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) /oxmsgc) {
$e_string
.=
q{Eeucjp::MATCH()}
;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$ \s* POSTMATCH \b | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) /oxmsgc) {
$e_string
.=
q{Eeucjp::POSTMATCH()}
;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \{ \s* (?:
tr
|
index
|
rindex
|
reverse
) \s* \} ) /oxmsgc) {
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$ 0 ) /oxmsgc) {
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$ \{ \s* 0 \s* \} ) /oxmsgc) {
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) {
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ ([1-9][0-9]*) /oxmsgc) {
$e_string
.= e_capture($1);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ \{ \s* ([1-9][0-9]*) \s* \} /oxmsgc) {
$e_string
.= e_capture($1);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ .+? \] ) /oxmsgc) {
$e_string
.= e_capture($1.
'->'
.$2);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ .+? \} ) /oxmsgc) {
$e_string
.= e_capture($1.
'->'
.$2);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) /oxmsgc) {
$e_string
.= e_capture($1);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ \s* \{ ( \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} /oxmsgc) {
$e_string
.=
'${'
. $1 .
'}'
;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \$ \s* \{ \s* (
$qq_brace
) \s* \} /oxmsgc) {
$e_string
.= e_capture($1);
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( (?: [\$\@\%\&\*] | \$\
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G ( \$[\$\@\
$e_string
.= $1;
$slash
=
'div'
;
}
elsif
(
$string
=~ /\G \b (CORE:: | ->[ ]* (?:
atan2
| [a-z]{2,})) \b /oxgc) {
$e_string
.= $1;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
substr
\b /oxgc) {
$e_string
.=
'substr'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
chop
\b /oxgc) {
$e_string
.=
'Eeucjp::chop'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
index
\b /oxgc) {
$e_string
.=
'index'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b EUCJP::
index
\b /oxgc) {
$e_string
.=
'EUCJP::index'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
index
\b /oxgc) {
$e_string
.=
'Eeucjp::index'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
rindex
\b /oxgc) {
$e_string
.=
'rindex'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b EUCJP::
rindex
\b /oxgc) {
$e_string
.=
'EUCJP::rindex'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
rindex
\b /oxgc) {
$e_string
.=
'Eeucjp::rindex'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
lc
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
lc
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b
lcfirst
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
lcfirst
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b
uc
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
uc
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b
ucfirst
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
ucfirst
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b fc (?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::fc
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G -s \s+ \s* (\") ((?:
$qq_char
)+?) (\") /oxgc) {
$e_string
.=
'-s '
. e_qq(
''
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\() ((?:
$qq_paren
)+?) (\)) /oxgc) {
$e_string
.=
'-s '
. e_qq(
'qq'
,$1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\{) ((?:
$qq_brace
)+?) (\}) /oxgc) {
$e_string
.=
'-s '
. e_qq(
'qq'
,$1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\[) ((?:
$qq_bracket
)+?) (\]) /oxgc) {
$e_string
.=
'-s '
. e_qq(
'qq'
,$1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\<) ((?:
$qq_angle
)+?) (\>) /oxgc) {
$e_string
.=
'-s '
. e_qq(
'qq'
,$1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
qq \s*
(\S) ((?:
$qq_char
)+?) (\3) /oxgc) {
$e_string
.=
'-s '
. e_qq(
'qq'
,$1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+ \s* (\
') ((?:\\\1|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '
-s
' . e_q ('
', $1,$3,$2); $slash = '
m//'; }
elsif
(
$string
=~ /\G -s \s+
q
\s* (\
elsif
(
$string
=~ /\G -s \s+
q
\s* (\() ((?:\\\)|\\\\|
$q_paren
)+?) (\)) /oxgc) {
$e_string
.=
'-s '
. e_q (
'q'
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
q
\s* (\{) ((?:\\\}|\\\\|
$q_brace
)+?) (\}) /oxgc) {
$e_string
.=
'-s '
. e_q (
'q'
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
q
\s* (\[) ((?:\\\]|\\\\|
$q_bracket
)+?) (\]) /oxgc) {
$e_string
.=
'-s '
. e_q (
'q'
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
q
\s* (\<) ((?:\\\>|\\\\|
$q_angle
)+?) (\>) /oxgc) {
$e_string
.=
'-s '
. e_q (
'q'
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+
q
\s* (\S) ((?:\\\1|\\\\|
$q_char
)+?) (\3) /oxgc) {
$e_string
.=
'-s '
. e_q (
'q'
, $1,$3,$2);
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s* (\$ \w+(?: ::\w+)* (?: (?: ->)? (?: \( (?:
$qq_paren
)*? \) | \{ (?:
$qq_brace
)+? \} | \[ (?:
$qq_bracket
)+? \] ) )*) /oxgc)
{
$e_string
.=
"-s $1"
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s* \( ((?:
$qq_paren
)*?) \) /oxgc) {
$e_string
.=
"-s ($1)"
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s (?= \s+ [a-z]+) /oxgc) {
$e_string
.=
'-s'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \s+ (\w+) /oxgc) {
$e_string
.=
"-s $1"
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
length
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
length
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b bytes::
chr
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
chr
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b
chr
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
chr
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b bytes::
ord
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
ord
'; $slash = '
div'; }
elsif
(
$string
=~ /\G \b
ord
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = '
div'; }
elsif
(
$string
=~ /\G \b
glob
(?= \s+[A-Za-z_]|\s*[
'"`\$\@\&\*\(]) /oxgc) { $e_string .= '
Eeucjp::
glob
'; $slash = '
m//'; }
elsif
(
$string
=~ /\G \b
lc
\b /oxgc) {
$e_string
.=
'Eeucjp::lc_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
lcfirst
\b /oxgc) {
$e_string
.=
'Eeucjp::lcfirst_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
uc
\b /oxgc) {
$e_string
.=
'Eeucjp::uc_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
ucfirst
\b /oxgc) {
$e_string
.=
'Eeucjp::ucfirst_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b fc \b /oxgc) {
$e_string
.=
'Eeucjp::fc_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G -s \b /oxgc) {
$e_string
.=
'-s '
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
length
\b /oxgc) {
$e_string
.=
'length'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
chr
\b /oxgc) {
$e_string
.=
'chr'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
chr
\b /oxgc) {
$e_string
.=
'Eeucjp::chr_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b bytes::
ord
\b /oxgc) {
$e_string
.=
'ord'
;
$slash
=
'div'
; }
elsif
(
$string
=~ /\G \b
ord
\b /oxgc) {
$e_string
.=
$function_ord_
;
$slash
=
'div'
; }
elsif
(
$string
=~ /\G \b
glob
\b /oxgc) {
$e_string
.=
'Eeucjp::glob_'
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b
reverse
\b /oxgc) {
$e_string
.=
$function_reverse
;
$slash
=
'm//'
; }
elsif
(
$string
=~ /\G \b (
split
) \b (?! \s* => ) /oxgc) {
$slash
=
'm//'
;
my
$e
=
''
;
while
(
$string
=~ /\G ( \s+ | \( | \
$e
.= $1;
}
if
(
$string
=~ /\G (?= [,;\)\}\]] ) /oxgc) {
return
'Eeucjp::split'
.
$e
; }
elsif
(
$string
=~ /\G ( [\$\@\&\*]
$qq_scalar
) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
. e_string($1);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
qq
(\
elsif
(
$string
=~ /\G \b
qq (\s*)
(\() [ ] (\)) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
;
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
qq (\s*)
(\{) [ ] (\}) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
;
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
qq (\s*)
(\[) [ ] (\]) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
;
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
qq (\s*)
(\<) [ ] (\>) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
;
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
qq (\s*)
(\S) [ ] (\2) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq{$1qq$2 $3}
;
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
q
(\
elsif
(
$string
=~ /\G \b
q
(\s*) (\() [ ] (\)) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
q
(\s*) (\{) [ ] (\}) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
q
(\s*) (\[) [ ] (\]) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
q
(\s*) (\<) [ ] (\>) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b
q
(\s*) (\S) [ ] (\2) /oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq {$1q$2
$3};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G
' [ ] '
/oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq
{
' '
};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G
" [ ] "
/oxgc) {
$e_string
.=
'Eeucjp::split'
.
$e
.
qq
{
" "
};
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G \b (
qq) \b /oxgc)
{
if
(
$string
=~ /\G (\
else
{
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,
'{'
,
'}'
,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:
$qq_char
)*?) (\1) /oxgc) {
$e_string
.= e_split(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G \b (
qr) \b /oxgc)
{
if
(
$string
=~ /\G (\
else
{
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:
$qq_paren
)*?) (\)) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:
$qq_brace
)*?) (\}) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:
$qq_bracket
)*?) (\]) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:
$qq_angle
)*?) (\>) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\
') ((?:$qq_char)*?) (\') ([imosxpadlubB]*) /oxgc) { $e_string .= e_split_q($e.'
qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr '
'
elsif
(
$string
=~ /\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,
'{'
,
'}'
,$2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:
$qq_char
)*?) (\1) ([imosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G \b (
q) \b /oxgc)
{
if
(
$string
=~ /\G (\
else
{
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:\\\\|\\\)|\\\(|
$q_paren
)*?) (\)) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:\\\\|\\\}|\\\{|
$q_brace
)*?) (\}) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:\\\\|\\\]|\\\[|
$q_bracket
)*?) (\]) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:\\\\|\\\>|\\\<|
$q_angle
)*?) (\>) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G ([*\-:?\\^|]) ((?:
$q_char
)*?) (\1) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,
'{'
,
'}'
,$2,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:\\\\|\\\1|
$q_char
)*?) (\1) /oxgc) {
$e_string
.= e_split_q(
$e
.
'qr'
,$1,$3,$2,
''
);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G \b (m) \b /oxgc) {
if
(
$string
=~ /\G (\
else
{
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:
$qq_paren
)*?) (\)) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:
$qq_brace
)*?) (\}) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:
$qq_bracket
)*?) (\]) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:
$qq_angle
)*?) (\>) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\
') ((?:$qq_char)*?) (\') ([cgimosxpadlubB]*) /oxgc) { $e_string .= e_split_q($e.'
qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m '
' --> qr '
'
elsif
(
$string
=~ /\G ([*\-:?\\^|]) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,
'{'
,
'}'
,$2,$4);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:
$qq_char
)*?) (\1) ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split (
$e
.
'qr'
,$1, $3, $2,$4);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Search pattern not terminated"
;
}
}
elsif
(
$string
=~ /\G (\') /oxgc) {
my
$q_string
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\\\\) /oxgc) {
$q_string
.= $1; }
elsif
(
$string
=~ /\G (\\\
') /oxgc) { $q_string .= $1; } # splitqr'
' --> split qr'
'
elsif
(
$string
=~ /\G \
' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'
",
"'"
,
$q_string
,'
'); next E_STRING_LOOP; } # '
' --> qr '
'
elsif
(
$string
=~ /\G (
$q_char
) /oxgc) {
$q_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(
$string
=~ /\G (\") /oxgc) {
my
$qq_string
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\\\\) /oxgc) {
$qq_string
.= $1; }
elsif
(
$string
=~ /\G (\\\
") /oxgc) { $qq_string .= $1; } # splitqr"
" --> split qr"
"
elsif
(
$string
=~ /\G \
" /oxgc) { $e_string .= e_split($e.q{ qr},'"
',
'"'
,
$qq_string
,
''
);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (
$q_char
) /oxgc) {
$qq_string
.= $1; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
elsif
(
$string
=~ /\G (\/) /oxgc) {
my
$regexp
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\\\\) /oxgc) {
$regexp
.= $1; }
elsif
(
$string
=~ /\G (\\\/) /oxgc) {
$regexp
.= $1; }
elsif
(
$string
=~ /\G \/ ([cgimosxpadlubB]*) /oxgc) {
$e_string
.= e_split(
$e
.
q{ qr}
,
'/'
,
'/'
,
$regexp
,$1);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (
$q_char
) /oxgc) {
$regexp
.= $1; }
}
die
__FILE__,
": Search pattern not terminated"
;
}
}
elsif
(
$string
=~ /\G \b (
qq) \b /oxgc)
{
my
$ope
= $1;
if
(
$string
=~ /\G (\
$e_string
.= e_qq(
$ope
,$1,$3,$2);
}
else
{
my
$e
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:
$qq_char
)*?) (\1) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G \b (
qx) \b /oxgc)
{
my
$ope
= $1;
if
(
$string
=~ /\G (\
$e_string
.= e_qq(
$ope
,$1,$3,$2);
}
else
{
my
$e
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:
$qq_paren
)*?) (\)) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:
$qq_brace
)*?) (\}) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:
$qq_bracket
)*?) (\]) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:
$qq_angle
)*?) (\>) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\
') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx '
'
elsif
(
$string
=~ /\G (\S) ((?:
$qq_char
)*?) (\1) /oxgc) {
$e_string
.=
$e
. e_qq(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G \b (
q) \b /oxgc)
{
my
$ope
= $1;
if
(
$string
=~ /\G (\
$e_string
.= e_q(
$ope
,$1,$3,$2);
}
else
{
my
$e
=
''
;
while
(
$string
!~ /\G \z/oxgc) {
if
(
$string
=~ /\G (\s+|\
elsif
(
$string
=~ /\G (\() ((?:\\\\|\\\)|\\\(|
$q_paren
)*?) (\)) /oxgc) {
$e_string
.=
$e
. e_q(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\{) ((?:\\\\|\\\}|\\\{|
$q_brace
)*?) (\}) /oxgc) {
$e_string
.=
$e
. e_q(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\[) ((?:\\\\|\\\]|\\\[|
$q_bracket
)*?) (\]) /oxgc) {
$e_string
.=
$e
. e_q(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\<) ((?:\\\\|\\\>|\\\<|
$q_angle
)*?) (\>) /oxgc) {
$e_string
.=
$e
. e_q(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
elsif
(
$string
=~ /\G (\S) ((?:\\\\|\\\1|
$q_char
)*?) (\1) /oxgc) {
$e_string
.=
$e
. e_q(
$ope
,$1,$3,$2);
next
E_STRING_LOOP; }
}
die
__FILE__,
": Can't find string terminator anywhere before EOF"
;
}
}
elsif
(
$string
=~ /\G (?<![\w\$\@\%\&\*]) (\
') ((?:\\\'|\\\\|$q_char)*?) (\') /oxgc) { $e_string .= e_q('
',$1,$3,$2); }
elsif
(
$string
=~ /\G (\") ((?:
$qq_char
)*?) (\") /oxgc) {
$e_string
.= e_qq(
''
,$1,$3,$2); }
elsif
(
$string
=~ /\G (\`) ((?:
$qq_char
)*?) (\`) /oxgc) {
$e_string
.= e_qq(
''
,$1,$3,$2); }
elsif
(
$string
=~ /\G (<<=|<=>|<=|<) (?= \s* [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) {
$e_string
.= $1; }
elsif
(
$string
=~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) {
$e_string
.= $1; }
elsif
(
$string
=~ /\G < ((?:
$q_char
)+?) > /oxgc) {
$e_string
.=
'Eeucjp::glob("'
. $1 .
'")'
;
}
elsif
(
$string
=~ /\G ( << \s* ) (?= [0-9\$\@\&] ) /oxgc) {
$slash
=
'm//'
;
$e_string
.= $1; }
elsif
(
$string
=~ /\G ( <<
'([a-zA-Z_0-9]*)'
) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, $1 .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
$e_string
.=
$here_quote
;
}
elsif
(
$string
=~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, $1 .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
$e_string
.=
$here_quote
;
}
elsif
(
$string
=~ /\G ( <<
"([a-zA-Z_0-9]*)"
) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
$e_string
.=
$here_quote
;
}
elsif
(
$string
=~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
$e_string
.=
$here_quote
;
}
elsif
(
$string
=~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) {
$slash
=
'm//'
;
my
$here_quote
= $1;
my
$delimiter
= $2;
if
(
$here_script
eq
''
) {
$here_script
= CORE::
substr
$_
,
pos
$_
;
$here_script
=~ s/.*?\n//oxm;
}
if
(
$here_script
=~ s/\A (.*?) \n
$delimiter
\n //xms) {
push
@heredoc
, e_heredoc($1) .
qq{\n$delimiter\n}
;
push
@heredoc_delimiter
,
$delimiter
;
}
else
{
die
__FILE__,
": Can't find string terminator $delimiter anywhere before EOF"
;
}
$e_string
.=
$here_quote
;
}
elsif
(
$string
=~ /\G (
-- | \+\+ |
[\)\}\]]
) /oxgc) {
$slash
=
'div'
;
$e_string
.= $1; }
elsif
(
$string
=~ /\G (
!~~ | !~ | != | ! |
%= | % |
&&= | && | &= | & |
-= | -> | - |
:\s*= |
: |
<<= | <=> | <= | < |
== | => | =~ | = |
>>= | >> | >= | > |
\*\*= | \*\* | \*= | \* |
\+= | \+ |
\.\.\. | \.\. | \.= | \. |
\/\/= | \/\/ |
\/= | \/ |
\? |
\\ |
\^= | \^ |
\b x= |
\|\|= | \|\| | \|= | \| |
~~ | ~ |
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b |
\b(?:
print
)\b |
[,;\(\{\[]
) /oxgc) {
$slash
=
'm//'
;
$e_string
.= $1; }
elsif
(
$string
=~ /\G (
$q_char
) /oxgc) {
$e_string
.= $1; }
else
{
die
__FILE__,
": Oops, this shouldn't happen!"
;
}
}
return
$e_string
;
}
sub
character_class {
my
(
$char
,
$modifier
) =
@_
;
if
(
$char
eq
'.'
) {
if
(
$modifier
=~ /s/) {
return
'${Eeucjp::dot_s}'
;
}
else
{
return
'${Eeucjp::dot}'
;
}
}
else
{
return
Eeucjp::classic_character_class(
$char
);
}
}
sub
e_capture {
return
join
''
,
'${Eeucjp::capture('
,
$_
[0],
')}'
;
return
join
''
,
'$'
,
$_
[0];
}
sub
e_tr {
my
(
$variable
,
$charclass
,
$e
,
$charclass2
,
$modifier
) =
@_
;
my
$e_tr
=
''
;
$modifier
||=
''
;
$slash
=
'div'
;
$charclass
= q_tr(
$charclass
);
$charclass2
= q_tr(
$charclass2
);
if
(
$modifier
=~
tr
/bB//d) {
if
(
$variable
eq
''
) {
$e_tr
=
qq{tr$charclass$e$charclass2$modifier}
;
}
else
{
$e_tr
=
qq{$variable${bind_operator}
tr
$charclass
$e
$charclass2
$modifier
};
}
}
else
{
if
(
$variable
eq
''
) {
$e_tr
=
qq{Eeucjp::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}
;
}
else
{
$e_tr
=
qq{Eeucjp::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}
;
}
}
$tr_variable
=
''
;
$bind_operator
=
''
;
return
$e_tr
;
}
sub
q_tr {
my
(
$charclass
) =
@_
;
if
(
$charclass
!~ /'/oxms) {
return
e_q(
''
,
"'"
,
"'"
,
$charclass
);
}
elsif
(
$charclass
!~ /\//oxms) {
return
e_q(
'q'
,
'/'
,
'/'
,
$charclass
);
}
elsif
(
$charclass
!~ /\
return
e_q(
'q'
,
'#'
,
'#'
,
$charclass
); # -->
q# #
}
elsif
(
$charclass
!~ /[\<\>]/oxms) {
return
e_q(
'q'
,
'<'
,
'>'
,
$charclass
);
}
elsif
(
$charclass
!~ /[\(\)]/oxms) {
return
e_q(
'q'
,
'('
,
')'
,
$charclass
);
}
elsif
(
$charclass
!~ /[\{\}]/oxms) {
return
e_q(
'q'
,
'{'
,
'}'
,
$charclass
);
}
else
{
for
my
$char
(
qw( ! " $ % & * + . : = ? @ ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(
$charclass
!~ /\Q
$char
\E/xms) {
return
e_q(
'q'
,
$char
,
$char
,
$charclass
);
}
}
}
return
e_q(
'q'
,
'{'
,
'}'
,
$charclass
);
}
sub
e_q {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
) =
@_
;
$slash
=
'div'
;
return
join
''
,
$ope
,
$delimiter
,
$string
,
$end_delimiter
;
}
sub
e_qq {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
) =
@_
;
$slash
=
'div'
;
my
$left_e
= 0;
my
$right_e
= 0;
my
@char
=
$string
=~ /\G(
\\o\{ [0-7]+ \} |
\\x\{ [0-9A-Fa-f]+ \} |
\\N\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} |
\$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} |
\$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} |
\$ \s* \d+ |
\$ \s* \{ \s* \d+ \s* \} |
\$ \$ (?![\w\{]) |
\$ \s* \$ \s*
$qq_variable
|
\\?(?:
$q_char
)
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
((
$char
[
$i
] eq
'\L'
) and (
$char
[
$i
+1] eq
'\u'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
((
$char
[
$i
] eq
'\U'
) and (
$char
[
$i
+1] eq
'\l'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
(
$char
[
$i
] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::octchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::hexchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\ ( N\{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1;
}
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A ([<>]) \z/oxms) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
elsif
(
$char
[
$i
] eq
'\u'
) {
$char
[
$i
] =
'@{[Eeucjp::ucfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\l'
) {
$char
[
$i
] =
'@{[Eeucjp::lcfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\U'
) {
$char
[
$i
] =
'@{[Eeucjp::uc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\L'
) {
$char
[
$i
] =
'@{[Eeucjp::lc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\F'
) {
$char
[
$i
] =
'@{[Eeucjp::fc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
$char
[
$i
] =
'@{[CORE::quotemeta qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\E'
) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'>]}'
;
$right_e
++;
}
else
{
$char
[
$i
] =
''
;
}
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
while
(1) {
if
(++
$i
>
$#char
) {
last
;
}
if
(
$char
[
$i
] eq
'\E'
) {
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'\E'
) {
}
elsif
(
$char
[
$i
] =~ /\A \$ 0 \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* 0 \s* \} \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$\$ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ ([1-9][0-9]*) \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ (?:
$qq_bracket
)*? \] ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ (?:
$qq_brace
)*? \} ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A ( \$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::PREMATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A ( \$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::MATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A ( \$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::POSTMATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* \} \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* ( .+ ) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
}
}
if
(
$left_e
>
$right_e
) {
return
join
''
,
$ope
,
$delimiter
,
@char
,
'>]}'
x (
$left_e
-
$right_e
),
$end_delimiter
;
}
return
join
''
,
$ope
,
$delimiter
,
@char
,
$end_delimiter
;
}
sub
e_qw {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
) =
@_
;
$slash
=
'div'
;
my
%octet
=
map
{
$_
=> 1} (
$string
=~ /\G ([\x00-\xFF]) /oxmsg);
if
(not
$octet
{
$end_delimiter
}) {
return
join
''
,
$ope
,
$delimiter
,
$string
,
$end_delimiter
;
}
elsif
(not
$octet
{
')'
}) {
return
join
''
,
$ope
,
'('
,
$string
,
')'
;
}
elsif
(not
$octet
{
'}'
}) {
return
join
''
,
$ope
,
'{'
,
$string
,
'}'
;
}
elsif
(not
$octet
{
']'
}) {
return
join
''
,
$ope
,
'['
,
$string
,
']'
;
}
elsif
(not
$octet
{
'>'
}) {
return
join
''
,
$ope
,
'<'
,
$string
,
'>'
;
}
else
{
for
my
$char
(
qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(not
$octet
{
$char
}) {
return
join
''
,
$ope
,
$char
,
$string
,
$char
;
}
}
}
my
@string
= CORE::
split
(/\s+/,
$string
);
for
my
$string
(
@string
) {
my
@octet
=
$string
=~ /\G ([\x00-\xFF]) /oxmsg;
for
my
$octet
(
@octet
) {
if
(
$octet
=~ /\A (['\\]) \z/oxms) {
$octet
=
'\\'
. $1;
}
}
$string
=
join
''
,
@octet
;
}
return
join
''
,
'('
, (
join
', '
,
map
{
"'$_'"
}
@string
),
')'
;
}
sub
e_heredoc {
my
(
$string
) =
@_
;
$slash
=
'm//'
;
my
$metachar
=
qr/[\@\\|]/
oxms;
my
$left_e
= 0;
my
$right_e
= 0;
my
@char
=
$string
=~ /\G(
\\o\{ [0-7]+ \} |
\\x\{ [0-9A-Fa-f]+ \} |
\\N\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} |
\$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} |
\$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} |
\$ \s* \d+ |
\$ \s* \{ \s* \d+ \s* \} |
\$ \$ (?![\w\{]) |
\$ \s* \$ \s*
$qq_variable
|
\\?(?:
$q_char
)
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
((
$char
[
$i
] eq
'\L'
) and (
$char
[
$i
+1] eq
'\u'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
((
$char
[
$i
] eq
'\U'
) and (
$char
[
$i
+1] eq
'\l'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
(
$char
[
$i
] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::octchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::hexchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\ ( N\{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1;
}
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A ([<>]) \z/oxms) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
elsif
(
$char
[
$i
] eq
'\u'
) {
$char
[
$i
] =
'@{[Eeucjp::ucfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\l'
) {
$char
[
$i
] =
'@{[Eeucjp::lcfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\U'
) {
$char
[
$i
] =
'@{[Eeucjp::uc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\L'
) {
$char
[
$i
] =
'@{[Eeucjp::lc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\F'
) {
$char
[
$i
] =
'@{[Eeucjp::fc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
$char
[
$i
] =
'@{[CORE::quotemeta qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\E'
) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'>]}'
;
$right_e
++;
}
else
{
$char
[
$i
] =
''
;
}
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
while
(1) {
if
(++
$i
>
$#char
) {
last
;
}
if
(
$char
[
$i
] eq
'\E'
) {
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'\E'
) {
}
elsif
(
$char
[
$i
] =~ /\A \$ 0 \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* 0 \s* \} \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$\$ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ ([1-9][0-9]*) \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ (?:
$qq_bracket
)*? \] ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ (?:
$qq_brace
)*? \} ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) \z/oxms) {
$char
[
$i
] = e_capture($1);
}
elsif
(
$char
[
$i
] =~ /\A ( \$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::PREMATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A ( \$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::MATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A ( \$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) \z/oxmsgc) {
$char
[
$i
] =
'@{[Eeucjp::POSTMATCH()]}'
;
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* \} \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* ( .+ ) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
}
}
if
(
$left_e
>
$right_e
) {
return
join
''
,
@char
,
'>]}'
x (
$left_e
-
$right_e
);
}
return
join
''
,
@char
;
}
sub
e_qr {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$string
eq
''
) {
$modifier
=~
tr
/bB//d;
$modifier
=~
tr
/i//d;
return
join
''
,
$ope
,
$delimiter
,
$end_delimiter
,
$modifier
;
}
elsif
(
$modifier
=~
tr
/bB//d) {
if
(
$delimiter
=~ / [\@:] /oxms) {
my
@char
=
$string
=~ /\G([\x00-\xFF])/oxmsg;
my
%octet
=
map
{
$_
=> 1}
@char
;
if
(not
$octet
{
')'
}) {
$delimiter
=
'('
;
$end_delimiter
=
')'
;
}
elsif
(not
$octet
{
'}'
}) {
$delimiter
=
'{'
;
$end_delimiter
=
'}'
;
}
elsif
(not
$octet
{
']'
}) {
$delimiter
=
'['
;
$end_delimiter
=
']'
;
}
elsif
(not
$octet
{
'>'
}) {
$delimiter
=
'<'
;
$end_delimiter
=
'>'
;
}
else
{
for
my
$char
(
qw( ! " $ % & * + - . / = ? ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(not
$octet
{
$char
}) {
$delimiter
=
$char
;
$end_delimiter
=
$char
;
last
;
}
}
}
}
if
((
$ope
=~ /\A m? \z/oxms) and (
$delimiter
eq
'?'
)) {
return
join
''
,
$ope
,
$delimiter
,
$string
,
$matched
,
$end_delimiter
,
$modifier
;
}
else
{
return
join
''
,
$ope
,
$delimiter
,
'(?:'
,
$string
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
}
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
$metachar
=
qr/[\@\\|[\]{^]/
oxms;
my
@char
=
$string
=~ /\G(
\\o\{ [0-7]+ \} |
\\ [0-7]{2,3} |
\\x\{ [0-9A-Fa-f]+ \} |
\\x [0-9A-Fa-f]{1,2} |
\\c [\x40-\x5F] |
\\N\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\p\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\P\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\ (?:
$q_char
) |
\$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} |
\$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} |
\$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} |
[\$\@]
$qq_variable
|
\$ \s* \d+ |
\$ \s* \{ \s* \d+ \s* \} |
\$ \$ (?![\w\{]) |
\$ \s* \$ \s*
$qq_variable
|
\[\:\^ (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\: (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\^ |
\(\? |
(?:
$q_char
)
)/oxmsg;
if
(
$delimiter
=~ / [\@:] /oxms) {
my
%octet
=
map
{
$_
=> 1}
@char
;
if
(not
$octet
{
')'
}) {
$delimiter
=
'('
;
$end_delimiter
=
')'
;
}
elsif
(not
$octet
{
'}'
}) {
$delimiter
=
'{'
;
$end_delimiter
=
'}'
;
}
elsif
(not
$octet
{
']'
}) {
$delimiter
=
'['
;
$end_delimiter
=
']'
;
}
elsif
(not
$octet
{
'>'
}) {
$delimiter
=
'<'
;
$end_delimiter
=
'>'
;
}
else
{
for
my
$char
(
qw( ! " $ % & * + - . / = ? ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(not
$octet
{
$char
}) {
$delimiter
=
$char
;
$end_delimiter
=
$char
;
last
;
}
}
}
}
my
$left_e
= 0;
my
$right_e
= 0;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
((
$char
[
$i
] eq
'\L'
) and (
$char
[
$i
+1] eq
'\u'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
((
$char
[
$i
] eq
'\U'
) and (
$char
[
$i
+1] eq
'\l'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
(
$char
[
$i
] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::octchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::hexchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\ (N) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (p) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (P) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ ( [pPX] ) \z/oxms) {
$char
[
$i
] = $1;
}
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
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 (
eval
(
sprintf
'"%s%s%s%s"'
,
@char
[
$i
..
$i
+3]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 3;
}
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 (
eval
(
sprintf
'"%s%s%s"'
,
@char
[
$i
..
$i
+2]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 2;
}
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 (
eval
(
sprintf
'"%s%s"'
,
@char
[
$i
..
$i
+1]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 1;
}
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_not_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
(
$char
[
$i
] =~ /\A [<>] \z/oxms) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
elsif
(
$char
[
$i
] eq
'\u'
) {
$char
[
$i
] =
'@{[Eeucjp::ucfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\l'
) {
$char
[
$i
] =
'@{[Eeucjp::lcfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\U'
) {
$char
[
$i
] =
'@{[Eeucjp::uc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\L'
) {
$char
[
$i
] =
'@{[Eeucjp::lc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\F'
) {
$char
[
$i
] =
'@{[Eeucjp::fc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
$char
[
$i
] =
'@{[CORE::quotemeta qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\E'
) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'>]}'
;
$right_e
++;
}
else
{
$char
[
$i
] =
''
;
}
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
while
(1) {
if
(++
$i
>
$#char
) {
last
;
}
if
(
$char
[
$i
] eq
'\E'
) {
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'\E'
) {
}
elsif
(
$char
[
$i
] =~ /\A \$ 0 \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* 0 \s* \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$\$ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ ([1-9][0-9]*) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ (?:
$qq_bracket
)*? \] ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ (?:
$qq_brace
)*? \} ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::PREMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::PREMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::MATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::MATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::POSTMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::POSTMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ ( \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* ( .+ ) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A [\$\@].+ /oxms) {
$char
[
$i
] = e_string(
$char
[
$i
]);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
}
elsif
((
$ope
=~ /\A m? \z/oxms) and (
$delimiter
eq
'?'
)) {
my
$char
=
$char
[
$i
-1];
if
(
$char
[
$i
] eq
'{'
) {
die
__FILE__,
qq{: "MULTIBYTE{n}
" should be
"(MULTIBYTE){n}"
in m?? (and
shift
\$1,\$2,\$3,...) (
$char
){n}};
}
else
{
die
__FILE__,
qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]}
;
}
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
$modifier
=~
tr
/i//d;
if
(
$left_e
>
$right_e
) {
if
((
$ope
=~ /\A m? \z/oxms) and (
$delimiter
eq
'?'
)) {
return
join
''
,
$ope
,
$delimiter
,
$anchor
,
@char
,
'>]}'
x (
$left_e
-
$right_e
),
$matched
,
$end_delimiter
,
$modifier
;
}
else
{
return
join
''
,
$ope
,
$delimiter
,
$anchor
,
'(?:'
,
@char
,
'>]}'
x (
$left_e
-
$right_e
),
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
}
if
((
$ope
=~ /\A m? \z/oxms) and (
$delimiter
eq
'?'
)) {
return
join
''
,
$ope
,
$delimiter
,
$anchor
,
@char
,
$matched
,
$end_delimiter
,
$modifier
;
}
else
{
return
join
''
,
$ope
,
$delimiter
,
$anchor
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
}
sub
qq_stuff {
my
(
$delimiter
,
$end_delimiter
,
$stuff
) =
@_
;
if
(
$stuff
=~ /\A [\$\@] /oxms) {
return
$stuff
;
}
my
%octet
=
map
{
$_
=> 1} (
$stuff
=~ /\G ([\x00-\xFF]) /oxmsg);
for
my
$char
(
qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
next
if
$char
eq
$delimiter
;
next
if
$char
eq
$end_delimiter
;
if
(not
$octet
{
$char
}) {
return
join
''
,
'qq'
,
$char
,
$stuff
,
$char
;
}
}
return
join
''
,
'qq'
,
'<'
,
$stuff
,
'>'
;
}
sub
e_qr_q {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$string
eq
''
) {
$modifier
=~
tr
/bB//d;
$modifier
=~
tr
/i//d;
return
join
''
,
$ope
,
$delimiter
,
$end_delimiter
,
$modifier
;
}
elsif
(
$modifier
=~
tr
/bB//d) {
return
e_qr_qb(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
);
}
else
{
return
e_qr_qt(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
);
}
}
sub
e_qr_qt {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
@char
=
$string
=~ /\G(
\[\:\^ [a-z]+ \:\] |
\[\: [a-z]+ \:\] |
\[\^ |
[\$\@\/\\] |
\\? (?:
$q_char
)
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] =~ /\A [\$\@\/\\] \z/oxms) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A [\x00-\xFF] \z/oxms) {
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
$delimiter
=
'/'
;
$end_delimiter
=
'/'
;
$modifier
=~
tr
/i//d;
return
join
''
,
$ope
,
$delimiter
,
$anchor
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
sub
e_qr_qb {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
my
@char
=
$string
=~ /\G(
\\\\ |
[\$\@\/\\] |
[\x00-\xFF]
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] eq
'\\\\'
) {
}
elsif
(
$char
[
$i
] =~ /\A [\$\@\/\\] \z/oxms) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
$delimiter
=
'/'
;
$end_delimiter
=
'/'
;
return
join
''
,
$ope
,
$delimiter
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
sub
e_s1 {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$string
eq
''
) {
$modifier
=~
tr
/bB//d;
$modifier
=~
tr
/i//d;
return
join
''
,
$ope
,
$delimiter
,
$end_delimiter
,
$modifier
;
}
elsif
(
$modifier
=~
tr
/bB//d) {
if
(
$delimiter
=~ / [\@:] /oxms) {
my
@char
=
$string
=~ /\G([\x00-\xFF])/oxmsg;
my
%octet
=
map
{
$_
=> 1}
@char
;
if
(not
$octet
{
')'
}) {
$delimiter
=
'('
;
$end_delimiter
=
')'
;
}
elsif
(not
$octet
{
'}'
}) {
$delimiter
=
'{'
;
$end_delimiter
=
'}'
;
}
elsif
(not
$octet
{
']'
}) {
$delimiter
=
'['
;
$end_delimiter
=
']'
;
}
elsif
(not
$octet
{
'>'
}) {
$delimiter
=
'<'
;
$end_delimiter
=
'>'
;
}
else
{
for
my
$char
(
qw( ! " $ % & * + - . / = ? ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(not
$octet
{
$char
}) {
$delimiter
=
$char
;
$end_delimiter
=
$char
;
last
;
}
}
}
}
my
$prematch
=
''
;
$prematch
=
q{(\G[\x00-\xFF]*?)}
;
return
join
''
,
$ope
,
$delimiter
,
$prematch
,
'(?:'
,
$string
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
$metachar
=
qr/[\@\\|[\]{^]/
oxms;
my
@char
=
$string
=~ /\G(
\\g \s* \{ \s* - \s* [1-9][0-9]* \s* \} |
\\g \s* \{ \s* [1-9][0-9]* \s* \} |
\\g \s* [1-9][0-9]* |
\\o\{ [0-7]+ \} |
\\ [1-9][0-9]* |
\\ [0-7]{2,3} |
\\x\{ [0-9A-Fa-f]+ \} |
\\x [0-9A-Fa-f]{1,2} |
\\c [\x40-\x5F] |
\\N\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\p\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\P\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\ (?:
$q_char
) |
\$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} |
\$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} |
\$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} |
[\$\@]
$qq_variable
|
\$ \s* \d+ |
\$ \s* \{ \s* \d+ \s* \} |
\$ \$ (?![\w\{]) |
\$ \s* \$ \s*
$qq_variable
|
\[\:\^ (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\: (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\^ |
\(\? |
(?:
$q_char
)
)/oxmsg;
if
(
$delimiter
=~ / [\@:] /oxms) {
my
%octet
=
map
{
$_
=> 1}
@char
;
if
(not
$octet
{
')'
}) {
$delimiter
=
'('
;
$end_delimiter
=
')'
;
}
elsif
(not
$octet
{
'}'
}) {
$delimiter
=
'{'
;
$end_delimiter
=
'}'
;
}
elsif
(not
$octet
{
']'
}) {
$delimiter
=
'['
;
$end_delimiter
=
']'
;
}
elsif
(not
$octet
{
'>'
}) {
$delimiter
=
'<'
;
$end_delimiter
=
'>'
;
}
else
{
for
my
$char
(
qw( ! " $ % & * + - . / = ? ^ ` | ~ )
, "\x00
".."
\x1F
", "
\x7F
", "
\xFF") {
if
(not
$octet
{
$char
}) {
$delimiter
=
$char
;
$end_delimiter
=
$char
;
last
;
}
}
}
}
my
$parens
=
grep
{
$_
eq
'('
}
@char
;
my
$left_e
= 0;
my
$right_e
= 0;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
((
$char
[
$i
] eq
'\L'
) and (
$char
[
$i
+1] eq
'\u'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
((
$char
[
$i
] eq
'\U'
) and (
$char
[
$i
+1] eq
'\l'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
(
$char
[
$i
] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::octchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::hexchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\ (N) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (p) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (P) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ ( [pPX] ) \z/oxms) {
$char
[
$i
] = $1;
}
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
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 (
eval
(
sprintf
'"%s%s%s%s"'
,
@char
[
$i
..
$i
+3]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 3;
}
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 (
eval
(
sprintf
'"%s%s%s"'
,
@char
[
$i
..
$i
+2]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 2;
}
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 (
eval
(
sprintf
'"%s%s"'
,
@char
[
$i
..
$i
+1]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 1;
}
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_not_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
(
$char
[
$i
] =~ /\A [<>] \z/oxms) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
elsif
(
$char
[
$i
] eq
'\u'
) {
$char
[
$i
] =
'@{[Eeucjp::ucfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\l'
) {
$char
[
$i
] =
'@{[Eeucjp::lcfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\U'
) {
$char
[
$i
] =
'@{[Eeucjp::uc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\L'
) {
$char
[
$i
] =
'@{[Eeucjp::lc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\F'
) {
$char
[
$i
] =
'@{[Eeucjp::fc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
$char
[
$i
] =
'@{[CORE::quotemeta qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\E'
) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'>]}'
;
$right_e
++;
}
else
{
$char
[
$i
] =
''
;
}
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
while
(1) {
if
(++
$i
>
$#char
) {
last
;
}
if
(
$char
[
$i
] eq
'\E'
) {
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'\E'
) {
}
elsif
(
$char
[
$i
] =~ /\A \\ \s* 0 \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \\g \s* \{ \s* - \s* ([1-9][0-9]*) \s* \} \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \\g \s* \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
if
($1 <=
$parens
) {
$char
[
$i
] =
'\\g{'
. ($1 + 1) .
'}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \\g \s* ([1-9][0-9]*) \z/oxms) {
if
($1 <=
$parens
) {
$char
[
$i
] =
'\\g'
. ($1 + 1);
}
}
elsif
(
$char
[
$i
] =~ /\A \\ \s* ([1-9][0-9]*) \z/oxms) {
if
($1 <=
$parens
) {
$char
[
$i
] =
'\\'
. ($1 + 1);
}
}
elsif
(
$char
[
$i
] =~ /\A \$ 0 \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* 0 \s* \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$\$ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ ([1-9][0-9]*) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ (?:
$qq_bracket
)*? \] ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ (?:
$qq_brace
)*? \} ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::PREMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::PREMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::MATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::MATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::POSTMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::POSTMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ ( \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* ( .+ ) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A [\$\@].+ /oxms) {
$char
[
$i
] = e_string(
$char
[
$i
]);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
my
$prematch
=
''
;
$prematch
=
"($anchor)"
;
$modifier
=~
tr
/i//d;
if
(
$left_e
>
$right_e
) {
return
join
''
,
$ope
,
$delimiter
,
$prematch
,
'(?:'
,
@char
,
'>]}'
x (
$left_e
-
$right_e
),
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
return
join
''
,
$ope
,
$delimiter
,
$prematch
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
sub
e_s1_q {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$string
eq
''
) {
$modifier
=~
tr
/bB//d;
$modifier
=~
tr
/i//d;
return
join
''
,
$ope
,
$delimiter
,
$end_delimiter
,
$modifier
;
}
elsif
(
$modifier
=~
tr
/bB//d) {
return
e_s1_qb(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
);
}
else
{
return
e_s1_qt(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
);
}
}
sub
e_s1_qt {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
@char
=
$string
=~ /\G(
\[\:\^ [a-z]+ \:\] |
\[\: [a-z]+ \:\] |
\[\^ |
[\$\@\/\\] |
\\? (?:
$q_char
)
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] =~ /\A [\$\@\/\\] \z/oxms) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A [\x00-\xFF] \z/oxms) {
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
$modifier
=~
tr
/i//d;
$delimiter
=
'/'
;
$end_delimiter
=
'/'
;
my
$prematch
=
''
;
$prematch
=
"($anchor)"
;
return
join
''
,
$ope
,
$delimiter
,
$prematch
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
sub
e_s1_qb {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
my
@char
=
$string
=~ /\G(
\\\\ |
[\$\@\/\\] |
[\x00-\xFF]
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] eq
'\\\\'
) {
}
elsif
(
$char
[
$i
] =~ /\A [\$\@\/\\] \z/oxms) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
$delimiter
=
'/'
;
$end_delimiter
=
'/'
;
my
$prematch
=
''
;
$prematch
=
q{(\G[\x00-\xFF]*?)}
;
return
join
''
,
$ope
,
$delimiter
,
$prematch
,
'(?:'
,
@char
,
')'
,
$matched
,
$end_delimiter
,
$modifier
;
}
sub
e_s2_q {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
) =
@_
;
$slash
=
'div'
;
my
@char
=
$string
=~ / \G (\\\\|[\$\@\/\\]|
$q_char
) /oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A \\\\ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A [\$\@\/\\] \z/oxms) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
return
join
''
,
$ope
,
$delimiter
,
@char
,
$end_delimiter
;
}
sub
e_sub {
my
(
$variable
,
$delimiter1
,
$pattern
,
$end_delimiter1
,
$delimiter2
,
$replacement
,
$end_delimiter2
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
if
(
$variable
eq
''
) {
$variable
=
'$_'
;
$bind_operator
=
' =~ '
;
}
$slash
=
'div'
;
my
$e_modifier
=
$modifier
=~
tr
/e//d;
my
$r_modifier
=
$modifier
=~
tr
/r//d;
my
$my
=
''
;
if
(
$variable
=~ s/\A \( \s* ( (?:
local
\b |
my
\b |
our
\b | state \b )? .+ ) \) \z/$1/oxms) {
$my
=
$variable
;
$variable
=~ s/ (?:
local
\b |
my
\b |
our
\b | state \b ) \s* //oxms;
$variable
=~ s/ = .+ \z//oxms;
}
(
my
$variable_basename
=
$variable
) =~ s/ [\[\{].* \z//oxms;
$variable_basename
=~ s/ \s+ \z//oxms;
my
$e_replacement
=
''
;
if
(
$e_modifier
>= 1) {
$e_replacement
= e_qq(
''
,
''
,
''
,
$replacement
);
$e_modifier
--;
}
else
{
if
(
$delimiter2
eq
"'"
) {
$e_replacement
= e_s2_q(
'qq'
,
'/'
,
'/'
,
$replacement
);
}
else
{
$e_replacement
= e_qq (
'qq'
,
$delimiter2
,
$end_delimiter2
,
$replacement
);
}
}
my
$local
=
''
;
if
(
$variable_basename
=~ /::/) {
$local
=
'local'
;
}
else
{
$local
=
'my'
;
}
my
$sub
=
''
;
if
(
$r_modifier
) {
if
(0) {
}
elsif
(
$modifier
=~ /g/oxms) {
$sub
=
sprintf
(
q<eval{%s %s_t=%s; %s %s_a=''; while(%s_t =~ %s){%s local $^W=0; %s %s_r=%s; %s%s_t="%s_a${1}%s_r$'"; pos(%s_t)=length "%s_a${1}%s_r"; %s_a=substr(%s_t,0,pos(%s_t)); } return %s_t}>
,
$local
,
$variable_basename
,
$variable
,
$local
,
$variable_basename
,
$variable_basename
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
);
}
elsif
(
$modifier
=~ /g/oxms) {
$sub
=
sprintf
(
q<eval{%s %s_t=%s; while(%s_t =~ %s){%s local $^W=0; %s %s_r=%s; %s%s_t="$`%s_r$'"; pos(%s_t)=length "$`%s_r"; } return %s_t}>
,
$local
,
$variable_basename
,
$variable
,
$variable_basename
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
);
}
else
{
my
$prematch
=
q{$`}
;
$prematch
=
q{${1}
};
$sub
=
sprintf
(
q<(%s =~ %s) ? eval{%s local $^W=0; %s %s_r=%s; %s"%s%s_r$'" } : %s>
,
$variable
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$prematch
,
$variable_basename
,
$variable
,
);
}
if
(
$bind_operator
=~ / !~ /oxms) {
$sub
=
q{die("$0: Using !~ with s///r doesn't make sense"), }
.
$sub
;
}
}
else
{
if
(0) {
}
elsif
(
$modifier
=~ /g/oxms) {
$sub
=
sprintf
(
q<eval{%s %s_n=0; %s %s_a=''; while(%s =~ %s){%s local $^W=0; %s %s_r=%s; %s%s="%s_a${1}%s_r$'"; pos(%s)=length "%s_a${1}%s_r"; %s_a=substr(%s,0,pos(%s)); %s_n++} return %s%s_n}>
,
$local
,
$variable_basename
,
$local
,
$variable_basename
,
$variable
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$variable
,
$variable_basename
,
$variable_basename
,
$variable
,
$variable_basename
,
$variable_basename
,
$variable_basename
,
$variable
,
$variable
,
$variable_basename
,
(
$bind_operator
=~ / !~ /oxms) ?
'!'
:
''
,
$variable_basename
,
);
}
elsif
(
$modifier
=~ /g/oxms) {
$sub
=
sprintf
(
q<eval{%s %s_n=0; while(%s =~ %s){%s local $^W=0; %s %s_r=%s; %s%s="$`%s_r$'"; pos(%s)=length "$`%s_r"; %s_n++} return %s%s_n}>
,
$local
,
$variable_basename
,
$variable
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$variable
,
$variable_basename
,
$variable
,
$variable_basename
,
$variable_basename
,
(
$bind_operator
=~ / !~ /oxms) ?
'!'
:
''
,
$variable_basename
,
);
}
else
{
my
$prematch
=
q{$`}
;
$prematch
=
q{${1}
};
$sub
=
sprintf
(
(
$bind_operator
=~ / =~ /oxms) ?
q<(%s%s%s) ? eval{%s local $^W=0; %s %s_r=%s; %s%s="%s%s_r$'"; 1 } : undef>
:
q<(%s%s%s) ? 1 : eval{%s local $^W=0; %s %s_r=%s; %s%s="%s%s_r$'"; undef }>
,
$variable
,
$bind_operator
,
(
$delimiter1
eq
"'"
) ?
e_s1_q(
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
) :
e_s1 (
'm'
,
$delimiter1
,
$end_delimiter1
,
$pattern
,
$modifier
),
$s_matched
,
$local
,
$variable_basename
,
$e_replacement
,
sprintf
(
'%s_r=eval %s_r; '
,
$variable_basename
,
$variable_basename
) x
$e_modifier
,
$variable
,
$prematch
,
$variable_basename
,
);
}
}
if
(
$my
ne
''
) {
$sub
=
"($my, $sub)[1]"
;
}
$sub_variable
=
''
;
$bind_operator
=
''
;
return
$sub
;
}
sub
e_split {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$modifier
=~
tr
/bB//d) {
return
join
''
,
'split'
,
$ope
,
$delimiter
,
$string
,
$end_delimiter
,
$modifier
;
}
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
$metachar
=
qr/[\@\\|[\]{^]/
oxms;
my
@char
=
$string
=~ /\G(
\\o\{ [0-7]+ \} |
\\ [0-7]{2,3} |
\\x\{ [0-9A-Fa-f]+ \} |
\\x [0-9A-Fa-f]{1,2} |
\\c [\x40-\x5F] |
\\N\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\p\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\P\{ [^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]* \} |
\\ (?:
$q_char
) |
\$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} |
\$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} |
\$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} |
[\$\@]
$qq_variable
|
\$ \s* \d+ |
\$ \s* \{ \s* \d+ \s* \} |
\$ \$ (?![\w\{]) |
\$ \s* \$ \s*
$qq_variable
|
\[\:\^ (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\: (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|
print
|punct|space|upper|word|xdigit) :\] |
\[\^ |
\(\? |
(?:
$q_char
)
)/oxmsg;
my
$left_e
= 0;
my
$right_e
= 0;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
((
$char
[
$i
] eq
'\L'
) and (
$char
[
$i
+1] eq
'\u'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
((
$char
[
$i
] eq
'\U'
) and (
$char
[
$i
+1] eq
'\l'
)) {
@char
[
$i
,
$i
+1] =
@char
[
$i
+1,
$i
];
}
elsif
(
$char
[
$i
] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::octchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) {
$char
[
$i
] = Eeucjp::hexchr($1);
}
elsif
(
$char
[
$i
] =~ /\A \\ (N) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (p) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ (P) ( \{ ([^\x8E\x8F\xA1-\xFE0-9\}][^\x8E\x8F\xA1-\xFE\}]*) \} ) \z/oxms) {
$char
[
$i
] = $1 .
'\\'
. $2;
}
elsif
(
$char
[
$i
] =~ /\A \\ ( [pPX] ) \z/oxms) {
$char
[
$i
] = $1;
}
if
(0) {
}
elsif
(
$char
[
$i
] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) {
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 (
eval
(
sprintf
'"%s%s%s%s"'
,
@char
[
$i
..
$i
+3]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 3;
}
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 (
eval
(
sprintf
'"%s%s%s"'
,
@char
[
$i
..
$i
+2]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 2;
}
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 (
eval
(
sprintf
'"%s%s"'
,
@char
[
$i
..
$i
+1]) =~ /\A
$q_char
\z/oxms)) {
$char
[
$i
] .=
join
''
,
splice
@char
,
$i
+1, 1;
}
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
if
(
grep
(/\A [\$\@]/oxms,
@char
[
$left
+1..
$right
-1]) >= 1) {
splice
@char
,
$left
,
$right
-
$left
+1,
sprintf
(
q{@{[Eeucjp::charlist_not_qr(%s,'%s')]}
},
join
(
','
,
map
{qq_stuff(
$delimiter
,
$end_delimiter
,
$_
)}
@char
[
$left
+1..
$right
-1]),
$modifier
);
}
else
{
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
}
$i
=
$left
;
last
;
}
}
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
((
$char
[
$i
] eq
'^'
) and (
$modifier
!~ /m/oxms)) {
$modifier
.=
'm'
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ([<>]) \z/oxms) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'\\'
.
$char
[
$i
];
}
}
elsif
(
$char
[
$i
] eq
'\u'
) {
$char
[
$i
] =
'@{[Eeucjp::ucfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\l'
) {
$char
[
$i
] =
'@{[Eeucjp::lcfirst qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\U'
) {
$char
[
$i
] =
'@{[Eeucjp::uc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\L'
) {
$char
[
$i
] =
'@{[Eeucjp::lc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\F'
) {
$char
[
$i
] =
'@{[Eeucjp::fc qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
$char
[
$i
] =
'@{[CORE::quotemeta qq<'
;
$left_e
++;
}
elsif
(
$char
[
$i
] eq
'\E'
) {
if
(
$right_e
<
$left_e
) {
$char
[
$i
] =
'>]}'
;
$right_e
++;
}
else
{
$char
[
$i
] =
''
;
}
}
elsif
(
$char
[
$i
] eq
'\Q'
) {
while
(1) {
if
(++
$i
>
$#char
) {
last
;
}
if
(
$char
[
$i
] eq
'\E'
) {
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'\E'
) {
}
elsif
(
$char
[
$i
] =~ /\A \$ 0 \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* 0 \s* \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$\$ \z/oxms) {
}
elsif
(
$char
[
$i
] =~ /\A \$ ([1-9][0-9]*) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \{ \s* ([1-9][0-9]*) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \[ (?:
$qq_bracket
)*? \] ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) ( \{ (?:
$qq_brace
)*? \} ) \z/oxms) {
$char
[
$i
] = e_capture($1.
'->'
.$2);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ ( \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$` | \$\{`\} | \$ \s* PREMATCH | \$ \s* \{ \s* PREMATCH \s* \} | \$ \s* \{\^PREMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::PREMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::PREMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$& | \$\{&\} | \$ \s* MATCH | \$ \s* \{ \s* MATCH \s* \} | \$ \s* \{\^MATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::MATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::MATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A ( \$ \s* POSTMATCH | \$ \s* \{ \s* POSTMATCH \s* \} | \$ \s* \{\^POSTMATCH\} ) \z/oxmsgc) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase(Eeucjp::POSTMATCH())]}'
;
}
else
{
$char
[
$i
] =
'@{[Eeucjp::POSTMATCH()]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ ( \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) {
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
. $1 .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A \$ \s* \{ \s* ( .+ ) \s* \} \z/oxms) {
$char
[
$i
] = e_capture($1);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
(
$char
[
$i
] =~ /\A [\$\@].+ /oxms) {
$char
[
$i
] = e_string(
$char
[
$i
]);
if
(
$ignorecase
) {
$char
[
$i
] =
'@{[Eeucjp::ignorecase('
.
$char
[
$i
] .
')]}'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) {
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
$modifier
=~
tr
/i//d;
if
(
$left_e
>
$right_e
) {
return
join
''
,
'Eeucjp::split'
,
$ope
,
$delimiter
,
@char
,
'>]}'
x (
$left_e
-
$right_e
),
$end_delimiter
,
$modifier
;
}
return
join
''
,
'Eeucjp::split'
,
$ope
,
$delimiter
,
@char
,
$end_delimiter
,
$modifier
;
}
sub
e_split_q {
my
(
$ope
,
$delimiter
,
$end_delimiter
,
$string
,
$modifier
) =
@_
;
$modifier
||=
''
;
$modifier
=~
tr
/p//d;
if
(
$modifier
=~ /([adlu])/oxms) {
my
$line
= 0;
for
(
my
$i
=0;
my
(
$package
,
$filename
,
$use_line
,
$subroutine
) =
caller
(
$i
);
$i
++) {
if
(
$filename
ne __FILE__) {
$line
=
$use_line
+ (CORE::
substr
(
$_
,0,
pos
(
$_
)) =~
tr
/\n//) + 1;
last
;
}
}
die
qq{Unsupported modifier "$1" used at line $line.\n}
;
}
$slash
=
'div'
;
if
(
$modifier
=~
tr
/bB//d) {
return
join
''
,
'split'
,
$ope
,
$delimiter
,
$string
,
$end_delimiter
,
$modifier
;
}
my
$ignorecase
= (
$modifier
=~ /i/oxms) ? 1 : 0;
my
@char
=
$string
=~ /\G(
\[\:\^ [a-z]+ \:\] |
\[\: [a-z]+ \:\] |
\[\^ |
\\? (?:
$q_char
)
)/oxmsg;
for
(
my
$i
=0;
$i
<=
$#char
;
$i
++) {
if
(0) {
}
elsif
(
$char
[
$i
] eq
'['
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
$char
[
$i
] eq
'[^'
) {
my
$left
=
$i
;
if
(
$char
[
$i
+1] eq
']'
) {
$i
++;
}
while
(1) {
if
(++
$i
>
$#char
) {
die
__FILE__,
": Unmatched [] in regexp"
;
}
if
(
$char
[
$i
] eq
']'
) {
my
$right
=
$i
;
splice
@char
,
$left
,
$right
-
$left
+1, Eeucjp::charlist_not_qr(
@char
[
$left
+1..
$right
-1],
$modifier
);
$i
=
$left
;
last
;
}
}
}
elsif
(
my
$char
= character_class(
$char
[
$i
],
$modifier
)) {
$char
[
$i
] =
$char
;
}
elsif
((
$char
[
$i
] eq
'^'
) and (
$modifier
!~ /m/oxms)) {
$modifier
.=
'm'
;
}
elsif
(
$ignorecase
and (
$char
[
$i
] =~ /\A [\x00-\xFF] \z/oxms) and (Eeucjp::
uc
(
$char
[
$i
]) ne Eeucjp::fc(
$char
[
$i
]))) {
if
(CORE::
length
(Eeucjp::fc(
$char
[
$i
])) == 1) {
$char
[
$i
] =
'['
. Eeucjp::
uc
(
$char
[
$i
]) . Eeucjp::fc(
$char
[
$i
]) .
']'
;
}
else
{
$char
[
$i
] =
'(?:'
. Eeucjp::
uc
(
$char
[
$i
]) .
'|'
. Eeucjp::fc(
$char
[
$i
]) .
')'
;
}
}
elsif
((
$i
>= 1) and (
$char
[
$i
] =~ /\A [\?\+\*\{] \z/oxms)) {
if
(
$char
[
$i
-1] =~ /\A [\x00-\xFF] \z/oxms) {
}
else
{
$char
[
$i
-1] =
'(?:'
.
$char
[
$i
-1] .
')'
;
}
}
}
$modifier
=~
tr
/i//d;
return
join
''
,
'Eeucjp::split'
,
$ope
,
$delimiter
,
@char
,
$end_delimiter
,
$modifier
;
}
1;