diff options
author | Michael G. Schwern <schwern@pobox.com> | 2002-08-06 06:05:10 -0700 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-08-17 00:51:19 +0000 |
commit | 6d822dc4045278fb03135b2683bac92dba061369 (patch) | |
tree | 39e9aa0ce54a7caf711f12d43985793b79fb762d /av.c | |
parent | 485894a1e3cb3873ba7373c744a8b6231190fbf8 (diff) | |
download | perl-6d822dc4045278fb03135b2683bac92dba061369.tar.gz |
Remove pseudo-hashes (complete)
Message-id: <20020806200510.GC31473@ool-18b93024.dyn.optonline.net>
p4raw-id: //depot/perl@17725
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 101 |
1 files changed, 0 insertions, 101 deletions
@@ -835,104 +835,3 @@ Perl_av_exists(pTHX_ AV *av, I32 key) else return FALSE; } - -/* AVHV: Support for treating arrays as if they were hashes. The - * first element of the array should be a hash reference that maps - * hash keys to array indices. - */ - -STATIC I32 -S_avhv_index_sv(pTHX_ SV* sv) -{ - I32 index = SvIV(sv); - if (index < 1) - Perl_croak(aTHX_ "Bad index while coercing array into hash"); - return index; -} - -STATIC I32 -S_avhv_index(pTHX_ AV *av, SV *keysv, U32 hash) -{ - HV *keys; - HE *he; - STRLEN n_a; - - keys = avhv_keys(av); - he = hv_fetch_ent(keys, keysv, FALSE, hash); - if (!he) - Perl_croak(aTHX_ "No such pseudo-hash field \"%s\"", SvPV(keysv,n_a)); - return avhv_index_sv(HeVAL(he)); -} - -HV* -Perl_avhv_keys(pTHX_ AV *av) -{ - SV **keysp = av_fetch(av, 0, FALSE); - if (keysp) { - SV *sv = *keysp; - if (SvGMAGICAL(sv)) - mg_get(sv); - if (SvROK(sv)) { - sv = SvRV(sv); - if (SvTYPE(sv) == SVt_PVHV) - return (HV*)sv; - } - } - Perl_croak(aTHX_ "Can't coerce array into hash"); - return Nullhv; -} - -SV** -Perl_avhv_store_ent(pTHX_ AV *av, SV *keysv, SV *val, U32 hash) -{ - return av_store(av, avhv_index(av, keysv, hash), val); -} - -SV** -Perl_avhv_fetch_ent(pTHX_ AV *av, SV *keysv, I32 lval, U32 hash) -{ - return av_fetch(av, avhv_index(av, keysv, hash), lval); -} - -SV * -Perl_avhv_delete_ent(pTHX_ AV *av, SV *keysv, I32 flags, U32 hash) -{ - HV *keys = avhv_keys(av); - HE *he; - - he = hv_fetch_ent(keys, keysv, FALSE, hash); - if (!he || !SvOK(HeVAL(he))) - return Nullsv; - - return av_delete(av, avhv_index_sv(HeVAL(he)), flags); -} - -/* Check for the existence of an element named by a given key. - * - */ -bool -Perl_avhv_exists_ent(pTHX_ AV *av, SV *keysv, U32 hash) -{ - HV *keys = avhv_keys(av); - HE *he; - - he = hv_fetch_ent(keys, keysv, FALSE, hash); - if (!he || !SvOK(HeVAL(he))) - return FALSE; - - return av_exists(av, avhv_index_sv(HeVAL(he))); -} - -HE * -Perl_avhv_iternext(pTHX_ AV *av) -{ - HV *keys = avhv_keys(av); - return hv_iternext(keys); -} - -SV * -Perl_avhv_iterval(pTHX_ AV *av, register HE *entry) -{ - SV *sv = hv_iterval(avhv_keys(av), entry); - return *av_fetch(av, avhv_index_sv(sv), TRUE); -} |