summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2017-12-06 13:44:32 -0800
committerFather Chrysostomos <sprout@cpan.org>2017-12-10 10:33:23 -0800
commitb537774295099f6b543a9e2b7375f72593328389 (patch)
tree471f785405bd6976e3be12e7ae6d0c38b27ca2c0 /pp_ctl.c
parent436908e565f0e613465123e7cb08fa54487c3b8f (diff)
downloadperl-b537774295099f6b543a9e2b7375f72593328389.tar.gz
pp_ctl.c: Move goto-into-foreach error
Put it in a static function, instead of repeating the code. This way I can add more conditions to that code in subsequent commits.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 4026d4d579..f5ae9e3b96 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2709,6 +2709,17 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
}
+static void
+S_check_op_type(pTHX_ OP * const o)
+{
+ /* Eventually we may want to stack the needed arguments
+ * for each op. For now, we punt on the hard ones. */
+ /* XXX This comment seems to me like wishful thinking. --sprout */
+ if (o->op_type == OP_ENTERITER)
+ Perl_croak(aTHX_
+ "Can't \"goto\" into the middle of a foreach loop");
+}
+
/* also used for: pp_dump() */
PP(pp_goto)
@@ -3050,8 +3061,7 @@ PP(pp_goto)
if (leaving_eval && *enterops && enterops[1]) {
I32 i;
for (i = 1; enterops[i]; i++)
- if (enterops[i]->op_type == OP_ENTERITER)
- DIE(aTHX_ "Can't \"goto\" into the middle of a foreach loop");
+ S_check_op_type(aTHX_ enterops[i]);
}
if (*enterops && enterops[1]) {
@@ -3077,10 +3087,7 @@ PP(pp_goto)
ix = enterops[1]->op_type == OP_ENTER && in_block ? 2 : 1;
for (; enterops[ix]; ix++) {
PL_op = enterops[ix];
- /* Eventually we may want to stack the needed arguments
- * for each op. For now, we punt on the hard ones. */
- if (PL_op->op_type == OP_ENTERITER)
- DIE(aTHX_ "Can't \"goto\" into the middle of a foreach loop");
+ S_check_op_type(aTHX_ PL_op);
PL_op->op_ppaddr(aTHX);
}
PL_op = oldop;