diff options
author | David Mitchell <davem@iabyn.com> | 2017-06-01 11:08:27 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-06-07 09:11:08 +0100 |
commit | 2bfa133079ec76d63c52a467feba457718b4edad (patch) | |
tree | af784229b5dbe4fdb2075fb783ca13f744ba6cfa /sv.c | |
parent | 7637234e4ce791346982ea6e5a81e9e98f2757c2 (diff) | |
download | perl-2bfa133079ec76d63c52a467feba457718b4edad.tar.gz |
Perl_sv_vcatpvfn_flags: only do utf8 in radix code
For floating point formats, the output can only be utf8 if the radix point
is utf8. Currently the radix point code sets the is_utf8 variable, then
later, in the main floating-point code path, it tests is_utf8 and
upgrades the output string to utf8.
Instead, just do the upgrade directly in the radix code block.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -12851,7 +12851,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p && intsize != 'q' && ((eptr = F0convert(nv, ebuf + sizeof ebuf, &elen))) ) - goto float_concat_no_utf8; + goto float_concat; /* Determine the buffer size needed for the various * floating-point formats. @@ -12921,9 +12921,18 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p * space */ float_need += (SvCUR(PL_numeric_radix_sv) - 1); - /* note that this will convert the output to utf8 even if - * if the radix point didn't get output */ - is_utf8 = SvUTF8(PL_numeric_radix_sv); + + /* floating-point formats only get utf8 if the radix point + * is utf8. All other characters in the string are < 128 + * and so can be safely appended to both a non-utf8 and utf8 + * string as-is. + * Note that this will convert the output to utf8 even if + * the radix point didn't get output. + */ + if (SvUTF8(PL_numeric_radix_sv) && !has_utf8) { + sv_utf8_upgrade(sv); + has_utf8 = TRUE; + } } #endif @@ -13110,18 +13119,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p * loop which handles appending eptr to sv, and do our own * stripped-down version */ - /* floating-point formats only get is_utf8 if the radix point - * is utf8. All other characters in the string are < 128 - * and so can be safely appended to both a non-utf8 and utf8 - * string as-is. - */ - if (is_utf8 && !has_utf8) { - sv_utf8_upgrade(sv); - has_utf8 = TRUE; - } - - float_concat_no_utf8: - assert(!zeros); assert(!esignlen); assert(elen); |