diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-08-05 01:05:45 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-05 16:02:01 -0700 |
commit | f32c7e864b6210c7dabe6a78f842c37aa73c56c3 (patch) | |
tree | b6a222fda29c83ac85ef9cdd7a423c31907b3578 /pp_sys.c | |
parent | bb02a38febc60a289c616282d720015be97842a4 (diff) | |
download | perl-f32c7e864b6210c7dabe6a78f842c37aa73c56c3.tar.gz |
Recursive formats and closures in formats.
Formats called recursively were using the same set of lexicals, so the
inner call would stomp on the outer calls vars, usually clearing them
when exiting.
Previous commits prepared a CvDEPTH field for formats. This commit
sets it in P(USH|OP)FORMAT and pushes a new pad in enterwrite.
This also allows closures to work properly in formats. Formerly they
caused assertion failures in cv_clone. Now cv_clone’s assumptions
about CvDEPTH on CvOUTSIDE and find_runcv are met when subs are embed-
ded in formats.
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1335,8 +1335,12 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop) PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp); PUSHFORMAT(cx, retop); + if (CvDEPTH(cv) >= 2) { + PERL_STACK_OVERFLOW_CHECK(); + pad_push(CvPADLIST(cv), CvDEPTH(cv)); + } SAVECOMPPAD(); - PAD_SET_CUR_NOSAVE(CvPADLIST(cv), 1); + PAD_SET_CUR_NOSAVE(CvPADLIST(cv), CvDEPTH(cv)); setdefout(gv); /* locally select filehandle so $% et al work */ return CvSTART(cv); |