Change 13077 by jhi@alpha on 2001/11/18 17:07:12

        Retract 11635: close 20011113.110, reopen 20010809.028.
        
        Tiny problem in the test for 20011113.110: I hope
        'my $x= [("foo") x 1]' was never going to produce [qw(foo foo)] :-)

Affected files ...

.... //depot/perl/pp.c#313 edit
.... //depot/perl/t/op/repeat.t#10 edit

Differences ...

==== //depot/perl/pp.c#313 (text) ====
Index: perl/pp.c
--- perl/pp.c.~1~       Sun Nov 18 10:15:05 2001
+++ perl/pp.c   Sun Nov 18 10:15:05 2001
@@ -1256,10 +1256,33 @@
        MEXTEND(MARK, max);
        if (count > 1) {
            while (SP > MARK) {
+#if 0
+             /* This code was intended to fix 20010809.028:
+
+                $x = 'abcd';
+                for (($x =~ /./g) x 2) {
+                    print chop; # "abcdabcd" expected as output.
+                }
+
+              * but that change (#11635) broke this code:
+
+              $x = [("foo")x2]; # only one "foo" ended up in the anonlist.
+
+              * I can't think of a better fix that doesn't introduce
+              * an efficiency hit by copying the SVs. The stack isn't
+              * refcounted, and mortalisation obviously doesn't
+              * Do The Right Thing when the stack has more than
+              * one pointer to the same mortal value.
+              * .robin.
+              */
                if (*SP) {
                    *SP = sv_2mortal(newSVsv(*SP));
                    SvREADONLY_on(*SP);
                }
+#else
+               if (*SP)
+                  SvTEMP_off((*SP));
+#endif
                SP--;
            }
            MARK++;

==== //depot/perl/t/op/repeat.t#10 (xtext) ====
Index: perl/t/op/repeat.t
--- perl/t/op/repeat.t.~1~      Sun Nov 18 10:15:05 2001
+++ perl/t/op/repeat.t  Sun Nov 18 10:15:05 2001
@@ -6,7 +6,7 @@
 }
 
 require './test.pl';
-plan(tests => 24);
+plan(tests => 25);
 
 # compile time
 
@@ -118,7 +118,18 @@
 
 # perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
 {
-    local $TODO = 'list repeat in anon array ref broken [ID 20011113.110]';
-    my $x= [("foo") x 1];
-    is( join('', @$x), 'foofoo' );
+    my $x= [("foo") x 2];
+    is( join('', @$x), 'foofoo', 'list repeat in anon array ref broken [ID 
+20011113.110]' );
+}
+
+# [ID 20010809.028] x operator not copying elements in 'for' list?
+{
+    local $TODO = "x operator not copying elements in 'for' list? [ID 20010809.028]";
+    my $x = 'abcd';
+    my $y = '';
+    for (($x =~ /./g) x 2) {
+       $y .= chop;
+    }
+    is($y, 'abcdabcd');
 }
+
End of Patch.

Reply via email to