In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/b1b5a4ae28189de4ce324e4b00842813774490c0?hp=c08f093b3e154c428f604f89f7feb633e6c97869>

- Log -----------------------------------------------------------------
commit b1b5a4ae28189de4ce324e4b00842813774490c0
Author: Vincent Pit <[email protected]>
Date:   Mon Jun 27 09:37:30 2011 +0200

    In leavewhen, put the SP back when returning
    
    It may have changed in adjust_stack_on_leave() if the stack needed to be
    extended.

M       pp_ctl.c

commit 0787ea8aaa88d48f432536f8d8f6658fe8ba47ed
Author: Vincent Pit <[email protected]>
Date:   Mon Jun 27 09:35:57 2011 +0200

    Make sure break() resets the sp at its original level

M       pp_ctl.c
M       t/op/switch.t
-----------------------------------------------------------------------

Summary of changes:
 pp_ctl.c      |    7 ++++---
 t/op/switch.t |   16 +++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index 9eb2814..c5cf973 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4998,8 +4998,7 @@ PP(pp_leavewhen)
        return cx->blk_loop.my_op->op_nextop;
     }
     else
-       /* RETURNOP calls PUTBACK which restores the old old sp */
-       return cx->blk_givwhen.leave_op;
+       RETURNOP(cx->blk_givwhen.leave_op);
 }
 
 PP(pp_continue)
@@ -5045,7 +5044,9 @@ PP(pp_break)
     if (cxix < cxstack_ix)
         dounwind(cxix);
 
-    /* RETURNOP calls PUTBACK which restores the old old sp */
+    /* Restore the sp at the time we entered the given block */
+    TOPBLOCK(cx);
+
     return cx->blk_givwhen.leave_op;
 }
 
diff --git a/t/op/switch.t b/t/op/switch.t
index 7614630..bdf087d 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -9,7 +9,7 @@ BEGIN {
 use strict;
 use warnings;
 
-plan tests => 196;
+plan tests => 197;
 
 # The behaviour of the feature pragma should be tested by lib/feature.t
 # using the tests in t/lib/feature/*. This file tests the behaviour of
@@ -1347,6 +1347,20 @@ unreified_check(undef,"");
     };
 }
 
+# break() must reset the stack
+{
+    my @res = (1, do {
+       given ("x") {
+           2, 3, do {
+               when (/[a-z]/) {
+                   4, 5, 6, break
+               }
+           }
+       }
+    });
+    is "@res", "1", "break resets the stack";
+}
+
 # Okay, that'll do for now. The intricacies of the smartmatch
 # semantics are tested in t/op/smartmatch.t
 __END__

--
Perl5 Master Repository

Reply via email to