From fa0789a79059cdefbf7197a9330c0fd6a06011b2 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 13 Nov 2013 13:18:09 -0600 Subject: [PATCH] Add UTF8 flag to keys returned by B::HV->ARRAY hv_iternextsv() ignores the HEK flags, but we do care about the UTF8 flag at least when returning hash keys from B::HV->ARRAY --- ext/B/B.xs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/B/B.xs b/ext/B/B.xs index 0b097d4..1c44857 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1952,14 +1952,18 @@ HvARRAY(hv) B::HV hv PPCODE: if (HvUSEDKEYS(hv) > 0) { - SV *sv; - char *key; - I32 len; + HE *he; (void)hv_iterinit(hv); EXTEND(sp, HvUSEDKEYS(hv) * 2); - while ((sv = hv_iternextsv(hv, &key, &len))) { - mPUSHp(key, len); - PUSHs(make_sv_object(aTHX_ sv)); + while ((he = hv_iternext(hv))) { + if (HeSVKEY(he)) { + mPUSHs(HeSVKEY(he)); + } else if (HeKUTF8(he)) { + PUSHs(newSVpvn_flags(HeKEY(he), HeKLEN(he), SVf_UTF8|SVs_TEMP)); + } else { + mPUSHp(HeKEY(he), HeKLEN(he)); + } + PUSHs(make_sv_object(aTHX_ HeVAL(he))); } } -- 2.7.4