Change 31733 by [EMAIL PROTECTED] on 2007/08/18 11:15:19
TRIE must use 'yes' state transitions when more than one match possible
to ensure proper scope cleanup.
Fix and test for issue raised in:
Subject: Very strange interaction between regex and lexical array in
blead
From: Marcus Holland-Moritz <[EMAIL PROTECTED]>
Date: Sat, 18 Aug 2007 01:55:37 +0200
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/regexec.c#544 edit
... //depot/perl/regnodes.h#45 edit
... //depot/perl/t/op/pat.t#292 edit
Differences ...
==== //depot/perl/regexec.c#544 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#543~31455~ 2007-06-24 08:46:40.000000000 -0700
+++ perl/regexec.c 2007-08-18 04:15:19.000000000 -0700
@@ -2937,7 +2937,7 @@
if ( got_wordnum ) {
if ( ! ST.accepted ) {
ENTER;
- SAVETMPS;
+ /* SAVETMPS; */ /* XXX is this necessary? dmq */
bufflen = TRIE_INITAL_ACCEPT_BUFFLEN;
sv_accept_buff=newSV(bufflen *
sizeof(reg_trie_accepted) - 1);
@@ -3148,18 +3148,10 @@
PL_reginput = (char *)ST.accept_buff[ best ].endpos;
if ( !ST.jump || !ST.jump[ST.accept_buff[best].wordnum]) {
scan = ST.B;
- /* NOTREACHED */
} else {
scan = ST.me + ST.jump[ST.accept_buff[best].wordnum];
- /* NOTREACHED */
- }
- if (has_cutgroup) {
- PUSH_YES_STATE_GOTO(TRIE_next, scan);
- /* NOTREACHED */
- } else {
- PUSH_STATE_GOTO(TRIE_next, scan);
- /* NOTREACHED */
}
+ PUSH_YES_STATE_GOTO(TRIE_next, scan);
/* NOTREACHED */
}
/* NOTREACHED */
==== //depot/perl/regnodes.h#45 (text+w) ====
Index: perl/regnodes.h
--- perl/regnodes.h#44~31506~ 2007-06-30 08:37:41.000000000 -0700
+++ perl/regnodes.h 2007-08-18 04:15:19.000000000 -0700
@@ -625,7 +625,7 @@
EXTCONST char * PL_reg_extflags_name[];
#else
EXTCONST char * const PL_reg_extflags_name[] = {
- /* Bits in extflags defined: 10111111111111111111111100111111 */
+ /* Bits in extflags defined: 11111111111111111111111100111111 */
"ANCH_BOL", /* 0x00000001 */
"ANCH_MBOL", /* 0x00000002 */
"ANCH_SBOL", /* 0x00000004 */
@@ -656,7 +656,7 @@
"SPLIT", /* 0x08000000 */
"COPY_DONE", /* 0x10000000 */
"TAINTED_SEEN", /* 0x20000000 */
- "UNUSED_BIT_30", /* 0x40000000 */
+ "NULL", /* 0x40000000 */
"TAINTED", /* 0x80000000 */
};
#endif /* DOINIT */
==== //depot/perl/t/op/pat.t#292 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t#291~31451~ 2007-06-23 12:04:04.000000000 -0700
+++ perl/t/op/pat.t 2007-08-18 04:15:19.000000000 -0700
@@ -4459,6 +4459,25 @@
$_ = '123';
iseq("$1",'abc',"/g leads to unsafe match vars: $1");
}
+{
+ local $Message="Message-ID: <[EMAIL PROTECTED]>";
+ my $str= "";
+ for(0..5){
+ my @x;
+ $str .= "@x"; # this should ALWAYS be the empty string
+ 'a'=~/(a|)/;
+ push @x,1;
+ }
+ iseq(length($str),"0","Trie scope error, string should be empty");
+ $str="";
+ my @foo = ('a')x5;
+ for (@foo) {
+ my @bar;
+ $str .= "@bar";
+ s/a|/push @bar, 1/e;
+ }
+ iseq(length($str),"0","Trie scope error, string should be empty");
+}
# Test counter is at bottom of file. Put new tests above here.
#-------------------------------------------------------------------
@@ -4509,6 +4528,6 @@
iseq(0+$::test,$::TestCount,"Got the right number of tests!");
# Don't forget to update this!
BEGIN {
- $::TestCount = 1961;
+ $::TestCount = 1963;
print "1..$::TestCount\n";
}
End of Patch.