diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-05-29 22:58:46 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-05-29 22:58:46 +0000 |
commit | d8c5b3c5f8f46ae357e9c3ef6c3ccef73c567024 (patch) | |
tree | f027b074e15798b93fb92934b4ad09f900265168 /hv.c | |
parent | ecd6e0980bb546d8adbd5495a9a34caea25be6ad (diff) | |
download | perl-d8c5b3c5f8f46ae357e9c3ef6c3ccef73c567024.tar.gz |
Comprehensive regression tests for Perl_refcounted_he_fetch().
Fix a bug due to the fact that Perl's typedef'd "bool" type isn't
actually boolean.
p4raw-id: //depot/perl@28335
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -2709,12 +2709,16 @@ Perl_refcounted_he_fetch(pTHX_ const struct refcounted_he *chain, SV *keysv, /* Just to be awkward, if you're using this interface the UTF-8-or-not-ness of your key has to exactly match that which is stored. */ SV *value = &PL_sv_placeholder; + bool is_utf8; if (keysv) { if (flags & HVhek_FREEKEY) Safefree(key); key = SvPV_const(keysv, klen); flags = 0; + is_utf8 = (SvUTF8(keysv) != 0); + } else { + is_utf8 = ((flags & HVhek_UTF8) ? TRUE : FALSE); } if (!hash) { @@ -2733,6 +2737,8 @@ Perl_refcounted_he_fetch(pTHX_ const struct refcounted_he *chain, SV *keysv, continue; if (memNE(REF_HE_KEY(chain),key,klen)) continue; + if (!!is_utf8 != !!(chain->refcounted_he_data[0] & HVhek_UTF8)) + continue; #else if (hash != HEK_HASH(chain->refcounted_he_hek)) continue; @@ -2740,6 +2746,8 @@ Perl_refcounted_he_fetch(pTHX_ const struct refcounted_he *chain, SV *keysv, continue; if (memNE(HEK_KEY(chain->refcounted_he_hek),key,klen)) continue; + if (!!is_utf8 != !!HEK_UTF8(chain->refcounted_he_hek)) + continue; #endif value = sv_2mortal(refcounted_he_value(chain)); @@ -2775,7 +2783,7 @@ Perl_refcounted_he_new(pTHX_ struct refcounted_he *const parent, char flags; STRLEN key_offset; U32 hash; - bool is_utf8 = SvUTF8(key); + bool is_utf8 = SvUTF8(key) ? TRUE : FALSE; if (SvPOK(value)) { value_type = HVrhek_PV; |