From: Malcolm Beattie Date: Mon, 26 May 1997 11:38:45 +0000 (+0000) Subject: Add avhv_store_ent. Add missing avhv_* to global.sym. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5bc6513ddd9360f3cbfa6bf29425e38b658230f5;p=p5sagit%2Fp5-mst-13.2.git Add avhv_store_ent. Add missing avhv_* to global.sym. p4raw-id: //depot/perl@20 --- diff --git a/av.c b/av.c index e3d341c..af3e94e 100644 --- a/av.c +++ b/av.c @@ -561,6 +561,32 @@ U32 hash; return av_store(av, ind, val); } +SV** +avhv_store_ent(av, keysv, val, hash) +AV *av; +SV *keysv; +SV *val; +U32 hash; +{ + SV **keys; + HE *he; + I32 ind; + + keys = av_fetch(av, 0, FALSE); + if (!keys || !SvROK(*keys) || SvTYPE(SvRV(*keys)) != SVt_PVHV) + croak("Can't coerce array into hash"); + he = hv_fetch_ent((HV*)SvRV(*keys), keysv, FALSE, hash); + if (he) { + ind = SvIV(HeVAL(he)); + if (ind < 1) + croak("Bad index while coercing array into hash"); + } else { + ind = AvFILL(av) + 1; + hv_store_ent((HV*)SvRV(*keys), keysv, newSViv(ind), hash); + } + return av_store(av, ind, val); +} + bool avhv_exists_ent(av, keysv, hash) AV *av; diff --git a/global.sym b/global.sym index 1a8dd7f..27d80c5 100644 --- a/global.sym +++ b/global.sym @@ -303,13 +303,17 @@ append_list apply assertref avhv_delete +avhv_delete_ent avhv_exists +avhv_exists_ent avhv_fetch +avhv_fetch_ent avhv_iterinit avhv_iternext avhv_iternextsv avhv_iterval avhv_store +avhv_store_ent av_clear av_extend av_fake