summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-22 15:37:17 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-22 15:37:17 +0000
commit652088fc08273e36aaeda0e9cea8c66eb6a0bb2b (patch)
tree77126a0c60fe8885a8af67b175ba70ddb36eeafc /sv.c
parentd9e635b60b0e1dc8328faaa9dce7938f09f59b6f (diff)
downloadperl-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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index 0d1bc6ce1c..93188dff27 100644
--- a/sv.c
+++ b/sv.c
@@ -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 {