diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-21 11:59:44 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-25 14:24:36 -0700 |
commit | ce0b554bf53c768c04939d95a2e6b23356a045b0 (patch) | |
tree | a45b49a4116aed4454c29095fdcd727ec8350b23 /pp_ctl.c | |
parent | c2f922f11b8978a4eea0e0d28626dd3c1f6eaba7 (diff) | |
download | perl-ce0b554bf53c768c04939d95a2e6b23356a045b0.tar.gz |
&CORE::caller()
This commit allows &CORE::caller to be called through references and
via ampersand syntax. pp_caller is modified to take into account
two things:
1) pp_coreargs pushes a null on to the stack, since it has no other
way to tell caller whether it has an argument.
2) The value coming from pp_coreargs (when not null) is off by
one. The OPpOFFYBONE flag was added in commit 93f0bc4935 for
this purpose.
pp_coreargs is also modified, since it assumed till now that an
optional first argument was an implicit $_.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1871,11 +1871,15 @@ PP(pp_caller) I32 gimme; const char *stashname; I32 count = 0; + bool has_arg = MAXARG && TOPs; - if (MAXARG) + if (MAXARG) { + if (has_arg) count = POPi; + else (void)POPs; + } - cx = caller_cx(count, &dbcx); + cx = caller_cx(count + !!(PL_op->op_private & OPpOFFBYONE), &dbcx); if (!cx) { if (GIMME != G_ARRAY) { EXTEND(SP, 1); @@ -1905,7 +1909,7 @@ PP(pp_caller) mPUSHs(newSVpv(stashname, 0)); mPUSHs(newSVpv(OutCopFILE(cx->blk_oldcop), 0)); mPUSHi((I32)CopLINE(cx->blk_oldcop)); - if (!MAXARG) + if (!has_arg) RETURN; if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) { GV * const cvgv = CvGV(dbcx->blk_sub.cv); |