diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-22 15:37:17 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-22 15:37:17 +0000 |
commit | 652088fc08273e36aaeda0e9cea8c66eb6a0bb2b (patch) | |
tree | 77126a0c60fe8885a8af67b175ba70ddb36eeafc /sv.c | |
parent | d9e635b60b0e1dc8328faaa9dce7938f09f59b6f (diff) | |
download | perl-652088fc08273e36aaeda0e9cea8c66eb6a0bb2b.tar.gz |
Add sv_force_normal() to sv_utf8_downgrade() as suggested
by Inaba Hiroto.
p4raw-id: //depot/perl@8517
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -2957,6 +2957,7 @@ Perl_sv_utf8_upgrade(pTHX_ register SV *sv) if (hibit) { STRLEN len; + if (SvREADONLY(sv) && SvFAKE(sv)) { sv_force_normal(sv); s = SvPVX(sv); @@ -2987,10 +2988,13 @@ Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok) { if (SvPOK(sv) && SvUTF8(sv)) { if (SvCUR(sv)) { - char *c = SvPVX(sv); - STRLEN len = SvCUR(sv); + char *s; + STRLEN len; - if (!utf8_to_bytes((U8*)c, &len)) { + if (SvREADONLY(sv) && SvFAKE(sv)) + sv_force_normal(sv); + s = SvPV(sv, len); + if (!utf8_to_bytes((U8*)s, &len)) { if (fail_ok) return FALSE; else { |