summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-05-23 20:25:45 +0100
committerDavid Mitchell <davem@iabyn.com>2015-06-19 08:44:17 +0100
commitd3e5e568e186db1fcbf1fee0ea8e4e265b90f686 (patch)
tree18ae79f447f70838a6b250d08b080b3b2c9cff90 /pp_ctl.c
parent5ad25bdcb978e712488e7c2656949d6efd14e0b5 (diff)
downloadperl-d3e5e568e186db1fcbf1fee0ea8e4e265b90f686.tar.gz
pp_last: only handle loop context types
pp_last pops to the next relevant loop context type, or croaks. Yet once it does this, it attempts to handle *all* context types (subs, evals etc), even those which can never be the current context. Rip all this dead code out, and replace with an assertion that the context is one of the loop types. This dead code has been there since 5.000.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c51
1 files changed, 10 insertions, 41 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 6490140822..f26beb90b2 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2595,42 +2595,23 @@ S_unwind_loop(pTHX_ const char * const opname)
PP(pp_last)
{
PERL_CONTEXT *cx;
- I32 pop2 = 0;
I32 gimme;
- I32 optype;
OP *nextop = NULL;
SV **newsp;
PMOP *newpm;
- SV *sv = NULL;
S_unwind_loop(aTHX_ "last");
POPBLOCK(cx,newpm);
cxstack_ix++; /* temporarily protect top context */
- switch (CxTYPE(cx)) {
- case CXt_LOOP_LAZYIV:
- case CXt_LOOP_LAZYSV:
- case CXt_LOOP_FOR:
- case CXt_LOOP_PLAIN:
- pop2 = CxTYPE(cx);
- newsp = PL_stack_base + cx->blk_loop.resetsp;
- nextop = cx->blk_loop.my_op->op_lastop->op_next;
- break;
- case CXt_SUB:
- pop2 = CXt_SUB;
- nextop = cx->blk_sub.retop;
- break;
- case CXt_EVAL:
- POPEVAL(cx);
- nextop = cx->blk_eval.retop;
- break;
- case CXt_FORMAT:
- POPFORMAT(cx);
- nextop = cx->blk_sub.retop;
- break;
- default:
- DIE(aTHX_ "panic: last, type=%u", (unsigned) CxTYPE(cx));
- }
+ assert(
+ CxTYPE(cx) == CXt_LOOP_LAZYIV
+ || CxTYPE(cx) == CXt_LOOP_LAZYSV
+ || CxTYPE(cx) == CXt_LOOP_FOR
+ || CxTYPE(cx) == CXt_LOOP_PLAIN
+ );
+ newsp = PL_stack_base + cx->blk_loop.resetsp;
+ nextop = cx->blk_loop.my_op->op_lastop->op_next;
TAINT_NOT;
PL_stack_sp = newsp;
@@ -2638,22 +2619,10 @@ PP(pp_last)
LEAVE;
cxstack_ix--;
/* Stack values are safe: */
- switch (pop2) {
- case CXt_LOOP_LAZYIV:
- case CXt_LOOP_PLAIN:
- case CXt_LOOP_LAZYSV:
- case CXt_LOOP_FOR:
- POPLOOP(cx); /* release loop vars ... */
- LEAVE;
- break;
- case CXt_SUB:
- POPSUB(cx,sv); /* release CV and @_ ... */
- break;
- }
+ POPLOOP(cx); /* release loop vars ... */
+ LEAVE;
PL_curpm = newpm; /* ... and pop $1 et al */
- LEAVESUB(sv);
- PERL_UNUSED_VAR(optype);
PERL_UNUSED_VAR(gimme);
return nextop;
}