Change 30200 by [EMAIL PROTECTED] on 2007/02/10 20:41:31
Subject: Re: [NL-PM] Fw: [PATCH - provisional] H. Merijn Brands idea of
buffer numbering.
From: demerphq <[EMAIL PROTECTED]>
Date: Sat, 10 Feb 2007 21:31:55 +0100
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/regcomp.c#553 edit
... //depot/perl/t/op/pat.t#278 edit
Differences ...
==== //depot/perl/regcomp.c#553 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#552~30184~ 2007-02-09 12:06:44.000000000 -0800
+++ perl/regcomp.c 2007-02-10 12:41:31.000000000 -0800
@@ -5168,11 +5168,26 @@
Perl_croak(aTHX_
"panic: paren_name hash element allocation
failed");
} else if ( SvPOK(sv_dat) ) {
- IV count=SvIV(sv_dat);
- I32
*pv=(I32*)SvGROW(sv_dat,SvCUR(sv_dat)+sizeof(I32)+1);
- SvCUR_set(sv_dat,SvCUR(sv_dat)+sizeof(I32));
- pv[count]=RExC_npar;
- SvIVX(sv_dat)++;
+ /* (?|...) can mean we have dupes so scan to check
+ its already been stored. Maybe a flag indicating
+ we are inside such a construct would be useful,
+ but the arrays are likely to be quite small, so
+ for now we punt -- dmq */
+ IV count = SvIV(sv_dat);
+ I32 *pv = (I32*)SvPVX(sv_dat);
+ IV i;
+ for ( i = 0 ; i < count ; i++ ) {
+ if ( pv[i] == RExC_npar ) {
+ count = 0;
+ break;
+ }
+ }
+ if ( count ) {
+ pv = (I32*)SvGROW(sv_dat, SvCUR(sv_dat) +
sizeof(I32)+1);
+ SvCUR_set(sv_dat, SvCUR(sv_dat) + sizeof(I32));
+ pv[count] = RExC_npar;
+ SvIVX(sv_dat)++;
+ }
} else {
(void)SvUPGRADE(sv_dat,SVt_PVNV);
sv_setpvn(sv_dat, (char *)&(RExC_npar),
sizeof(I32));
==== //depot/perl/t/op/pat.t#278 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t#277~30148~ 2007-02-06 13:54:12.000000000 -0800
+++ perl/t/op/pat.t 2007-02-10 12:41:31.000000000 -0800
@@ -4299,6 +4299,22 @@
}
}
+{
+ my $res="";
+
+ if ('1' =~ /(?|(?<digit>1)|(?<digit>2))/) {
+ $res = "@{$- {digit}}";
+ }
+ iseq($res,"1",
+ "Check that (?|...) doesnt cause dupe entries in the names array");
+ #---
+ $res="";
+ if ('11' =~ /(?|(?<digit>1)|(?<digit>2))(?&digit)/) {
+ $res = "@{$- {digit}}";
+ }
+ iseq($res, "1",
+ "Check that (?&..) to a buffer inside a (?|...) goes to the leftmost");
+}
# Test counter is at bottom of file. Put new tests above here.
#-------------------------------------------------------------------
@@ -4349,7 +4365,7 @@
iseq(0+$::test,$::TestCount,"Got the right number of tests!");
# Don't forget to update this!
BEGIN {
- $::TestCount = 1636;
+ $::TestCount = 1638;
print "1..$::TestCount\n";
}
End of Patch.