summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-03-28 13:32:21 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-03-28 13:32:21 +0000
commitc750a3ec3b866067ab46dbcc9083205d823047c3 (patch)
treedf8ac921c8928fe673a259a2f22aa1f53156cb92 /doop.c
parentcfe4554026dfe078c2d7c706ace0e327f16b2c05 (diff)
downloadperl-c750a3ec3b866067ab46dbcc9083205d823047c3.tar.gz
Initial devel changes.
Pseudo-hashes. Optional strong typing. RESTART {}. p4raw-id: //depot/perl@2
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/doop.c b/doop.c
index c906db70d1..9512533041 100644
--- a/doop.c
+++ b/doop.c
@@ -628,15 +628,19 @@ dARGS
SV *tmpstr;
I32 dokeys = (op->op_type == OP_KEYS);
I32 dovalues = (op->op_type == OP_VALUES);
-
+ I32 realhv = (SvTYPE(hv) == SVt_PVHV);
+
if (op->op_type == OP_RV2HV || op->op_type == OP_PADHV)
dokeys = dovalues = TRUE;
if (!hv)
RETURN;
- (void)hv_iterinit(hv); /* always reset iterator regardless */
-
+ if (realhv)
+ (void)hv_iterinit(hv); /* always reset iterator regardless */
+ else
+ (void)avhv_iterinit((AV*)hv);
+
if (GIMME != G_ARRAY) {
dTARGET;
@@ -645,7 +649,7 @@ dARGS
else {
i = 0;
/*SUPPRESS 560*/
- while (entry = hv_iternext(hv)) {
+ while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
i++;
}
}
@@ -657,7 +661,7 @@ dARGS
EXTEND(sp, HvMAX(hv) * (dokeys + dovalues));
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
- while (entry = hv_iternext(hv)) {
+ while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
SPAGAIN;
if (dokeys) {
tmps = hv_iterkey(entry,&i); /* won't clobber stack_sp */
@@ -668,7 +672,8 @@ dARGS
if (dovalues) {
tmpstr = NEWSV(45,0);
PUTBACK;
- sv_setsv(tmpstr,hv_iterval(hv,entry));
+ sv_setsv(tmpstr,realhv ?
+ hv_iterval(hv,entry) : avhv_iterval((AV*)hv,entry));
SPAGAIN;
DEBUG_H( {
sprintf(buf,"%d%%%d=%d\n",entry->hent_hash,
@@ -681,4 +686,3 @@ dARGS
}
return NORMAL;
}
-