Change 30073 by [EMAIL PROTECTED] on 2007/01/29 22:44:03

        Integrate:
        [ 29311]
        Subject: [perl #18209] bug in regex s/\s$word\s/ /gi; and $& 
        From: "yves orton via RT" <[EMAIL PROTECTED]>
        Date: Fri, 17 Nov 2006 10:17:48 -0800
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 29312]
        Subject: [perl #18209] bug in regex s/\s$word\s/ /gi; and $& 
        From: "yves orton via RT" <[EMAIL PROTECTED]>
        Date: Fri, 17 Nov 2006 10:17:48 -0800
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/maint-5.8/perl/mg.c#144 integrate
... //depot/maint-5.8/perl/t/op/pat.t#37 edit

Differences ...

==== //depot/maint-5.8/perl/mg.c#144 (text) ====
Index: perl/mg.c
--- perl/mg.c#143~30071~        2007-01-29 14:30:00.000000000 -0800
+++ perl/mg.c   2007-01-29 14:44:03.000000000 -0800
@@ -496,9 +496,18 @@
     if (PL_curpm) {
        register const REGEXP * const rx = PM_GETRE(PL_curpm);
        if (rx) {
-           return mg->mg_obj
-               ? rx->nparens       /* @+ */
-               : rx->lastparen;    /* @- */
+           if (mg->mg_obj) {                   /* @+ */
+               /* return the number possible */
+               return rx->nparens;
+           } else {                            /* @- */
+               I32 paren = rx->lastparen;
+
+               /* return the last filled */
+               while ( paren >= 0 &&
+                   rx->startp[paren] == -1 || rx->endp[paren] == -1)
+               paren--;
+               return (U32)paren;
+           }
        }
     }
 

==== //depot/maint-5.8/perl/t/op/pat.t#37 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t#36~30070~   2007-01-29 14:12:03.000000000 -0800
+++ perl/t/op/pat.t     2007-01-29 14:44:03.000000000 -0800
@@ -7,7 +7,7 @@
 $| = 1;
 
 # please update note at bottom of file when you change this
-print "1..1219\n";
+print "1..1222\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -3474,5 +3474,30 @@
        iseq($l+1,$count,"Should be L+1 not L*(L+3)/2 (L=$l)");
     }
 }
+{
+    local $Message = "RT#22614";
+    local $_='ab';
+    our @len=();
+    /(.){1,}(?{push @len,[EMAIL PROTECTED])(.){1,}(?{})^/;
+    iseq("@len","2 2 2");
+}
+{
+    local $Message = "RT#18209";
+    my $text = ' word1 word2 word3 word4 word5 word6 ';
+
+    my @words = ('word1', 'word3', 'word5');
+    my $count;
+    foreach my $word (@words){
+        $text =~ s/$word\s//gi; # Leave a space to seperate words in the 
resultant str.
+        # The following block is not working.
+        if($&){
+            $count++;
+        }
+        # End bad block
+    }
+    iseq($count,3);
+    iseq($text,' word2 word4 word6 ');
+}
+
 
-# last test 1219
+# last test 1222
End of Patch.

Reply via email to