diff options
-rw-r--r-- | ObjXSub.h | 2 | ||||
-rw-r--r-- | av.c | 7 | ||||
-rw-r--r-- | doop.c | 27 | ||||
-rw-r--r-- | embed.h | 1 | ||||
-rw-r--r-- | global.sym | 1 | ||||
-rw-r--r-- | objpp.h | 2 | ||||
-rw-r--r-- | pp.c | 9 | ||||
-rw-r--r-- | proto.h | 1 | ||||
-rwxr-xr-x | t/op/avhv.t | 7 |
9 files changed, 22 insertions, 35 deletions
@@ -723,8 +723,6 @@ #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 @@ -759,13 +759,6 @@ avhv_delete_ent(AV *av, SV *keysv, I32 flags, U32 hash) return sv; } -I32 -avhv_iterinit(AV *av) -{ - HV *keys = avhv_keys(av); - return hv_iterinit(keys); -} - HE * avhv_iternext(AV *av) { @@ -445,6 +445,7 @@ do_kv(ARGSproto) { djSP; HV *hv = (HV*)POPs; + HV *keys; register HE *entry; SV *tmpstr; I32 gimme = GIMME_V; @@ -465,10 +466,8 @@ do_kv(ARGSproto) 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; @@ -483,33 +482,31 @@ do_kv(ARGSproto) 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 */ @@ -520,8 +517,8 @@ do_kv(ARGSproto) 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); } @@ -52,7 +52,6 @@ #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 diff --git a/global.sym b/global.sym index 5001c3c35e..4a7c4b539a 100644 --- a/global.sym +++ b/global.sym @@ -187,7 +187,6 @@ avhv_exists avhv_exists_ent avhv_fetch avhv_fetch_ent -avhv_iterinit avhv_iternext avhv_iternextsv avhv_iterval @@ -67,8 +67,6 @@ #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 @@ -2418,7 +2418,6 @@ PP(pp_exists) 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); @@ -2428,18 +2427,18 @@ PP(pp_hslice) 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) { @@ -34,7 +34,6 @@ VIRTUAL bool avhv_exists _((AV *ar, char* key, U32 klen)); 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)); diff --git a/t/op/avhv.t b/t/op/avhv.t index a7ce58ab87..84d3f270fb 100755 --- a/t/op/avhv.t +++ b/t/op/avhv.t @@ -17,7 +17,7 @@ sub STORESIZE { $#{$_[0]} = $_[1]+1 } package main; -print "1..5\n"; +print "1..6\n"; $sch = { 'abc' => 1, @@ -74,3 +74,8 @@ $a->[0] = \%fake; $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"; |