summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorAnno Siegel <anno4000@lublin.zrz.tu-berlin.de>2006-06-22 00:39:51 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-06-23 16:28:03 +0000
commit1e73acc8af3eecb1b36ee831483e1e9a7b3d1662 (patch)
treea723894f28f77db0a42b0de6599f6be9243cc439 /hv.c
parent7d3c2c289ea5236d2681b4bfba871738a7751375 (diff)
downloadperl-1e73acc8af3eecb1b36ee831483e1e9a7b3d1662.tar.gz
Re: [PATCH] Hash::Util::FieldHash
Message-Id: <974A5B4B-7614-4F3F-BA7C-828960D82C55@mailbox.tu-berlin.de> p4raw-id: //depot/perl@28419
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/hv.c b/hv.c
index eee7de044a..4f55ccaccc 100644
--- a/hv.c
+++ b/hv.c
@@ -436,6 +436,8 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
return NULL;
if (keysv) {
+ if (SvSMAGICAL(hv) && SvGMAGICAL(hv))
+ keysv = hv_magic_uvar_xkey(hv, keysv, action);
if (flags & HVhek_FREEKEY)
Safefree(key);
key = SvPV_const(keysv, klen);
@@ -965,6 +967,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
return NULL;
if (keysv) {
+ if (SvSMAGICAL(hv) && SvGMAGICAL(hv))
+ keysv = hv_magic_uvar_xkey(hv, keysv, -1);
if (k_flags & HVhek_FREEKEY)
Safefree(key);
key = SvPV_const(keysv, klen);
@@ -2511,6 +2515,24 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
return HeKEY_hek(entry);
}
+STATIC SV *
+S_hv_magic_uvar_xkey(pTHX_ HV* hv, SV* keysv, int action)
+{
+ MAGIC* mg;
+ if ((mg = mg_find((SV*)hv, PERL_MAGIC_uvar))) {
+ struct ufuncs * const uf = (struct ufuncs *)mg->mg_ptr;
+ if (uf->uf_set == NULL) {
+ SV* obj = mg->mg_obj;
+ mg->mg_obj = keysv; /* pass key */
+ uf->uf_index = action; /* pass action */
+ magic_getuvar((SV*)hv, mg);
+ keysv = mg->mg_obj; /* may have changed */
+ mg->mg_obj = obj;
+ }
+ }
+ return keysv;
+}
+
I32 *
Perl_hv_placeholders_p(pTHX_ HV *hv)
{