diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-23 23:38:23 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 16:14:31 -0800 |
commit | 3f4d1d7873e4e02f3801f2982565de93d2127bbd (patch) | |
tree | 65564dfc914364d6f7e51cd51dc6253631d5747d /hv.c | |
parent | f6f8d80714cb1a3a1417012c378a197e6d221f36 (diff) | |
download | perl-3f4d1d7873e4e02f3801f2982565de93d2127bbd.tar.gz |
hv.c: Make newHVhv work on tied hashes
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1358,7 +1358,7 @@ Perl_newHVhv(pTHX_ HV *ohv) HV * const hv = newHV(); STRLEN hv_max; - if (!ohv || !HvTOTALKEYS(ohv)) + if (!ohv || (!HvTOTALKEYS(ohv) && !SvMAGICAL((const SV *)ohv))) return hv; hv_max = HvMAX(ohv); @@ -1421,9 +1421,13 @@ Perl_newHVhv(pTHX_ HV *ohv) hv_iterinit(ohv); while ((entry = hv_iternext_flags(ohv, 0))) { - SV *const val = HeVAL(entry); - (void)hv_store_flags(hv, HeKEY(entry), HeKLEN(entry), - SvIMMORTAL(val) ? val : newSVsv(val), + SV *val = hv_iterval(ohv,entry); + SV * const keysv = HeSVKEY(entry); + val = SvIMMORTAL(val) ? val : newSVsv(val); + if (keysv) + (void)hv_store_ent(hv, keysv, val, 0); + else + (void)hv_store_flags(hv, HeKEY(entry), HeKLEN(entry), val, HeHASH(entry), HeKFLAGS(entry)); } HvRITER_set(ohv, riter); |