#define avhv_fetch pPerl->Perl_avhv_fetch
#undef avhv_fetch_ent
#define avhv_fetch_ent pPerl->Perl_avhv_fetch_ent
-#undef avhv_iterinit
-#define avhv_iterinit pPerl->Perl_avhv_iterinit
#undef avhv_iternext
#define avhv_iternext pPerl->Perl_avhv_iternext
#undef avhv_iternextsv
return sv;
}
-I32
-avhv_iterinit(AV *av)
-{
- HV *keys = avhv_keys(av);
- return hv_iterinit(keys);
-}
-
HE *
avhv_iternext(AV *av)
{
{
djSP;
HV *hv = (HV*)POPs;
+ HV *keys;
register HE *entry;
SV *tmpstr;
I32 gimme = GIMME_V;
RETURN;
}
- if (realhv)
- (void)hv_iterinit(hv); /* always reset iterator regardless */
- else
- (void)avhv_iterinit((AV*)hv);
+ keys = realhv ? hv : avhv_keys((AV*)hv);
+ (void)hv_iterinit(keys); /* always reset iterator regardless */
if (gimme == G_VOID)
RETURN;
sv_magic(TARG, Nullsv, 'k', Nullch, 0);
}
LvTYPE(TARG) = 'k';
- if (LvTARG(TARG) != (SV*)hv) {
+ if (LvTARG(TARG) != (SV*)keys) {
if (LvTARG(TARG))
SvREFCNT_dec(LvTARG(TARG));
- LvTARG(TARG) = SvREFCNT_inc(hv);
+ LvTARG(TARG) = SvREFCNT_inc(keys);
}
PUSHs(TARG);
RETURN;
}
- if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P'))
- i = HvKEYS(hv);
+ if (!SvRMAGICAL(keys) || !mg_find((SV*)keys,'P'))
+ i = HvKEYS(keys);
else {
i = 0;
/*SUPPRESS 560*/
- while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
- i++;
- }
+ while (hv_iternext(keys)) i++;
}
PUSHi( i );
RETURN;
}
/* Guess how much room we need. hv_max may be a few too many. Oh well. */
- EXTEND(SP, HvMAX(hv) * (dokeys + dovalues));
+ EXTEND(SP, HvMAX(keys) * (dokeys + dovalues));
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
- while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
+ while (entry = hv_iternext(keys)) {
SPAGAIN;
if (dokeys)
XPUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
hv_iterval(hv,entry) : avhv_iterval((AV*)hv,entry));
DEBUG_H(sv_setpvf(tmpstr, "%lu%%%d=%lu",
(unsigned long)HeHASH(entry),
- HvMAX(hv)+1,
- (unsigned long)(HeHASH(entry) & HvMAX(hv))));
+ HvMAX(keys)+1,
+ (unsigned long)(HeHASH(entry) & HvMAX(keys))));
SPAGAIN;
XPUSHs(tmpstr);
}
#define avhv_exists_ent Perl_avhv_exists_ent
#define avhv_fetch Perl_avhv_fetch
#define avhv_fetch_ent Perl_avhv_fetch_ent
-#define avhv_iterinit Perl_avhv_iterinit
#define avhv_iternext Perl_avhv_iternext
#define avhv_iternextsv Perl_avhv_iternextsv
#define avhv_iterval Perl_avhv_iterval
avhv_exists_ent
avhv_fetch
avhv_fetch_ent
-avhv_iterinit
avhv_iternext
avhv_iternextsv
avhv_iterval
#define avhv_delete CPerlObj::Perl_avhv_delete
#undef avhv_delete_ent
#define avhv_delete_ent CPerlObj::Perl_avhv_delete_ent
-#undef avhv_iterinit
-#define avhv_iterinit CPerlObj::Perl_avhv_iterinit
#undef avhv_iternext
#define avhv_iternext CPerlObj::Perl_avhv_iternext
#undef avhv_iterval
PP(pp_hslice)
{
djSP; dMARK; dORIGMARK;
- register HE *he;
register HV *hv = (HV*)POPs;
register I32 lval = op->op_flags & OPf_MOD;
I32 realhv = (SvTYPE(hv) == SVt_PVHV);
SV *keysv = *MARK;
SV **svp;
if (realhv) {
- he = hv_fetch_ent(hv, keysv, lval, 0);
+ HE *he = hv_fetch_ent(hv, keysv, lval, 0);
svp = he ? &HeVAL(he) : 0;
} else {
svp = avhv_fetch_ent((AV*)hv, keysv, lval, 0);
}
if (lval) {
- if (!he || HeVAL(he) == &sv_undef)
+ if (!svp || *svp == &sv_undef)
DIE(no_helem, SvPV(keysv, na));
if (op->op_private & OPpLVAL_INTRO)
- save_helem(hv, keysv, &HeVAL(he));
+ save_helem(hv, keysv, svp);
}
- *MARK = he ? HeVAL(he) : &sv_undef;
+ *MARK = svp ? *svp : &sv_undef;
}
}
if (GIMME != G_ARRAY) {
VIRTUAL bool avhv_exists_ent _((AV *ar, SV* keysv, U32 hash));
VIRTUAL SV** avhv_fetch _((AV *ar, char* key, U32 klen, I32 lval));
VIRTUAL SV** avhv_fetch_ent _((AV *ar, SV* keysv, I32 lval, U32 hash));
-VIRTUAL I32 avhv_iterinit _((AV *ar));
VIRTUAL HE* avhv_iternext _((AV *ar));
VIRTUAL SV * avhv_iternextsv _((AV *ar, char** key, I32* retlen));
VIRTUAL SV* avhv_iterval _((AV *ar, HE* entry));
package main;
-print "1..5\n";
+print "1..6\n";
$sch = {
'abc' => 1,
$a->{'abc'} = 'ABC';
if ($a->{'abc'} eq 'ABC') {print "ok 5\n";} else {print "not ok 5\n";}
+
+# hash slice
+my $slice = join('', 'x',@$a{'abc','def'},'x');
+print "not " if $slice ne 'xABCx';
+print "ok 6\n";