summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-25 18:06:23 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-25 23:02:09 -0700
commit19c481f4fff148c75b12b0f9ef8dadc7116b1001 (patch)
tree0c081b0056c58f0e0c8e1ffccff320314dc03e6a /pp.c
parent30901a8a3fcf590cb60375fd3b39c6b0d0bf6e00 (diff)
downloadperl-19c481f4fff148c75b12b0f9ef8dadc7116b1001.tar.gz
&CORE::foo() for dbmopen and dbmclose
This commit allows the subs in the CORE package for close, getc and readline to be called through references and via ampersand syntax. A special case for each of them is added to pp_coreargs to deal with calls with no arguments. Pushing a null on to the stack (which I’m doing for other ops) won’t work, as a null already means something for these cases: close($f) won’t vivify a typeglob if $f is a string, so the implicit rv2gv pushes a null on to the stack.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 1a92796d91..e185cadd84 100644
--- a/pp.c
+++ b/pp.c
@@ -6010,10 +6010,10 @@ PP(pp_coreargs)
{
dSP;
int opnum = SvIOK(cSVOP_sv) ? (int)SvUV(cSVOP_sv) : 0;
- int defgv = PL_opargs[opnum] & OA_DEFGV;
+ int defgv = PL_opargs[opnum] & OA_DEFGV, whicharg = 0;
AV * const at_ = GvAV(PL_defgv);
SV **svp = AvARRAY(at_);
- I32 minargs = 0, maxargs = 0, numargs = AvFILLp(at_)+1, whicharg = 0;
+ I32 minargs = 0, maxargs = 0, numargs = AvFILLp(at_)+1;
I32 oa = opnum ? PL_opargs[opnum] >> OASHIFT : 0;
bool seen_question = 0;
const char *err = NULL;
@@ -6084,6 +6084,16 @@ PP(pp_coreargs)
svp++;
}
RETURN;
+ case OA_HVREF:
+ if (!svp || !*svp || !SvROK(*svp)
+ || SvTYPE(SvRV(*svp)) != SVt_PVHV)
+ DIE(aTHX_
+ /* diag_listed_as: Type of arg %d to &CORE::%s must be %s*/
+ "Type of arg %d to &CORE::%s must be hash reference",
+ whicharg, OP_DESC(PL_op->op_next)
+ );
+ PUSHs(SvRV(*svp));
+ break;
case OA_FILEREF:
if (!numargs) PUSHs(NULL);
else if(svp && *svp && SvROK(*svp) && isGV_with_GP(SvRV(*svp)))