Change 30011 by [EMAIL PROTECTED] on 2007/01/26 14:31:27
Integrate:
[ 28370]
Revert change #20462 (except the regression test),
since the bug has been really fixed by change #22074,
as explained in :
Subject: Re: [perl #39247] defined-ness of substrings disappear over
repeated calls
From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
Date: Thu, 01 Jun 2006 08:16:51 +0900
Message-Id: <[EMAIL PROTECTED]>
[ 28548]
Revert bogus fix for bug #27940, which wasn't really a bug,
and a new test item, as found and suggested by Sadahiro Tomoyuki.
[ 28620]
Subject: interpolation of @- (and @+) in patterns ([perl #27940] comes
back)
From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
Date: Tue, 25 Jul 2006 00:15:50 +0900
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
... //depot/maint-5.8/perl/pod/perlop.pod#29 integrate
... //depot/maint-5.8/perl/pp.c#130 integrate
... //depot/maint-5.8/perl/t/op/pat.t#35 integrate
... //depot/maint-5.8/perl/t/op/subst.t#11 integrate
... //depot/maint-5.8/perl/t/op/tr.t#5 integrate
... //depot/maint-5.8/perl/toke.c#155 integrate
Differences ...
==== //depot/maint-5.8/perl/pod/perlop.pod#29 (text) ====
Index: perl/pod/perlop.pod
--- perl/pod/perlop.pod#28~26628~ 2006-01-03 13:34:41.000000000 -0800
+++ perl/pod/perlop.pod 2007-01-26 06:31:27.000000000 -0800
@@ -1826,10 +1826,10 @@
performed whatsoever. This is the first step at which the presence
of the C<//x> modifier is relevant.
-Interpolation has several quirks: C<$|>, C<$(>, and C<$)> are not
-interpolated, and constructs C<$var[SOMETHING]> are voted (by several
-different estimators) to be either an array element or C<$var>
-followed by an RE alternative. This is where the notation
+Interpolation in patterns has several quirks: C<$|>, C<$(>, C<$)>, C<@+>
+and C<@-> are not interpolated, and constructs C<$var[SOMETHING]> are
+voted (by several different estimators) to be either an array element
+or C<$var> followed by an RE alternative. This is where the notation
C<${arr[$bar]}> comes handy: C</${arr[0-9]}/> is interpreted as
array element C<-9>, not as a regular expression from the variable
C<$arr> followed by a digit, which would be the interpretation of
==== //depot/maint-5.8/perl/pp.c#130 (text) ====
Index: perl/pp.c
--- perl/pp.c#129~29997~ 2007-01-26 02:30:23.000000000 -0800
+++ perl/pp.c 2007-01-26 06:31:27.000000000 -0800
@@ -3126,8 +3126,6 @@
sv_upgrade(TARG, SVt_PVLV);
sv_magic(TARG, NULL, PERL_MAGIC_substr, NULL, 0);
}
- else
- SvOK_off(TARG);
LvTYPE(TARG) = 'x';
if (LvTARG(TARG) != sv) {
==== //depot/maint-5.8/perl/t/op/pat.t#35 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t#34~29770~ 2007-01-12 04:22:53.000000000 -0800
+++ perl/t/op/pat.t 2007-01-26 06:31:27.000000000 -0800
@@ -6,7 +6,8 @@
$| = 1;
-print "1..1195\n";
+# please update note at bottom of file when you change this
+print "1..1215\n";
BEGIN {
chdir 't' if -d 't';
@@ -3301,6 +3302,7 @@
ok("a\cBb" =~ /[\cA-\cC]/, '\cB in character class range');
ok("a\cCbc" =~ /[^\cA-\cB]/, '\cC in negated character class range');
ok("a\cAb" =~ /(??{"\cA"})/, '\cA in ??{} pattern');
+ok("ab" !~ /a\cIb/x, '\cI in pattern');
# perl #28532: optional zero-width match at end of string is ignored
ok(("abc" =~ /^abc(\z)?/) && defined($1),
@@ -3416,5 +3418,31 @@
"# assigning to original string should not corrupt match vars");
}
-# last test 1195
+{ # related to [perl #27940]
+ ok("\0-A" =~ /[EMAIL PROTECTED]/, '@- should not be interpolated in a
pattern');
+ ok("\0\0A" =~ /[EMAIL PROTECTED]/, '@+ should not be interpolated in a
pattern');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/, '@- should not be
interpolated in a pattern');
+ ok("[EMAIL PROTECTED]@A" =~ /[EMAIL PROTECTED]/, '@+ should not be
interpolated in a pattern');
+
+ ok("X\0A" =~ /[EMAIL PROTECTED]/, '[EMAIL PROTECTED]');
+ ok("X\0A" =~ /[EMAIL PROTECTED]/, '[EMAIL PROTECTED]');
+ ok("X\0A" =~ /X\c@(A)/, '\c@(');
+ ok("X\0A" =~ /X(\c@)A/, '\c@)');
+ ok("X\0A" =~ /X\c@|ZA/, '\c@|');
+
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/, '@?');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/, '@*');
+ ok("[EMAIL PROTECTED]" =~ /X@(A)/, '@(');
+ ok("[EMAIL PROTECTED]" =~ /X(@)A/, '@)');
+ ok("[EMAIL PROTECTED]" =~ /X@|ZA/, '@|');
+
+ local $" = ','; # non-whitespace and non-RE-specific
+ ok('abc' =~ /(.)(.)(.)/, 'the last successful match is bogus');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/, 'interpolation of @+ in
/@{+}/');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/, 'interpolation of @- in
/@{-}/');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/x, 'interpolation of @+ in
/@{+}/x');
+ ok("[EMAIL PROTECTED]" =~ /[EMAIL PROTECTED]/x, 'interpolation of @- in
/@{-}/x');
+}
+
+# last test 1215
==== //depot/maint-5.8/perl/t/op/subst.t#11 (xtext) ====
Index: perl/t/op/subst.t
--- perl/t/op/subst.t#10~25569~ 2005-09-22 05:44:27.000000000 -0700
+++ perl/t/op/subst.t 2007-01-26 06:31:27.000000000 -0800
@@ -7,7 +7,7 @@
}
require './test.pl';
-plan( tests => 131 );
+plan( tests => 133 );
$x = 'foo';
$_ = "x";
@@ -553,3 +553,13 @@
}
+{ # [perl #27940] perlbug: [\x00-\x1f] works, [EMAIL PROTECTED] does not
+ my $c;
+
+ ($c = "[EMAIL PROTECTED]") =~ s/[EMAIL PROTECTED]//g;
+ is($c, "\x20\x30\x40\x50\x60", "s/[EMAIL PROTECTED]//g");
+
+ ($c = "\x20\x00\x30\x01\x40\x1A\x50\x1F\x60") =~ s/[\x00-\x1f]//g;
+ is($c, "\x20\x30\x40\x50\x60", "s/[\\x00-\\x1f]//g");
+}
+
==== //depot/maint-5.8/perl/t/op/tr.t#5 (xtext) ====
Index: perl/t/op/tr.t
--- perl/t/op/tr.t#4~26584~ 2006-01-02 12:28:21.000000000 -0800
+++ perl/t/op/tr.t 2007-01-26 06:31:27.000000000 -0800
@@ -6,7 +6,7 @@
require './test.pl';
}
-plan tests => 100;
+plan tests => 102;
my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1);
@@ -384,3 +384,13 @@
# rt.perl.org 36622. Perl didn't like a y/// at end of file. No trailing
# newline allowed.
fresh_perl_is(q[$_ = "foo"; y/A-Z/a-z/], '');
+{ # related to [perl #27940]
+ my $c;
+
+ ($c = "[EMAIL PROTECTED]") =~ tr/[EMAIL PROTECTED]//d;
+ is($c, "\x20\x30\x40\x50\x60", "tr/[EMAIL PROTECTED]//d");
+
+ ($c = "\x20\x00\x30\x01\x40\x1A\x50\x1F\x60") =~ tr/\x00-\x1f//d;
+ is($c, "\x20\x30\x40\x50\x60", "tr/\\x00-\\x1f//d");
+}
+
==== //depot/maint-5.8/perl/toke.c#155 (text) ====
Index: perl/toke.c
--- perl/toke.c#154~30007~ 2007-01-26 05:50:55.000000000 -0800
+++ perl/toke.c 2007-01-26 06:31:27.000000000 -0800
@@ -1441,7 +1441,7 @@
const char * const leaveit = /* set of acceptably-backslashed characters */
PL_lex_inpat
- ? "[EMAIL PROTECTED]|()-nrtfeaxz0123456789[{]} \t\n\r\f\v#"
+ ? "[EMAIL PROTECTED]|()-nrtfeaxcz0123456789[{]} \t\n\r\f\v#"
: "";
if (PL_lex_inwhat == OP_TRANS && PL_sublex_info.sub_op) {
@@ -1577,9 +1577,14 @@
/* check for embedded arrays
(@foo, @::foo, @'foo, @{foo}, @$foo, @+, @-)
*/
- else if (*s == '@' && s[1]
- && (isALNUM_lazy_if(s+1,UTF) || strchr(":'{$+-", s[1])))
- break;
+ else if (*s == '@' && s[1]) {
+ if (isALNUM_lazy_if(s+1,UTF))
+ break;
+ if (strchr(":'{$", s[1]))
+ break;
+ if (!PL_lex_inpat && (s[1] == '+' || s[1] == '-'))
+ break; /* in regexp, neither @+ nor @- are interpolated */
+ }
/* check for embedded scalars. only stop if we're sure it's a
variable.
End of Patch.