diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-01-30 10:44:38 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-01-30 10:44:38 +0000 |
commit | 6b6eec5b869ecabb6b96b0d84c01808aecc78d84 (patch) | |
tree | be188f6c9db63d9911541036c2e15a4d6b607b5d /hv.c | |
parent | 65c6b2907476177557b1357ec8e2bda83f220e47 (diff) | |
parent | 875e910638b0552c0eec0bc83eb2d5b3f85f5df5 (diff) | |
download | perl-6b6eec5b869ecabb6b96b0d84c01808aecc78d84.tar.gz |
[asperl] initial merge of latest win32 branch into ASPerl
p4raw-id: //depot/asperl@445
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 68 |
1 files changed, 41 insertions, 27 deletions
@@ -259,7 +259,6 @@ hv_magic_check (HV *hv, bool *needs_copy, bool *needs_store) *needs_copy = TRUE; switch (mg->mg_type) { case 'P': - case 'I': case 'S': *needs_store = FALSE; } @@ -426,26 +425,33 @@ hv_delete(HV *hv, char *key, U32 klen, I32 flags) register U32 hash; register HE *entry; register HE **oentry; + SV **svp; SV *sv; if (!hv) return Nullsv; if (SvRMAGICAL(hv)) { - sv = *hv_fetch(hv, key, klen, TRUE); - mg_clear(sv); - if (mg_find(sv, 's')) { - return Nullsv; /* %SIG elements cannot be deleted */ - } - else if (mg_find(sv, 'p')) { - sv_unmagic(sv, 'p'); /* No longer an element */ - return sv; - } + bool needs_copy; + bool needs_store; + hv_magic_check (hv, &needs_copy, &needs_store); + + if (needs_copy && (svp = hv_fetch(hv, key, klen, TRUE))) { + sv = *svp; + mg_clear(sv); + if (!needs_store) { + if (mg_find(sv, 'p')) { + sv_unmagic(sv, 'p'); /* No longer an element */ + return sv; + } + return Nullsv; /* element cannot be deleted */ + } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv,'E')) { - sv = sv_2mortal(newSVpv(key,klen)); - key = strupr(SvPVX(sv)); - } + else if (mg_find((SV*)hv,'E')) { + sv = sv_2mortal(newSVpv(key,klen)); + key = strupr(SvPVX(sv)); + } #endif + } } xhv = (XPVHV*)SvANY(hv); if (!xhv->xhv_array) @@ -494,21 +500,29 @@ hv_delete_ent(HV *hv, SV *keysv, I32 flags, U32 hash) if (!hv) return Nullsv; if (SvRMAGICAL(hv)) { - entry = hv_fetch_ent(hv, keysv, TRUE, hash); - sv = HeVAL(entry); - mg_clear(sv); - if (mg_find(sv, 'p')) { - sv_unmagic(sv, 'p'); /* No longer an element */ - return sv; - } + bool needs_copy; + bool needs_store; + hv_magic_check (hv, &needs_copy, &needs_store); + + if (needs_copy && (entry = hv_fetch_ent(hv, keysv, TRUE, hash))) { + sv = HeVAL(entry); + mg_clear(sv); + if (!needs_store) { + if (mg_find(sv, 'p')) { + sv_unmagic(sv, 'p'); /* No longer an element */ + return sv; + } + return Nullsv; /* element cannot be deleted */ + } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv,'E')) { - key = SvPV(keysv, klen); - keysv = sv_2mortal(newSVpv(key,klen)); - (void)strupr(SvPVX(keysv)); - hash = 0; - } + else if (mg_find((SV*)hv,'E')) { + key = SvPV(keysv, klen); + keysv = sv_2mortal(newSVpv(key,klen)); + (void)strupr(SvPVX(keysv)); + hash = 0; + } #endif + } } xhv = (XPVHV*)SvANY(hv); if (!xhv->xhv_array) |